Skip to content

Commit

Permalink
[llvm-project] Drop temporary parser functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
hahnjo committed Feb 26, 2025
1 parent 07e738c commit 18d1e19
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 41 deletions.
11 changes: 4 additions & 7 deletions interpreter/llvm-project/clang/include/clang/Parse/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,8 @@ class Parser : public CodeCompletionHandler {
/// a statement expression and builds a suitable expression statement.
StmtResult handleExprStmt(ExprResult E, ParsedStmtContext StmtCtx);

bool IsTemporary;

public:
Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies,
bool isTemp = false);
Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies);
~Parser() override;

const LangOptions &getLangOpts() const { return PP.getLangOpts(); }
Expand All @@ -482,7 +479,7 @@ class Parser : public CodeCompletionHandler {

public:
ParserCurTokRestoreRAII(Parser &P)
: P(P), SavedTok(P.Tok)
: P(P), SavedTok(P.Tok)
{
}

Expand All @@ -491,7 +488,7 @@ class Parser : public CodeCompletionHandler {
return;

P.Tok = SavedTok;

SavedTok.startToken();
}

Expand Down Expand Up @@ -1261,7 +1258,7 @@ class Parser : public CodeCompletionHandler {
return Diag(Tok, DiagID);
}

protected:
private:
void SuggestParentheses(SourceLocation Loc, unsigned DK,
SourceRange ParenRange);
void CheckNestedObjCContexts(SourceLocation AtLoc);
Expand Down
8 changes: 0 additions & 8 deletions interpreter/llvm-project/clang/lib/Parse/ParsePragma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,6 @@ void markAsReinjectedForRelexing(llvm::MutableArrayRef<clang::Token> Toks) {
} // end namespace

void Parser::initializePragmaHandlers() {
// No pragma parsing for temporary parsers.
if (IsTemporary)
return;

AlignHandler = std::make_unique<PragmaAlignHandler>();
PP.AddPragmaHandler(AlignHandler.get());

Expand Down Expand Up @@ -572,10 +568,6 @@ 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();
Expand Down
40 changes: 15 additions & 25 deletions interpreter/llvm-project/clang/lib/Parse/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,15 @@ IdentifierInfo *Parser::getSEHExceptKeyword() {
return Ident__except;
}

Parser::Parser(Preprocessor &pp, Sema &actions, bool skipFunctionBodies,
bool isTemporary /*=false*/)
Parser::Parser(Preprocessor &pp, Sema &actions, bool skipFunctionBodies)
: PP(pp), PreferredType(pp.isCodeCompletionEnabled()), Actions(actions),
Diags(PP.getDiagnostics()), GreaterThanIsOperator(true),
ColonIsSacred(false), InMessageExpression(false),
TemplateParameterDepth(0), ParsingInObjCContainer(false),
IsTemporary(isTemporary) {
TemplateParameterDepth(0), ParsingInObjCContainer(false) {
SkipFunctionBodies = pp.isCodeCompletionEnabled() || skipFunctionBodies;
Tok.startToken();
Tok.setKind(tok::eof);
if (!IsTemporary)
Actions.CurScope = nullptr;
Actions.CurScope = nullptr;
NumCachedScopes = 0;
CurParsedObjCImpl = nullptr;

Expand All @@ -70,17 +67,14 @@ Parser::Parser(Preprocessor &pp, Sema &actions, bool skipFunctionBodies,
initializePragmaHandlers();

CommentSemaHandler.reset(new ActionCommentHandler(actions));
if (!IsTemporary)
PP.addCommentHandler(CommentSemaHandler.get());

if (!IsTemporary) {
PP.setCodeCompletionHandler(*this);
Actions.ParseTypeFromStringCallback = [this](StringRef TypeStr,
StringRef Context,
SourceLocation IncludeLoc) {
return this->ParseTypeFromString(TypeStr, Context, IncludeLoc);
};
}
PP.addCommentHandler(CommentSemaHandler.get());

PP.setCodeCompletionHandler(*this);

Actions.ParseTypeFromStringCallback =
[this](StringRef TypeStr, StringRef Context, SourceLocation IncludeLoc) {
return this->ParseTypeFromString(TypeStr, Context, IncludeLoc);
};
}

DiagnosticBuilder Parser::Diag(SourceLocation Loc, unsigned DiagID) {
Expand Down Expand Up @@ -474,22 +468,18 @@ Parser::ParseScopeFlags::~ParseScopeFlags() {

Parser::~Parser() {
// If we still have scopes active, delete the scope tree.
if (!IsTemporary) {
delete getCurScope();
Actions.CurScope = nullptr;
}
delete getCurScope();
Actions.CurScope = nullptr;

// Free the scope cache.
for (unsigned i = 0, e = NumCachedScopes; i != e; ++i)
delete ScopeCache[i];

resetPragmaHandlers();

if (!IsTemporary)
PP.removeCommentHandler(CommentSemaHandler.get());
PP.removeCommentHandler(CommentSemaHandler.get());

if (!IsTemporary)
PP.clearCodeCompletionHandler();
PP.clearCodeCompletionHandler();

DestroyTemplateIds();
}
Expand Down
2 changes: 1 addition & 1 deletion interpreter/llvm-project/llvm-project.tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ROOT-llvm18-20250207-02
ROOT-llvm18-20250225-01

0 comments on commit 18d1e19

Please sign in to comment.