[PATCH] D82738: [clang] Fix a null-NSS-access crash in DependentNameType.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 2 02:39:28 PDT 2020
hokein updated this revision to Diff 275027.
hokein marked 2 inline comments as done.
hokein added a comment.
refine the fix.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82738/new/
https://reviews.llvm.org/D82738
Files:
clang/lib/Sema/SemaTemplate.cpp
clang/test/Parser/cxx-template-decl.cpp
Index: clang/test/Parser/cxx-template-decl.cpp
===================================================================
--- clang/test/Parser/cxx-template-decl.cpp
+++ clang/test/Parser/cxx-template-decl.cpp
@@ -286,3 +286,17 @@
template<int> int b;
template<int> auto f() -> b<0>; // expected-error +{{}}
}
+
+namespace NoCrashOnNullNNSTypoCorrection {
+
+int AddObservation(); // expected-note {{declared here}}
+
+template <typename T, typename... Args> // expected-note {{template parameter is declared here}}
+class UsingImpl {};
+class AddObservation {
+ using Using =
+ UsingImpl<AddObservationFn, const int>; // expected-error {{use of undeclared identifier 'AddObservationFn'; did you mean}} \
+ expected-error {{template argument for template type parameter must be a type}}
+};
+
+}
Index: clang/lib/Sema/SemaTemplate.cpp
===================================================================
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -4844,10 +4844,7 @@
CXXScopeSpec SS;
DeclarationNameInfo NameInfo;
- if (DeclRefExpr *ArgExpr = dyn_cast<DeclRefExpr>(Arg.getAsExpr())) {
- SS.Adopt(ArgExpr->getQualifierLoc());
- NameInfo = ArgExpr->getNameInfo();
- } else if (DependentScopeDeclRefExpr *ArgExpr =
+ if (DependentScopeDeclRefExpr *ArgExpr =
dyn_cast<DependentScopeDeclRefExpr>(Arg.getAsExpr())) {
SS.Adopt(ArgExpr->getQualifierLoc());
NameInfo = ArgExpr->getNameInfo();
@@ -4866,6 +4863,7 @@
if (Result.getAsSingle<TypeDecl>() ||
Result.getResultKind() ==
LookupResult::NotFoundInCurrentInstantiation) {
+ assert(SS.getScopeRep() && "A scope specifier must be present.");
// Suggest that the user add 'typename' before the NNS.
SourceLocation Loc = AL.getSourceRange().getBegin();
Diag(Loc, getLangOpts().MSVCCompat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82738.275027.patch
Type: text/x-patch
Size: 1938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200702/69f5b8f2/attachment.bin>
More information about the cfe-commits
mailing list