Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Root
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
cxwx
Root
Commits
b0c5f6f6
Commit
b0c5f6f6
authored
7 years ago
by
Axel Naumann
Browse files
Options
Downloads
Patches
Plain Diff
Remove stray file, leftover of llvm upgrade.
parent
ade6f001
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
interpreter/llvm/src/tools/clang/D0bb39a5.diff
+0
-195
0 additions, 195 deletions
interpreter/llvm/src/tools/clang/D0bb39a5.diff
with
0 additions
and
195 deletions
interpreter/llvm/src/tools/clang/D0bb39a5.diff
deleted
100644 → 0
+
0
−
195
View file @
ade6f001
commit 0bb39a5d9a5da83ee9aefd26f6001cd8abf6f4f2
Author: Axel Naumann <Axel.Naumann@cern.ch>
Date: Mon Aug 26 14:29:24 2013 +0200
Temporary parsers should not manipulate global parser state.
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h
index 9d59f25..7dda3ea 100644
--- a/include/clang/Parse/Parser.h
+++ b/include/clang/Parse/Parser.h
@@ -48,6 +48,7 @@
namespace clang {
class OMPClause;
class ObjCTypeParamList;
class ObjCTypeParameter;
+ class DestroyTemplateIdAnnotationsRAIIObj;
/// Parser - This implements a parser for the C family of languages. After
/// parsing units of the grammar, productions are invoked to handle whatever has
@@ -60,6 +61,7 @@
class Parser : public CodeCompletionHandler {
friend class ObjCDeclContextSwitch;
friend class ParenBraceBracketBalancer;
friend class BalancedDelimiterTracker;
+ friend class DestroyTemplateIdAnnotationsRAIIObj;
Preprocessor &PP;
@@ -243,8 +245,10 @@
class Parser : public CodeCompletionHandler {
bool SkipFunctionBodies;
+ bool IsTemporary;
public:
- Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies);
+ Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies,
+ bool isTemp = false);
~Parser() override;
const LangOptions &getLangOpts() const { return PP.getLangOpts(); }
@@ -254,6 +258,34 @@
public:
AttributeFactory &getAttrFactory() { return AttrFactory; }
const Token &getCurToken() const { return Tok; }
+
+ /// A RAII object to temporarily reset PP's state and restore it.
+ class ParserCurTokRestoreRAII {
+ private:
+ Parser &P;
+ Token SavedTok;
+
+ public:
+ ParserCurTokRestoreRAII(Parser &P)
+ : P(P), SavedTok(P.Tok)
+ {
+ }
+
+ void pop() {
+ if (SavedTok.is(tok::unknown))
+ return;
+
+ P.Tok = SavedTok;
+
+ SavedTok.startToken();
+ }
+
+ ~ParserCurTokRestoreRAII() {
+ pop();
+ }
+ };
+
+
Scope *getCurScope() const { return Actions.getCurScope(); }
void incrementMSManglingNumber() const {
return Actions.incrementMSManglingNumber();
@@ -852,7 +884,7 @@
public:
return Diag(Tok, DiagID);
}
-private:
+protected:
void SuggestParentheses(SourceLocation Loc, unsigned DK,
SourceRange ParenRange);
void CheckNestedObjCContexts(SourceLocation AtLoc);
diff --git a/lib/Parse/ParsePragma.cpp b/lib/Parse/ParsePragma.cpp
index bff5d11..282245d 100644
--- a/lib/Parse/ParsePragma.cpp
+++ b/lib/Parse/ParsePragma.cpp
@@ -164,6 +164,10 @@
struct PragmaMSRuntimeChecksHandler : public EmptyPragmaHandler {
} // end namespace
void Parser::initializePragmaHandlers() {
+ // No pragma parsing for temporary parsers.
+ if (IsTemporary)
+ return;
+
AlignHandler.reset(new PragmaAlignHandler());
PP.AddPragmaHandler(AlignHandler.get());
@@ -245,6 +249,10 @@
void Parser::initializePragmaHandlers() {
}
void Parser::resetPragmaHandlers() {
+ // No pragma parsing for temporary parsers.
+ if (IsTemporary)
+ return;
+
// Remove the pragma handlers we installed.
PP.RemovePragmaHandler(AlignHandler.get());
AlignHandler.reset();
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index f968f99..8e1c057 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -68,15 +68,17 @@
IdentifierInfo *Parser::getSEHExceptKeyword() {
return Ident__except;
}
-Parser::Parser(Preprocessor &pp, Sema &actions, bool skipFunctionBodies)
+Parser::Parser(Preprocessor &pp, Sema &actions, bool skipFunctionBodies,
+ bool isTemporary /*=false*/)
: PP(pp), Actions(actions), Diags(PP.getDiagnostics()),
GreaterThanIsOperator(true), ColonIsSacred(false),
InMessageExpression(false), TemplateParameterDepth(0),
- ParsingInObjCContainer(false) {
+ ParsingInObjCContainer(false), IsTemporary(isTemporary) {
SkipFunctionBodies = pp.isCodeCompletionEnabled() || skipFunctionBodies;
Tok.startToken();
Tok.setKind(tok::eof);
- Actions.CurScope = nullptr;
+ if (!IsTemporary)
+ Actions.CurScope = nullptr;
NumCachedScopes = 0;
ParenCount = BracketCount = BraceCount = 0;
CurParsedObjCImpl = nullptr;
@@ -86,9 +88,11 @@
Parser::Parser(Preprocessor &pp, Sema &actions, bool skipFunctionBodies)
initializePragmaHandlers();
CommentSemaHandler.reset(new ActionCommentHandler(actions));
- PP.addCommentHandler(CommentSemaHandler.get());
+ if (!IsTemporary)
+ PP.addCommentHandler(CommentSemaHandler.get());
- PP.setCodeCompletionHandler(*this);
+ if (!IsTemporary)
+ PP.setCodeCompletionHandler(*this);
}
DiagnosticBuilder Parser::Diag(SourceLocation Loc, unsigned DiagID) {
@@ -422,8 +426,10 @@
Parser::ParseScopeFlags::~ParseScopeFlags() {
Parser::~Parser() {
// If we still have scopes active, delete the scope tree.
+ if (!IsTemporary) {
delete getCurScope();
Actions.CurScope = nullptr;
+ }
// Free the scope cache.
for (unsigned i = 0, e = NumCachedScopes; i != e; ++i)
@@ -534,13 +540,13 @@
void Parser::LateTemplateParserCleanupCallback(void *P) {
// While this RAII helper doesn't bracket any actual work, the destructor will
// clean up annotations that were created during ActOnEndOfTranslationUnit
// when incremental processing is enabled.
- DestroyTemplateIdAnnotationsRAIIObj CleanupRAII(((Parser *)P)->TemplateIds);
+ DestroyTemplateIdAnnotationsRAIIObj CleanupRAII(*(Parser*)P);
}
/// ParseTopLevelDecl - Parse one top-level declaration, return whatever the
/// action tells us to. This returns true if the EOF was encountered.
bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result) {
- DestroyTemplateIdAnnotationsRAIIObj CleanupRAII(TemplateIds);
+ DestroyTemplateIdAnnotationsRAIIObj CleanupRAII(*this);
// Skip over the EOF token, flagging end of previous input for incremental
// processing
@@ -579,9 +585,8 @@
bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result) {
PP.isIncrementalProcessingEnabled() ?
LateTemplateParserCleanupCallback : nullptr,
this);
- if (!PP.isIncrementalProcessingEnabled())
- Actions.ActOnEndOfTranslationUnit();
- //else don't tell Sema that we ended parsing: more input might come.
+ Actions.ActOnEndOfTranslationUnit();
+
return true;
default:
@@ -622,7 +627,7 @@
bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result) {
Parser::DeclGroupPtrTy
Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
ParsingDeclSpec *DS) {
- DestroyTemplateIdAnnotationsRAIIObj CleanupRAII(TemplateIds);
+ DestroyTemplateIdAnnotationsRAIIObj CleanupRAII(*this);
ParenBraceBracketBalancer BalancerRAIIObj(*this);
if (PP.isCodeCompletionReached()) {
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment