]> granicus.if.org Git - clang/commitdiff
[Modules] Make the DeclUpdates map be processed in insertion order.
authorChandler Carruth <chandlerc@gmail.com>
Wed, 25 Mar 2015 01:02:12 +0000 (01:02 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Wed, 25 Mar 2015 01:02:12 +0000 (01:02 +0000)
This fixes my stress tests non-determinism so far. However, I've not
started playing with templates, friends, or terrible macros. I've found
at least two more seeming instabilities and am just waiting for a test
case to actually trigger them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233162 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Serialization/ASTWriter.h
test/Modules/Inputs/stress1/common.h [new file with mode: 0644]
test/Modules/Inputs/stress1/m00.h [new file with mode: 0644]
test/Modules/Inputs/stress1/m01.h [new file with mode: 0644]
test/Modules/Inputs/stress1/m02.h [new file with mode: 0644]
test/Modules/Inputs/stress1/m03.h [new file with mode: 0644]
test/Modules/Inputs/stress1/merge00.h [new file with mode: 0644]
test/Modules/Inputs/stress1/module.modulemap [new file with mode: 0644]
test/Modules/stress1.cpp [new file with mode: 0644]

index 1d872a8c0519d93c52405ce95e55ccf2f7a73ea8..d120c98553f8bdee69aa230b1a572b7d44aa527f 100644 (file)
@@ -321,7 +321,7 @@ private:
   };
 
   typedef SmallVector<DeclUpdate, 1> UpdateRecord;
-  typedef llvm::DenseMap<const Decl *, UpdateRecord> DeclUpdateMap;
+  typedef llvm::MapVector<const Decl *, UpdateRecord> DeclUpdateMap;
   /// \brief Mapping from declarations that came from a chained PCH to the
   /// record containing modifications to them.
   DeclUpdateMap DeclUpdates;
diff --git a/test/Modules/Inputs/stress1/common.h b/test/Modules/Inputs/stress1/common.h
new file mode 100644 (file)
index 0000000..d2fff10
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef STRESS1_COMMON_H
+#define STRESS1_COMMON_H
+
+inline char function00(char x) { return x + x; }
+inline short function00(short x) { return x + x; }
+inline int function00(int x) { return x + x; }
+
+namespace N00 {
+struct S00 {
+  char c;
+  short s;
+  int i;
+
+  S00(char x) : c(x) {}
+  S00(short x) : s(x) {}
+  S00(int x) : i(x) {}
+
+  char method00(char x) { return x + x; }
+  short method00(short x) { return x + x; }
+  int method00(int x) { return x + x; }
+
+  operator char() { return c; }
+  operator short() { return s; }
+  operator int() { return i; }
+};
+struct S01 {};
+struct S03 {};
+}
+
+namespace N01 {
+struct S00 : N00::S00 {
+  using N00::S00::S00;
+};
+struct S01 {};
+struct S02 {};
+}
+
+#endif
diff --git a/test/Modules/Inputs/stress1/m00.h b/test/Modules/Inputs/stress1/m00.h
new file mode 100644 (file)
index 0000000..ca5af38
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef STRESS1_M00_H
+#define STRESS1_M00_H
+
+#include "common.h"
+
+#endif
diff --git a/test/Modules/Inputs/stress1/m01.h b/test/Modules/Inputs/stress1/m01.h
new file mode 100644 (file)
index 0000000..d0b150a
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef STRESS1_M01_H
+#define STRESS1_M01_H
+
+#include "common.h"
+
+#endif
diff --git a/test/Modules/Inputs/stress1/m02.h b/test/Modules/Inputs/stress1/m02.h
new file mode 100644 (file)
index 0000000..bb9714f
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef STRESS1_M02_H
+#define STRESS1_M02_H
+
+#include "common.h"
+
+#endif
diff --git a/test/Modules/Inputs/stress1/m03.h b/test/Modules/Inputs/stress1/m03.h
new file mode 100644 (file)
index 0000000..b6dbb68
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef STRESS1_M03_H
+#define STRESS1_M03_H
+
+#include "common.h"
+
+#endif
diff --git a/test/Modules/Inputs/stress1/merge00.h b/test/Modules/Inputs/stress1/merge00.h
new file mode 100644 (file)
index 0000000..c6dccdf
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef STRESS1_MERGE00_H
+#define STRESS1_MERGE00_H
+
+#include "m00.h"
+#include "m01.h"
+#include "m02.h"
+#include "m03.h"
+
+inline int g() { return N00::S00('a').method00('b') + (int)N00::S00(42) + function00(42); }
+
+#endif
diff --git a/test/Modules/Inputs/stress1/module.modulemap b/test/Modules/Inputs/stress1/module.modulemap
new file mode 100644 (file)
index 0000000..2b687b0
--- /dev/null
@@ -0,0 +1,6 @@
+module m00 { header "Inputs/stress1/m00.h" export * }
+module m01 { header "Inputs/stress1/m01.h" export * }
+module m02 { header "Inputs/stress1/m02.h" export * }
+module m03 { header "Inputs/stress1/m03.h" export * }
+
+module merge00 { header "Inputs/stress1/merge00.h" export * }
diff --git a/test/Modules/stress1.cpp b/test/Modules/stress1.cpp
new file mode 100644 (file)
index 0000000..55d9533
--- /dev/null
@@ -0,0 +1,100 @@
+// RUN: rm -rf %t
+// RUN: cd %S
+//
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
+// RUN:   -I Inputs/stress1 \
+// RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
+// RUN:   -fmodule-map-file-home-is-cwd \
+// RUN:   -emit-module -fmodule-name=m00 -o %t/m00.pcm \
+// RUN:   Inputs/stress1/module.modulemap
+//
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
+// RUN:   -I Inputs/stress1 \
+// RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
+// RUN:   -fmodule-map-file-home-is-cwd \
+// RUN:   -emit-module -fmodule-name=m00 -o %t/m00_check.pcm \
+// RUN:   Inputs/stress1/module.modulemap
+//
+// RUN: diff %t/m00.pcm %t/m00_check.pcm
+//
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
+// RUN:   -I Inputs/stress1 \
+// RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
+// RUN:   -fmodule-map-file-home-is-cwd \
+// RUN:   -emit-module -fmodule-name=m01 -o %t/m01.pcm \
+// RUN:   Inputs/stress1/module.modulemap
+//
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
+// RUN:   -I Inputs/stress1 \
+// RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
+// RUN:   -fmodule-map-file-home-is-cwd \
+// RUN:   -emit-module -fmodule-name=m02 -o %t/m02.pcm \
+// RUN:   Inputs/stress1/module.modulemap
+//
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
+// RUN:   -I Inputs/stress1 \
+// RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
+// RUN:   -fmodule-map-file-home-is-cwd \
+// RUN:   -emit-module -fmodule-name=m03 -o %t/m03.pcm \
+// RUN:   Inputs/stress1/module.modulemap
+//
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
+// RUN:   -I Inputs/stress1 \
+// RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
+// RUN:   -fmodule-map-file-home-is-cwd \
+// RUN:   -fmodule-file=%t/m00.pcm \
+// RUN:   -fmodule-file=%t/m01.pcm \
+// RUN:   -fmodule-file=%t/m02.pcm \
+// RUN:   -fmodule-file=%t/m03.pcm \
+// RUN:   -emit-module -fmodule-name=merge00 -o %t/merge00.pcm \
+// RUN:   Inputs/stress1/module.modulemap
+//
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
+// RUN:   -I Inputs/stress1 \
+// RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
+// RUN:   -fmodule-map-file-home-is-cwd \
+// RUN:   -fmodule-file=%t/m00.pcm \
+// RUN:   -fmodule-file=%t/m01.pcm \
+// RUN:   -fmodule-file=%t/m02.pcm \
+// RUN:   -fmodule-file=%t/m03.pcm \
+// RUN:   -emit-module -fmodule-name=merge00 -o %t/merge00_check.pcm \
+// RUN:   Inputs/stress1/module.modulemap
+//
+// RUN: diff %t/merge00.pcm %t/merge00_check.pcm
+//
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
+// RUN:   -I Inputs/stress1 \
+// RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
+// RUN:   -fmodule-map-file-home-is-cwd \
+// RUN:   -fmodule-map-file=Inputs/stress1/module.modulemap \
+// RUN:   -fmodule-file=%t/m00.pcm \
+// RUN:   -fmodule-file=%t/m01.pcm \
+// RUN:   -fmodule-file=%t/m02.pcm \
+// RUN:   -fmodule-file=%t/m03.pcm \
+// RUN:   -fmodule-file=%t/merge00.pcm \
+// RUN:   -verify stress1.cpp -S -emit-llvm -o %t/stress1.ll
+//
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
+// RUN:   -I Inputs/stress1 \
+// RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
+// RUN:   -fmodule-map-file-home-is-cwd \
+// RUN:   -fmodule-map-file=Inputs/stress1/module.modulemap \
+// RUN:   -fmodule-file=%t/m00.pcm \
+// RUN:   -fmodule-file=%t/m01.pcm \
+// RUN:   -fmodule-file=%t/m02.pcm \
+// RUN:   -fmodule-file=%t/m03.pcm \
+// RUN:   -fmodule-file=%t/merge00.pcm \
+// RUN:   -verify stress1.cpp -S -emit-llvm -o %t/stress1_check.ll
+//
+// RUN: diff -u %t/stress1.ll %t/stress1_check.ll
+//
+// expected-no-diagnostics
+
+#include "m00.h"
+#include "m01.h"
+#include "m02.h"
+#include "m03.h"
+
+#include "merge00.h"
+
+int f() { return N01::S00('a').method00('b') + (int)N00::S00(42) + function00(42) + g(); }