diff options
Diffstat (limited to 'clang/lib/Parse')
| -rw-r--r-- | clang/lib/Parse/MinimalAction.cpp | 23 | ||||
| -rw-r--r-- | clang/lib/Parse/Parser.cpp | 38 | 
2 files changed, 39 insertions, 22 deletions
diff --git a/clang/lib/Parse/MinimalAction.cpp b/clang/lib/Parse/MinimalAction.cpp index 5238a899574..3b8694c5d7a 100644 --- a/clang/lib/Parse/MinimalAction.cpp +++ b/clang/lib/Parse/MinimalAction.cpp @@ -19,6 +19,29 @@  #include "llvm/Support/raw_ostream.h"  using namespace clang; +///  Out-of-line virtual destructor to provide home for Action class. +ActionBase::~ActionBase() {} + +///  Out-of-line virtual destructor to provide home for Action class. +Action::~Action() {} + +// Defined out-of-line here because of dependecy on AttributeList +Action::DeclTy *Action::ActOnUsingDirective(Scope *CurScope, +                                            SourceLocation UsingLoc, +                                            SourceLocation NamespcLoc, +                                            const CXXScopeSpec &SS, +                                            SourceLocation IdentLoc, +                                            IdentifierInfo *NamespcName, +                                            AttributeList *AttrList) { +   +  // FIXME: Parser seems to assume that Action::ActOn* takes ownership over +  // passed AttributeList, however other actions don't free it, is it +  // temporary state or bug? +  delete AttrList; +  return 0; +} + +  void PrettyStackTraceDecl::print(llvm::raw_ostream &OS) const {    if (Loc.isValid()) {      Loc.print(OS, SM); diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 3cdaab6e889..70a336678cd 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -15,12 +15,13 @@  #include "clang/Parse/ParseDiagnostic.h"  #include "clang/Parse/DeclSpec.h"  #include "clang/Parse/Scope.h" +#include "llvm/Support/raw_ostream.h"  #include "ExtensionRAIIObject.h"  #include "ParsePragma.h"  using namespace clang;  Parser::Parser(Preprocessor &pp, Action &actions) -  : PP(pp), Actions(actions), Diags(PP.getDiagnostics()),  +  : CrashInfo(*this), PP(pp), Actions(actions), Diags(PP.getDiagnostics()),       GreaterThanIsOperator(true) {    Tok.setKind(tok::eof);    CurScope = 0; @@ -38,30 +39,23 @@ Parser::Parser(Preprocessor &pp, Action &actions)    PushTopClassStack();  } -///  Out-of-line virtual destructor to provide home for Action class. -ActionBase::~ActionBase() {} - -///  Out-of-line virtual destructor to provide home for Action class. -Action::~Action() {} - -// Defined out-of-line here because of dependecy on AttributeList -Action::DeclTy *Action::ActOnUsingDirective(Scope *CurScope, -                                            SourceLocation UsingLoc, -                                            SourceLocation NamespcLoc, -                                            const CXXScopeSpec &SS, -                                            SourceLocation IdentLoc, -                                            IdentifierInfo *NamespcName, -                                            AttributeList *AttrList) { - -  // FIXME: Parser seems to assume that Action::ActOn* takes ownership over -  // passed AttributeList, however other actions don't free it, is it -  // temporary state or bug? -  delete AttrList; -  return 0; +/// If a crash happens while the parser is active, print out a line indicating +/// what the current token is. +void PrettyStackTraceParserEntry::print(llvm::raw_ostream &OS) const { +  const Token &Tok = P.getCurToken(); +  if (Tok.getLocation().isInvalid()) { +    OS << "<eof> parser at end of file\n"; +    return; +  } +   +  const Preprocessor &PP = P.getPreprocessor(); +  Tok.getLocation().print(OS, PP.getSourceManager()); +  OS << ": current parser token '" << PP.getSpelling(Tok) << "'\n";  } +  DiagnosticBuilder Parser::Diag(SourceLocation Loc, unsigned DiagID) { -  return Diags.Report(FullSourceLoc(Loc,PP.getSourceManager()), DiagID); +  return Diags.Report(FullSourceLoc(Loc, PP.getSourceManager()), DiagID);  }  DiagnosticBuilder Parser::Diag(const Token &Tok, unsigned DiagID) {  | 

