From: Vedant Kumar Date: Mon, 11 Jul 2016 22:57:44 +0000 (+0000) Subject: [Coverage] Move logic to skip decl's into a helper (NFC) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a64bed41d1a957fa037843dc544ea47d20621265;p=clang [Coverage] Move logic to skip decl's into a helper (NFC) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@275120 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CodeGenPGO.cpp b/lib/CodeGen/CodeGenPGO.cpp index c19321b512..4eefdd72b7 100644 --- a/lib/CodeGen/CodeGenPGO.cpp +++ b/lib/CodeGen/CodeGenPGO.cpp @@ -659,12 +659,18 @@ void CodeGenPGO::mapRegionCounters(const Decl *D) { FunctionHash = Walker.Hash.finalize(); } -void CodeGenPGO::emitCounterRegionMapping(const Decl *D) { +bool CodeGenPGO::skipRegionMappingForDecl(const Decl *D) { if (SkipCoverageMapping) - return; - // Don't map the functions inside the system headers + return true; + + // Don't map the functions in system headers. + const auto &SM = CGM.getContext().getSourceManager(); auto Loc = D->getBody()->getLocStart(); - if (CGM.getContext().getSourceManager().isInSystemHeader(Loc)) + return SM.isInSystemHeader(Loc); +} + +void CodeGenPGO::emitCounterRegionMapping(const Decl *D) { + if (skipRegionMappingForDecl(D)) return; std::string CoverageMapping; @@ -685,11 +691,7 @@ void CodeGenPGO::emitCounterRegionMapping(const Decl *D) { void CodeGenPGO::emitEmptyCounterMapping(const Decl *D, StringRef Name, llvm::GlobalValue::LinkageTypes Linkage) { - if (SkipCoverageMapping) - return; - // Don't map the functions inside the system headers - auto Loc = D->getBody()->getLocStart(); - if (CGM.getContext().getSourceManager().isInSystemHeader(Loc)) + if (skipRegionMappingForDecl(D)) return; std::string CoverageMapping; diff --git a/lib/CodeGen/CodeGenPGO.h b/lib/CodeGen/CodeGenPGO.h index ccda5759e6..d03f23535b 100644 --- a/lib/CodeGen/CodeGenPGO.h +++ b/lib/CodeGen/CodeGenPGO.h @@ -103,6 +103,7 @@ private: llvm::Function *Fn); void loadRegionCounts(llvm::IndexedInstrProfReader *PGOReader, bool IsInMainFile); + bool skipRegionMappingForDecl(const Decl *D); void emitCounterRegionMapping(const Decl *D); public: