From 914913952c6c3f3c23a5b499a263e11e972b51af Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Sun, 1 Mar 2015 06:49:49 +0000 Subject: [PATCH] [llvm-pdbdump] Add regex-based filtering. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230888 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/tools/llvm-pdbdump/Inputs/FilterTest.cpp | 29 +++++++ test/tools/llvm-pdbdump/Inputs/FilterTest.pdb | Bin 0 -> 44032 bytes test/tools/llvm-pdbdump/lit.local.cfg | 1 + test/tools/llvm-pdbdump/regex-filter.test | 76 ++++++++++++++++++ tools/llvm-pdbdump/ClassDefinitionDumper.cpp | 9 +++ tools/llvm-pdbdump/CompilandDumper.cpp | 14 ++++ tools/llvm-pdbdump/LinePrinter.cpp | 35 ++++++++ tools/llvm-pdbdump/LinePrinter.h | 22 ++++- tools/llvm-pdbdump/TypeDumper.cpp | 22 ++--- tools/llvm-pdbdump/TypeDumper.h | 3 +- tools/llvm-pdbdump/VariableDumper.cpp | 3 + tools/llvm-pdbdump/llvm-pdbdump.cpp | 20 ++++- 12 files changed, 220 insertions(+), 14 deletions(-) create mode 100644 test/tools/llvm-pdbdump/Inputs/FilterTest.cpp create mode 100644 test/tools/llvm-pdbdump/Inputs/FilterTest.pdb create mode 100644 test/tools/llvm-pdbdump/lit.local.cfg create mode 100644 test/tools/llvm-pdbdump/regex-filter.test diff --git a/test/tools/llvm-pdbdump/Inputs/FilterTest.cpp b/test/tools/llvm-pdbdump/Inputs/FilterTest.cpp new file mode 100644 index 00000000000..5f803e69849 --- /dev/null +++ b/test/tools/llvm-pdbdump/Inputs/FilterTest.cpp @@ -0,0 +1,29 @@ +// Compile with "cl /c /Zi /GR- FilterTest.cpp" +// Link with "link FilterTest.obj /debug /nodefaultlib /entry:main" + +class FilterTestClass { +public: + typedef int NestedTypedef; + enum NestedEnum { + NestedEnumValue1 + }; + + void MemberFunc() {} + +private: + int IntMemberVar; + double DoubleMemberVar; +}; + +int IntGlobalVar; +double DoubleGlobalVar; +typedef int GlobalTypedef; +enum GlobalEnum { + GlobalEnumVal1 +} GlobalEnumVar; + +int main(int argc, char **argv) { + FilterTestClass TestClass; + GlobalTypedef v1; + return 0; +} diff --git a/test/tools/llvm-pdbdump/Inputs/FilterTest.pdb b/test/tools/llvm-pdbdump/Inputs/FilterTest.pdb new file mode 100644 index 0000000000000000000000000000000000000000..5f01ec701b815d525033084ad530f4ecc4cb5b0f GIT binary patch literal 44032 zcmeHQYiwM{bw2wLMTvTlG(|hIV_(a(qldX%DvHH2mbDZ~S(HhcmZ(QvM$~fmlH7P- z-n~mbYR7Er{z(%QX`R9-4Ajj7Nl*v%kG5#j9~Dv;=?nc+ph(d_HC&`E`Ut2Nh|v~S zzi;l`-OJsjwIrojG-ssY+&MFIX6DS9nRDl!Gdq?_6mrGfjAIS<3?4XOjh#7e9gak! z+qdo>IwNplksyKt@UJrt_oy3~zlH*a0_&Xup@sKv8fPeAD6k0IIk2_aV#d;oqoJY5_77Wl33+u`Xpxq%FP(;I0tfD~hS?Y}%Ip zy0OT3NM;JQE$TTeS-a#E;%RZyHpz6(nUlqN*}Q9$GzT4E3$=<&P0c5!;*L{DO_vYc z!>tI9NvORQJtF>c>p-5JyMofUl(sLO(JL~ zc|#-{cT)3ZUI|Ddm(jctluSGupS6>SlRrY5KX#y9HLbDd?W{9ZuoE`070SKC&|S^j zW&Tjlv1Rhs*r>l#;{pQ5E=-{2NFtw?#iv%>uF3gC@4;vUjpaJ|pSpZ^!s>oLWp$5DSluIg zR@vf_Q-h;thlcm80mZxyE3Qb#6zf$75N9rA%F9w<>lyl`S|ZIWcZ^Um&e_OQ;ij4Qk{{%2ksq zBUhChi{!13gTwKjaQ`QbtM`Aee@vtIJMQBCxOp}dFcesS6yW?nCIN~8E7&V1ecM`Y z`tvB;FHg1wEbigl`L~}Al*7ulx%c!w>)E`M%A~GAKDP#QnLM`Fg6tP1hRFLUNk=(= zvIO54f>>?wAL~yb6HjI3!L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{$%0>eS>H4*- z^AzH`>(T~3Jm$sAbaK~h;`8nTVShtd&jvLvrqq$Q?^u8N&Y%={tD7p2dFJ?7WIKVi*3!{|pN{4?J>6;C_dCCkLAdzDC? zd<~7`7gxbS#_^KXu-o;Y~-eCVL?_8&_@7qaNH3&E1^vdEX@J>MU&KTNS zF_2bUOMic*2uI=kp-Mbfl{XdxFZN3qZy5{TcPn-qt|})novVVOH0S=aXamQ|8ym*Q z;d%dxcQ4Sq9vjL%Zgcb&g!=i8a|-z@&6Gus+jD@qJM!^THoM75RtDc)xr_WUyQ0 zp9e)gb5!K79u~RuDbNUnI`*{4-{S@J{uz` zV65;RwC&%}hqv)g`;{YD;&5TvUtbaVUDVM$4jt#mMP|0)JRi7z@GO4c1pRtBgR&Pz z9_bSK_BoN?1db=;B1PPG^dt2D4Se8v??II76FCaQi8s)`KYtlS0Z$lbD6n2AaO4b5 zZs2?1`{7679r%~vUxELv36bB!T;i>HzrRQ1SMg&1bBExBqiV%cXF^*#FUx z(AfW#XIt$9f8&F^!aaRC`+o~*w1+*S_kOED|CC-?8&v6B)`IJ(3>*EQDssl4 z6J_*&>Tn8l7jKvTkNN%2#^$E^{ZCitKg^d!^ZTDmesq@W)O!8>PyhZ;UBQkz`aeS$ zaeD6mqwsV_|Hu6PCx7&GqyGM<(f={}KlSu~zPVTAfBLaNs(n%|mFAD3z+Fp$wd(); zGIWFtuiv%9YZ_)K@SzlFL+b1BQ16rf!`a_<$p51}{D&LIH@}zQ)B4QsO~5R82k{RO z-iI`v2lAbO-wG^vsOt)GQYZQzc&Ob9)NXMp0Yd>p0Yd>p0Yd>p0Yd>p0Yd>p0Yd>p V0Yd>p0Yd>p0Yd>pfuAx3{vUFtpL75K literal 0 HcmV?d00001 diff --git a/test/tools/llvm-pdbdump/lit.local.cfg b/test/tools/llvm-pdbdump/lit.local.cfg new file mode 100644 index 00000000000..28a895f5114 --- /dev/null +++ b/test/tools/llvm-pdbdump/lit.local.cfg @@ -0,0 +1 @@ +config.unsupported = not config.have_dia_sdk diff --git a/test/tools/llvm-pdbdump/regex-filter.test b/test/tools/llvm-pdbdump/regex-filter.test new file mode 100644 index 00000000000..5f08d7348d9 --- /dev/null +++ b/test/tools/llvm-pdbdump/regex-filter.test @@ -0,0 +1,76 @@ +; RUN: llvm-pdbdump -symbols -globals -class-definitions -types %p/Inputs/FilterTest.pdb \ +; RUN: | FileCheck --check-prefix=NO_FILTER %s +; RUN: llvm-pdbdump -class-definitions -types -exclude-types="GlobalTypedef|NestedTypedef" \ +; RUN: %p/Inputs/FilterTest.pdb | FileCheck --check-prefix=EXCLUDE_TYPEDEFS %s +; RUN: llvm-pdbdump -class-definitions -types -exclude-types="GlobalEnum|NestedEnum" \ +; RUN: %p/Inputs/FilterTest.pdb | FileCheck --check-prefix=EXCLUDE_ENUMS %s +; RUN: llvm-pdbdump -class-definitions -types -symbols -globals \ +; RUN: -exclude-symbols="MemberVar|GlobalVar" %p/Inputs/FilterTest.pdb | FileCheck \ +; RUN: --check-prefix=EXCLUDE_VARS %s +; RUN: llvm-pdbdump -types -class-definitions -exclude-types="FilterTestClass" \ +; RUN: %p/Inputs/FilterTest.pdb | FileCheck --check-prefix=EXCLUDE_WHOLE_CLASS %s +; RUN: llvm-pdbdump -symbols -globals -exclude-compilands="FilterTest.obj" \ +; RUN: %p/Inputs/FilterTest.pdb | FileCheck --check-prefix=EXCLUDE_COMPILAND %s + +; NO_FILTER: ---TYPES--- +; NO_FILTER: Enums: +; NO_FILTER: enum GlobalEnum +; NO_FILTER: Typedefs +; NO_FILTER: typedef int GlobalTypedef +; NO_FILTER: Classes: +; NO_FILTER: class __vc_attributes +; NO_FILTER: class FilterTestClass +; NO_FILTER-DAG: typedef int NestedTypedef +; NO_FILTER-DAG: enum NestedEnum +; NO_FILTER-DAG: int IntMemberVar +; NO_FILTER-DAG: double DoubleMemberVar +; NO_FILTER: ---SYMBOLS--- +; NO_FILTER: Inputs\FilterTest.obj +; NO_FILTER: int __cdecl main(int argc, char** argv) +; NO_FILTER: ---GLOBALS--- +; NO_FILTER-DAG: double DoubleGlobalVar +; NO_FILTER-DAG: int IntGlobalVar +; NO_FILTER-DAG: GlobalEnum GlobalEnumVar + +; EXCLUDE_TYPEDEFS: ---TYPES--- +; EXCLUDE_TYPEDEFS: Enums: +; EXCLUDE_TYPEDEFS: GlobalEnum +; EXCLUDE_TYPEDEFS: Typedefs +; EXCLUDE_TYPEDEFS-NOT: GlobalTypedef +; EXCLUDE_TYPEDEFS: Classes +; EXCLUDE_TYPEDEFS: class FilterTestClass +; EXCLUDE_TYPEDEFS-NOT: NestedTypedef +; EXCLUDE_TYPEDEFS: private: + +; EXCLUDE_ENUMS: ---TYPES--- +; EXCLUDE_ENUMS: Enums: +; EXCLUDE_ENUMS-NOT: GlobalEnum +; EXCLUDE_ENUMS: Typedefs +; EXCLUDE_ENUMS: GlobalTypedef +; EXCLUDE_ENUMS: Classes +; EXCLUDE_ENUMS: class FilterTestClass +; EXCLUDE_ENUMS-NOT: NestedEnum +; EXCLUDE_ENUMS: private: + +; EXCLUDE_VARS: ---TYPES--- +; EXCLUDE_VARS: Classes: +; EXCLUDE_VARS: class FilterTestClass +; EXCLUDE_VARS: private: +; EXCLUDE_VARS-NOT: IntMemberVar +; EXCLUDE_VARS-NOT: DoubleMemberVar +; EXCLUDE_VARS: ---GLOBALS--- +; EXCLUDE_VARS-NOT: DoubleGlobalVar +; EXCLUDE_VARS-NOT: IntGlobalVar + +; EXCLUDE_WHOLE_CLASS: ---TYPES--- +; EXCLUDE_WHOLE_CLASS-NOT: class FilterTestClass +; EXCLUDE_WHOLE_CLASS-NOT: typedef int NestedTypedef +; EXCLUDE_WHOLE_CLASS-NOT: enum NestedEnum +; EXCLUDE_WHOLE_CLASS-NOT: int IntMemberVar +; EXCLUDE_WHOLE_CLASS-NOT: double DoubleMemberVar + +; EXCLUDE_COMPILAND: ---SYMBOLS--- +; EXCLUDE_COMPILAND-NOT: FilterTest.obj +; EXCLUDE_COMPILAND-NOT: __cdecl main +; EXCLUDE_COMPILAND: * Linker * +; EXCLUDE_COMPILAND: ---GLOBALS--- diff --git a/tools/llvm-pdbdump/ClassDefinitionDumper.cpp b/tools/llvm-pdbdump/ClassDefinitionDumper.cpp index 8a0c04fc5e4..d6fcaea3eda 100644 --- a/tools/llvm-pdbdump/ClassDefinitionDumper.cpp +++ b/tools/llvm-pdbdump/ClassDefinitionDumper.cpp @@ -142,6 +142,9 @@ void ClassDefinitionDumper::dump(const PDBSymbolData &Symbol, raw_ostream &OS, void ClassDefinitionDumper::dump(const PDBSymbolFunc &Symbol, raw_ostream &OS, int Indent) { + if (Printer.IsSymbolExcluded(Symbol.getName())) + return; + Printer.NewLine(); FunctionDumper Dumper(Printer); Dumper.start(Symbol, FunctionDumper::PointerType::None, OS, Indent); @@ -152,6 +155,9 @@ void ClassDefinitionDumper::dump(const PDBSymbolTypeVTable &Symbol, void ClassDefinitionDumper::dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS, int Indent) { + if (Printer.IsTypeExcluded(Symbol.getName())) + return; + Printer.NewLine(); WithColor(Printer, PDB_ColorItem::Keyword).get() << "enum "; WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName(); @@ -159,6 +165,9 @@ void ClassDefinitionDumper::dump(const PDBSymbolTypeEnum &Symbol, void ClassDefinitionDumper::dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS, int Indent) { + if (Printer.IsTypeExcluded(Symbol.getName())) + return; + Printer.NewLine(); TypedefDumper Dumper(Printer); Dumper.start(Symbol, OS, Indent); diff --git a/tools/llvm-pdbdump/CompilandDumper.cpp b/tools/llvm-pdbdump/CompilandDumper.cpp index e15384ce71c..14197a8b48e 100644 --- a/tools/llvm-pdbdump/CompilandDumper.cpp +++ b/tools/llvm-pdbdump/CompilandDumper.cpp @@ -47,6 +47,9 @@ void CompilandDumper::dump(const PDBSymbolCompilandEnv &Symbol, raw_ostream &OS, void CompilandDumper::start(const PDBSymbolCompiland &Symbol, raw_ostream &OS, int Indent, bool Children) { std::string FullName = Symbol.getName(); + if (Printer.IsCompilandExcluded(FullName)) + return; + Printer.NewLine(); WithColor(Printer, PDB_ColorItem::Path).get() << FullName; if (!Children) @@ -61,6 +64,9 @@ void CompilandDumper::start(const PDBSymbolCompiland &Symbol, raw_ostream &OS, void CompilandDumper::dump(const PDBSymbolData &Symbol, raw_ostream &OS, int Indent) { + if (Printer.IsSymbolExcluded(Symbol.getName())) + return; + Printer.NewLine(); switch (auto LocType = Symbol.getLocationType()) { @@ -86,6 +92,8 @@ void CompilandDumper::dump(const PDBSymbolFunc &Symbol, raw_ostream &OS, int Indent) { if (Symbol.getLength() == 0) return; + if (Printer.IsSymbolExcluded(Symbol.getName())) + return; Printer.NewLine(); FunctionDumper Dumper(Printer); @@ -94,6 +102,9 @@ void CompilandDumper::dump(const PDBSymbolFunc &Symbol, raw_ostream &OS, void CompilandDumper::dump(const PDBSymbolLabel &Symbol, raw_ostream &OS, int Indent) { + if (Printer.IsSymbolExcluded(Symbol.getName())) + return; + Printer.NewLine(); Printer << "label "; WithColor(Printer, PDB_ColorItem::Address).get() @@ -103,6 +114,9 @@ void CompilandDumper::dump(const PDBSymbolLabel &Symbol, raw_ostream &OS, void CompilandDumper::dump(const PDBSymbolThunk &Symbol, raw_ostream &OS, int Indent) { + if (Printer.IsSymbolExcluded(Symbol.getName())) + return; + Printer.NewLine(); Printer << "thunk "; PDB_ThunkOrdinal Ordinal = Symbol.getThunkOrdinal(); diff --git a/tools/llvm-pdbdump/LinePrinter.cpp b/tools/llvm-pdbdump/LinePrinter.cpp index 09ba329ad0a..7aa93599a20 100644 --- a/tools/llvm-pdbdump/LinePrinter.cpp +++ b/tools/llvm-pdbdump/LinePrinter.cpp @@ -9,6 +9,8 @@ #include "LinePrinter.h" +#include "llvm/Support/Regex.h" + #include using namespace llvm; @@ -27,6 +29,39 @@ void LinePrinter::NewLine() { OS.indent(CurrentIndent); } +bool LinePrinter::IsTypeExcluded(llvm::StringRef TypeName) { + if (TypeName.empty()) + return false; + + for (auto &Expr : TypeFilters) { + if (Expr.match(TypeName)) + return true; + } + return false; +} + +bool LinePrinter::IsSymbolExcluded(llvm::StringRef SymbolName) { + if (SymbolName.empty()) + return false; + + for (auto &Expr : SymbolFilters) { + if (Expr.match(SymbolName)) + return true; + } + return false; +} + +bool LinePrinter::IsCompilandExcluded(llvm::StringRef CompilandName) { + if (CompilandName.empty()) + return false; + + for (auto &Expr : CompilandFilters) { + if (Expr.match(CompilandName)) + return true; + } + return false; +} + WithColor::WithColor(LinePrinter &P, PDB_ColorItem C) : OS(P.OS) { if (C == PDB_ColorItem::None) OS.resetColor(); diff --git a/tools/llvm-pdbdump/LinePrinter.h b/tools/llvm-pdbdump/LinePrinter.h index 0f66d1f7c85..003e847bbb4 100644 --- a/tools/llvm-pdbdump/LinePrinter.h +++ b/tools/llvm-pdbdump/LinePrinter.h @@ -12,6 +12,9 @@ #include "llvm/ADT/Twine.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/Regex.h" + +#include namespace llvm { @@ -21,17 +24,34 @@ class LinePrinter { public: LinePrinter(int Indent, raw_ostream &Stream); + template void SetTypeFilters(Iter Begin, Iter End) { + TypeFilters.assign(Begin, End); + } + template void SetSymbolFilters(Iter Begin, Iter End) { + SymbolFilters.assign(Begin, End); + } + template void SetCompilandFilters(Iter Begin, Iter End) { + CompilandFilters.assign(Begin, End); + } + void Indent(); void Unindent(); - void NewLine(); raw_ostream &getStream() { return OS; } + bool IsTypeExcluded(llvm::StringRef TypeName); + bool IsSymbolExcluded(llvm::StringRef SymbolName); + bool IsCompilandExcluded(llvm::StringRef CompilandName); + private: raw_ostream &OS; int IndentSpaces; int CurrentIndent; + + std::list CompilandFilters; + std::list TypeFilters; + std::list SymbolFilters; }; template diff --git a/tools/llvm-pdbdump/TypeDumper.cpp b/tools/llvm-pdbdump/TypeDumper.cpp index 71ed203637a..8bca68e8d8b 100644 --- a/tools/llvm-pdbdump/TypeDumper.cpp +++ b/tools/llvm-pdbdump/TypeDumper.cpp @@ -22,9 +22,8 @@ using namespace llvm; -TypeDumper::TypeDumper(LinePrinter &P, bool Inline, bool ClassDefs) - : PDBSymDumper(true), Printer(P), InlineDump(Inline), - FullClassDefs(ClassDefs) {} +TypeDumper::TypeDumper(LinePrinter &P, bool ClassDefs) + : PDBSymDumper(true), Printer(P), FullClassDefs(ClassDefs) {} void TypeDumper::start(const PDBSymbolExe &Exe, raw_ostream &OS, int Indent) { auto Enums = Exe.findAllChildren(); @@ -59,9 +58,9 @@ void TypeDumper::dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS, int Indent) { if (Symbol.getUnmodifiedTypeId() != 0) return; - - if (!InlineDump) - Printer.NewLine(); + if (Printer.IsTypeExcluded(Symbol.getName())) + return; + Printer.NewLine(); WithColor(Printer, PDB_ColorItem::Keyword).get() << "enum "; WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName(); @@ -69,9 +68,10 @@ void TypeDumper::dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS, void TypeDumper::dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS, int Indent) { - if (!InlineDump) - Printer.NewLine(); + if (Printer.IsTypeExcluded(Symbol.getName())) + return; + Printer.NewLine(); TypedefDumper Dumper(Printer); Dumper.start(Symbol, OS, Indent); } @@ -80,8 +80,10 @@ void TypeDumper::dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS, int Indent) { if (Symbol.getUnmodifiedTypeId() != 0) return; - if (!InlineDump) - Printer.NewLine(); + if (Printer.IsTypeExcluded(Symbol.getName())) + return; + + Printer.NewLine(); if (FullClassDefs) { ClassDefinitionDumper Dumper(Printer); diff --git a/tools/llvm-pdbdump/TypeDumper.h b/tools/llvm-pdbdump/TypeDumper.h index b0bfe570e91..51d2d4a5553 100644 --- a/tools/llvm-pdbdump/TypeDumper.h +++ b/tools/llvm-pdbdump/TypeDumper.h @@ -18,7 +18,7 @@ class LinePrinter; class TypeDumper : public PDBSymDumper { public: - TypeDumper(LinePrinter &P, bool Inline, bool ClassDefs); + TypeDumper(LinePrinter &P, bool ClassDefs); void start(const PDBSymbolExe &Exe, raw_ostream &OS, int Indent); @@ -31,7 +31,6 @@ public: private: LinePrinter &Printer; - bool InlineDump; bool FullClassDefs; }; } diff --git a/tools/llvm-pdbdump/VariableDumper.cpp b/tools/llvm-pdbdump/VariableDumper.cpp index 90c418cf52a..ec72d16fef9 100644 --- a/tools/llvm-pdbdump/VariableDumper.cpp +++ b/tools/llvm-pdbdump/VariableDumper.cpp @@ -32,6 +32,9 @@ VariableDumper::VariableDumper(LinePrinter &P) void VariableDumper::start(const PDBSymbolData &Var, raw_ostream &OS, int Indent) { + if (Printer.IsSymbolExcluded(Var.getName())) + return; + Printer.NewLine(); Printer << "data "; diff --git a/tools/llvm-pdbdump/llvm-pdbdump.cpp b/tools/llvm-pdbdump/llvm-pdbdump.cpp index 98b26144e34..9ad79ad3b32 100644 --- a/tools/llvm-pdbdump/llvm-pdbdump.cpp +++ b/tools/llvm-pdbdump/llvm-pdbdump.cpp @@ -63,6 +63,19 @@ cl::opt Globals("globals", cl::desc("Dump global symbols")); cl::opt Types("types", cl::desc("Display types")); cl::opt ClassDefs("class-definitions", cl::desc("Display full class definitions")); + +cl::list + ExcludeTypes("exclude-types", + cl::desc("Exclude types by regular expression"), + cl::ZeroOrMore); +cl::list + ExcludeSymbols("exclude-symbols", + cl::desc("Exclude symbols by regular expression"), + cl::ZeroOrMore); +cl::list + ExcludeCompilands("exclude-compilands", + cl::desc("Exclude compilands by regular expression"), + cl::ZeroOrMore); } static void dumpInput(StringRef Path) { @@ -90,6 +103,11 @@ static void dumpInput(StringRef Path) { } LinePrinter Printer(2, outs()); + Printer.SetTypeFilters(opts::ExcludeTypes.begin(), opts::ExcludeTypes.end()); + Printer.SetSymbolFilters(opts::ExcludeSymbols.begin(), + opts::ExcludeSymbols.end()); + Printer.SetCompilandFilters(opts::ExcludeCompilands.begin(), + opts::ExcludeCompilands.end()); auto GlobalScope(Session->getGlobalScope()); std::string FileName(GlobalScope->getSymbolsFileName()); @@ -140,7 +158,7 @@ static void dumpInput(StringRef Path) { Printer.NewLine(); WithColor(Printer, PDB_ColorItem::SectionHeader).get() << "---TYPES---"; Printer.Indent(); - TypeDumper Dumper(Printer, false, opts::ClassDefs); + TypeDumper Dumper(Printer, opts::ClassDefs); Dumper.start(*GlobalScope, outs(), 2); Printer.Unindent(); } -- 2.34.1