diff --git a/clang/docs/SanitizerSpecialCaseList.rst b/clang/docs/SanitizerSpecialCaseList.rst --- a/clang/docs/SanitizerSpecialCaseList.rst +++ b/clang/docs/SanitizerSpecialCaseList.rst @@ -62,9 +62,8 @@ Entries contain an entity type, followed by a colon and a regular expression, specifying the names of the entities, optionally followed by an equals sign and -a tool-specific category, e.g. ``fun:*ExampleFunc=example_category``. The -meaning of ``*`` in regular expression for entity names is different - it is -treated as in shell wildcarding. Two generic entity types are ``src`` and +a tool-specific category, e.g. ``fun:*ExampleFunc=example_category``. +Two generic entity types are ``src`` and ``fun``, which allow users to specify source files and functions, respectively. Some sanitizer tools may introduce custom entity types and categories - refer to tool-specific docs. @@ -72,19 +71,18 @@ .. code-block:: bash # Lines starting with # are ignored. - # Turn off checks for the source file (use absolute path or path relative - # to the current working directory): - src:/path/to/source/file.c + # Turn off checks for the source file + src:path/to/source/file.c + src:*/source/file.c # Turn off checks for this main file, including files included by it. # Useful when the main file instead of an included file should be ignored. mainfile:file.c # Turn off checks for a particular functions (use mangled names): - fun:MyFooBar fun:_Z8MyFooBarv # Extended regular expressions are supported: fun:bad_(foo|bar) src:bad_source[1-9].c - # Shell like usage of * is supported (* is treated as .*): + # "*" is treated as ".*": src:bad/sources/* fun:*BadFunction* # Specific sanitizer tools may introduce categories. diff --git a/clang/test/CodeGen/profile-filter-new.c b/clang/test/CodeGen/profile-filter-new.c --- a/clang/test/CodeGen/profile-filter-new.c +++ b/clang/test/CodeGen/profile-filter-new.c @@ -1,20 +1,14 @@ -// RUN: %clang_cc1 -fprofile-instrument=llvm -emit-llvm %s -o - | FileCheck %s --implicit-check-not="; {{.* (noprofile|skipprofile)}}" +// RUN: split-file %s %t -// RUN: echo -e "[llvm]\nfunction:foo=skip" > %t0.list -// RUN: %clang_cc1 -fprofile-instrument=llvm -fprofile-list=%t0.list -emit-llvm %s -o - | FileCheck %s --implicit-check-not="; {{.* (noprofile|skipprofile)}}" --check-prefixes=CHECK,SKIP-FOO - -// RUN: echo -e "[csllvm]\nfunction:bar=forbid" > %t1.list -// RUN: %clang_cc1 -fprofile-instrument=csllvm -fprofile-list=%t1.list -emit-llvm %s -o - | FileCheck %s --implicit-check-not="; {{.* (noprofile|skipprofile)}}" --check-prefixes=CHECK,FORBID-BAR -// RUN: %clang_cc1 -fprofile-instrument=llvm -fprofile-list=%t1.list -emit-llvm %s -o - | FileCheck %s --implicit-check-not="; {{.* (noprofile|skipprofile)}}" - -// RUN: echo -e "[llvm]\ndefault:forbid\nfunction:foo=allow" > %t2.list -// RUN: %clang_cc1 -fprofile-instrument=llvm -fprofile-list=%t2.list -emit-llvm %s -o - | FileCheck %s --implicit-check-not="; {{.* (noprofile|skipprofile)}}" --check-prefixes=CHECK,FORBID - -// RUN: echo "[llvm]" > %t2.list -// RUN: echo "source:%s=forbid" | sed -e 's/\\/\\\\/g' >> %t2.list -// RUN: echo "function:foo=allow" >> %t2.list -// RUN: %clang_cc1 -fprofile-instrument=llvm -fprofile-list=%t2.list -emit-llvm %s -o - | FileCheck %s --implicit-check-not="; {{.* (noprofile|skipprofile)}}" --check-prefixes=CHECK,FORBID +// RUN: %clang_cc1 -fprofile-instrument=llvm -emit-llvm %t/Inputs/src/code.c -o - | FileCheck %s --implicit-check-not="; {{.* (noprofile|skipprofile)}}" +// RUN: %clang_cc1 -fprofile-instrument=llvm -fprofile-list=%t/Inputs/skip-foo.txt -emit-llvm %t/Inputs/src/code.c -o - | FileCheck %s --implicit-check-not="; {{.* (noprofile|skipprofile)}}" --check-prefixes=CHECK,SKIP-FOO +// RUN: %clang_cc1 -fprofile-instrument=csllvm -fprofile-list=%t/Inputs/forbid-bar.txt -emit-llvm %t/Inputs/src/code.c -o - | FileCheck %s --implicit-check-not="; {{.* (noprofile|skipprofile)}}" --check-prefixes=CHECK,FORBID-BAR +// RUN: %clang_cc1 -fprofile-instrument=llvm -fprofile-list=%t/Inputs/forbid-bar.txt -emit-llvm %t/Inputs/src/code.c -o - | FileCheck %s --implicit-check-not="; {{.* (noprofile|skipprofile)}}" +// RUN: %clang_cc1 -fprofile-instrument=llvm -fprofile-list=%t/Inputs/forbid-default.txt -emit-llvm %t/Inputs/src/code.c -o - | FileCheck %s --implicit-check-not="; {{.* (noprofile|skipprofile)}}" --check-prefixes=CHECK,FORBID +// RUN: %clang_cc1 -fprofile-instrument=csllvm -fprofile-list=%t/Inputs/forbid-default.txt -emit-llvm %t/Inputs/src/code.c -o - | FileCheck %s --implicit-check-not="; {{.* (noprofile|skipprofile)}}" --check-prefixes=CHECK,FORBID +// RUN: %clang_cc1 -fprofile-instrument=llvm -fprofile-list=%t/Inputs/forbid-source.txt -emit-llvm %t/Inputs/src/code.c -o - | FileCheck %s --implicit-check-not="; {{.* (noprofile|skipprofile)}}" --check-prefixes=CHECK,FORBID +//--- Inputs/src/code.c // SKIP-FOO: skipprofile // CHECK-LABEL: define {{.*}} @foo int foo(int a) { return 4 * a + 1; } @@ -27,3 +21,26 @@ // FORBID: noprofile // CHECK-LABEL: define {{.*}} @goo int goo(int a) { return 4 * a + 3; } + +//--- Inputs/skip-foo.txt +[llvm] +# This is a comment +# Use mangled names to select functions +function:foo=skip + +//--- Inputs/forbid-bar.txt +[csllvm] +function:bar=forbid + +//--- Inputs/forbid-default.txt +[llvm|csllvm] +default:forbid +function:foo=allow + +//--- Inputs/forbid-source.txt +[llvm] +# The "*" prefix matches the whole directory "%t/Inputs/" and "(/|\\)" matches +# unix-like and windows path separators +source:*(/|\\)src(/|\\)code.c=forbid +# Function entries take precedence over source entries +function:foo=allow