| 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. |
| 7 |
|
| 8 |
// RUN: rm -rf %t |
| 9 |
// RUN: split-file %s %t |
| 10 |
|
| 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 |
| 15 |
|
| 16 |
// RUN: mv %t/cache/A.pcm %t/A1.pcm |
| 17 |
|
| 18 |
// RUN: llvm-bcanalyzer --dump --disable-histogram %t/A1.pcm | FileCheck %s |
| 19 |
|
| 20 |
// CHECK: <DIAG_PRAGMA_MAPPINGS |
| 21 |
|
| 22 |
// == Initial mappings |
| 23 |
// Number of mappings = 3 |
| 24 |
// CHECK-SAME: op2=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= |
| 31 |
|
| 32 |
// == Pragmas: |
| 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 |
| 35 |
// isPragma=false. |
| 36 |
|
| 37 |
// == ignored "-Wfloat-equal" |
| 38 |
// CHECK-SAME: op{{[0-9]+}}=1 |
| 39 |
// CHECK-SAME: op{{[0-9]+}}=[[FLOAT_EQ]] op{{[0-9]+}}= |
| 40 |
|
| 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]+}}= |
| 45 |
|
| 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]+}}= |
| 51 |
|
| 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]+}}= |
| 57 |
|
| 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 |
| 62 |
|
| 63 |
// RUN: diff %t/cache/A.pcm %t/A1.pcm |
| 64 |
|
| 65 |
//--- module.modulemap |
| 66 |
module A { header "a.h" } |
| 67 |
|
| 68 |
//--- a.h |
| 69 |
// Lex warning |
| 70 |
#warning "w" |
| 71 |
|
| 72 |
static inline void f() { |
| 73 |
// Parse warning |
| 74 |
; |
| 75 |
} |
| 76 |
|
| 77 |
#pragma clang diagnostic push |
| 78 |
#pragma clang diagnostic ignored "-Wfloat-equal" |
| 79 |
#pragma clang diagnostic ignored "-Wstack-protector" |
| 80 |
|
| 81 |
static inline void g() { |
| 82 |
// Sema warning |
| 83 |
int x; |
| 84 |
} |
| 85 |
|
| 86 |
#pragma clang diagnostic push |
| 87 |
#pragma clang diagnostic warning "-Wempty-translation-unit" |
| 88 |
#pragma clang diagnostic warning "-Wstack-protector" |
| 89 |
|
| 90 |
#pragma clang diagnostic pop |
| 91 |
#pragma clang diagnostic pop |
| 92 |
|
| 93 |
//--- main.m |
| 94 |
#import "a.h" |