Skip to content

Commit

Permalink
[index] Fix a crash indexing a non-canonical template declaration
Browse files Browse the repository at this point in the history
rdar://problem/33811115
  • Loading branch information
benlangmuir committed Aug 10, 2017
1 parent 3f0f001 commit f45c389
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Index/IndexRecordHasher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ static hash_code computeHash(TemplateName Name, IndexRecordHasher &Hasher) {
return COMBINE_HASH('t', TTP->getDepth(), TTP->getIndex());
}

return COMBINE_HASH(Hasher.hash(Template));
return COMBINE_HASH(Hasher.hash(Template->getCanonicalDecl()));
}

// FIXME: Hash dependent template names.
Expand Down
19 changes: 19 additions & 0 deletions test/Index/Store/record-hash-crash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,22 @@ namespace crash1 {
// CHECK: [[@LINE+1]]:6 | function/C
auto getit() { return []() {}; }
}

namespace crash2 {
// CHECK: [[@LINE+2]]:7 | class(Gen)/C++ | c:@N@crash2@ST>1#T@Foo | Ref,RelCont | rel: 1
template <typename T>
class Foo; // canonical decl

// CHECK: [[@LINE+2]]:7 | class(Gen)/C++ | c:@N@crash2@ST>1#T@Foo | Def,RelChild | rel: 1
template <typename T>
class Foo {};

// CHECK: [[@LINE+2]]:8 | struct(Gen)/C++ | c:@N@crash2@ST>1#t>1#pT@Wrapper | Def,RelChild | rel: 1
template <template <typename... ARGS> class TYPE>
struct Wrapper {};

// CHECK: [[@LINE+3]]:8 | struct(Gen,TS)/C++ | c:@N@crash2@S@Wrapper>#@N@crash2@ST>1#T@Foo | Def,RelChild,RelSpecialization | rel: 2
// CHECK: RelSpecialization | c:@N@crash2@ST>1#t>1#pT@Wrapper
template <>
struct Wrapper<Foo> {};
}

0 comments on commit f45c389

Please sign in to comment.