diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-01-04 23:14:16 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-01-04 23:14:16 +0000 |
commit | 1cf4541c4f3ae2f6eaadb6d7972cf8cc71118965 (patch) | |
tree | df4d8e965429e869efc0446847b66f82039e72c3 /clang/lib/Sema/SemaExpr.cpp | |
parent | a977582dead2c6696ff5e273efe84a3878bb6e61 (diff) | |
download | bcm5719-llvm-1cf4541c4f3ae2f6eaadb6d7972cf8cc71118965.tar.gz bcm5719-llvm-1cf4541c4f3ae2f6eaadb6d7972cf8cc71118965.zip |
Bail out if we try to build a DeclRefExpr naming an invalid declaration.
Most code paths would already bail out in this case, but certain paths,
particularly overload resolution and typo correction, would not. Carrying on
with an invalid declaration could in some cases result in crashes due to
downstream code relying on declaration invariants that are not necessarily
met for invalid declarations, and in other cases just resulted in undesirable
follow-on diagnostics.
llvm-svn: 291030
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 3c554c9a524..1509b22a9e5 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -2777,6 +2777,9 @@ bool Sema::UseArgumentDependentLookup(const CXXScopeSpec &SS, /// were not overloaded, and it doesn't promise that the declaration /// will in fact be used. static bool CheckDeclInExpr(Sema &S, SourceLocation Loc, NamedDecl *D) { + if (D->isInvalidDecl()) + return true; + if (isa<TypedefNameDecl>(D)) { S.Diag(Loc, diag::err_unexpected_typedef) << D->getDeclName(); return true; |