From: Chandler Carruth Date: Wed, 25 Mar 2015 01:02:12 +0000 (+0000) Subject: [Modules] Make the DeclUpdates map be processed in insertion order. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dea925c6e3be64ed84636767f40c72afed786d25;p=clang [Modules] Make the DeclUpdates map be processed in insertion order. 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 --- diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h index 1d872a8c05..d120c98553 100644 --- a/include/clang/Serialization/ASTWriter.h +++ b/include/clang/Serialization/ASTWriter.h @@ -321,7 +321,7 @@ private: }; typedef SmallVector UpdateRecord; - typedef llvm::DenseMap DeclUpdateMap; + typedef llvm::MapVector 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 index 0000000000..d2fff1098d --- /dev/null +++ b/test/Modules/Inputs/stress1/common.h @@ -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 index 0000000000..ca5af38f58 --- /dev/null +++ b/test/Modules/Inputs/stress1/m00.h @@ -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 index 0000000000..d0b150a738 --- /dev/null +++ b/test/Modules/Inputs/stress1/m01.h @@ -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 index 0000000000..bb9714ff74 --- /dev/null +++ b/test/Modules/Inputs/stress1/m02.h @@ -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 index 0000000000..b6dbb68ccd --- /dev/null +++ b/test/Modules/Inputs/stress1/m03.h @@ -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 index 0000000000..c6dccdf530 --- /dev/null +++ b/test/Modules/Inputs/stress1/merge00.h @@ -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 index 0000000000..2b687b0152 --- /dev/null +++ b/test/Modules/Inputs/stress1/module.modulemap @@ -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 index 0000000000..55d9533b7a --- /dev/null +++ b/test/Modules/stress1.cpp @@ -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(); }