[clang] 3029378 - Update clang/test/system_macro.cpp for both -system-headers-coverage=true/false

NAKAMURA Takumi via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 9 06:51:25 PDT 2024


Author: NAKAMURA Takumi
Date: 2024-07-09T22:21:20+09:00
New Revision: 302937859fce0bb506ef6edf9c3e77c86ab44b86

URL: https://github.com/llvm/llvm-project/commit/302937859fce0bb506ef6edf9c3e77c86ab44b86
DIFF: https://github.com/llvm/llvm-project/commit/302937859fce0bb506ef6edf9c3e77c86ab44b86.diff

LOG: Update clang/test/system_macro.cpp for both -system-headers-coverage=true/false

Part of #97952

Added: 
    

Modified: 
    clang/test/CoverageMapping/system_macro.cpp

Removed: 
    


################################################################################
diff  --git a/clang/test/CoverageMapping/system_macro.cpp b/clang/test/CoverageMapping/system_macro.cpp
index 725752553bcf7..3909c17a9b5c6 100644
--- a/clang/test/CoverageMapping/system_macro.cpp
+++ b/clang/test/CoverageMapping/system_macro.cpp
@@ -1,4 +1,15 @@
-// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -mllvm -system-headers-coverage -std=c++11 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name system_macro.cpp -o - %s | FileCheck %s
+// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -mllvm -system-headers-coverage=true -std=c++11 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm -main-file-name system_macro.cpp -o %t.w_sys.ll %s | FileCheck %s --check-prefixes=CHECK,W_SYS
+// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -mllvm -system-headers-coverage=false -std=c++11 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm -main-file-name system_macro.cpp -o %t.wosys.ll %s | FileCheck %s --check-prefixes=CHECK,WOSYS
+// RUN: FileCheck %s --check-prefixes=LL_CHECK,LL_W_SYS < %t.w_sys.ll
+// RUN: FileCheck %s --check-prefixes=LL_CHECK,LL_WOSYS < %t.wosys.ll
+
+// LL_CHECK: @__covrec_
+// LL_W_SYS: [[PROFC:@.*__profc_.*SysTmpl.*]] =
+// LL_WOSYS: [[PROFC:@.*__profc_.*SysTmpl.*]] =
+// LL_W_SYS: @{{.*}}__profd_{{.*}}SysTmpl{{.*}} =
+// LL_WOSYS: @{{.*}}__profd_{{.*}}SysTmpl{{.*}} =
+
+// LL_CHECK: @llvm.used =
 
 #ifdef IS_SYSHEADER
 
@@ -6,6 +17,12 @@
 #define Func(x) if (x) {}
 #define SomeType int
 
+// LL_CHECK: define {{.*}} i1 @{{.*}}SysTmpl
+template <bool f> bool SysTmpl() { return f; }
+// Check SysTmpl() is instrumented or not.
+// LL_W_SYS: load i64, ptr [[PROFC]],
+// LL_WOSYS: load i64, ptr [[PROFC]],
+
 #else
 
 #define IS_SYSHEADER
@@ -13,15 +30,22 @@
 
 // CHECK-LABEL: doSomething
 void doSomething(int x) { // CHECK: File 0, [[@LINE]]:25 -> {{[0-9:]+}} = #0
-  Func(x); // CHECK: Expansion,File 0, [[@LINE]]:3 -> [[@LINE]]:7
+  // WOSYS-NOT: Expansion,
+  // W_SYS: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:7
+  Func(x);
+  // CHECK: Gap,File 0, [[@LINE+1]]:10
   return;
-  // CHECK: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:11
+  // WOSYS-NOT: Expansion,
+  // W_SYS: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:11
   SomeType *f; // CHECK: File 0, [[@LINE]]:11 -> {{[0-9:]+}} = 0
 }
 
 // CHECK-LABEL: main
 int main() { // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+2]]:2 = #0
-  Func([] { return true; }());
+  Func([] { return SysTmpl<true>(); }());
 }
 
+// W_SYS: SysTmpl
+// WOSYS-NOT: SysTmpl
+
 #endif


        


More information about the cfe-commits mailing list