]> granicus.if.org Git - clang/commitdiff
InstrProf: Fix a misuse of the FunctionDecl API when generating coverage
authorJustin Bogner <mail@justinbogner.com>
Tue, 28 Jul 2015 00:41:51 +0000 (00:41 +0000)
committerJustin Bogner <mail@justinbogner.com>
Tue, 28 Jul 2015 00:41:51 +0000 (00:41 +0000)
This was calling FD->hasBody(), meaning "Does the function that this
decl refers to have a body?", rather than
FD->doesThisDeclarationHaveABody(), meaning "Is this decl a
non-deleted definition?".

We might want to consider renaming these APIs :/

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

lib/CodeGen/CodeGenModule.cpp
test/CoverageMapping/decl.c [new file with mode: 0644]

index f6bd6a4069b9b3e1a0850275acb986a95dd4b5fc..e899c9442b2d94eeb708c3ade37b7a1b4059004b 100644 (file)
@@ -3406,7 +3406,7 @@ void CodeGenModule::AddDeferredUnusedCoverageMapping(Decl *D) {
   case Decl::ObjCMethod:
   case Decl::CXXConstructor:
   case Decl::CXXDestructor: {
-    if (!cast<FunctionDecl>(D)->hasBody())
+    if (!cast<FunctionDecl>(D)->doesThisDeclarationHaveABody())
       return;
     auto I = DeferredEmptyCoverageMappingDecls.find(D);
     if (I == DeferredEmptyCoverageMappingDecls.end())
diff --git a/test/CoverageMapping/decl.c b/test/CoverageMapping/decl.c
new file mode 100644 (file)
index 0000000..96ee303
--- /dev/null
@@ -0,0 +1,15 @@
+// Ensure that declarations without definitions don't have maps emitted for them
+
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s > %t
+// FileCheck -input-file %t %s
+// RUN: FileCheck -check-prefix BAR -input-file %t %s
+
+// FOO: foo:
+// FOO-NOT: foo:
+inline int foo() { return 0; }
+extern inline int foo();
+
+// BAR: bar:
+// BAR-NOT: bar:
+int bar() { return 0; }
+extern int bar();