diff options
author | Daniel Dunbar <daniel@zuster.org> | 2012-03-09 01:51:51 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2012-03-09 01:51:51 +0000 |
commit | 3d13c5a1e72ed8f8be9c083791d30643d1b1ec43 (patch) | |
tree | 6c29efdfbe48d1b6141cb7ae80761e075dc5af2c /lib/Sema/SemaExpr.cpp | |
parent | 76aadc346c3a4c363238a1e1232f324c3355d9e0 (diff) |
[AST] Reduce Decl::getASTContext() calls.
- This function is not at all free; pass it around along some hot paths instead
of recomputing it deep inside various VarDecl methods.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152363 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index b989fac838..64008e1093 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -10145,7 +10145,7 @@ static void MarkVarDeclODRUsed(Sema &SemaRef, VarDecl *Var, SourceLocation Loc) { // Keep track of used but undefined variables. // FIXME: We shouldn't suppress this warning for static data members. - if (Var->hasDefinition() == VarDecl::DeclarationOnly && + if (Var->hasDefinition(SemaRef.Context) == VarDecl::DeclarationOnly && Var->getLinkage() != ExternalLinkage && !(Var->isStaticDataMember() && Var->hasInit())) { SourceLocation &old = SemaRef.UndefinedInternals[Var->getCanonicalDecl()]; @@ -10218,7 +10218,8 @@ static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc, assert(MSInfo && "Missing member specialization information?"); bool AlreadyInstantiated = !MSInfo->getPointOfInstantiation().isInvalid(); if (MSInfo->getTemplateSpecializationKind() == TSK_ImplicitInstantiation && - (!AlreadyInstantiated || Var->isUsableInConstantExpressions())) { + (!AlreadyInstantiated || + Var->isUsableInConstantExpressions(SemaRef.Context))) { if (!AlreadyInstantiated) { // This is a modification of an existing AST node. Notify listeners. if (ASTMutationListener *L = SemaRef.getASTMutationListener()) @@ -10226,7 +10227,7 @@ static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc, MSInfo->setPointOfInstantiation(Loc); } SourceLocation PointOfInstantiation = MSInfo->getPointOfInstantiation(); - if (Var->isUsableInConstantExpressions()) + if (Var->isUsableInConstantExpressions(SemaRef.Context)) // Do not defer instantiations of variables which could be used in a // constant expression. SemaRef.InstantiateStaticDataMemberDefinition(PointOfInstantiation,Var); @@ -10246,7 +10247,7 @@ static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc, // apply to references, since they are not objects. const VarDecl *DefVD; if (E && !isa<ParmVarDecl>(Var) && !Var->getType()->isReferenceType() && - Var->isUsableInConstantExpressions() && + Var->isUsableInConstantExpressions(SemaRef.Context) && Var->getAnyInitializer(DefVD) && DefVD->checkInitIsICE()) SemaRef.MaybeODRUseExprs.insert(E); else |