https://github.com/shivatinker created 
https://github.com/llvm/llvm-project/pull/187512

Added instructions for using the `-fprofile-instr-generate=` parameter to 
specify a coverage directory at compile-time. It was completely undocumented in 
this page, while being very useful.

>From e50e18e0a4b42dd2bb109a554faa8018de7fdb44 Mon Sep 17 00:00:00 2001
From: Andrii Zinoviev <[email protected]>
Date: Thu, 19 Mar 2026 15:26:13 +0100
Subject: [PATCH] Document coverage directory configuration in clang

Added instructions for using the -fprofile-instr-generate parameter to specify 
a coverage directory at compile-time.
---
 clang/docs/SourceBasedCodeCoverage.rst | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/clang/docs/SourceBasedCodeCoverage.rst 
b/clang/docs/SourceBasedCodeCoverage.rst
index 395f2bcc85ef0..2e54e2d832302 100644
--- a/clang/docs/SourceBasedCodeCoverage.rst
+++ b/clang/docs/SourceBasedCodeCoverage.rst
@@ -64,6 +64,14 @@ To compile code with coverage enabled, pass 
``-fprofile-instr-generate
 Note that linking together code with and without coverage instrumentation is
 supported. Uninstrumented code simply won't be accounted for in reports.
 
+You can also pass the path with ``-fprofile-instr-generate=`` parameter to bake
+the coverage directory at compile-time. Instrumented program will use this path
+for coverage profile, unless ``LLVM_PROFILE_FILE`` environment variable is 
specified.
+
+.. code-block:: console
+
+    % clang++ -fprofile-instr-generate="foo.profraw" -fcoverage-mapping foo.cc 
-o foo
+
 To compile code with Modified Condition/Decision Coverage (MC/DC) enabled,
 pass ``-fcoverage-mcdc`` in addition to the clang options specified above.
 MC/DC is an advanced form of code coverage most applicable to the embedded
@@ -74,7 +82,9 @@ Running the instrumented program
 
 The next step is to run the instrumented program. When the program exits, it
 will write a **raw profile** to the path specified by the ``LLVM_PROFILE_FILE``
-environment variable. If that variable does not exist, the profile is written
+environment variable. If that variable does not exist, program will write 
coverage
+profile to the path specified by ``-fprofile-instr-generate=`` option. If that 
+value does not exist, the profile is written
 to ``default.profraw`` in the current directory of the program. If
 ``LLVM_PROFILE_FILE`` specifies a path to a non-existent directory, the missing
 directory structure will be created.  Additionally, the following special

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to