@@ -31,9 +31,37 @@ class Value;
3131class GlobalVariable ;
3232class Module ;
3333class DIFile ;
34+ class DILocation ;
3435} // namespace llvm
3536
3637namespace psr {
38+ struct DebugLocation {
39+ unsigned Line{};
40+ unsigned Column{};
41+ const llvm::DIFile *File{};
42+ };
43+
44+ struct SourceCodeInfo {
45+ std::string SourceCodeLine;
46+ std::string SourceCodeFilename;
47+ std::string SourceCodeFunctionName;
48+ unsigned Line = 0 ;
49+ unsigned Column = 0 ;
50+
51+ [[nodiscard]] bool empty () const noexcept ;
52+
53+ [[nodiscard]] bool operator ==(const SourceCodeInfo &Other) const noexcept ;
54+ [[nodiscard]] inline bool
55+ operator !=(const SourceCodeInfo &Other) const noexcept {
56+ return !(*this == Other);
57+ }
58+
59+ // / Similar to operator==, but takes different SourceCodeFileName locations
60+ // / into account
61+ [[nodiscard]] bool equivalentWith (const SourceCodeInfo &Other) const ;
62+ };
63+
64+ [[nodiscard]] llvm::DILocation *getDILocation (const llvm::Value *V);
3765
3866[[nodiscard]] std::string getVarNameFromIR (const llvm::Value *V);
3967
@@ -55,29 +83,10 @@ getLineAndColFromIR(const llvm::Value *V);
5583
5684[[nodiscard]] std::string getSrcCodeFromIR (const llvm::Value *V,
5785 bool Trim = true );
86+ [[nodiscard]] std::string getSrcCodeFromIR (DebugLocation Loc, bool Trim = true );
5887
5988[[nodiscard]] std::string getModuleIDFromIR (const llvm::Value *V);
6089
61- struct SourceCodeInfo {
62- std::string SourceCodeLine;
63- std::string SourceCodeFilename;
64- std::string SourceCodeFunctionName;
65- unsigned Line = 0 ;
66- unsigned Column = 0 ;
67-
68- [[nodiscard]] bool empty () const noexcept ;
69-
70- [[nodiscard]] bool operator ==(const SourceCodeInfo &Other) const noexcept ;
71- [[nodiscard]] inline bool
72- operator !=(const SourceCodeInfo &Other) const noexcept {
73- return !(*this == Other);
74- }
75-
76- // / Similar to operator==, but takes different SourceCodeFileName locations
77- // / into account
78- [[nodiscard]] bool equivalentWith (const SourceCodeInfo &Other) const ;
79- };
80-
8190// / Used from the JSON library internally to implicitly convert between json and
8291// / SourceCodeInfo
8392void from_json (const nlohmann::json &J, SourceCodeInfo &Info);
@@ -87,12 +96,6 @@ void to_json(nlohmann::json &J, const SourceCodeInfo &Info);
8796
8897[[nodiscard]] SourceCodeInfo getSrcCodeInfoFromIR (const llvm::Value *V);
8998
90- struct DebugLocation {
91- unsigned Line{};
92- unsigned Column{};
93- const llvm::DIFile *File{};
94- };
95-
9699[[nodiscard]] std::optional<DebugLocation>
97100getDebugLocation (const llvm::Value *V);
98101
0 commit comments