Skip to content

Commit c468bb8

Browse files
committed
[Coverage] Move logic to skip decl's into a helper (NFC)
llvm-svn: 275120
1 parent aacb808 commit c468bb8

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

clang/lib/CodeGen/CodeGenPGO.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -659,12 +659,18 @@ void CodeGenPGO::mapRegionCounters(const Decl *D) {
659659
FunctionHash = Walker.Hash.finalize();
660660
}
661661

662-
void CodeGenPGO::emitCounterRegionMapping(const Decl *D) {
662+
bool CodeGenPGO::skipRegionMappingForDecl(const Decl *D) {
663663
if (SkipCoverageMapping)
664-
return;
665-
// Don't map the functions inside the system headers
664+
return true;
665+
666+
// Don't map the functions in system headers.
667+
const auto &SM = CGM.getContext().getSourceManager();
666668
auto Loc = D->getBody()->getLocStart();
667-
if (CGM.getContext().getSourceManager().isInSystemHeader(Loc))
669+
return SM.isInSystemHeader(Loc);
670+
}
671+
672+
void CodeGenPGO::emitCounterRegionMapping(const Decl *D) {
673+
if (skipRegionMappingForDecl(D))
668674
return;
669675

670676
std::string CoverageMapping;
@@ -685,11 +691,7 @@ void CodeGenPGO::emitCounterRegionMapping(const Decl *D) {
685691
void
686692
CodeGenPGO::emitEmptyCounterMapping(const Decl *D, StringRef Name,
687693
llvm::GlobalValue::LinkageTypes Linkage) {
688-
if (SkipCoverageMapping)
689-
return;
690-
// Don't map the functions inside the system headers
691-
auto Loc = D->getBody()->getLocStart();
692-
if (CGM.getContext().getSourceManager().isInSystemHeader(Loc))
694+
if (skipRegionMappingForDecl(D))
693695
return;
694696

695697
std::string CoverageMapping;

clang/lib/CodeGen/CodeGenPGO.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class CodeGenPGO {
103103
llvm::Function *Fn);
104104
void loadRegionCounts(llvm::IndexedInstrProfReader *PGOReader,
105105
bool IsInMainFile);
106+
bool skipRegionMappingForDecl(const Decl *D);
106107
void emitCounterRegionMapping(const Decl *D);
107108

108109
public:

0 commit comments

Comments
 (0)