Support for printing/dumping static asserts

llvm-svn: 127744
This commit is contained in:
Peter Collingbourne 2011-03-16 18:37:27 +00:00
parent 4828368dc8
commit 7d8a0b52d4
2 changed files with 15 additions and 0 deletions

View File

@ -54,6 +54,7 @@ namespace {
void VisitLabelDecl(LabelDecl *D);
void VisitParmVarDecl(ParmVarDecl *D);
void VisitFileScopeAsmDecl(FileScopeAsmDecl *D);
void VisitStaticAssertDecl(StaticAssertDecl *D);
void VisitNamespaceDecl(NamespaceDecl *D);
void VisitUsingDirectiveDecl(UsingDirectiveDecl *D);
void VisitNamespaceAliasDecl(NamespaceAliasDecl *D);
@ -590,6 +591,14 @@ void DeclPrinter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) {
Out << ")";
}
void DeclPrinter::VisitStaticAssertDecl(StaticAssertDecl *D) {
Out << "static_assert(";
D->getAssertExpr()->printPretty(Out, Context, 0, Policy, Indentation);
Out << ", ";
D->getMessage()->printPretty(Out, Context, 0, Policy, Indentation);
Out << ")";
}
//----------------------------------------------------------------------------
// C++ declarations
//----------------------------------------------------------------------------

View File

@ -284,6 +284,12 @@ void StmtDumper::DumpDeclarator(Decl *D) {
OS << ";\"";
} else if (LabelDecl *LD = dyn_cast<LabelDecl>(D)) {
OS << "label " << LD->getNameAsString();
} else if (StaticAssertDecl *SAD = dyn_cast<StaticAssertDecl>(D)) {
OS << "\"static_assert(\n";
DumpSubTree(SAD->getAssertExpr());
OS << ",\n";
DumpSubTree(SAD->getMessage());
OS << ");\"";
} else {
assert(0 && "Unexpected decl");
}