summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2015-03-26 08:32:49 +0000
committerChandler Carruth <chandlerc@gmail.com>2015-03-26 08:32:49 +0000
commitf85d98285e8eb6bcf42c2821e3b03abfc22ffac9 (patch)
tree611357433af1c908392bcd691daa41a33b1bfc9b /clang/test
parent23536d92c75dfebd65afa5ce1e588470e908b594 (diff)
downloadbcm5719-llvm-f85d98285e8eb6bcf42c2821e3b03abfc22ffac9.tar.gz
bcm5719-llvm-f85d98285e8eb6bcf42c2821e3b03abfc22ffac9.zip
[Modules] Make "#pragma weak" undeclared identifiers be tracked
deterministically. This fixes a latent issue where even Clang's Sema (and diagnostics) were non-deterministic in the face of this pragma. The fix is super simple -- just use a MapVector so we track the order in which these are parsed (or imported). Especially considering how rare they are, this seems like the perfect tradeoff. I've also simplified the client code with judicious use of auto and range based for loops. I've added some pretty hilarious code to my stress test which now survives the binary diff without issue. llvm-svn: 233261
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Modules/Inputs/stress1/common.h14
-rw-r--r--clang/test/Modules/Inputs/stress1/merge00.h14
-rw-r--r--clang/test/Modules/stress1.cpp5
3 files changed, 33 insertions, 0 deletions
diff --git a/clang/test/Modules/Inputs/stress1/common.h b/clang/test/Modules/Inputs/stress1/common.h
index d2fff1098d9..b158a8e6c1e 100644
--- a/clang/test/Modules/Inputs/stress1/common.h
+++ b/clang/test/Modules/Inputs/stress1/common.h
@@ -35,4 +35,18 @@ struct S01 {};
struct S02 {};
}
+#pragma weak pragma_weak00
+#pragma weak pragma_weak01
+#pragma weak pragma_weak02
+#pragma weak pragma_weak03
+#pragma weak pragma_weak04
+#pragma weak pragma_weak05
+
+extern "C" int pragma_weak00();
+extern "C" int pragma_weak01();
+extern "C" int pragma_weak02();
+extern "C" int pragma_weak03;
+extern "C" int pragma_weak04;
+extern "C" int pragma_weak05;
+
#endif
diff --git a/clang/test/Modules/Inputs/stress1/merge00.h b/clang/test/Modules/Inputs/stress1/merge00.h
index c6dccdf5305..b769b0877dd 100644
--- a/clang/test/Modules/Inputs/stress1/merge00.h
+++ b/clang/test/Modules/Inputs/stress1/merge00.h
@@ -1,6 +1,14 @@
#ifndef STRESS1_MERGE00_H
#define STRESS1_MERGE00_H
+// These don't match the imported declarations because we import them from
+// modules which are built in isolation of the current header's pragma state
+// much like they are built in isolation of the incoming macro state.
+// FIXME: We should expect warnings here but we can't because verify doesn't
+// work for modules.
+//#pragma weak pragma_weak01 // expected-warning {{weak identifier 'pragma_weak01' never declared}}
+//#pragma weak pragma_weak04 // expected-warning {{weak identifier 'pragma_waek04' never declared}}
+
#include "m00.h"
#include "m01.h"
#include "m02.h"
@@ -8,4 +16,10 @@
inline int g() { return N00::S00('a').method00('b') + (int)N00::S00(42) + function00(42); }
+#pragma weak pragma_weak02
+#pragma weak pragma_weak05
+
+extern "C" int pragma_weak02();
+int pragma_weak05;
+
#endif
diff --git a/clang/test/Modules/stress1.cpp b/clang/test/Modules/stress1.cpp
index 55d9533b7ae..e03e538a3ce 100644
--- a/clang/test/Modules/stress1.cpp
+++ b/clang/test/Modules/stress1.cpp
@@ -98,3 +98,8 @@
#include "merge00.h"
int f() { return N01::S00('a').method00('b') + (int)N00::S00(42) + function00(42) + g(); }
+
+int f2() {
+ return pragma_weak00() + pragma_weak01() + pragma_weak02() +
+ pragma_weak03 + pragma_weak04 + pragma_weak05;
+}
OpenPOWER on IntegriCloud