diff options
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 1e9164bc3ac..7eb5bcbbbb0 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1762,7 +1762,7 @@ Sema::ActOnStringLiteral(ArrayRef<Token> StringToks, Scope *UDLScope) { llvm_unreachable("unexpected literal operator lookup result"); } -ExprResult +DeclRefExpr * Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS) { @@ -1770,36 +1770,33 @@ Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, return BuildDeclRefExpr(D, Ty, VK, NameInfo, SS); } +DeclRefExpr * +Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, + const DeclarationNameInfo &NameInfo, + const CXXScopeSpec *SS, NamedDecl *FoundD, + SourceLocation TemplateKWLoc, + const TemplateArgumentListInfo *TemplateArgs) { + NestedNameSpecifierLoc NNS = + SS ? SS->getWithLocInContext(Context) : NestedNameSpecifierLoc(); + return BuildDeclRefExpr(D, Ty, VK, NameInfo, NNS, FoundD, TemplateKWLoc, + TemplateArgs); +} + /// BuildDeclRefExpr - Build an expression that references a /// declaration that does not require a closure capture. -ExprResult +DeclRefExpr * Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, const DeclarationNameInfo &NameInfo, - const CXXScopeSpec *SS, NamedDecl *FoundD, + NestedNameSpecifierLoc NNS, NamedDecl *FoundD, + SourceLocation TemplateKWLoc, const TemplateArgumentListInfo *TemplateArgs) { bool RefersToCapturedVariable = isa<VarDecl>(D) && NeedToCaptureVariable(cast<VarDecl>(D), NameInfo.getLoc()); - DeclRefExpr *E; - if (isa<VarTemplateSpecializationDecl>(D)) { - VarTemplateSpecializationDecl *VarSpec = - cast<VarTemplateSpecializationDecl>(D); - - E = DeclRefExpr::Create(Context, SS ? SS->getWithLocInContext(Context) - : NestedNameSpecifierLoc(), - VarSpec->getTemplateKeywordLoc(), D, - RefersToCapturedVariable, NameInfo.getLoc(), Ty, VK, - FoundD, TemplateArgs); - } else { - assert(!TemplateArgs && "No template arguments for non-variable" - " template specialization references"); - E = DeclRefExpr::Create(Context, SS ? SS->getWithLocInContext(Context) - : NestedNameSpecifierLoc(), - SourceLocation(), D, RefersToCapturedVariable, - NameInfo, Ty, VK, FoundD); - } - + DeclRefExpr *E = DeclRefExpr::Create(Context, NNS, TemplateKWLoc, D, + RefersToCapturedVariable, NameInfo, Ty, + VK, FoundD, TemplateArgs); MarkDeclRefReferenced(E); if (getLangOpts().ObjCWeak && isa<VarDecl>(D) && @@ -3141,6 +3138,7 @@ ExprResult Sema::BuildDeclarationNameExpr( } return BuildDeclRefExpr(VD, type, valueKind, NameInfo, &SS, FoundD, + /*FIXME: TemplateKWLoc*/ SourceLocation(), TemplateArgs); } } @@ -5615,8 +5613,8 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc, } } - if (isa<DeclRefExpr>(NakedFn)) { - NDecl = cast<DeclRefExpr>(NakedFn)->getDecl(); + if (auto *DRE = dyn_cast<DeclRefExpr>(NakedFn)) { + NDecl = DRE->getDecl(); FunctionDecl *FDecl = dyn_cast<FunctionDecl>(NDecl); if (FDecl && FDecl->getBuiltinID()) { |