]> granicus.if.org Git - clang/commitdiff
Revert [Coverage] Fix an assertion failure if the definition of an unused function...
authorIgor Kudrin <ikudrin.dev@gmail.com>
Tue, 7 Jun 2016 04:11:51 +0000 (04:11 +0000)
committerIgor Kudrin <ikudrin.dev@gmail.com>
Tue, 7 Jun 2016 04:11:51 +0000 (04:11 +0000)
r271969 The test case fails on Windows.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@271976 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CoverageMappingGen.cpp
test/CoverageMapping/Inputs/ends_a_scope_only [deleted file]
test/CoverageMapping/Inputs/starts_a_scope_only [deleted file]
test/CoverageMapping/unused_function.cpp [deleted file]

index 44c90e30cd8d2f7f5c8034f35bcf23a4615b3465..bd34e1c5a85998da38edcf78cffb0bbe936891b2 100644 (file)
@@ -130,16 +130,6 @@ public:
     return strcmp(SM.getBufferName(SM.getSpellingLoc(Loc)), "<built-in>") == 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
diff --git a/test/CoverageMapping/Inputs/ends_a_scope_only b/test/CoverageMapping/Inputs/ends_a_scope_only
deleted file mode 100644 (file)
index 5c34318..0000000
+++ /dev/null
@@ -1 +0,0 @@
-}
diff --git a/test/CoverageMapping/Inputs/starts_a_scope_only b/test/CoverageMapping/Inputs/starts_a_scope_only
deleted file mode 100644 (file)
index 98232c6..0000000
+++ /dev/null
@@ -1 +0,0 @@
-{
diff --git a/test/CoverageMapping/unused_function.cpp b/test/CoverageMapping/unused_function.cpp
deleted file mode 100644 (file)
index b50b089..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
-
-#define START_SCOPE {
-#define END_SCOPE }
-
-// CHECK: _Z2f0v:
-// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:20 = 0
-inline void f0() {}
-
-// CHECK: _Z2f1v:
-// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:31 = 0
-inline void f1() START_SCOPE }
-
-// CHECK: _Z2f2v:
-// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:29 = 0
-inline void f2() { END_SCOPE
-
-// CHECK: _Z2f3v:
-// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:39 = 0
-inline void f3() START_SCOPE END_SCOPE
-
-// CHECK: _Z2f4v:
-// CHECK-NEXT: File 0, [[@LINE+2]]:10 -> [[@LINE+3]]:2 = 0
-inline void f4()
-#include "Inputs/starts_a_scope_only"
-}
-
-// CHECK: _Z2f5v:
-// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+2]]:36 = 0
-inline void f5() {
-#include "Inputs/ends_a_scope_only"
-
-// CHECK: _Z2f6v:
-// CHECK-NEXT: File 0, [[@LINE+2]]:10 -> [[@LINE+3]]:36 = 0
-inline void f6()
-#include "Inputs/starts_a_scope_only"
-#include "Inputs/ends_a_scope_only"