]> granicus.if.org Git - clang/commitdiff
[ODRHash] Adjust info stored for FunctionTemplateDecl.
authorRichard Trieu <rtrieu@google.com>
Thu, 7 Jun 2018 00:20:58 +0000 (00:20 +0000)
committerRichard Trieu <rtrieu@google.com>
Thu, 7 Jun 2018 00:20:58 +0000 (00:20 +0000)
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

lib/AST/ODRHash.cpp
test/Modules/odr_hash.cpp

index 7a3a6964e5b5dc07b99763b02b47196ba3eeeba2..126b6de25e41db9530ff262d44c2a24b9b8486da 100644 (file)
@@ -427,7 +427,7 @@ public:
 
   void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
     Visit(D->getTemplatedDecl());
-    ID.AddInteger(D->getTemplatedDecl()->getODRHash());
+    AddDecl(D->getTemplatedDecl());
     Inherited::VisitFunctionTemplateDecl(D);
   }
 };
index dd3952232bfd99631678f9c6ff211cef43e335bb..9cb177fbfce84d7aa34959c31a8f0f00f4e29291 100644 (file)
@@ -3617,6 +3617,20 @@ int I10 = F10();
 #endif
 // expected-error@second.h:* {{'FunctionDecl::F10' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
 // expected-note@first.h:* {{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 {