1111//
1212// ===----------------------------------------------------------------------===//
1313
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"
1616#include " llvm/Support/CommandLine.h"
17+ #include " llvm/Support/InitLLVM.h"
1718#include " llvm/Support/MemoryBuffer.h"
1819#include " llvm/Support/ScopedPrinter.h"
19- #include " llvm/DebugInfo/LogicalView/LVReaderHandler.h"
20- #include " llvm/ADT/SetVector.h"
20+ #include " llvm/Support/TargetSelect.h"
2121
2222#include < string>
23- #include < unordered_set>
2423#include < unordered_map>
24+ #include < unordered_set>
2525
2626using namespace llvm ;
2727using namespace logicalview ;
@@ -32,7 +32,8 @@ static cl::opt<std::string>
3232 cl::Required);
3333
3434static 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" ));
3637static cl::opt<bool > IncludeVars (" vars" , cl::desc(" Include live variables" ));
3738
3839template <typename T> T Take (Expected<T> ExpectedResult, const Twine &Msg) {
@@ -52,16 +53,14 @@ struct ScopePrinter {
5253 LivetimeEndsExclusive;
5354 raw_ostream &OS;
5455
55- void Walk (raw_ostream &OS, const LVScope* Scope) {
56+ void Walk (raw_ostream &OS, const LVScope * Scope) {
5657 if (Scope->scopeCount ()) {
5758 for (const LVScope *ChildScope : *Scope->getScopes ())
5859 Walk (OS, ChildScope);
5960 }
6061 if (Scope->lineCount ()) {
6162 for (const LVLine *Line : *Scope->getLines ()) {
6263 Lines.push_back (Line);
63- if (Line->getParentScope () != Scope)
64- OS << " " ;
6564 }
6665 }
6766 if (Scope->symbolCount ()) {
@@ -72,7 +71,8 @@ struct ScopePrinter {
7271 continue ;
7372
7473 if (IncludeRanges) {
75- OS << " RANGES: " << Symbol->getName () << " (line " << Symbol->getLineNumber () << " )" << " : " ;
74+ OS << " RANGES: " << Symbol->getName () << " (line "
75+ << Symbol->getLineNumber () << " )" << " : " ;
7676 }
7777
7878 for (const LVLocation *Loc : SymbolLocations) {
@@ -111,14 +111,15 @@ struct ScopePrinter {
111111 OS << " " ;
112112 }
113113
114- static void PrintCallstack (raw_ostream& OS, const LVScope* Scope) {
114+ static void PrintCallstack (raw_ostream & OS, const LVScope * Scope) {
115115 bool First = true ;
116116 const LVScope *PrevScope = nullptr ;
117117 while (Scope) {
118118 if (Scope->getIsFunction () || Scope->getIsInlinedFunction ()) {
119119 OS << " [" << Scope->getName ();
120120 if (PrevScope && PrevScope->getIsInlinedFunction ()) {
121- OS << " :" << cast<LVScopeFunctionInlined>(PrevScope)->getCallLineNumber ();
121+ OS << " :"
122+ << cast<LVScopeFunctionInlined>(PrevScope)->getCallLineNumber ();
122123 }
123124 OS << " ]" ;
124125 First = false ;
@@ -138,7 +139,8 @@ struct ScopePrinter {
138139 }
139140
140141 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.
142144 int LastLine = -1 ;
143145 StringRef LastFilename;
144146 for (const LVLine *Line : Lines) {
@@ -165,16 +167,13 @@ struct ScopePrinter {
165167 if (IncludeVars) {
166168 for (auto SymLoc : LiveSymbols) {
167169 const LVSymbol *Sym = SymLoc->getParentSymbol ();
168- if (Sym->getName () == " InMRT1" )
169- outs () << " " ;
170170 auto SymScope = Sym->getParentScope ();
171171 auto LineScope = LineDebug->getParentScope ();
172172 if (SymScope != LineScope && !IsChildScopeOf (LineScope, SymScope))
173173 continue ;
174174 PrintIndent (OS, 1 );
175175 OS << " VAR: " << Sym->getName () << " : "
176- << Sym->getType ()->getName ()
177- << " : " ;
176+ << Sym->getType ()->getName () << " : " ;
178177 SymLoc->printLocations (OS);
179178 OS << " (line " << Sym->getLineNumber () << " )" ;
180179 OS << " \n " ;
@@ -200,8 +199,8 @@ int main(int argc, char *argv[]) {
200199 llvm::InitializeAllTargetMCs ();
201200 InitializeAllDisassemblers ();
202201
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 " );
205204
206205 ScopedPrinter W (llvm::outs ());
207206 LVOptions Options;
@@ -213,8 +212,8 @@ int main(int argc, char *argv[]) {
213212 std::vector<std::string> Objects;
214213 LVReaderHandler Handler (Objects, W, Options);
215214 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 (" '" ));
218217
219218 auto *CU = Readers->getCompileUnit ();
220219 if (!CU)
@@ -228,7 +227,7 @@ int main(int argc, char *argv[]) {
228227 if (!Lines)
229228 continue ;
230229 outs () << " FUNCTION: " << Child->getName () << " \n " ;
231-
230+
232231 ScopePrinter P (outs (), Fn);
233232 P.Print ();
234233 }
0 commit comments