95 lines · c
1// Test that diagnostic mappings are emitted only when needed and in order of2// diagnostic ID rather than non-deterministically. This test passes 33// -W options and expects exactly 3 mappings to be emitted in the pcm. The -W4// options are chosen to be far apart in ID (see DiagnosticIDs.h) so we can5// check they are ordered. We also intentionally trigger several other warnings6// inside the module and ensure they do not show up in the pcm as mappings.7 8// RUN: rm -rf %t9// RUN: split-file %s %t10 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-equal15 16// RUN: mv %t/cache/A.pcm %t/A1.pcm17 18// RUN: llvm-bcanalyzer --dump --disable-histogram %t/A1.pcm | FileCheck %s19 20// CHECK: <DIAG_PRAGMA_MAPPINGS21 22// == Initial mappings23// Number of mappings = 324// CHECK-SAME: op2=325// 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 changes28// CHECK-SAME: op5=[[EMPTY_TU:[12][0-9][0-9][0-9]]] op6=29// Sema diag id is > 200030// 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. The34// initial mappings are copied as well, but are not serialized since they have35// isPragma=false.36 37// == ignored "-Wfloat-equal"38// CHECK-SAME: op{{[0-9]+}}=139// CHECK-SAME: op{{[0-9]+}}=[[FLOAT_EQ]] op{{[0-9]+}}=40 41// == ignored "-Wstack-protector"42// CHECK-SAME: op{{[0-9]+}}=243// 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]+}}=348// 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]+}}=354// 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-equal62 63// RUN: diff %t/cache/A.pcm %t/A1.pcm64 65//--- module.modulemap66module A { header "a.h" }67 68//--- a.h69// Lex warning70#warning "w"71 72static inline void f() {73// Parse warning74 ;75}76 77#pragma clang diagnostic push78#pragma clang diagnostic ignored "-Wfloat-equal"79#pragma clang diagnostic ignored "-Wstack-protector"80 81static inline void g() {82// Sema warning83 int x;84}85 86#pragma clang diagnostic push87#pragma clang diagnostic warning "-Wempty-translation-unit"88#pragma clang diagnostic warning "-Wstack-protector"89 90#pragma clang diagnostic pop91#pragma clang diagnostic pop92 93//--- main.m94#import "a.h"95