diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/DeclBase.cpp | 22 | ||||
-rw-r--r-- | lib/Parse/MinimalAction.cpp | 2 | ||||
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 6 | ||||
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 12 | ||||
-rw-r--r-- | lib/Parse/ParseObjc.cpp | 6 | ||||
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 6 |
6 files changed, 38 insertions, 16 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 3e968c7896..1e7ef549b4 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -19,6 +19,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/Type.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/Support/raw_ostream.h" #include <algorithm> #include <cstdio> #include <functional> @@ -92,6 +93,27 @@ void Decl::addDeclKind(Kind k) { } //===----------------------------------------------------------------------===// +// PrettyStackTraceDecl Implementation +//===----------------------------------------------------------------------===// + +void PrettyStackTraceDecl::print(llvm::raw_ostream &OS) const { + SourceLocation TheLoc = Loc; + if (TheLoc.isInvalid() && TheDecl) + TheLoc = TheDecl->getLocation(); + + if (TheLoc.isValid()) { + TheLoc.print(OS, SM); + OS << ": "; + } + + OS << Message; + + if (NamedDecl *DN = dyn_cast_or_null<NamedDecl>(TheDecl)) + OS << " '" << DN->getQualifiedNameAsString() << '\''; + OS << '\n'; +} + +//===----------------------------------------------------------------------===// // Decl Implementation //===----------------------------------------------------------------------===// diff --git a/lib/Parse/MinimalAction.cpp b/lib/Parse/MinimalAction.cpp index 3b8694c5d7..41ad36c83e 100644 --- a/lib/Parse/MinimalAction.cpp +++ b/lib/Parse/MinimalAction.cpp @@ -42,7 +42,7 @@ Action::DeclTy *Action::ActOnUsingDirective(Scope *CurScope, } -void PrettyStackTraceDecl::print(llvm::raw_ostream &OS) const { +void PrettyStackTraceActionsDecl::print(llvm::raw_ostream &OS) const { if (Loc.isValid()) { Loc.print(OS, SM); OS << ": "; diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 6e0ffe5e2b..50b6716df8 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1096,9 +1096,9 @@ ParseStructDeclaration(DeclSpec &DS, /// void Parser::ParseStructUnionBody(SourceLocation RecordLoc, unsigned TagType, DeclTy *TagDecl) { - PrettyStackTraceDecl CrashInfo(TagDecl, RecordLoc, Actions, - PP.getSourceManager(), - "parsing struct/union body"); + PrettyStackTraceActionsDecl CrashInfo(TagDecl, RecordLoc, Actions, + PP.getSourceManager(), + "parsing struct/union body"); SourceLocation LBraceLoc = ConsumeBrace(); diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 538185abc4..ef57737675 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -73,9 +73,9 @@ Parser::DeclTy *Parser::ParseNamespace(unsigned Context) { DeclTy *NamespcDecl = Actions.ActOnStartNamespaceDef(CurScope, IdentLoc, Ident, LBrace); - PrettyStackTraceDecl CrashInfo(NamespcDecl, NamespaceLoc, Actions, - PP.getSourceManager(), - "parsing namespace"); + PrettyStackTraceActionsDecl CrashInfo(NamespcDecl, NamespaceLoc, Actions, + PP.getSourceManager(), + "parsing namespace"); while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof)) ParseExternalDeclaration(); @@ -793,9 +793,9 @@ void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc, TagType == DeclSpec::TST_union || TagType == DeclSpec::TST_class) && "Invalid TagType!"); - PrettyStackTraceDecl CrashInfo(TagDecl, RecordLoc, Actions, - PP.getSourceManager(), - "parsing struct/union/class body"); + PrettyStackTraceActionsDecl CrashInfo(TagDecl, RecordLoc, Actions, + PP.getSourceManager(), + "parsing struct/union/class body"); SourceLocation LBraceLoc = ConsumeBrace(); diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index 981333d7e9..e9bb3d7c31 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -1356,9 +1356,9 @@ Parser::OwningStmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) { Parser::DeclTy *Parser::ParseObjCMethodDefinition() { DeclTy *MDecl = ParseObjCMethodPrototype(ObjCImpDecl); - PrettyStackTraceDecl CrashInfo(MDecl, Tok.getLocation(), Actions, - PP.getSourceManager(), - "parsing Objective-C method"); + PrettyStackTraceActionsDecl CrashInfo(MDecl, Tok.getLocation(), Actions, + PP.getSourceManager(), + "parsing Objective-C method"); // parse optional ';' if (Tok.is(tok::semi)) diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index cb9bdc7cfb..fe83247082 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -1288,9 +1288,9 @@ Parser::DeclTy *Parser::ParseFunctionStatementBody(DeclTy *Decl) { assert(Tok.is(tok::l_brace)); SourceLocation LBraceLoc = Tok.getLocation(); - PrettyStackTraceDecl CrashInfo(Decl, LBraceLoc, Actions, - PP.getSourceManager(), - "parsing function body"); + PrettyStackTraceActionsDecl CrashInfo(Decl, LBraceLoc, Actions, + PP.getSourceManager(), + "parsing function body"); // Do not enter a scope for the brace, as the arguments are in the same scope // (the function body) as the body itself. Instead, just read the statement |