1 // Test that diagnostic mappings are emitted only when needed and in order of
2 // diagnostic ID rather than non-deterministically. This test passes 3
3 // -W options and expects exactly 3 mappings to be emitted in the pcm. The -W
4 // options are chosen to be far apart in ID (see DiagnosticIDs.h) so we can
5 // check they are ordered. We also intentionally trigger several other warnings
6 // inside the module and ensure they do not show up in the pcm as mappings.
9 // RUN: split-file %s %t
11 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
12 // RUN: -fmodules-cache-path=%t/cache -triple x86_64-apple-macosx10.11.0 \
13 // RUN: %t/main.m -fdisable-module-hash \
14 // RUN: -Werror=stack-protector -Werror=empty-translation-unit -Werror=float-equal
16 // RUN: mv %t/cache/A.pcm %t/A1.pcm
18 // RUN: llvm-bcanalyzer --dump --disable-histogram %t/A1.pcm | FileCheck %s
20 // CHECK: <DIAG_PRAGMA_MAPPINGS
22 // == Initial mappings
23 // Number of mappings = 3
25 // Common diag id is < 1000 (see DiagnosticIDs.h)
26 // CHECK-SAME: op3=[[STACK_PROT:[0-9][0-9]?[0-9]?]] op4=
27 // Parse diag id is somewhere in 1000..2999, leaving room for changes
28 // CHECK-SAME: op5=[[EMPTY_TU:[12][0-9][0-9][0-9]]] op6=
29 // Sema diag id is > 2000
30 // CHECK-SAME: op7=[[FLOAT_EQ:[2-9][0-9][0-9][0-9]]] op8=
33 // Each pragma creates a mapping table; and each copies the previous table. The
34 // initial mappings are copied as well, but are not serialized since they have
37 // == ignored "-Wfloat-equal"
38 // CHECK-SAME: op{{[0-9]+}}=1
39 // CHECK-SAME: op{{[0-9]+}}=[[FLOAT_EQ]] op{{[0-9]+}}=
41 // == ignored "-Wstack-protector"
42 // CHECK-SAME: op{{[0-9]+}}=2
43 // CHECK-SAME: op{{[0-9]+}}=[[STACK_PROT]] op{{[0-9]+}}=
44 // CHECK-SAME: op{{[0-9]+}}=[[FLOAT_EQ]] op{{[0-9]+}}=
46 // == warning "-Wempty-translation-unit"
47 // CHECK-SAME: op{{[0-9]+}}=3
48 // CHECK-SAME: op{{[0-9]+}}=[[STACK_PROT]] op{{[0-9]+}}=
49 // CHECK-SAME: op{{[0-9]+}}=[[EMPTY_TU]] op{{[0-9]+}}=
50 // CHECK-SAME: op{{[0-9]+}}=[[FLOAT_EQ]] op{{[0-9]+}}=
52 // == warning "-Wstack-protector"
53 // CHECK-SAME: op{{[0-9]+}}=3
54 // CHECK-SAME: op{{[0-9]+}}=[[STACK_PROT]] op{{[0-9]+}}=
55 // CHECK-SAME: op{{[0-9]+}}=[[EMPTY_TU]] op{{[0-9]+}}=
56 // CHECK-SAME: op{{[0-9]+}}=[[FLOAT_EQ]] op{{[0-9]+}}=
58 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
59 // RUN: -fmodules-cache-path=%t/cache -triple x86_64-apple-macosx10.11.0 \
60 // RUN: %t/main.m -fdisable-module-hash \
61 // RUN: -Werror=stack-protector -Werror=empty-translation-unit -Werror=float-equal
63 // RUN: diff %t/cache/A.pcm %t/A1.pcm
65 //--- module.modulemap
66 module A
{ header
"a.h" }
72 static inline void f() {
77 #pragma clang diagnostic push
78 #pragma clang diagnostic ignored "-Wfloat-equal"
79 #pragma clang diagnostic ignored "-Wstack-protector"
81 static inline void g() {
86 #pragma clang diagnostic push
87 #pragma clang diagnostic warning "-Wempty-translation-unit"
88 #pragma clang diagnostic warning "-Wstack-protector"
90 #pragma clang diagnostic pop
91 #pragma clang diagnostic pop