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@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;
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@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;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits