From 9f7098b8fff3efcda76f0f5a14b69706999dcad3 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Fri, 25 Dec 2020 17:14:40 +0200 Subject: [PATCH] Simplify the marking of invalid functions Signed-off-by: Dimitar Dobrev --- src/CppParser/Parser.cpp | 27 --------------------------- src/CppParser/Parser.h | 1 - 2 files changed, 28 deletions(-) diff --git a/src/CppParser/Parser.cpp b/src/CppParser/Parser.cpp index 9cb8607d..2ab04dd6 100644 --- a/src/CppParser/Parser.cpp +++ b/src/CppParser/Parser.cpp @@ -3140,29 +3140,6 @@ static bool IsInvalid(clang::Stmt* Body, std::unordered_set& Bodie return false; } -std::stack Parser::GetScopesFor(clang::FunctionDecl* FD) -{ - using namespace clang; - - std::stack Contexts; - DeclContext* DC = FD; - while (DC) - { - Contexts.push(DC); - DC = DC->getParent(); - } - std::stack Scopes; - while (!Contexts.empty()) - { - Scope S(Scopes.empty() ? 0 : &Scopes.top(), - Scope::ScopeFlags::DeclScope, c->getDiagnostics()); - S.setEntity(Contexts.top()); - Scopes.push(S); - Contexts.pop(); - } - return Scopes; -} - void Parser::MarkValidity(Function* F) { using namespace clang; @@ -3177,12 +3154,8 @@ void Parser::MarkValidity(Function* F) SemaDiagnostics->Decl = FD; c->getSema().getDiagnostics().setClient(SemaDiagnostics.get(), false); - auto TUScope = c->getSema().TUScope; - std::stack Scopes = GetScopesFor(FD); - c->getSema().TUScope = &Scopes.top(); c->getSema().InstantiateFunctionDefinition(FD->getBeginLoc(), FD, /*Recursive*/true); - c->getSema().TUScope = TUScope; F->isInvalid = FD->isInvalidDecl(); if (!F->isInvalid) { diff --git a/src/CppParser/Parser.h b/src/CppParser/Parser.h index 6d927d8c..b865be0b 100644 --- a/src/CppParser/Parser.h +++ b/src/CppParser/Parser.h @@ -137,7 +137,6 @@ private: Parameter* WalkParameter(const clang::ParmVarDecl* PVD, const clang::SourceLocation& ParamStartLoc); void SetBody(const clang::FunctionDecl* FD, Function* F); - std::stack GetScopesFor(clang::FunctionDecl* FD); void MarkValidity(Function* F); void WalkFunction(const clang::FunctionDecl* FD, Function* F); int GetAlignAs(const clang::AlignedAttr* alignedAttr);