summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2018-01-17 11:41:51 +0000
committerHans Wennborg <hans@hanshq.net>2018-01-17 11:41:51 +0000
commit06686ae9ac50d03925b14372223519d50dc968fd (patch)
treecd66a2dd5acfb51528ddfc301c17cdb5c5236706
parent46dbd51f523128d92890d4cb9e202d3645ba158b (diff)
downloadclang-06686ae9ac50d03925b14372223519d50dc968fd.tar.gz
Merging r322350, r322405, r322420, r322593:
------------------------------------------------------------------------ r322350 | rtrieu | 2018-01-11 20:42:27 -0800 (Thu, 11 Jan 2018) | 6 lines [ODRHash] Don't hash friend functions. In certain combinations of templated classes and friend functions, the body of friend functions does not get propagated along with function signature. Exclude friend functions for hashing to avoid this case. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r322405 | rtrieu | 2018-01-12 13:49:20 -0800 (Fri, 12 Jan 2018) | 2 lines Disable test for Windows to fix Windows buildbots. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r322420 | rtrieu | 2018-01-12 15:13:33 -0800 (Fri, 12 Jan 2018) | 2 lines Try to suppress Windows testing again. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r322593 | rtrieu | 2018-01-16 11:53:06 -0800 (Tue, 16 Jan 2018) | 6 lines Add context to why test was disabled on Windows test/Modules/odr_hash-Friend.cpp triggers an assertion in MicrosoftMangle.cpp This has been reported in PR35939 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@322632 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AST/ODRHash.cpp2
-rw-r--r--test/Modules/Inputs/odr_hash-Friend/Box.h14
-rw-r--r--test/Modules/Inputs/odr_hash-Friend/M1.h6
-rw-r--r--test/Modules/Inputs/odr_hash-Friend/M2.h5
-rw-r--r--test/Modules/Inputs/odr_hash-Friend/M3.h7
-rw-r--r--test/Modules/Inputs/odr_hash-Friend/module.modulemap15
-rw-r--r--test/Modules/odr_hash-Friend.cpp22
7 files changed, 71 insertions, 0 deletions
diff --git a/lib/AST/ODRHash.cpp b/lib/AST/ODRHash.cpp
index 088d8bedd4..38e8d34135 100644
--- a/lib/AST/ODRHash.cpp
+++ b/lib/AST/ODRHash.cpp
@@ -478,6 +478,8 @@ void ODRHash::AddFunctionDecl(const FunctionDecl *Function) {
// TODO: Fix hashing for class methods.
if (isa<CXXMethodDecl>(Function)) return;
+ // And friend functions.
+ if (Function->getFriendObjectKind()) return;
// Skip functions that are specializations or in specialization context.
const DeclContext *DC = Function;
diff --git a/test/Modules/Inputs/odr_hash-Friend/Box.h b/test/Modules/Inputs/odr_hash-Friend/Box.h
new file mode 100644
index 0000000000..01ab90d601
--- /dev/null
+++ b/test/Modules/Inputs/odr_hash-Friend/Box.h
@@ -0,0 +1,14 @@
+template <class T>
+struct iterator {
+ void Compare(const iterator &x) { }
+ friend void Check(iterator) {}
+};
+
+template <class T = int> struct Box {
+ iterator<T> I;
+
+ void test() {
+ Check(I);
+ I.Compare(I);
+ }
+};
diff --git a/test/Modules/Inputs/odr_hash-Friend/M1.h b/test/Modules/Inputs/odr_hash-Friend/M1.h
new file mode 100644
index 0000000000..202ad06c34
--- /dev/null
+++ b/test/Modules/Inputs/odr_hash-Friend/M1.h
@@ -0,0 +1,6 @@
+#include "Box.h"
+
+void Peek() {
+ Box<> Gift;
+ Gift.test();
+}
diff --git a/test/Modules/Inputs/odr_hash-Friend/M2.h b/test/Modules/Inputs/odr_hash-Friend/M2.h
new file mode 100644
index 0000000000..69f08a957e
--- /dev/null
+++ b/test/Modules/Inputs/odr_hash-Friend/M2.h
@@ -0,0 +1,5 @@
+#include "Box.h"
+void x() {
+ Box<> Unused;
+ //Unused.test();
+}
diff --git a/test/Modules/Inputs/odr_hash-Friend/M3.h b/test/Modules/Inputs/odr_hash-Friend/M3.h
new file mode 100644
index 0000000000..ab457e0c08
--- /dev/null
+++ b/test/Modules/Inputs/odr_hash-Friend/M3.h
@@ -0,0 +1,7 @@
+#include "Box.h"
+#include "M2.h"
+
+void Party() {
+ Box<> Present;
+ Present.test();
+}
diff --git a/test/Modules/Inputs/odr_hash-Friend/module.modulemap b/test/Modules/Inputs/odr_hash-Friend/module.modulemap
new file mode 100644
index 0000000000..28e1832e30
--- /dev/null
+++ b/test/Modules/Inputs/odr_hash-Friend/module.modulemap
@@ -0,0 +1,15 @@
+module Box {
+ header "Box.h"
+}
+
+module Module1 {
+ header "M1.h"
+}
+
+module Module2 {
+ header "M2.h"
+}
+
+module Module3 {
+ header "M3.h"
+}
diff --git a/test/Modules/odr_hash-Friend.cpp b/test/Modules/odr_hash-Friend.cpp
new file mode 100644
index 0000000000..39c0c4b762
--- /dev/null
+++ b/test/Modules/odr_hash-Friend.cpp
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/modules.cache \
+// RUN: -I %S/Inputs/odr_hash-Friend \
+// RUN: -emit-obj -o /dev/null \
+// RUN: -fmodules \
+// RUN: -fimplicit-module-maps \
+// RUN: -fmodules-cache-path=%t/modules.cache \
+// RUN: -std=c++11 -x c++ %s -verify
+
+// PR35939: MicrosoftMangle.cpp triggers an assertion failure on this test.
+// UNSUPPORTED: system-windows
+
+// expected-no-diagnostics
+
+#include "Box.h"
+#include "M1.h"
+#include "M3.h"
+
+void Run() {
+ Box<> Present;
+}