diff options
author | Kaelyn Takata <rikka@google.com> | 2014-11-20 22:06:33 +0000 |
---|---|---|
committer | Kaelyn Takata <rikka@google.com> | 2014-11-20 22:06:33 +0000 |
commit | 6f71ce2e212df2d0b834bf71ad128ea95508adbe (patch) | |
tree | de4be08ab060872c6500bc5c9a9eb358c478a069 /clang/lib/Sema/SemaExpr.cpp | |
parent | 3f9794f288d89d33fe42e89cdf57371784bf0258 (diff) | |
download | bcm5719-llvm-6f71ce2e212df2d0b834bf71ad128ea95508adbe.tar.gz bcm5719-llvm-6f71ce2e212df2d0b834bf71ad128ea95508adbe.zip |
Add a flag to BuildDeclarationNameExpr to not reject invalid decls.
llvm-svn: 222463
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 0104020bba8..22657ba3695 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -2613,15 +2613,15 @@ static bool CheckDeclInExpr(Sema &S, SourceLocation Loc, NamedDecl *D) { return false; } -ExprResult -Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS, - LookupResult &R, - bool NeedsADL) { +ExprResult Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS, + LookupResult &R, bool NeedsADL, + bool AcceptInvalidDecl) { // If this is a single, fully-resolved result and we don't need ADL, // just build an ordinary singleton decl ref. if (!NeedsADL && R.isSingleResult() && !R.getAsSingle<FunctionTemplateDecl>()) return BuildDeclarationNameExpr(SS, R.getLookupNameInfo(), R.getFoundDecl(), - R.getRepresentativeDecl()); + R.getRepresentativeDecl(), nullptr, + AcceptInvalidDecl); // We only need to check the declaration if there's exactly one // result, because in the overloaded case the results can only be @@ -2648,7 +2648,8 @@ Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS, /// \brief Complete semantic analysis for a reference to the given declaration. ExprResult Sema::BuildDeclarationNameExpr( const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, NamedDecl *D, - NamedDecl *FoundD, const TemplateArgumentListInfo *TemplateArgs) { + NamedDecl *FoundD, const TemplateArgumentListInfo *TemplateArgs, + bool AcceptInvalidDecl) { assert(D && "Cannot refer to a NULL declaration"); assert(!isa<FunctionTemplateDecl>(D) && "Cannot refer unambiguously to a function template"); @@ -2683,7 +2684,7 @@ ExprResult Sema::BuildDeclarationNameExpr( return ExprError(); // Only create DeclRefExpr's for valid Decl's. - if (VD->isInvalidDecl()) + if (VD->isInvalidDecl() && !AcceptInvalidDecl) return ExprError(); // Handle members of anonymous structs and unions. If we got here, |