11
11
//
12
12
// ===----------------------------------------------------------------------===//
13
13
14
- #include " llvm/Support/InitLLVM .h"
15
- #include " llvm/Support/TargetSelect .h"
14
+ #include " llvm/ADT/SetVector .h"
15
+ #include " llvm/DebugInfo/LogicalView/LVReaderHandler .h"
16
16
#include " llvm/Support/CommandLine.h"
17
+ #include " llvm/Support/InitLLVM.h"
17
18
#include " llvm/Support/MemoryBuffer.h"
18
19
#include " llvm/Support/ScopedPrinter.h"
19
- #include " llvm/DebugInfo/LogicalView/LVReaderHandler.h"
20
- #include " llvm/ADT/SetVector.h"
20
+ #include " llvm/Support/TargetSelect.h"
21
21
22
22
#include < string>
23
- #include < unordered_set>
24
23
#include < unordered_map>
24
+ #include < unordered_set>
25
25
26
26
using namespace llvm ;
27
27
using namespace logicalview ;
@@ -32,7 +32,8 @@ static cl::opt<std::string>
32
32
cl::Required);
33
33
34
34
static cl::opt<bool > IncludeCode (" code" , cl::desc(" Include asm" ));
35
- static cl::opt<bool > IncludeRanges (" ranges" , cl::desc(" Include variable ranges" ));
35
+ static cl::opt<bool > IncludeRanges (" ranges" ,
36
+ cl::desc (" Include variable ranges" ));
36
37
static cl::opt<bool > IncludeVars (" vars" , cl::desc(" Include live variables" ));
37
38
38
39
template <typename T> T Take (Expected<T> ExpectedResult, const Twine &Msg) {
@@ -52,16 +53,14 @@ struct ScopePrinter {
52
53
LivetimeEndsExclusive;
53
54
raw_ostream &OS;
54
55
55
- void Walk (raw_ostream &OS, const LVScope* Scope) {
56
+ void Walk (raw_ostream &OS, const LVScope * Scope) {
56
57
if (Scope->scopeCount ()) {
57
58
for (const LVScope *ChildScope : *Scope->getScopes ())
58
59
Walk (OS, ChildScope);
59
60
}
60
61
if (Scope->lineCount ()) {
61
62
for (const LVLine *Line : *Scope->getLines ()) {
62
63
Lines.push_back (Line);
63
- if (Line->getParentScope () != Scope)
64
- OS << " " ;
65
64
}
66
65
}
67
66
if (Scope->symbolCount ()) {
@@ -72,7 +71,8 @@ struct ScopePrinter {
72
71
continue ;
73
72
74
73
if (IncludeRanges) {
75
- OS << " RANGES: " << Symbol->getName () << " (line " << Symbol->getLineNumber () << " )" << " : " ;
74
+ OS << " RANGES: " << Symbol->getName () << " (line "
75
+ << Symbol->getLineNumber () << " )" << " : " ;
76
76
}
77
77
78
78
for (const LVLocation *Loc : SymbolLocations) {
@@ -111,14 +111,15 @@ struct ScopePrinter {
111
111
OS << " " ;
112
112
}
113
113
114
- static void PrintCallstack (raw_ostream& OS, const LVScope* Scope) {
114
+ static void PrintCallstack (raw_ostream & OS, const LVScope * Scope) {
115
115
bool First = true ;
116
116
const LVScope *PrevScope = nullptr ;
117
117
while (Scope) {
118
118
if (Scope->getIsFunction () || Scope->getIsInlinedFunction ()) {
119
119
OS << " [" << Scope->getName ();
120
120
if (PrevScope && PrevScope->getIsInlinedFunction ()) {
121
- OS << " :" << cast<LVScopeFunctionInlined>(PrevScope)->getCallLineNumber ();
121
+ OS << " :"
122
+ << cast<LVScopeFunctionInlined>(PrevScope)->getCallLineNumber ();
122
123
}
123
124
OS << " ]" ;
124
125
First = false ;
@@ -138,7 +139,8 @@ struct ScopePrinter {
138
139
}
139
140
140
141
void Print () {
141
- SetVector<const LVLocation *> LiveSymbols; // This needs to be ordered since we're iterating over it.
142
+ SetVector<const LVLocation *>
143
+ LiveSymbols; // This needs to be ordered since we're iterating over it.
142
144
int LastLine = -1 ;
143
145
StringRef LastFilename;
144
146
for (const LVLine *Line : Lines) {
@@ -165,16 +167,13 @@ struct ScopePrinter {
165
167
if (IncludeVars) {
166
168
for (auto SymLoc : LiveSymbols) {
167
169
const LVSymbol *Sym = SymLoc->getParentSymbol ();
168
- if (Sym->getName () == " InMRT1" )
169
- outs () << " " ;
170
170
auto SymScope = Sym->getParentScope ();
171
171
auto LineScope = LineDebug->getParentScope ();
172
172
if (SymScope != LineScope && !IsChildScopeOf (LineScope, SymScope))
173
173
continue ;
174
174
PrintIndent (OS, 1 );
175
175
OS << " VAR: " << Sym->getName () << " : "
176
- << Sym->getType ()->getName ()
177
- << " : " ;
176
+ << Sym->getType ()->getName () << " : " ;
178
177
SymLoc->printLocations (OS);
179
178
OS << " (line " << Sym->getLineNumber () << " )" ;
180
179
OS << " \n " ;
@@ -200,8 +199,8 @@ int main(int argc, char *argv[]) {
200
199
llvm::InitializeAllTargetMCs ();
201
200
InitializeAllDisassemblers ();
202
201
203
- cl::ParseCommandLineOptions (argc, argv,
204
- " Check debug info correctness via annotations.\n " );
202
+ cl::ParseCommandLineOptions (
203
+ argc, argv, " Check debug info correctness via annotations.\n " );
205
204
206
205
ScopedPrinter W (llvm::outs ());
207
206
LVOptions Options;
@@ -213,8 +212,8 @@ int main(int argc, char *argv[]) {
213
212
std::vector<std::string> Objects;
214
213
LVReaderHandler Handler (Objects, W, Options);
215
214
auto Readers = Take (Handler.createReader (InputFilename),
216
- Twine (" Failed to create LV reader from '" ) + Twine (InputFilename ) +
217
- Twine (" '" ));
215
+ Twine (" Failed to create LV reader from '" ) +
216
+ Twine (InputFilename) + Twine (" '" ));
218
217
219
218
auto *CU = Readers->getCompileUnit ();
220
219
if (!CU)
@@ -228,7 +227,7 @@ int main(int argc, char *argv[]) {
228
227
if (!Lines)
229
228
continue ;
230
229
outs () << " FUNCTION: " << Child->getName () << " \n " ;
231
-
230
+
232
231
ScopePrinter P (outs (), Fn);
233
232
P.Print ();
234
233
}
0 commit comments