r336244 - [Sema] Fix crash in getConstructorName.
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 4 01:50:12 PDT 2018
Author: ibiryukov
Date: Wed Jul 4 01:50:12 2018
New Revision: 336244
URL: http://llvm.org/viewvc/llvm-project?rev=336244&view=rev
Log:
[Sema] Fix crash in getConstructorName.
Summary:
Can happen when getConstructorName is called on invalid decls,
specifically the ones that do not have the injected class name.
Reviewers: bkramer, rsmith
Reviewed By: rsmith
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D48880
Added:
cfe/trunk/test/SemaCXX/injected-class-name-crash.cpp
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=336244&r1=336243&r2=336244&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Jul 4 01:50:12 2018
@@ -113,6 +113,8 @@ ParsedType Sema::getConstructorName(Iden
break;
}
}
+ if (!InjectedClassName && CurClass->isInvalidDecl())
+ return ParsedType();
assert(InjectedClassName && "couldn't find injected class name");
QualType T = Context.getTypeDeclType(InjectedClassName);
Added: cfe/trunk/test/SemaCXX/injected-class-name-crash.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/injected-class-name-crash.cpp?rev=336244&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/injected-class-name-crash.cpp (added)
+++ cfe/trunk/test/SemaCXX/injected-class-name-crash.cpp Wed Jul 4 01:50:12 2018
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template <class T>
+struct X : public Foo<Bar { // expected-error {{unknown template name 'Foo'}} expected-error {{use of undeclared identifier 'Bar'}}
+ X();
+}; // expected-error {{expected '{' after base class list}}
+
+
+template <class T>
+X<T>::X() {
+}
More information about the cfe-commits
mailing list