[Coverage] Add empty line regions to SkippedRegions

Differential Revision: https://reviews.llvm.org/D84988
This commit is contained in:
Zequan Wu 2020-09-02 14:50:32 -07:00
parent 6bad3caeb0
commit 9caa3fbe03
63 changed files with 247 additions and 135 deletions

View File

@ -128,6 +128,10 @@ class Lexer : public PreprocessorLexer {
bool HasLeadingEmptyMacro;
// NewLinePtr - A pointer to new line character '\n' being lexed. For '\r\n',
// it also points to '\n.'
const char *NewLinePtr;
// CurrentConflictMarkerState - The kind of conflict marker we are handling.
ConflictMarkerKind CurrentConflictMarkerState;

View File

@ -67,6 +67,7 @@ class CodeCompletionHandler;
class CommentHandler;
class DirectoryEntry;
class DirectoryLookup;
class EmptylineHandler;
class ExternalPreprocessorSource;
class FileEntry;
class FileManager;
@ -256,6 +257,9 @@ class Preprocessor {
/// with this preprocessor.
std::vector<CommentHandler *> CommentHandlers;
/// Empty line handler.
EmptylineHandler *Emptyline = nullptr;
/// True if we want to ignore EOF token and continue later on (thus
/// avoid tearing the Lexer and etc. down).
bool IncrementalProcessing = false;
@ -1219,6 +1223,11 @@ public:
/// Install empty handlers for all pragmas (making them ignored).
void IgnorePragmas();
/// Set empty line handler.
void setEmptylineHandler(EmptylineHandler *Handler) { Emptyline = Handler; }
EmptylineHandler *getEmptylineHandler() const { return Emptyline; }
/// Add the specified comment handler to the preprocessor.
void addCommentHandler(CommentHandler *Handler);
@ -2390,6 +2399,16 @@ public:
virtual bool HandleComment(Preprocessor &PP, SourceRange Comment) = 0;
};
/// Abstract base class that describes a handler that will receive
/// source ranges for empty lines encountered in the source file.
class EmptylineHandler {
public:
virtual ~EmptylineHandler();
// The handler handles empty lines.
virtual void HandleEmptyline(SourceRange Range) = 0;
};
/// Registry of pragma handlers added by plugins
using PragmaHandlerRegistry = llvm::Registry<PragmaHandler>;

View File

@ -31,40 +31,61 @@
// is textually included.
#define COVMAP_V3
static llvm::cl::opt<bool> EmptyLineCommentCoverage(
"emptyline-comment-coverage",
llvm::cl::desc("Emit emptylines and comment lines as skipped regions (only "
"disable it on test)"),
llvm::cl::init(true), llvm::cl::Hidden);
using namespace clang;
using namespace CodeGen;
using namespace llvm::coverage;
CoverageSourceInfo *
CoverageMappingModuleGen::setUpCoverageCallbacks(Preprocessor &PP) {
CoverageSourceInfo *CoverageInfo = new CoverageSourceInfo();
CoverageSourceInfo *CoverageInfo =
new CoverageSourceInfo(PP.getSourceManager());
PP.addPPCallbacks(std::unique_ptr<PPCallbacks>(CoverageInfo));
PP.addCommentHandler(CoverageInfo);
PP.setPreprocessToken(true);
PP.setTokenWatcher([CoverageInfo](clang::Token Tok) {
// Update previous token location.
CoverageInfo->PrevTokLoc = Tok.getLocation();
if (Tok.getKind() != clang::tok::eod)
CoverageInfo->updateNextTokLoc(Tok.getLocation());
});
if (EmptyLineCommentCoverage) {
PP.addCommentHandler(CoverageInfo);
PP.setEmptylineHandler(CoverageInfo);
PP.setPreprocessToken(true);
PP.setTokenWatcher([CoverageInfo](clang::Token Tok) {
// Update previous token location.
CoverageInfo->PrevTokLoc = Tok.getLocation();
if (Tok.getKind() != clang::tok::eod)
CoverageInfo->updateNextTokLoc(Tok.getLocation());
});
}
return CoverageInfo;
}
void CoverageSourceInfo::AddSkippedRange(SourceRange Range) {
if (EmptyLineCommentCoverage && !SkippedRanges.empty() &&
PrevTokLoc == SkippedRanges.back().PrevTokLoc &&
SourceMgr.isWrittenInSameFile(SkippedRanges.back().Range.getEnd(),
Range.getBegin()))
SkippedRanges.back().Range.setEnd(Range.getEnd());
else
SkippedRanges.push_back({Range, PrevTokLoc});
}
void CoverageSourceInfo::SourceRangeSkipped(SourceRange Range, SourceLocation) {
SkippedRanges.push_back({Range});
AddSkippedRange(Range);
}
void CoverageSourceInfo::HandleEmptyline(SourceRange Range) {
AddSkippedRange(Range);
}
bool CoverageSourceInfo::HandleComment(Preprocessor &PP, SourceRange Range) {
SkippedRanges.push_back({Range, PrevTokLoc});
AfterComment = true;
AddSkippedRange(Range);
return false;
}
void CoverageSourceInfo::updateNextTokLoc(SourceLocation Loc) {
if (AfterComment) {
if (!SkippedRanges.empty() && SkippedRanges.back().NextTokLoc.isInvalid())
SkippedRanges.back().NextTokLoc = Loc;
AfterComment = false;
}
}
namespace {
@ -311,24 +332,17 @@ public:
SourceLocation PrevTokLoc,
SourceLocation NextTokLoc) {
SpellingRegion SR{SM, LocStart, LocEnd};
// If Range begin location is invalid, it's not a comment region.
if (PrevTokLoc.isInvalid())
SR.ColumnStart = 1;
if (PrevTokLoc.isValid() && SM.isWrittenInSameFile(LocStart, PrevTokLoc) &&
SR.LineStart == SM.getSpellingLineNumber(PrevTokLoc))
SR.LineStart++;
if (NextTokLoc.isValid() && SM.isWrittenInSameFile(LocEnd, NextTokLoc) &&
SR.LineEnd == SM.getSpellingLineNumber(NextTokLoc)) {
SR.LineEnd--;
SR.ColumnEnd++;
}
if (SR.isInSourceOrder())
return SR;
unsigned PrevTokLine = SM.getSpellingLineNumber(PrevTokLoc);
unsigned NextTokLine = SM.getSpellingLineNumber(NextTokLoc);
SpellingRegion newSR(SR);
if (SM.isWrittenInSameFile(LocStart, PrevTokLoc) &&
SR.LineStart == PrevTokLine) {
newSR.LineStart = SR.LineStart + 1;
newSR.ColumnStart = 1;
}
if (SM.isWrittenInSameFile(LocEnd, NextTokLoc) &&
SR.LineEnd == NextTokLine) {
newSR.LineEnd = SR.LineEnd - 1;
newSR.ColumnEnd = SR.ColumnStart + 1;
}
if (newSR.isInSourceOrder())
return newSR;
return None;
}

View File

@ -45,22 +45,29 @@ struct SkippedRange {
/// Stores additional source code information like skipped ranges which
/// is required by the coverage mapping generator and is obtained from
/// the preprocessor.
class CoverageSourceInfo : public PPCallbacks, public CommentHandler {
class CoverageSourceInfo : public PPCallbacks,
public CommentHandler,
public EmptylineHandler {
// A vector of skipped source ranges and PrevTokLoc with NextTokLoc.
std::vector<SkippedRange> SkippedRanges;
bool AfterComment = false;
SourceManager &SourceMgr;
public:
// Location of the token parsed before HandleComment is called. This is
// updated every time Preprocessor::Lex lexes a new token.
SourceLocation PrevTokLoc;
// The location of token before comment.
SourceLocation BeforeCommentLoc;
CoverageSourceInfo(SourceManager &SourceMgr) : SourceMgr(SourceMgr) {}
std::vector<SkippedRange> &getSkippedRanges() { return SkippedRanges; }
void AddSkippedRange(SourceRange Range);
void SourceRangeSkipped(SourceRange Range, SourceLocation EndifLoc) override;
void HandleEmptyline(SourceRange Range) override;
bool HandleComment(Preprocessor &PP, SourceRange Range) override;
void updateNextTokLoc(SourceLocation Loc);

View File

@ -125,6 +125,8 @@ void Lexer::InitLexer(const char *BufStart, const char *BufPtr,
// Default to not keeping comments.
ExtendedTokenMode = 0;
NewLinePtr = nullptr;
}
/// Lexer constructor - Create a new lexer object for the specified buffer
@ -2197,6 +2199,15 @@ bool Lexer::SkipWhitespace(Token &Result, const char *CurPtr,
unsigned char Char = *CurPtr;
const char *lastNewLine = nullptr;
auto setLastNewLine = [&](const char *Ptr) {
lastNewLine = Ptr;
if (!NewLinePtr)
NewLinePtr = Ptr;
};
if (SawNewline)
setLastNewLine(CurPtr - 1);
// Skip consecutive spaces efficiently.
while (true) {
// Skip horizontal whitespace very aggressively.
@ -2214,6 +2225,8 @@ bool Lexer::SkipWhitespace(Token &Result, const char *CurPtr,
}
// OK, but handle newline.
if (*CurPtr == '\n')
setLastNewLine(CurPtr);
SawNewline = true;
Char = *++CurPtr;
}
@ -2237,6 +2250,12 @@ bool Lexer::SkipWhitespace(Token &Result, const char *CurPtr,
if (SawNewline) {
Result.setFlag(Token::StartOfLine);
TokAtPhysicalStartOfLine = true;
if (NewLinePtr && lastNewLine && NewLinePtr != lastNewLine && PP) {
if (auto *Handler = PP->getEmptylineHandler())
Handler->HandleEmptyline(SourceRange(getSourceLocation(NewLinePtr + 1),
getSourceLocation(lastNewLine)));
}
}
BufferPtr = CurPtr;
@ -2377,7 +2396,7 @@ bool Lexer::SkipLineComment(Token &Result, const char *CurPtr,
// contribute to another token), it isn't needed for correctness. Note that
// this is ok even in KeepWhitespaceMode, because we would have returned the
/// comment above in that mode.
++CurPtr;
NewLinePtr = CurPtr++;
// The next returned token is at the start of the line.
Result.setFlag(Token::StartOfLine);
@ -3211,6 +3230,9 @@ LexNextToken:
char Char = getAndAdvanceChar(CurPtr, Result);
tok::TokenKind Kind;
if (!isVerticalWhitespace(Char))
NewLinePtr = nullptr;
switch (Char) {
case 0: // Null.
// Found end of file?
@ -3265,6 +3287,7 @@ LexNextToken:
// Since we consumed a newline, we are back at the start of a line.
IsAtStartOfLine = true;
IsAtPhysicalStartOfLine = true;
NewLinePtr = CurPtr - 1;
Kind = tok::eod;
break;

View File

@ -1417,6 +1417,8 @@ ModuleLoader::~ModuleLoader() = default;
CommentHandler::~CommentHandler() = default;
EmptylineHandler::~EmptylineHandler() = default;
CodeCompletionHandler::~CodeCompletionHandler() = default;
void Preprocessor::createPreprocessingRecord() {

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -mllvm -enable-name-compression=false -emit-llvm -main-file-name abspath.cpp %S/Inputs/../abspath.cpp -o - | FileCheck -check-prefix=RMDOTS %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -mllvm -enable-name-compression=false -emit-llvm -main-file-name abspath.cpp %S/Inputs/../abspath.cpp -o - | FileCheck -check-prefix=RMDOTS %s
// RMDOTS: @__llvm_coverage_mapping = {{.*}}"\01
// RMDOTS-NOT: Inputs
@ -6,7 +6,7 @@
// RUN: mkdir -p %t/test && cd %t/test
// RUN: echo "void f1() {}" > f1.c
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -mllvm -enable-name-compression=false -emit-llvm -main-file-name abspath.cpp ../test/f1.c -o - | FileCheck -check-prefix=RELPATH %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -mllvm -enable-name-compression=false -emit-llvm -main-file-name abspath.cpp ../test/f1.c -o - | FileCheck -check-prefix=RELPATH %s
// RELPATH: @__llvm_coverage_mapping = {{.*}}"\01
// RELPATH: {{[/\\].*(/|\\\\)test(/|\\\\)f1}}.c

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -triple x86_64-apple-darwin -fobjc-runtime=macosx-10.10.0 -fblocks -fobjc-arc %s | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -triple x86_64-apple-darwin -fobjc-runtime=macosx-10.10.0 -fblocks -fobjc-arc %s | FileCheck %s
@interface Foo
@end

View File

@ -1,5 +1,4 @@
// RUN: %strip_comments > %t.stripped.c
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name break.c %t.stripped.c | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name break.c %s | FileCheck %s
int main() { // CHECK: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0
int cnt = 0; // CHECK-NEXT: File 0, [[@LINE+1]]:9 -> [[@LINE+1]]:18 = #0

View File

@ -1,5 +1,4 @@
// RUN: %strip_comments > %t.stripped.c
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name builtinmacro.c %t.stripped.c | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name builtinmacro.c %s | FileCheck %s
// Test the coverage mapping generation for built-in macroes.

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name casts.c %s | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name casts.c %s | FileCheck %s
int main() { // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+4]]:2 = #0
// CHECK: File 0, [[@LINE+1]]:41 -> [[@LINE+1]]:54 = #1

View File

@ -1,5 +1,4 @@
// RUN: %strip_comments > %t.stripped.cpp
// 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
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -triple %itanium_abi_triple -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name classtemplate.cpp %s > %tmapping
// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-CONSTRUCTOR
// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-GETTER
// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-SETTER

View File

@ -1,5 +1,4 @@
// RUN: %strip_comments > %t.stripped.c
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %t.stripped.c | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
#define x1 "" // ...
#define x2 return 0
@ -8,5 +7,5 @@ int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+3]]:2 = #0
x1; // CHECK-NEXT: Expansion,File 0, [[@LINE]]:3 -> [[@LINE]]:5 = #0
x2; // CHECK-NEXT: Expansion,File 0, [[@LINE]]:3 -> [[@LINE]]:5 = #0
}
// CHECK-NEXT: File 1, 4:12 -> 4:14 = #0
// CHECK-NEXT: File 2, 5:12 -> 5:20 = #0
// CHECK-NEXT: File 1, 3:12 -> 3:14 = #0
// CHECK-NEXT: File 2, 4:12 -> 4:20 = #0

View File

@ -1,5 +1,4 @@
// RUN: %strip_comments > %t.stripped.c
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name continue.c %t.stripped.c | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name continue.c %s | FileCheck %s
int main() { // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+21]]:2 = #0
int j = 0; // CHECK-NEXT: File 0, [[@LINE+2]]:18 -> [[@LINE+2]]:24 = (#0 + #1)

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
#define ifc if

View File

@ -1,7 +1,6 @@
// fixme: the following line is added to cleanup bots, will be removed in weeks.
// RUN: rm -f %S/coroutine.ll
// RUN: %strip_comments > %t.stripped.cpp
// 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
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -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
namespace std::experimental {
template <typename... T>

View File

@ -1,6 +1,6 @@
// Ensure that declarations without definitions don't have maps emitted for them
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s > %t
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s > %t
// FileCheck -input-file %t %s
// RUN: FileCheck -check-prefix BAR -input-file %t %s

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++17 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name default-method.cpp -w %s | FileCheck %s -implicit-check-not="->"
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -triple %itanium_abi_triple -std=c++17 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name default-method.cpp -w %s | FileCheck %s -implicit-check-not="->"
namespace PR39822 {
struct unique_ptr {

View File

@ -1,5 +1,4 @@
// RUN: %strip_comments > %t.stripped.cpp
// 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
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -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
#define IF if
#define STMT(S) S

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple i686-windows -emit-llvm-only -fcoverage-mapping -dump-coverage-mapping -fprofile-instrument=clang %s | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -triple i686-windows -emit-llvm-only -fcoverage-mapping -dump-coverage-mapping -fprofile-instrument=clang %s | FileCheck %s
struct A {
virtual ~A();

View File

@ -1,9 +1,9 @@
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name header.cpp %s > %tmapping
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name header.cpp %s > %tmapping
// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-FUNC
// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-STATIC-FUNC
// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-STATIC-FUNC2
//
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -mllvm -limited-coverage-experimental=true -dump-coverage-mapping -emit-llvm-only -main-file-name header.cpp %s > %tmapping.limited
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -mllvm -limited-coverage-experimental=true -dump-coverage-mapping -emit-llvm-only -main-file-name header.cpp %s > %tmapping.limited
// RUN: FileCheck -input-file %tmapping.limited %s --check-prefix=CHECK-LIMITED
#include "Inputs/header1.h"

View File

@ -1,5 +1,4 @@
// RUN: %strip_comments > %t.stripped.cpp
// 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
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -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
int nop() { return 0; }

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -triple x86_64-apple-darwin -fobjc-runtime=macosx-10.10.0 -fblocks -fobjc-arc -w %s | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -triple x86_64-apple-darwin -fobjc-runtime=macosx-10.10.0 -fblocks -fobjc-arc -w %s | FileCheck %s
@interface Foo
@end

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name include-macros.c %s | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name include-macros.c %s | FileCheck %s
#include "Inputs/macros.h"

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name includehell.cpp %s > %tmapping
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name includehell.cpp %s > %tmapping
int main() {
int x = 0;
@ -51,7 +51,6 @@ int main() {
// CHECK-START: File [[START3]], 4:29 -> 5:1 = #9
// CHECK-CODE: File [[CODE1:[0-9]]], 1:1 -> 14:1 = #1
// CHECK-CODE: Skipped,File [[CODE1]], 1:1 -> 1:41 = 0
// CHECK-CODE-NEXT: File [[CODE1]], 4:5 -> 4:11 = #1
// CHECK-CODE: File [[CODE1]], 4:13 -> 6:2 = #2
// CHECK-CODE: File [[CODE1]], 6:8 -> 8:2 = (#1 - #2)
@ -59,7 +58,6 @@ int main() {
// CHECK-CODE: File [[CODE1]], 9:11 -> 11:2 = #3
// CHECK-CODE: File [[CODE1]], 11:8 -> 13:2 = (#1 - #3)
// CHECK-CODE: File [[CODE2:[0-9]]], 1:1 -> 14:1 = #5
// CHECK-CODE: Skipped,File [[CODE2]], 1:1 -> 1:41 = 0
// CHECK-CODE-NEXT: File [[CODE2]], 4:5 -> 4:11 = #5
// CHECK-CODE: File [[CODE2]], 4:13 -> 6:2 = #6
// CHECK-CODE: File [[CODE2]], 6:8 -> 8:2 = (#5 - #6)

View File

@ -1,6 +1,6 @@
// Check the data structures emitted by coverage mapping
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name ir.c %s -o - -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -mllvm -enable-name-compression=false | FileCheck %s -check-prefixes=COMMON,DARWIN
// RUN: %clang_cc1 -triple x86_64--windows-msvc -main-file-name ir.c %s -o - -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -mllvm -enable-name-compression=false | FileCheck %s -check-prefixes=COMMON,WINDOWS
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -triple x86_64-apple-macosx10.9 -main-file-name ir.c %s -o - -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -mllvm -enable-name-compression=false | FileCheck %s -check-prefixes=COMMON,DARWIN
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -triple x86_64--windows-msvc -main-file-name ir.c %s -o - -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -mllvm -enable-name-compression=false | FileCheck %s -check-prefixes=COMMON,WINDOWS
static inline void unused() {}

View File

@ -1,5 +1,4 @@
// RUN: %strip_comments > %t.stripped.cpp
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name label.cpp %t.stripped.cpp | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name label.cpp %s | FileCheck %s
// CHECK: func
void func() { // CHECK-NEXT: File 0, [[@LINE]]:13 -> {{[0-9]+}}:2 = #0

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -x c++ -std=c++11 -triple %itanium_abi_triple -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s -main-file-name lambda.cpp | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -x c++ -std=c++11 -triple %itanium_abi_triple -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s -main-file-name lambda.cpp | FileCheck %s
// CHECK-LABEL: _Z3fooi:
void foo(int i) { // CHECK: File 0, [[@LINE]]:17 -> {{[0-9]+}}:2 = #0

View File

@ -1,5 +1,4 @@
// RUN: %strip_comments > %t.stripped.cpp
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name logical.cpp %t.stripped.cpp | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name logical.cpp %s | FileCheck %s
int main() { // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+15]]:2 = #0
bool bt = true;

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loopmacro.c %s | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loopmacro.c %s | FileCheck %s
// CHECK: main
// CHECK-NEXT: File 0, {{[0-9]+}}:12 -> {{[0-9]+}}:2 = #0

View File

@ -1,5 +1,4 @@
// RUN: %strip_comments > %t.stripped.cpp
// 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
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -std=c++11 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loops.cpp %s | FileCheck %s
// CHECK: rangedFor
void rangedFor() { // CHECK-NEXT: File 0, [[@LINE]]:18 -> {{[0-9]+}}:2 = #0

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macro-expansion.c %s | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macro-expansion.c %s | FileCheck %s
// CHECK: func
// CHECK: File 1, [[@LINE+5]]:12 -> [[@LINE+5]]:38 = #0

View File

@ -1,5 +1,5 @@
// RUN: %strip_comments > %t.stripped.cpp
// 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
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -std=c++11 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macro-expressions.cpp -w %s | FileCheck %s
#define EXPR(x) (x)
#define NEXPR(x) (!x)
#define DECL(T, x) T x

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple %itanium_abi_triple -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -triple %itanium_abi_triple -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
// PR39942

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroception.c %s | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroception.c %s | FileCheck %s
#define M2 {
#define M1 M2

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroparams.c %s | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroparams.c %s | FileCheck %s
// CHECK: main
// CHECK-NEXT: File 0, {{[0-9]+}}:12 -> {{[0-9]+}}:2 = #0

View File

@ -1,5 +1,5 @@
// RUN: %strip_comments > %t.stripped.c
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroparams2.c %t.stripped.c | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroparams2.c %s | FileCheck %s
#define MACRO(REFS, CALLS) (4 * (CALLS) < (REFS))
struct S {

View File

@ -1,5 +1,5 @@
// RUN: %strip_comments > %t.stripped.c
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macros.c %t.stripped.c | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macros.c %s | FileCheck %s
#define MACRO return; bar()
#define MACRO_2 bar()
#define MACRO_1 return; MACRO_2

View File

@ -1,5 +1,5 @@
// RUN: %strip_comments > %t.stripped.cpp
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroscopes.cpp %t.stripped.cpp | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroscopes.cpp %s | FileCheck %s
#define starts_a_scope for (int i = 0; i < 2; ++i) {
#define ends_a_scope \

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++11 %s | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++11 %s | FileCheck %s
#define BREAK break

View File

@ -1,5 +1,5 @@
// RUN: %strip_comments > %t.stripped.c
// 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
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macro-expansion.c %s | FileCheck %s
#define LBRAC {
#define RBRAC }

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name nestedclass.cpp %s > %tmapping
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name nestedclass.cpp %s > %tmapping
// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-OUTER
// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-INNER
// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-INNERMOST

View File

@ -1,5 +1,4 @@
// RUN: %strip_comments > %t.stripped.m
// 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
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -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
@interface A
- (void)bork:(int)msg;

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fopenmp -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name openmp.c %s | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fopenmp -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name openmp.c %s | FileCheck %s
// CHECK: openmp.c:{{.+}}omp_outlined{{.+}}:
// CHECK: File 0, 10:3 -> 10:31

View File

@ -1,6 +1,5 @@
// RUN: %strip_comments > %t.stripped.cpp
// 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
// 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
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -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
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -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
template <typename T, int S1>
struct CreateSpecialization;

View File

@ -1,5 +1,4 @@
// RUN: %strip_comments > %t.stripped.c
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name preprocessor.c %t.stripped.c | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name preprocessor.c %s | FileCheck %s
// CHECK: func
void func() { // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0
@ -12,7 +11,7 @@ void func() { // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0
// CHECK: main
int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0
int i = 0;
#if 0 // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+4]]:9 = 0
#if 0 // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+4]]:29 = 0
if(i == 0) {
i = 1;
}
@ -30,7 +29,7 @@ int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0
}
#endif
// CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:8
// CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:24
#\
if 0
#\
@ -60,7 +59,7 @@ int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0
#\
endif
// CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+6]]:10
// CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+6]]:26
#\
ifdef NOT_DEFINED
#\

View File

@ -1,7 +1,6 @@
// RUN: %strip_comments > %t.stripped.c
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name return.c %t.stripped.c | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name return.c %s | FileCheck %s
// CHECK: func
// CHECK: func
void func() { // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+3]]:2 = #0
return;
int i = 0; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = 0

View File

@ -1,5 +1,4 @@
// RUN: %strip_comments > %t.stripped.cpp
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++1z -triple %itanium_abi_triple -main-file-name switch.cpp %t.stripped.cpp | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++1z -triple %itanium_abi_triple -main-file-name switch.cpp %s | FileCheck %s
// CHECK: foo
void foo(int i) { // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+8]]:2 = #0

View File

@ -1,5 +1,4 @@
// RUN: %strip_comments > %t.stripped.c
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name switchmacro.c %t.stripped.c | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name switchmacro.c %s | FileCheck %s
#define FOO(x) (void)x

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -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 -std=c++11 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name system_macro.cpp -o - %s | FileCheck %s
#ifdef IS_SYSHEADER

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name templates.cpp %s | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name templates.cpp %s | FileCheck %s
template<typename T>
void unused(T x) {

View File

@ -1,5 +1,4 @@
// RUN: %strip_comments > %t.stripped.c
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name test.c %t.stripped.c | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name test.c %s | FileCheck %s
void bar();
static void static_func();

View File

@ -1,5 +1,4 @@
// RUN: %strip_comments > %t.stripped.cpp
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 -fexceptions -fcxx-exceptions -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name trycatch.cpp %t.stripped.cpp | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -triple %itanium_abi_triple -std=c++11 -fexceptions -fcxx-exceptions -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name trycatch.cpp %s | FileCheck %s
class Error {
};

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 -fexceptions -fcxx-exceptions -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name trymacro.cpp %s | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -triple %itanium_abi_triple -std=c++11 -fexceptions -fcxx-exceptions -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name trymacro.cpp %s | FileCheck %s
// CHECK: Z3fn1v:
void fn1() try { return; } // CHECK: [[@LINE]]:12 -> [[@LINE+1]]:14 = #1

View File

@ -1,5 +1,5 @@
// RUN: %strip_comments > %t.stripped.c
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %t.stripped.c | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
#define WHILE while (0) {}
// CHECK: counters_in_macro_following_unreachable

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
#define START_SCOPE {
#define END_SCOPE }

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -main-file-name unused_names.c -o - %s > %t
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -main-file-name unused_names.c -o - %s > %t
// RUN: FileCheck -input-file %t %s
// RUN: FileCheck -check-prefix=SYSHEADER -input-file %t %s

View File

@ -1,5 +1,4 @@
// RUN: %strip_comments > %t.stripped.c
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loops.cpp %t.stripped.c | FileCheck %s
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loops.cpp %s | FileCheck %s
// CHECK: main
int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+8]]:2 = #0

View File

@ -91,10 +91,6 @@ config.substitutions.append(
('%hmaptool', "'%s' %s" % (config.python_executable,
os.path.join(config.clang_tools_dir, 'hmaptool'))))
# Strip C++ comments "//"" from tests
config.substitutions.append(
('%strip_comments', "sed 's/[ \t]*\/\/.*//' %s")
)
# Plugins (loadable modules)
if config.has_plugins and config.llvm_plugin_ext:

View File

@ -0,0 +1,61 @@
// Remove comments first.
// RUN: sed 's/[ \t]*\/\/.*//' %s > %t.stripped.cpp
// RUN: %clangxx_profgen -fcoverage-mapping -o %t %t.stripped.cpp
// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
// RUN: llvm-profdata merge -o %t.profdata %t.profraw
// RUN: llvm-cov show %t -instr-profile %t.profdata -path-equivalence=/tmp,%S 2>&1 | FileCheck %s
int main() { // CHECK: [[# @LINE]]| 1|int main() {
int x = 0; // CHECK-NEXT: [[# @LINE]]| 1|
// CHECK-NEXT: [[# @LINE]]| |
x = 1; // CHECK-NEXT: [[# @LINE]]| 1|
if (x) // CHECK-NEXT: [[# @LINE]]| 1|
// CHECK-NEXT: [[# @LINE]]| |
x // CHECK-NEXT: [[# @LINE]]| 1|
// CHECK-NEXT: [[# @LINE]]| |
= // CHECK-NEXT: [[# @LINE]]| 1|
// CHECK-NEXT: [[# @LINE]]| |
// CHECK-NEXT: [[# @LINE]]| |
0; // CHECK-NEXT: [[# @LINE]]| 1|
// CHECK-NEXT: [[# @LINE]]| |
if (x) // CHECK-NEXT: [[# @LINE]]| 1|
// CHECK-NEXT: [[# @LINE]]| |
// CHECK-NEXT: [[# @LINE]]| |
x = 1; // CHECK-NEXT: [[# @LINE]]| 0|
// CHECK-NEXT: [[# @LINE]]| |
#ifdef UNDEFINED // CHECK-NEXT: [[# @LINE]]| |
// CHECK-NEXT: [[# @LINE]]| |
int y = 0; // CHECK-NEXT: [[# @LINE]]| |
// CHECK-NEXT: [[# @LINE]]| |
y = 1; // CHECK-NEXT: [[# @LINE]]| |
if (y) // CHECK-NEXT: [[# @LINE]]| |
// CHECK-NEXT: [[# @LINE]]| |
y // CHECK-NEXT: [[# @LINE]]| |
// CHECK-NEXT: [[# @LINE]]| |
= // CHECK-NEXT: [[# @LINE]]| |
// CHECK-NEXT: [[# @LINE]]| |
// CHECK-NEXT: [[# @LINE]]| |
0; // CHECK-NEXT: [[# @LINE]]| |
// CHECK-NEXT: [[# @LINE]]| |
#endif // CHECK-NEXT: [[# @LINE]]| |
// CHECK-NEXT: [[# @LINE]]| |
#define DEFINED 1 // CHECK-NEXT: [[# @LINE]]| 1|
// CHECK-NEXT: [[# @LINE]]| |
#ifdef DEFINED // CHECK-NEXT: [[# @LINE]]| 1|
// CHECK-NEXT: [[# @LINE]]| |
int y = 0; // CHECK-NEXT: [[# @LINE]]| 1|
// CHECK-NEXT: [[# @LINE]]| |
y = 1; // CHECK-NEXT: [[# @LINE]]| 1|
if (y) // CHECK-NEXT: [[# @LINE]]| 1|
// CHECK-NEXT: [[# @LINE]]| |
y // CHECK-NEXT: [[# @LINE]]| 1|
// CHECK-NEXT: [[# @LINE]]| |
= // CHECK-NEXT: [[# @LINE]]| 1|
// CHECK-NEXT: [[# @LINE]]| |
// CHECK-NEXT: [[# @LINE]]| |
0; // CHECK-NEXT: [[# @LINE]]| 1|
#endif // CHECK-NEXT: [[# @LINE]]| 1|
// CHECK-NEXT: [[# @LINE]]| |
return 0; // CHECK-NEXT: [[# @LINE]]| 1|
} // CHECK-NEXT: [[# @LINE]]| 1|

View File

@ -31,13 +31,13 @@ int main(int argc, const char *argv[]) {
// CHECK: 14| 2|int main(int argc, const char *argv[]) {
// CHECK: 15| 2| if (argc < 2)
// CHECK: 16| 0| return 1;
// CHECK: 17| 2|
// CHECK: 17| |
// CHECK: 18| 2| FILE *F = fopen(argv[1], "r+b");
// CHECK: 19| 2| if (!F) {
// CHECK: 20| | // File might not exist, try opening with truncation
// CHECK: 21| 1| F = fopen(argv[1], "w+b");
// CHECK: 22| 1| }
// CHECK: 23| 2| __llvm_profile_set_file_object(F, 1);
// CHECK: 24| 2|
// CHECK: 24| |
// CHECK: 25| 2| return 0;
// CHECK: 26| 2|}

View File

@ -24,7 +24,7 @@ int main(int argc, const char *argv[]) {
// CHECK: 12| 1|int main(int argc, const char *argv[]) {
// CHECK: 13| 1| if (argc < 2)
// CHECK: 14| 0| return 1;
// CHECK: 15| 1|
// CHECK: 15| |
// CHECK: 16| 1| FILE *F = fopen(argv[1], "w+b");
// CHECK: 17| 1| __llvm_profile_set_file_object(F, 0);
// CHECK: 18| 1| return 0;

View File

@ -485,9 +485,15 @@ class SegmentBuilder {
if (CurStartLoc == CR.value().endLoc()) {
// Avoid making zero-length regions active. If it's the last region,
// emit a skipped segment. Otherwise use its predecessor's count.
const bool Skipped = (CR.index() + 1) == Regions.size();
const bool Skipped =
(CR.index() + 1) == Regions.size() ||
CR.value().Kind == CounterMappingRegion::SkippedRegion;
startSegment(ActiveRegions.empty() ? CR.value() : *ActiveRegions.back(),
CurStartLoc, !GapRegion, Skipped);
// If it is skipped segment, create a segment with last pushed
// regions's count at CurStartLoc.
if (Skipped && !ActiveRegions.empty())
startSegment(*ActiveRegions.back(), CurStartLoc, false);
continue;
}
if (CR.index() + 1 == Regions.size() ||
@ -587,6 +593,8 @@ public:
const auto &L = Segments[I - 1];
const auto &R = Segments[I];
if (!(L.Line < R.Line) && !(L.Line == R.Line && L.Col < R.Col)) {
if (L.Line == R.Line && L.Col == R.Col && !L.HasCount)
continue;
LLVM_DEBUG(dbgs() << " ! Segment " << L.Line << ":" << L.Col
<< " followed by " << R.Line << ":" << R.Col << "\n");
assert(false && "Coverage segments not unique or sorted");