[clang] 9caa3fb - [Coverage] Add empty line regions to SkippedRegions
Zequan Wu via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 21 12:44:21 PDT 2020
Author: Zequan Wu
Date: 2020-09-21T12:42:53-07:00
New Revision: 9caa3fbe03f43e3eec30262fbba87c1ee15c05a3
URL: https://github.com/llvm/llvm-project/commit/9caa3fbe03f43e3eec30262fbba87c1ee15c05a3
DIFF: https://github.com/llvm/llvm-project/commit/9caa3fbe03f43e3eec30262fbba87c1ee15c05a3.diff
LOG: [Coverage] Add empty line regions to SkippedRegions
Differential Revision: https://reviews.llvm.org/D84988
Added:
compiler-rt/test/profile/coverage_emptylines.cpp
Modified:
clang/include/clang/Lex/Lexer.h
clang/include/clang/Lex/Preprocessor.h
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/lib/CodeGen/CoverageMappingGen.h
clang/lib/Lex/Lexer.cpp
clang/lib/Lex/Preprocessor.cpp
clang/test/CoverageMapping/abspath.cpp
clang/test/CoverageMapping/block-storage-starts-region.m
clang/test/CoverageMapping/break.c
clang/test/CoverageMapping/builtinmacro.c
clang/test/CoverageMapping/casts.c
clang/test/CoverageMapping/classtemplate.cpp
clang/test/CoverageMapping/comment-in-macro.c
clang/test/CoverageMapping/continue.c
clang/test/CoverageMapping/control-flow-macro.c
clang/test/CoverageMapping/coroutine.cpp
clang/test/CoverageMapping/decl.c
clang/test/CoverageMapping/default-method.cpp
clang/test/CoverageMapping/deferred-region.cpp
clang/test/CoverageMapping/empty-destructor.cpp
clang/test/CoverageMapping/header.cpp
clang/test/CoverageMapping/if.cpp
clang/test/CoverageMapping/implicit-def-in-macro.m
clang/test/CoverageMapping/include-macros.c
clang/test/CoverageMapping/includehell.cpp
clang/test/CoverageMapping/ir.c
clang/test/CoverageMapping/label.cpp
clang/test/CoverageMapping/lambda.cpp
clang/test/CoverageMapping/logical.cpp
clang/test/CoverageMapping/loopmacro.c
clang/test/CoverageMapping/loops.cpp
clang/test/CoverageMapping/macro-expansion.c
clang/test/CoverageMapping/macro-expressions.cpp
clang/test/CoverageMapping/macro-stringize-twice.cpp
clang/test/CoverageMapping/macroception.c
clang/test/CoverageMapping/macroparams.c
clang/test/CoverageMapping/macroparams2.c
clang/test/CoverageMapping/macros.c
clang/test/CoverageMapping/macroscopes.cpp
clang/test/CoverageMapping/md.cpp
clang/test/CoverageMapping/moremacros.c
clang/test/CoverageMapping/nestedclass.cpp
clang/test/CoverageMapping/objc.m
clang/test/CoverageMapping/openmp.c
clang/test/CoverageMapping/pr32679.cpp
clang/test/CoverageMapping/preprocessor.c
clang/test/CoverageMapping/return.c
clang/test/CoverageMapping/switch.cpp
clang/test/CoverageMapping/switchmacro.c
clang/test/CoverageMapping/system_macro.cpp
clang/test/CoverageMapping/templates.cpp
clang/test/CoverageMapping/test.c
clang/test/CoverageMapping/trycatch.cpp
clang/test/CoverageMapping/trymacro.cpp
clang/test/CoverageMapping/unreachable-macro.c
clang/test/CoverageMapping/unused_function.cpp
clang/test/CoverageMapping/unused_names.c
clang/test/CoverageMapping/while.c
clang/test/lit.cfg.py
compiler-rt/test/profile/instrprof-set-file-object-merging.c
compiler-rt/test/profile/instrprof-set-file-object.c
llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Lex/Lexer.h b/clang/include/clang/Lex/Lexer.h
index 97a222f4a703..b27a041eb037 100644
--- a/clang/include/clang/Lex/Lexer.h
+++ b/clang/include/clang/Lex/Lexer.h
@@ -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;
diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h
index b0dd363555ab..68139cb24b31 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -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 @@ class Preprocessor {
/// 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 @@ class CommentHandler {
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>;
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 022713771342..8d9c1979d87c 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -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 @@ class CoverageMappingBuilder {
SourceLocation PrevTokLoc,
SourceLocation NextTokLoc) {
SpellingRegion SR{SM, LocStart, LocEnd};
- // If Range begin location is invalid, it's not a comment region.
- if (PrevTokLoc.isInvalid())
- 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;
+ 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 (SM.isWrittenInSameFile(LocEnd, NextTokLoc) &&
- SR.LineEnd == NextTokLine) {
- newSR.LineEnd = SR.LineEnd - 1;
- newSR.ColumnEnd = SR.ColumnStart + 1;
- }
- if (newSR.isInSourceOrder())
- return newSR;
+ if (SR.isInSourceOrder())
+ return SR;
return None;
}
diff --git a/clang/lib/CodeGen/CoverageMappingGen.h b/clang/lib/CodeGen/CoverageMappingGen.h
index d3eec226d67c..645ad23a9ccd 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.h
+++ b/clang/lib/CodeGen/CoverageMappingGen.h
@@ -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);
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index a559ca3eac2b..d7a3c20573b8 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -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 @@ bool Lexer::LexTokenInternal(Token &Result, bool TokAtPhysicalStartOfLine) {
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 @@ bool Lexer::LexTokenInternal(Token &Result, bool TokAtPhysicalStartOfLine) {
// 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;
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index 58c28cea30a1..5f362ed0754d 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -1417,6 +1417,8 @@ ModuleLoader::~ModuleLoader() = default;
CommentHandler::~CommentHandler() = default;
+EmptylineHandler::~EmptylineHandler() = default;
+
CodeCompletionHandler::~CodeCompletionHandler() = default;
void Preprocessor::createPreprocessingRecord() {
diff --git a/clang/test/CoverageMapping/abspath.cpp b/clang/test/CoverageMapping/abspath.cpp
index 1c4156916518..3c593f40b7dd 100644
--- a/clang/test/CoverageMapping/abspath.cpp
+++ b/clang/test/CoverageMapping/abspath.cpp
@@ -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
diff --git a/clang/test/CoverageMapping/block-storage-starts-region.m b/clang/test/CoverageMapping/block-storage-starts-region.m
index 7e25438fc0e0..47696c42d55c 100644
--- a/clang/test/CoverageMapping/block-storage-starts-region.m
+++ b/clang/test/CoverageMapping/block-storage-starts-region.m
@@ -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
diff --git a/clang/test/CoverageMapping/break.c b/clang/test/CoverageMapping/break.c
index 191f34765a65..741e551967e1 100644
--- a/clang/test/CoverageMapping/break.c
+++ b/clang/test/CoverageMapping/break.c
@@ -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
diff --git a/clang/test/CoverageMapping/builtinmacro.c b/clang/test/CoverageMapping/builtinmacro.c
index 0de0e8e6a125..482b74158bb3 100644
--- a/clang/test/CoverageMapping/builtinmacro.c
+++ b/clang/test/CoverageMapping/builtinmacro.c
@@ -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.
diff --git a/clang/test/CoverageMapping/casts.c b/clang/test/CoverageMapping/casts.c
index 6f479fd58838..a289cb88dd8f 100644
--- a/clang/test/CoverageMapping/casts.c
+++ b/clang/test/CoverageMapping/casts.c
@@ -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
diff --git a/clang/test/CoverageMapping/classtemplate.cpp b/clang/test/CoverageMapping/classtemplate.cpp
index 9250069e04f6..60ddc36be99e 100644
--- a/clang/test/CoverageMapping/classtemplate.cpp
+++ b/clang/test/CoverageMapping/classtemplate.cpp
@@ -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
diff --git a/clang/test/CoverageMapping/comment-in-macro.c b/clang/test/CoverageMapping/comment-in-macro.c
index 86b554f8bd50..8e77050e8bbd 100644
--- a/clang/test/CoverageMapping/comment-in-macro.c
+++ b/clang/test/CoverageMapping/comment-in-macro.c
@@ -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
diff --git a/clang/test/CoverageMapping/continue.c b/clang/test/CoverageMapping/continue.c
index 774fe2ee6fff..2c3eec07de2f 100644
--- a/clang/test/CoverageMapping/continue.c
+++ b/clang/test/CoverageMapping/continue.c
@@ -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)
diff --git a/clang/test/CoverageMapping/control-flow-macro.c b/clang/test/CoverageMapping/control-flow-macro.c
index 8508e53f333f..b73ac989057d 100644
--- a/clang/test/CoverageMapping/control-flow-macro.c
+++ b/clang/test/CoverageMapping/control-flow-macro.c
@@ -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
diff --git a/clang/test/CoverageMapping/coroutine.cpp b/clang/test/CoverageMapping/coroutine.cpp
index a614e6e8ea40..8eac751e309e 100644
--- a/clang/test/CoverageMapping/coroutine.cpp
+++ b/clang/test/CoverageMapping/coroutine.cpp
@@ -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>
diff --git a/clang/test/CoverageMapping/decl.c b/clang/test/CoverageMapping/decl.c
index e4770288d987..73433eba574b 100644
--- a/clang/test/CoverageMapping/decl.c
+++ b/clang/test/CoverageMapping/decl.c
@@ -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
diff --git a/clang/test/CoverageMapping/default-method.cpp b/clang/test/CoverageMapping/default-method.cpp
index 6b5428306b71..beaac0db2fc7 100644
--- a/clang/test/CoverageMapping/default-method.cpp
+++ b/clang/test/CoverageMapping/default-method.cpp
@@ -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 {
diff --git a/clang/test/CoverageMapping/deferred-region.cpp b/clang/test/CoverageMapping/deferred-region.cpp
index 8db6119472db..86d0265c7f5a 100644
--- a/clang/test/CoverageMapping/deferred-region.cpp
+++ b/clang/test/CoverageMapping/deferred-region.cpp
@@ -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
diff --git a/clang/test/CoverageMapping/empty-destructor.cpp b/clang/test/CoverageMapping/empty-destructor.cpp
index cfc29a75c6d7..840c4b26554e 100644
--- a/clang/test/CoverageMapping/empty-destructor.cpp
+++ b/clang/test/CoverageMapping/empty-destructor.cpp
@@ -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();
diff --git a/clang/test/CoverageMapping/header.cpp b/clang/test/CoverageMapping/header.cpp
index d42c15444664..6c9d7d3a4b6d 100644
--- a/clang/test/CoverageMapping/header.cpp
+++ b/clang/test/CoverageMapping/header.cpp
@@ -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"
diff --git a/clang/test/CoverageMapping/if.cpp b/clang/test/CoverageMapping/if.cpp
index 8ffc09d29a3c..1734f7baf07c 100644
--- a/clang/test/CoverageMapping/if.cpp
+++ b/clang/test/CoverageMapping/if.cpp
@@ -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; }
diff --git a/clang/test/CoverageMapping/implicit-def-in-macro.m b/clang/test/CoverageMapping/implicit-def-in-macro.m
index 71184fc78af9..feeffc520f6c 100644
--- a/clang/test/CoverageMapping/implicit-def-in-macro.m
+++ b/clang/test/CoverageMapping/implicit-def-in-macro.m
@@ -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
diff --git a/clang/test/CoverageMapping/include-macros.c b/clang/test/CoverageMapping/include-macros.c
index 113721c21a5b..3cd0b49c475f 100644
--- a/clang/test/CoverageMapping/include-macros.c
+++ b/clang/test/CoverageMapping/include-macros.c
@@ -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"
diff --git a/clang/test/CoverageMapping/includehell.cpp b/clang/test/CoverageMapping/includehell.cpp
index c92f12e5e80d..09e03e77799d 100644
--- a/clang/test/CoverageMapping/includehell.cpp
+++ b/clang/test/CoverageMapping/includehell.cpp
@@ -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)
diff --git a/clang/test/CoverageMapping/ir.c b/clang/test/CoverageMapping/ir.c
index f5ba39c74721..da36312fe8bd 100644
--- a/clang/test/CoverageMapping/ir.c
+++ b/clang/test/CoverageMapping/ir.c
@@ -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() {}
diff --git a/clang/test/CoverageMapping/label.cpp b/clang/test/CoverageMapping/label.cpp
index e77372d325e5..385fbc0f6046 100644
--- a/clang/test/CoverageMapping/label.cpp
+++ b/clang/test/CoverageMapping/label.cpp
@@ -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
diff --git a/clang/test/CoverageMapping/lambda.cpp b/clang/test/CoverageMapping/lambda.cpp
index 4f23c157e385..0d3189c56da1 100644
--- a/clang/test/CoverageMapping/lambda.cpp
+++ b/clang/test/CoverageMapping/lambda.cpp
@@ -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
diff --git a/clang/test/CoverageMapping/logical.cpp b/clang/test/CoverageMapping/logical.cpp
index cca03377c98a..143256668549 100644
--- a/clang/test/CoverageMapping/logical.cpp
+++ b/clang/test/CoverageMapping/logical.cpp
@@ -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;
diff --git a/clang/test/CoverageMapping/loopmacro.c b/clang/test/CoverageMapping/loopmacro.c
index cffeca087c53..069740ea7f84 100644
--- a/clang/test/CoverageMapping/loopmacro.c
+++ b/clang/test/CoverageMapping/loopmacro.c
@@ -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
diff --git a/clang/test/CoverageMapping/loops.cpp b/clang/test/CoverageMapping/loops.cpp
index 498d214e69d9..bc391583c5ff 100644
--- a/clang/test/CoverageMapping/loops.cpp
+++ b/clang/test/CoverageMapping/loops.cpp
@@ -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
diff --git a/clang/test/CoverageMapping/macro-expansion.c b/clang/test/CoverageMapping/macro-expansion.c
index 1e4a28b32d88..b0a00e40f59b 100644
--- a/clang/test/CoverageMapping/macro-expansion.c
+++ b/clang/test/CoverageMapping/macro-expansion.c
@@ -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
diff --git a/clang/test/CoverageMapping/macro-expressions.cpp b/clang/test/CoverageMapping/macro-expressions.cpp
index 60afc5238b9e..c45549721342 100644
--- a/clang/test/CoverageMapping/macro-expressions.cpp
+++ b/clang/test/CoverageMapping/macro-expressions.cpp
@@ -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
diff --git a/clang/test/CoverageMapping/macro-stringize-twice.cpp b/clang/test/CoverageMapping/macro-stringize-twice.cpp
index 7a91d910cfe5..a5c3641d2e0e 100644
--- a/clang/test/CoverageMapping/macro-stringize-twice.cpp
+++ b/clang/test/CoverageMapping/macro-stringize-twice.cpp
@@ -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
diff --git a/clang/test/CoverageMapping/macroception.c b/clang/test/CoverageMapping/macroception.c
index 7c142ef5afde..d38150c2ca92 100644
--- a/clang/test/CoverageMapping/macroception.c
+++ b/clang/test/CoverageMapping/macroception.c
@@ -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
diff --git a/clang/test/CoverageMapping/macroparams.c b/clang/test/CoverageMapping/macroparams.c
index efffc77a07bf..d0480f6da5cc 100644
--- a/clang/test/CoverageMapping/macroparams.c
+++ b/clang/test/CoverageMapping/macroparams.c
@@ -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
diff --git a/clang/test/CoverageMapping/macroparams2.c b/clang/test/CoverageMapping/macroparams2.c
index 30ce25d9accd..ec1a762c8077 100644
--- a/clang/test/CoverageMapping/macroparams2.c
+++ b/clang/test/CoverageMapping/macroparams2.c
@@ -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 {
diff --git a/clang/test/CoverageMapping/macros.c b/clang/test/CoverageMapping/macros.c
index 83e2029be561..93bc2a100fc0 100644
--- a/clang/test/CoverageMapping/macros.c
+++ b/clang/test/CoverageMapping/macros.c
@@ -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
diff --git a/clang/test/CoverageMapping/macroscopes.cpp b/clang/test/CoverageMapping/macroscopes.cpp
index 62f5dbe77981..8353321dfcc6 100644
--- a/clang/test/CoverageMapping/macroscopes.cpp
+++ b/clang/test/CoverageMapping/macroscopes.cpp
@@ -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 \
diff --git a/clang/test/CoverageMapping/md.cpp b/clang/test/CoverageMapping/md.cpp
index 5f2b2d61224f..41f70b889513 100644
--- a/clang/test/CoverageMapping/md.cpp
+++ b/clang/test/CoverageMapping/md.cpp
@@ -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
diff --git a/clang/test/CoverageMapping/moremacros.c b/clang/test/CoverageMapping/moremacros.c
index ed89dcafd672..05f3ffdc4095 100644
--- a/clang/test/CoverageMapping/moremacros.c
+++ b/clang/test/CoverageMapping/moremacros.c
@@ -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 }
diff --git a/clang/test/CoverageMapping/nestedclass.cpp b/clang/test/CoverageMapping/nestedclass.cpp
index 6cbddebe9fcd..ade0a19f23f9 100644
--- a/clang/test/CoverageMapping/nestedclass.cpp
+++ b/clang/test/CoverageMapping/nestedclass.cpp
@@ -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
diff --git a/clang/test/CoverageMapping/objc.m b/clang/test/CoverageMapping/objc.m
index 008d291aee31..dc47c60dc982 100644
--- a/clang/test/CoverageMapping/objc.m
+++ b/clang/test/CoverageMapping/objc.m
@@ -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;
diff --git a/clang/test/CoverageMapping/openmp.c b/clang/test/CoverageMapping/openmp.c
index 1ac12624e01a..eb17968f8631 100644
--- a/clang/test/CoverageMapping/openmp.c
+++ b/clang/test/CoverageMapping/openmp.c
@@ -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
diff --git a/clang/test/CoverageMapping/pr32679.cpp b/clang/test/CoverageMapping/pr32679.cpp
index c93133f8c2f2..8e000765710c 100644
--- a/clang/test/CoverageMapping/pr32679.cpp
+++ b/clang/test/CoverageMapping/pr32679.cpp
@@ -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;
diff --git a/clang/test/CoverageMapping/preprocessor.c b/clang/test/CoverageMapping/preprocessor.c
index b68aa2e0e93c..1bff72699ca3 100644
--- a/clang/test/CoverageMapping/preprocessor.c
+++ b/clang/test/CoverageMapping/preprocessor.c
@@ -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
#\
diff --git a/clang/test/CoverageMapping/return.c b/clang/test/CoverageMapping/return.c
index fae2e9f761b7..cc7b462a9b03 100644
--- a/clang/test/CoverageMapping/return.c
+++ b/clang/test/CoverageMapping/return.c
@@ -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
diff --git a/clang/test/CoverageMapping/switch.cpp b/clang/test/CoverageMapping/switch.cpp
index 1a8db09b3ff1..61b639f6eb2b 100644
--- a/clang/test/CoverageMapping/switch.cpp
+++ b/clang/test/CoverageMapping/switch.cpp
@@ -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
diff --git a/clang/test/CoverageMapping/switchmacro.c b/clang/test/CoverageMapping/switchmacro.c
index 5c6a37e77f94..72a9a2b96e33 100644
--- a/clang/test/CoverageMapping/switchmacro.c
+++ b/clang/test/CoverageMapping/switchmacro.c
@@ -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
diff --git a/clang/test/CoverageMapping/system_macro.cpp b/clang/test/CoverageMapping/system_macro.cpp
index ce0da17ce06c..66782b6b29b0 100644
--- a/clang/test/CoverageMapping/system_macro.cpp
+++ b/clang/test/CoverageMapping/system_macro.cpp
@@ -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
diff --git a/clang/test/CoverageMapping/templates.cpp b/clang/test/CoverageMapping/templates.cpp
index bdba1d41f0b3..7010edbc32c3 100644
--- a/clang/test/CoverageMapping/templates.cpp
+++ b/clang/test/CoverageMapping/templates.cpp
@@ -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) {
diff --git a/clang/test/CoverageMapping/test.c b/clang/test/CoverageMapping/test.c
index 559036a3be9b..6080ed47d696 100644
--- a/clang/test/CoverageMapping/test.c
+++ b/clang/test/CoverageMapping/test.c
@@ -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();
diff --git a/clang/test/CoverageMapping/trycatch.cpp b/clang/test/CoverageMapping/trycatch.cpp
index ba1b26b7acee..74bed397e002 100644
--- a/clang/test/CoverageMapping/trycatch.cpp
+++ b/clang/test/CoverageMapping/trycatch.cpp
@@ -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 {
};
diff --git a/clang/test/CoverageMapping/trymacro.cpp b/clang/test/CoverageMapping/trymacro.cpp
index 32f44381b938..22de2ccb0776 100644
--- a/clang/test/CoverageMapping/trymacro.cpp
+++ b/clang/test/CoverageMapping/trymacro.cpp
@@ -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
diff --git a/clang/test/CoverageMapping/unreachable-macro.c b/clang/test/CoverageMapping/unreachable-macro.c
index b84acca33f93..30cc8880c7b6 100644
--- a/clang/test/CoverageMapping/unreachable-macro.c
+++ b/clang/test/CoverageMapping/unreachable-macro.c
@@ -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
diff --git a/clang/test/CoverageMapping/unused_function.cpp b/clang/test/CoverageMapping/unused_function.cpp
index 6a46b1d2af1f..0dcd95f5343f 100644
--- a/clang/test/CoverageMapping/unused_function.cpp
+++ b/clang/test/CoverageMapping/unused_function.cpp
@@ -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 }
diff --git a/clang/test/CoverageMapping/unused_names.c b/clang/test/CoverageMapping/unused_names.c
index 649fa09b245f..3076d8321d0b 100644
--- a/clang/test/CoverageMapping/unused_names.c
+++ b/clang/test/CoverageMapping/unused_names.c
@@ -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
diff --git a/clang/test/CoverageMapping/while.c b/clang/test/CoverageMapping/while.c
index e0c3ca35537f..538ac9408422 100644
--- a/clang/test/CoverageMapping/while.c
+++ b/clang/test/CoverageMapping/while.c
@@ -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
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 6c677eda9a09..f4657f58236c 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -91,10 +91,6 @@
('%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:
diff --git a/compiler-rt/test/profile/coverage_emptylines.cpp b/compiler-rt/test/profile/coverage_emptylines.cpp
new file mode 100644
index 000000000000..ba3c1a180484
--- /dev/null
+++ b/compiler-rt/test/profile/coverage_emptylines.cpp
@@ -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|
diff --git a/compiler-rt/test/profile/instrprof-set-file-object-merging.c b/compiler-rt/test/profile/instrprof-set-file-object-merging.c
index 35e9becf228f..d9529e27eb59 100644
--- a/compiler-rt/test/profile/instrprof-set-file-object-merging.c
+++ b/compiler-rt/test/profile/instrprof-set-file-object-merging.c
@@ -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|}
diff --git a/compiler-rt/test/profile/instrprof-set-file-object.c b/compiler-rt/test/profile/instrprof-set-file-object.c
index 813130007f04..d0b37facc19b 100644
--- a/compiler-rt/test/profile/instrprof-set-file-object.c
+++ b/compiler-rt/test/profile/instrprof-set-file-object.c
@@ -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;
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
index 3197f5d1a3d9..ec840a3f628e 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -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 @@ class SegmentBuilder {
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");
More information about the cfe-commits
mailing list