[PATCH] D35212: [Index] Prevent canonical decl becoming nullptr
Krasimir Georgiev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 18 00:21:37 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308269: [Index] Prevent canonical decl becoming nullptr (authored by krasimir).
Repository:
rL LLVM
https://reviews.llvm.org/D35212
Files:
cfe/trunk/lib/Index/IndexingContext.cpp
cfe/trunk/test/Index/Core/no-templated-canonical-decl.cpp
Index: cfe/trunk/test/Index/Core/no-templated-canonical-decl.cpp
===================================================================
--- cfe/trunk/test/Index/Core/no-templated-canonical-decl.cpp
+++ cfe/trunk/test/Index/Core/no-templated-canonical-decl.cpp
@@ -0,0 +1,4 @@
+// RUN: c-index-test core -print-source-symbols -include-locals -- %s | FileCheck %s
+
+template <template <typename> class A> class B { typedef A<int> A_int; };
+// CHECK: [[@LINE-1]]:46 | class(Gen)/C++ | B | c:@ST>1#t>1#T at B | <no-cgname> | Def | rel: 0
Index: cfe/trunk/lib/Index/IndexingContext.cpp
===================================================================
--- cfe/trunk/lib/Index/IndexingContext.cpp
+++ cfe/trunk/lib/Index/IndexingContext.cpp
@@ -260,8 +260,10 @@
static const Decl *getCanonicalDecl(const Decl *D) {
D = D->getCanonicalDecl();
if (auto TD = dyn_cast<TemplateDecl>(D)) {
- D = TD->getTemplatedDecl();
- assert(D->isCanonicalDecl());
+ if (auto TTD = TD->getTemplatedDecl()) {
+ D = TTD;
+ assert(D->isCanonicalDecl());
+ }
}
return D;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35212.107021.patch
Type: text/x-patch
Size: 1078 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170718/860d9307/attachment.bin>
More information about the cfe-commits
mailing list