Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit f88836d

Browse files
committed
Move PrettyStackTraceParserEntry to ParseAST.cpp
r128056 moved PrettyStackTraceParserEntry construction from Parser.h to ParseAST.cpp, so there's no need to keep this class in a header. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168731 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent d1bac8d commit f88836d

File tree

3 files changed

+35
-35
lines changed

3 files changed

+35
-35
lines changed

include/clang/Parse/Parser.h

-9
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,6 @@ namespace clang {
4444
class PoisonSEHIdentifiersRAIIObject;
4545
class VersionTuple;
4646

47-
/// PrettyStackTraceParserEntry - If a crash happens while the parser is active,
48-
/// an entry is printed for it.
49-
class PrettyStackTraceParserEntry : public llvm::PrettyStackTraceEntry {
50-
const Parser &P;
51-
public:
52-
PrettyStackTraceParserEntry(const Parser &p) : P(p) {}
53-
virtual void print(raw_ostream &OS) const;
54-
};
55-
5647
/// PrecedenceLevels - These are precedences for the binary/ternary
5748
/// operators in the C99 grammar. These have been named to relate
5849
/// with the C99 grammar productions. Low precedences numbers bind

lib/Parse/ParseAST.cpp

+35-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,40 @@
2929

3030
using namespace clang;
3131

32+
namespace {
33+
34+
/// If a crash happens while the parser is active, an entry is printed for it.
35+
class PrettyStackTraceParserEntry : public llvm::PrettyStackTraceEntry {
36+
const Parser &P;
37+
public:
38+
PrettyStackTraceParserEntry(const Parser &p) : P(p) {}
39+
virtual void print(raw_ostream &OS) const;
40+
};
41+
42+
/// If a crash happens while the parser is active, print out a line indicating
43+
/// what the current token is.
44+
void PrettyStackTraceParserEntry::print(raw_ostream &OS) const {
45+
const Token &Tok = P.getCurToken();
46+
if (Tok.is(tok::eof)) {
47+
OS << "<eof> parser at end of file\n";
48+
return;
49+
}
50+
51+
if (Tok.getLocation().isInvalid()) {
52+
OS << "<unknown> parser at unknown location\n";
53+
return;
54+
}
55+
56+
const Preprocessor &PP = P.getPreprocessor();
57+
Tok.getLocation().print(OS, PP.getSourceManager());
58+
if (Tok.isAnnotation())
59+
OS << ": at annotation token \n";
60+
else
61+
OS << ": current parser token '" << PP.getSpelling(Tok) << "'\n";
62+
}
63+
64+
} // namespace
65+
3266
//===----------------------------------------------------------------------===//
3367
// Public interface to the file
3468
//===----------------------------------------------------------------------===//
@@ -43,9 +77,7 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
4377
CodeCompleteConsumer *CompletionConsumer,
4478
bool SkipFunctionBodies) {
4579

46-
OwningPtr<Sema> S(new Sema(PP, Ctx, *Consumer,
47-
TUKind,
48-
CompletionConsumer));
80+
OwningPtr<Sema> S(new Sema(PP, Ctx, *Consumer, TUKind, CompletionConsumer));
4981

5082
// Recover resources if we crash before exiting this method.
5183
llvm::CrashRecoveryContextCleanupRegistrar<Sema> CleanupSema(S.get());

lib/Parse/Parser.cpp

-23
Original file line numberDiff line numberDiff line change
@@ -103,29 +103,6 @@ Parser::Parser(Preprocessor &pp, Sema &actions, bool skipFunctionBodies)
103103
PP.setCodeCompletionHandler(*this);
104104
}
105105

106-
/// If a crash happens while the parser is active, print out a line indicating
107-
/// what the current token is.
108-
void PrettyStackTraceParserEntry::print(raw_ostream &OS) const {
109-
const Token &Tok = P.getCurToken();
110-
if (Tok.is(tok::eof)) {
111-
OS << "<eof> parser at end of file\n";
112-
return;
113-
}
114-
115-
if (Tok.getLocation().isInvalid()) {
116-
OS << "<unknown> parser at unknown location\n";
117-
return;
118-
}
119-
120-
const Preprocessor &PP = P.getPreprocessor();
121-
Tok.getLocation().print(OS, PP.getSourceManager());
122-
if (Tok.isAnnotation())
123-
OS << ": at annotation token \n";
124-
else
125-
OS << ": current parser token '" << PP.getSpelling(Tok) << "'\n";
126-
}
127-
128-
129106
DiagnosticBuilder Parser::Diag(SourceLocation Loc, unsigned DiagID) {
130107
return Diags.Report(Loc, DiagID);
131108
}

0 commit comments

Comments
 (0)