diff options
author | Richard Trieu <rtrieu@google.com> | 2016-10-28 00:15:24 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2016-10-28 00:15:24 +0000 |
commit | 42b98e2a824a234c69b46fe26b87906a5eb198d5 (patch) | |
tree | dce319fff7cc0c2bea9ea6778ab1b78c689e3bbe /clang/lib/Sema/SemaCXXScopeSpec.cpp | |
parent | ed2977fabe45764608ac82d7239a6e08d575a781 (diff) | |
download | bcm5719-llvm-42b98e2a824a234c69b46fe26b87906a5eb198d5.tar.gz bcm5719-llvm-42b98e2a824a234c69b46fe26b87906a5eb198d5.zip |
Fix a crash on invalid code.
The diagnostic was attempting to access the QualType of a TypeDecl by calling
TypeDecl::getTypeForDecl. However, the Type pointer stored there is lazily
loaded by functions in ASTContext. In most cases, the pointer is loaded and
this does not cause a problem. However, when more that 50 or so unknown types
are seen beforehand, this causes the Type to not be loaded, passing a null
Type to the diagnostics, leading to the crash. Using
ASTContext::getTypeDeclType will give a proper QualType for all cases.
llvm-svn: 285370
Diffstat (limited to 'clang/lib/Sema/SemaCXXScopeSpec.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCXXScopeSpec.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaCXXScopeSpec.cpp b/clang/lib/Sema/SemaCXXScopeSpec.cpp index c350f6ca0b8..6c7d8133173 100644 --- a/clang/lib/Sema/SemaCXXScopeSpec.cpp +++ b/clang/lib/Sema/SemaCXXScopeSpec.cpp @@ -801,7 +801,7 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, if (!Found.empty()) { if (TypeDecl *TD = Found.getAsSingle<TypeDecl>()) Diag(IdInfo.IdentifierLoc, diag::err_expected_class_or_namespace) - << QualType(TD->getTypeForDecl(), 0) << getLangOpts().CPlusPlus; + << Context.getTypeDeclType(TD) << getLangOpts().CPlusPlus; else { Diag(IdInfo.IdentifierLoc, diag::err_expected_class_or_namespace) << IdInfo.Identifier << getLangOpts().CPlusPlus; |