From a8c1d8bb6db4ed012398f8d45f5ec019707c00d4 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Tue, 7 Jun 2016 04:11:51 +0000 Subject: Revert [Coverage] Fix an assertion failure if the definition of an unused function spans multiple files. r271969 The test case fails on Windows. llvm-svn: 271976 --- clang/lib/CodeGen/CoverageMappingGen.cpp | 42 +++++++++----------------------- 1 file changed, 11 insertions(+), 31 deletions(-) (limited to 'clang/lib/CodeGen/CoverageMappingGen.cpp') diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index 44c90e30cd8..bd34e1c5a85 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -130,16 +130,6 @@ public: return strcmp(SM.getBufferName(SM.getSpellingLoc(Loc)), "") == 0; } - /// \brief Check whether \c Loc is included or expanded from \c Parent. - bool isNestedIn(SourceLocation Loc, FileID Parent) { - do { - Loc = getIncludeOrExpansionLoc(Loc); - if (Loc.isInvalid()) - return false; - } while (!SM.isInFileID(Loc, Parent)); - return true; - } - /// \brief Get the start of \c S ignoring macro arguments and builtin macros. SourceLocation getStart(const Stmt *S) { SourceLocation Loc = S->getLocStart(); @@ -320,27 +310,7 @@ struct EmptyCoverageMappingBuilder : public CoverageMappingBuilder { if (!D->hasBody()) return; auto Body = D->getBody(); - SourceLocation Start = getStart(Body); - SourceLocation End = getEnd(Body); - if (!SM.isWrittenInSameFile(Start, End)) { - // Walk up to find the common ancestor. - // Correct the locations accordingly. - FileID StartFileID = SM.getFileID(Start); - FileID EndFileID = SM.getFileID(End); - while (StartFileID != EndFileID && !isNestedIn(End, StartFileID)) { - Start = getIncludeOrExpansionLoc(Start); - assert(Start.isValid() && - "Declaration start location not nested within a known region"); - StartFileID = SM.getFileID(Start); - } - while (StartFileID != EndFileID) { - End = getPreciseTokenLocEnd(getIncludeOrExpansionLoc(End)); - assert(End.isValid() && - "Declaration end location not nested within a known region"); - EndFileID = SM.getFileID(End); - } - } - SourceRegions.emplace_back(Counter(), Start, End); + SourceRegions.emplace_back(Counter(), getStart(Body), getEnd(Body)); } /// \brief Write the mapping data to the output stream @@ -501,6 +471,16 @@ struct CounterCoverageMappingBuilder MostRecentLocation = getIncludeOrExpansionLoc(MostRecentLocation); } + /// \brief Check whether \c Loc is included or expanded from \c Parent. + bool isNestedIn(SourceLocation Loc, FileID Parent) { + do { + Loc = getIncludeOrExpansionLoc(Loc); + if (Loc.isInvalid()) + return false; + } while (!SM.isInFileID(Loc, Parent)); + return true; + } + /// \brief Adjust regions and state when \c NewLoc exits a file. /// /// If moving from our most recently tracked location to \c NewLoc exits any -- cgit v1.2.3