Skip to content

Commit

Permalink
[ODRHash] Adjust info stored for FunctionTemplateDecl.
Browse files Browse the repository at this point in the history
Avoid storing information for definitions since those can be out-of-line and
vary between modules even when the declarations are the same.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334151 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Weverything committed Jun 7, 2018
1 parent f7a73f3 commit 45021ac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/AST/ODRHash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ class ODRDeclVisitor : public ConstDeclVisitor<ODRDeclVisitor> {

void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
Visit(D->getTemplatedDecl());
ID.AddInteger(D->getTemplatedDecl()->getODRHash());
AddDecl(D->getTemplatedDecl());
Inherited::VisitFunctionTemplateDecl(D);
}
};
Expand Down
14 changes: 14 additions & 0 deletions test/Modules/odr_hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3617,6 +3617,20 @@ int I10 = F10();
#endif
// [email protected]:* {{'FunctionDecl::F10' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
// [email protected]:* {{but in 'FirstModule' found a different body}}

#if defined(FIRST)
struct S11 {
template <int> void foo();
};
#elif defined(SECOND)
struct S11 {
template <int> void foo();
};
template <int> void S11::foo() {}
#else
S11 s11;
#endif

} // namespace FunctionDecl

namespace DeclTemplateArguments {
Expand Down

0 comments on commit 45021ac

Please sign in to comment.