Skip to content

Commit abd4515

Browse files
committed
[Coverage] Add comment to skipped regions
Bug filled here: https://bugs.llvm.org/show_bug.cgi?id=45757. Add comment to skipped regions so we don't track execution count for lines containing only comments. Differential Revision: https://reviews.llvm.org/D84208
1 parent ace0bf7 commit abd4515

35 files changed

+257
-61
lines changed

clang/include/clang/Lex/Preprocessor.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@ class Preprocessor {
419419
/// The number of (LexLevel 0) preprocessor tokens.
420420
unsigned TokenCount = 0;
421421

422+
/// Preprocess every token regardless of LexLevel.
423+
bool PreprocessToken = false;
424+
422425
/// The maximum number of (LexLevel 0) tokens before issuing a -Wmax-tokens
423426
/// warning, or zero for unlimited.
424427
unsigned MaxTokens = 0;
@@ -1038,6 +1041,8 @@ class Preprocessor {
10381041
OnToken = std::move(F);
10391042
}
10401043

1044+
void setPreprocessToken(bool Preprocess) { PreprocessToken = Preprocess; }
1045+
10411046
bool isMacroDefined(StringRef Id) {
10421047
return isMacroDefined(&Identifiers.get(Id));
10431048
}

clang/lib/CodeGen/CodeGenAction.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -990,11 +990,9 @@ CodeGenAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
990990

991991
CoverageSourceInfo *CoverageInfo = nullptr;
992992
// Add the preprocessor callback only when the coverage mapping is generated.
993-
if (CI.getCodeGenOpts().CoverageMapping) {
994-
CoverageInfo = new CoverageSourceInfo;
995-
CI.getPreprocessor().addPPCallbacks(
996-
std::unique_ptr<PPCallbacks>(CoverageInfo));
997-
}
993+
if (CI.getCodeGenOpts().CoverageMapping)
994+
CoverageInfo = CodeGen::CoverageMappingModuleGen::setUpCoverageCallbacks(
995+
CI.getPreprocessor());
998996

999997
std::unique_ptr<BackendConsumer> Result(new BackendConsumer(
1000998
BA, CI.getDiagnostics(), CI.getHeaderSearchOpts(),

clang/lib/CodeGen/CoverageMappingGen.cpp

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,40 @@ using namespace clang;
3535
using namespace CodeGen;
3636
using namespace llvm::coverage;
3737

38+
CoverageSourceInfo *
39+
CoverageMappingModuleGen::setUpCoverageCallbacks(Preprocessor &PP) {
40+
CoverageSourceInfo *CoverageInfo = new CoverageSourceInfo;
41+
PP.addPPCallbacks(std::unique_ptr<PPCallbacks>(CoverageInfo));
42+
PP.addCommentHandler(CoverageInfo);
43+
PP.setPreprocessToken(true);
44+
PP.setTokenWatcher([CoverageInfo](clang::Token Tok) {
45+
// Update previous token location.
46+
CoverageInfo->PrevTokLoc = Tok.getLocation();
47+
CoverageInfo->updateNextTokLoc(Tok.getLocation());
48+
});
49+
return CoverageInfo;
50+
}
51+
3852
void CoverageSourceInfo::SourceRangeSkipped(SourceRange Range, SourceLocation) {
39-
SkippedRanges.push_back(Range);
53+
SkippedRanges.push_back({Range});
54+
}
55+
56+
bool CoverageSourceInfo::HandleComment(Preprocessor &PP, SourceRange Range) {
57+
if (PrevTokLoc.isValid() && PrevTokLoc == BeforeCommentLoc)
58+
SkippedRanges.back().Range.setEnd(Range.getEnd());
59+
else {
60+
SkippedRanges.push_back({Range, PrevTokLoc});
61+
BeforeCommentLoc = PrevTokLoc;
62+
}
63+
LastCommentIndex = SkippedRanges.size() - 1;
64+
return false;
65+
}
66+
67+
void CoverageSourceInfo::updateNextTokLoc(SourceLocation Loc) {
68+
if (LastCommentIndex) {
69+
SkippedRanges[LastCommentIndex.getValue()].NextTokLoc = Loc;
70+
LastCommentIndex = None;
71+
}
4072
}
4173

4274
namespace {
@@ -274,8 +306,34 @@ class CoverageMappingBuilder {
274306
return None;
275307
}
276308

309+
/// This shrinks the skipped range if it spans a line that contains a
310+
/// non-comment token. If shrinking the skipped range would make it empty,
311+
/// this returns None.
312+
Optional<SpellingRegion> adjustSkippedRange(SourceManager &SM,
313+
SpellingRegion SR,
314+
SourceLocation PrevTokLoc,
315+
SourceLocation NextTokLoc) {
316+
// If Range begin location is invalid, it's not a comment region.
317+
if (PrevTokLoc.isInvalid())
318+
return SR;
319+
unsigned PrevTokLine = SM.getSpellingLineNumber(PrevTokLoc);
320+
unsigned NextTokLine = SM.getSpellingLineNumber(NextTokLoc);
321+
SpellingRegion newSR(SR);
322+
if (SR.LineStart == PrevTokLine) {
323+
newSR.LineStart = SR.LineStart + 1;
324+
newSR.ColumnStart = 1;
325+
}
326+
if (SR.LineEnd == NextTokLine) {
327+
newSR.LineEnd = SR.LineEnd - 1;
328+
newSR.ColumnEnd = 1;
329+
}
330+
if (newSR.isInSourceOrder())
331+
return newSR;
332+
return None;
333+
}
334+
277335
/// Gather all the regions that were skipped by the preprocessor
278-
/// using the constructs like #if.
336+
/// using the constructs like #if or comments.
279337
void gatherSkippedRegions() {
280338
/// An array of the minimum lineStarts and the maximum lineEnds
281339
/// for mapping regions from the appropriate source files.
@@ -291,16 +349,22 @@ class CoverageMappingBuilder {
291349
}
292350

293351
auto SkippedRanges = CVM.getSourceInfo().getSkippedRanges();
294-
for (const auto &I : SkippedRanges) {
295-
auto LocStart = I.getBegin();
296-
auto LocEnd = I.getEnd();
352+
for (auto &I : SkippedRanges) {
353+
SourceRange Range = I.Range;
354+
auto LocStart = Range.getBegin();
355+
auto LocEnd = Range.getEnd();
297356
assert(SM.isWrittenInSameFile(LocStart, LocEnd) &&
298357
"region spans multiple files");
299358

300359
auto CovFileID = getCoverageFileID(LocStart);
301360
if (!CovFileID)
302361
continue;
303362
SpellingRegion SR{SM, LocStart, LocEnd};
363+
if (Optional<SpellingRegion> res =
364+
adjustSkippedRange(SM, SR, I.PrevTokLoc, I.NextTokLoc))
365+
SR = res.getValue();
366+
else
367+
continue;
304368
auto Region = CounterMappingRegion::makeSkipped(
305369
*CovFileID, SR.LineStart, SR.ColumnStart, SR.LineEnd, SR.ColumnEnd);
306370
// Make sure that we only collect the regions that are inside

clang/lib/CodeGen/CoverageMappingGen.h

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "clang/Basic/LLVM.h"
1717
#include "clang/Basic/SourceLocation.h"
1818
#include "clang/Lex/PPCallbacks.h"
19+
#include "clang/Lex/Preprocessor.h"
1920
#include "llvm/ADT/DenseMap.h"
2021
#include "llvm/IR/GlobalValue.h"
2122
#include "llvm/Support/raw_ostream.h"
@@ -29,15 +30,42 @@ class Preprocessor;
2930
class Decl;
3031
class Stmt;
3132

33+
struct SkippedRange {
34+
SourceRange Range;
35+
// The location of token before the skipped source range.
36+
SourceLocation PrevTokLoc;
37+
// The location of token after the skipped source range.
38+
SourceLocation NextTokLoc;
39+
40+
SkippedRange(SourceRange Range, SourceLocation PrevTokLoc = SourceLocation(),
41+
SourceLocation NextTokLoc = SourceLocation())
42+
: Range(Range), PrevTokLoc(PrevTokLoc), NextTokLoc(NextTokLoc) {}
43+
};
44+
3245
/// Stores additional source code information like skipped ranges which
3346
/// is required by the coverage mapping generator and is obtained from
3447
/// the preprocessor.
35-
class CoverageSourceInfo : public PPCallbacks {
36-
std::vector<SourceRange> SkippedRanges;
48+
class CoverageSourceInfo : public PPCallbacks, public CommentHandler {
49+
// A vector of skipped source ranges and PrevTokLoc with NextTokLoc.
50+
std::vector<SkippedRange> SkippedRanges;
51+
Optional<unsigned> LastCommentIndex = None;
52+
3753
public:
38-
ArrayRef<SourceRange> getSkippedRanges() const { return SkippedRanges; }
54+
// Location of the token parsed before HandleComment is called. This is
55+
// updated every time Preprocessor::Lex lexes a new token.
56+
SourceLocation PrevTokLoc;
57+
// The location of token before comment.
58+
SourceLocation BeforeCommentLoc;
59+
60+
std::vector<SkippedRange> &getSkippedRanges() {
61+
return SkippedRanges;
62+
}
3963

4064
void SourceRangeSkipped(SourceRange Range, SourceLocation EndifLoc) override;
65+
66+
bool HandleComment(Preprocessor &PP, SourceRange Range) override;
67+
68+
void updateNextTokLoc(SourceLocation Loc);
4169
};
4270

4371
namespace CodeGen {
@@ -66,6 +94,8 @@ class CoverageMappingModuleGen {
6694
uint64_t FilenamesRef);
6795

6896
public:
97+
static CoverageSourceInfo *setUpCoverageCallbacks(Preprocessor &PP);
98+
6999
CoverageMappingModuleGen(CodeGenModule &CGM, CoverageSourceInfo &SourceInfo)
70100
: CGM(CGM), SourceInfo(SourceInfo) {}
71101

clang/lib/Lex/Preprocessor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,8 @@ void Preprocessor::Lex(Token &Result) {
969969
LastTokenWasAt = Result.is(tok::at);
970970
--LexLevel;
971971

972-
if (LexLevel == 0 && !Result.getFlag(Token::IsReinjected)) {
972+
if ((LexLevel == 0 || PreprocessToken) &&
973+
!Result.getFlag(Token::IsReinjected)) {
973974
++TokenCount;
974975
if (OnToken)
975976
OnToken(Result);

clang/test/CoverageMapping/break.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name break.c %s | FileCheck %s
1+
// RUN: %strip_comments > %t.stripped.c
2+
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name break.c %t.stripped.c | FileCheck %s
23

34
int main() { // CHECK: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0
45
int cnt = 0; // CHECK-NEXT: File 0, [[@LINE+1]]:9 -> [[@LINE+1]]:18 = #0

clang/test/CoverageMapping/builtinmacro.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name builtinmacro.c %s | FileCheck %s
1+
// RUN: %strip_comments > %t.stripped.c
2+
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name builtinmacro.c %t.stripped.c | FileCheck %s
23

34
// Test the coverage mapping generation for built-in macroes.
45

clang/test/CoverageMapping/classtemplate.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %clang_cc1 -triple %itanium_abi_triple -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name classtemplate.cpp %s > %tmapping
1+
// RUN: %strip_comments > %t.stripped.cpp
2+
// RUN: %clang_cc1 -triple %itanium_abi_triple -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name classtemplate.cpp %t.stripped.cpp > %tmapping
23
// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-CONSTRUCTOR
34
// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-GETTER
45
// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-SETTER
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
1+
// RUN: %strip_comments > %t.stripped.c
2+
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %t.stripped.c | FileCheck %s
23

34
#define x1 "" // ...
45
#define x2 return 0
@@ -7,5 +8,5 @@ int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+3]]:2 = #0
78
x1; // CHECK-NEXT: Expansion,File 0, [[@LINE]]:3 -> [[@LINE]]:5 = #0
89
x2; // CHECK-NEXT: Expansion,File 0, [[@LINE]]:3 -> [[@LINE]]:5 = #0
910
}
10-
// CHECK-NEXT: File 1, 3:12 -> 3:14 = #0
11-
// CHECK-NEXT: File 2, 4:12 -> 4:20 = #0
11+
// CHECK-NEXT: File 1, 4:12 -> 4:14 = #0
12+
// CHECK-NEXT: File 2, 5:12 -> 5:20 = #0

clang/test/CoverageMapping/continue.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name continue.c %s | FileCheck %s
1+
// RUN: %strip_comments > %t.stripped.c
2+
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name continue.c %t.stripped.c | FileCheck %s
23

34
int main() { // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+21]]:2 = #0
45
int j = 0; // CHECK-NEXT: File 0, [[@LINE+2]]:18 -> [[@LINE+2]]:24 = (#0 + #1)

clang/test/CoverageMapping/coroutine.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// fixme: the following line is added to cleanup bots, will be removed in weeks.
22
// RUN: rm -f %S/coroutine.ll
3-
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %s -o - | FileCheck %s
3+
// RUN: %strip_comments > %t.stripped.cpp
4+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %t.stripped.cpp -o - | FileCheck %s
45

56
namespace std::experimental {
67
template <typename... T>

clang/test/CoverageMapping/deferred-region.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %clang_cc1 -std=c++11 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -fexceptions -fcxx-exceptions -emit-llvm-only -triple %itanium_abi_triple -main-file-name deferred-region.cpp -I %S/Inputs %s | FileCheck %s
1+
// RUN: %strip_comments > %t.stripped.cpp
2+
// RUN: %clang_cc1 -std=c++11 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -fexceptions -fcxx-exceptions -emit-llvm-only -triple %itanium_abi_triple -main-file-name deferred-region.cpp -I %S/Inputs %t.stripped.cpp | FileCheck %s
23

34
#define IF if
45
#define STMT(S) S

clang/test/CoverageMapping/if.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++1z -triple %itanium_abi_triple -main-file-name if.cpp %s | FileCheck %s
1+
// RUN: %strip_comments > %t.stripped.cpp
2+
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++1z -triple %itanium_abi_triple -main-file-name if.cpp %t.stripped.cpp | FileCheck %s
23

34
int nop() { return 0; }
45

clang/test/CoverageMapping/includehell.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name includehell.cpp %s > %tmapping
2-
1+
// RUN: %strip_comments > %t.stripped.cpp
2+
// RUN: %clang_cc1 -I/%S -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name includehell.cpp %t.stripped.cpp > %tmapping
33
int main() {
44
int x = 0;
55

@@ -51,13 +51,15 @@ int main() {
5151
// CHECK-START: File [[START3]], 4:29 -> 5:1 = #9
5252

5353
// CHECK-CODE: File [[CODE1:[0-9]]], 1:1 -> 14:1 = #1
54+
// CHECK-CODE: Skipped,File [[CODE1]], 1:1 -> 1:41 = 0
5455
// CHECK-CODE-NEXT: File [[CODE1]], 4:5 -> 4:11 = #1
5556
// CHECK-CODE: File [[CODE1]], 4:13 -> 6:2 = #2
5657
// CHECK-CODE: File [[CODE1]], 6:8 -> 8:2 = (#1 - #2)
5758
// CHECK-CODE-NEXT: File [[CODE1]], 9:5 -> 9:9 = #1
5859
// CHECK-CODE: File [[CODE1]], 9:11 -> 11:2 = #3
5960
// CHECK-CODE: File [[CODE1]], 11:8 -> 13:2 = (#1 - #3)
6061
// CHECK-CODE: File [[CODE2:[0-9]]], 1:1 -> 14:1 = #5
62+
// CHECK-CODE: Skipped,File [[CODE2]], 1:1 -> 1:41 = 0
6163
// CHECK-CODE-NEXT: File [[CODE2]], 4:5 -> 4:11 = #5
6264
// CHECK-CODE: File [[CODE2]], 4:13 -> 6:2 = #6
6365
// CHECK-CODE: File [[CODE2]], 6:8 -> 8:2 = (#5 - #6)

clang/test/CoverageMapping/label.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name label.cpp %s | FileCheck %s
1+
// RUN: %strip_comments > %t.stripped.cpp
2+
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name label.cpp %t.stripped.cpp | FileCheck %s
23

3-
// CHECK: func
4+
// CHECK: func
45
void func() { // CHECK-NEXT: File 0, [[@LINE]]:13 -> {{[0-9]+}}:2 = #0
56
int i = 0; // CHECK-NEXT: File 0, [[@LINE+2]]:14 -> [[@LINE+2]]:20 = (#0 + #3)
67
// CHECK-NEXT: File 0, [[@LINE+1]]:22 -> [[@LINE+1]]:25 = #3

clang/test/CoverageMapping/logical.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name logical.cpp %s | FileCheck %s
1+
// RUN: %strip_comments > %t.stripped.cpp
2+
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name logical.cpp %t.stripped.cpp | FileCheck %s
23

34
int main() { // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+15]]:2 = #0
45
bool bt = true;

clang/test/CoverageMapping/loops.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
// RUN: %clang_cc1 -std=c++11 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loops.cpp %s | FileCheck %s
1+
// RUN: %strip_comments > %t.stripped.cpp
2+
// RUN: %clang_cc1 -std=c++11 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loops.cpp %t.stripped.cpp | FileCheck %s
23

3-
// CHECK: rangedFor
4+
// CHECK: rangedFor
45
void rangedFor() { // CHECK-NEXT: File 0, [[@LINE]]:18 -> {{[0-9]+}}:2 = #0
56
int arr[] = { 1, 2, 3, 4, 5 };
67
int sum = 0; // CHECK: Gap,File 0, [[@LINE+1]]:20 -> [[@LINE+1]]:21 = #1

clang/test/CoverageMapping/macro-expressions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clang_cc1 -std=c++11 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macro-expressions.cpp -w %s | FileCheck %s
2-
1+
// RUN: %strip_comments > %t.stripped.cpp
2+
// RUN: %clang_cc1 -std=c++11 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macro-expressions.cpp -w %t.stripped.cpp | FileCheck %s
33
#define EXPR(x) (x)
44
#define NEXPR(x) (!x)
55
#define DECL(T, x) T x

clang/test/CoverageMapping/macroparams2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroparams2.c %s | FileCheck %s
2-
1+
// RUN: %strip_comments > %t.stripped.c
2+
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroparams2.c %t.stripped.c | FileCheck %s
33
#define MACRO(REFS, CALLS) (4 * (CALLS) < (REFS))
44

55
struct S {

clang/test/CoverageMapping/macros.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macros.c %s | FileCheck %s
2-
1+
// RUN: %strip_comments > %t.stripped.c
2+
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macros.c %t.stripped.c | FileCheck %s
33
#define MACRO return; bar()
44
#define MACRO_2 bar()
55
#define MACRO_1 return; MACRO_2

clang/test/CoverageMapping/macroscopes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroscopes.cpp %s | FileCheck %s
2-
1+
// RUN: %strip_comments > %t.stripped.cpp
2+
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroscopes.cpp %t.stripped.cpp | FileCheck %s
33
#define starts_a_scope for (int i = 0; i < 2; ++i) {
44

55
#define ends_a_scope \

clang/test/CoverageMapping/moremacros.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macro-expansion.c %s | FileCheck %s
2-
1+
// RUN: %strip_comments > %t.stripped.c
2+
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macro-expansion.c %t.stripped.c | FileCheck %s
33
#define LBRAC {
44
#define RBRAC }
55

clang/test/CoverageMapping/objc.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name objc.m -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -w %s | FileCheck %s
1+
// RUN: %strip_comments > %t.stripped.m
2+
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name objc.m -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -w %t.stripped.m | FileCheck %s
23

34
@interface A
45
- (void)bork:(int)msg;

clang/test/CoverageMapping/pr32679.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// RUN: %clang_cc1 -cc1 -triple i686-pc-windows-msvc19.0.0 -emit-obj -fprofile-instrument=clang -std=c++14 -fdelayed-template-parsing -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name pr32679.cpp -o - %s | FileCheck %s -check-prefix=MSABI -implicit-check-not=f2
2-
// RUN: %clang_cc1 -cc1 -triple %itanium_abi_triple -emit-obj -fprofile-instrument=clang -std=c++14 -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name pr32679.cpp -o - %s | FileCheck %s -check-prefix=ITANIUM -implicit-check-not=f2
1+
// RUN: %strip_comments > %t.stripped.cpp
2+
// RUN: %clang_cc1 -cc1 -triple i686-pc-windows-msvc19.0.0 -emit-obj -fprofile-instrument=clang -std=c++14 -fdelayed-template-parsing -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name pr32679.cpp -o - %t.stripped.cpp | FileCheck %s -check-prefix=MSABI -implicit-check-not=f2
3+
// RUN: %clang_cc1 -cc1 -triple %itanium_abi_triple -emit-obj -fprofile-instrument=clang -std=c++14 -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name pr32679.cpp -o - %t.stripped.cpp | FileCheck %s -check-prefix=ITANIUM -implicit-check-not=f2
34

45
template <typename T, int S1>
56
struct CreateSpecialization;

0 commit comments

Comments
 (0)