[PATCH] D83592: [Parser] Add comment to skipped regions
Zequan Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 13 16:32:34 PDT 2020
zequanwu updated this revision to Diff 277606.
zequanwu added a comment.
Remove old code.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83592/new/
https://reviews.llvm.org/D83592
Files:
a.out
a.profdata
clang/lib/CodeGen/CodeGenAction.cpp
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/lib/CodeGen/CoverageMappingGen.h
default.profraw
Index: clang/lib/CodeGen/CoverageMappingGen.h
===================================================================
--- clang/lib/CodeGen/CoverageMappingGen.h
+++ clang/lib/CodeGen/CoverageMappingGen.h
@@ -16,6 +16,7 @@
#include "clang/Basic/LLVM.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/Support/raw_ostream.h"
@@ -32,12 +33,14 @@
/// 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 {
+class CoverageSourceInfo : public PPCallbacks, public CommentHandler {
std::vector<SourceRange> SkippedRanges;
public:
ArrayRef<SourceRange> getSkippedRanges() const { return SkippedRanges; }
void SourceRangeSkipped(SourceRange Range, SourceLocation EndifLoc) override;
+
+ bool HandleComment(Preprocessor &PP, SourceRange Range) override;
};
namespace CodeGen {
@@ -66,6 +69,8 @@
uint64_t FilenamesRef);
public:
+ static CoverageSourceInfo *setUpCoverageCallbacks(Preprocessor &PP);
+
CoverageMappingModuleGen(CodeGenModule &CGM, CoverageSourceInfo &SourceInfo)
: CGM(CGM), SourceInfo(SourceInfo) {}
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===================================================================
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -35,10 +35,23 @@
using namespace CodeGen;
using namespace llvm::coverage;
+CoverageSourceInfo *
+CoverageMappingModuleGen::setUpCoverageCallbacks(Preprocessor &PP) {
+ CoverageSourceInfo *CoverageInfo = new CoverageSourceInfo;
+ PP.addPPCallbacks(std::unique_ptr<PPCallbacks>(CoverageInfo));
+ PP.addCommentHandler(CoverageInfo);
+ return CoverageInfo;
+}
+
void CoverageSourceInfo::SourceRangeSkipped(SourceRange Range, SourceLocation) {
SkippedRanges.push_back(Range);
}
+bool CoverageSourceInfo::HandleComment(Preprocessor &, SourceRange Range) {
+ SkippedRanges.push_back(Range);
+ return false;
+}
+
namespace {
/// A region of source code that can be mapped to a counter.
Index: clang/lib/CodeGen/CodeGenAction.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -990,11 +990,9 @@
CoverageSourceInfo *CoverageInfo = nullptr;
// Add the preprocessor callback only when the coverage mapping is generated.
- if (CI.getCodeGenOpts().CoverageMapping) {
- CoverageInfo = new CoverageSourceInfo;
- CI.getPreprocessor().addPPCallbacks(
- std::unique_ptr<PPCallbacks>(CoverageInfo));
- }
+ if (CI.getCodeGenOpts().CoverageMapping)
+ CoverageInfo = CodeGen::CoverageMappingModuleGen::setUpCoverageCallbacks(
+ CI.getPreprocessor());
std::unique_ptr<BackendConsumer> Result(new BackendConsumer(
BA, CI.getDiagnostics(), CI.getHeaderSearchOpts(),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83592.277606.patch
Type: text/x-patch
Size: 3122 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200713/36e2fec0/attachment.bin>
More information about the llvm-commits
mailing list