forked from OSchip/llvm-project
DeclPrinter: add terse output mode and lots of tests
Add a flag PrintingPolicy::DontRecurseInDeclContext to provide "terse" output from DeclPrinter. The motivation is to use DeclPrinter to print declarations in user-friendly format, without overwhelming user with inner detail of the declaration being printed. Also add many tests for DeclPrinter. There are quite a few things that we print incorrectly: search for WRONG in DeclPrinterTest.cpp -- and these tests check our output against incorrect output, so that we can fix/refactor/rewrite the DeclPrinter later. llvm-svn: 162245
This commit is contained in:
parent
d8561f058d
commit
309856ae9f
|
@ -39,7 +39,7 @@ struct PrintingPolicy {
|
|||
SuppressUnwrittenScope(false), SuppressInitializers(false),
|
||||
ConstantArraySizeAsWritten(false), AnonymousTagLocations(true),
|
||||
SuppressStrongLifetime(false), Bool(LO.Bool),
|
||||
DumpSourceManager(0) { }
|
||||
DontRecurseInDeclContext(false), DumpSourceManager(0) { }
|
||||
|
||||
/// \brief What language we're printing.
|
||||
LangOptions LangOpts;
|
||||
|
@ -134,6 +134,9 @@ struct PrintingPolicy {
|
|||
/// doesn't actually have 'bool' (because, e.g., it is defined as a macro).
|
||||
unsigned Bool : 1;
|
||||
|
||||
/// Don't print contents of DeclContexts. Used to provide a 'terse' output.
|
||||
unsigned DontRecurseInDeclContext : 1;
|
||||
|
||||
/// \brief If we are "dumping" rather than "pretty-printing", this points to
|
||||
/// a SourceManager which will be used to dump SourceLocations. Dumping
|
||||
/// involves printing the internal details of the AST and pretty-printing
|
||||
|
|
|
@ -220,6 +220,9 @@ void DeclPrinter::Print(AccessSpecifier AS) {
|
|||
//----------------------------------------------------------------------------
|
||||
|
||||
void DeclPrinter::VisitDeclContext(DeclContext *DC, bool Indent) {
|
||||
if (Policy.DontRecurseInDeclContext)
|
||||
return;
|
||||
|
||||
if (Indent)
|
||||
Indentation += Policy.Indentation;
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
add_clang_unittest(ASTTests
|
||||
CommentLexer.cpp
|
||||
CommentParser.cpp
|
||||
DeclPrinterTest.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(ASTTests
|
||||
clangAST
|
||||
clangAST clangASTMatchers clangTooling
|
||||
)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -9,7 +9,10 @@
|
|||
|
||||
CLANG_LEVEL = ../..
|
||||
TESTNAME = AST
|
||||
LINK_COMPONENTS := support mc
|
||||
USEDLIBS = clangAST.a clangLex.a clangBasic.a
|
||||
include $(CLANG_LEVEL)/../../Makefile.config
|
||||
LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser support mc
|
||||
USEDLIBS = clangTooling.a clangFrontend.a clangSerialization.a clangDriver.a \
|
||||
clangRewrite.a clangParse.a clangSema.a clangAnalysis.a \
|
||||
clangAST.a clangASTMatchers.a clangLex.a clangBasic.a clangEdit.a
|
||||
|
||||
include $(CLANG_LEVEL)/unittests/Makefile
|
||||
|
|
Loading…
Reference in New Issue