summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKrasimir Georgiev <krasimir@google.com>2017-07-18 07:20:53 +0000
committerKrasimir Georgiev <krasimir@google.com>2017-07-18 07:20:53 +0000
commit906b61f528d9cba41ed36193916675e38d1c3310 (patch)
tree7fb145d3ae9902bb49ccbeb9917dcba54e345275 /lib
parentd0d080025d8dcf56db1fb86dc6951b247d4f2b39 (diff)
[Index] Prevent canonical decl becoming nullptr
Summary: This patch prevents getCanonicalDecl returning nullptr in case it finds a canonical TemplateDeclaration with no attached TemplatedDecl. Found by running the indexer over a version of the standard library deep inside a template metaprogramming mess. Reviewers: klimek, vsk Reviewed By: vsk Subscribers: vsk, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D35212 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308269 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Index/IndexingContext.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Index/IndexingContext.cpp b/lib/Index/IndexingContext.cpp
index c4aa51d62f..addee691e8 100644
--- a/lib/Index/IndexingContext.cpp
+++ b/lib/Index/IndexingContext.cpp
@@ -260,8 +260,10 @@ static const Decl *adjustParent(const Decl *Parent) {
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;