r243360 - InstrProf: Fix a misuse of the FunctionDecl API when generating coverage

Justin Bogner mail at justinbogner.com
Mon Jul 27 17:41:51 PDT 2015


Author: bogner
Date: Mon Jul 27 19:41:51 2015
New Revision: 243360

URL: http://llvm.org/viewvc/llvm-project?rev=243360&view=rev
Log:
InstrProf: Fix a misuse of the FunctionDecl API when generating coverage

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 :/

Added:
    cfe/trunk/test/CoverageMapping/decl.c
Modified:
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=243360&r1=243359&r2=243360&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Jul 27 19:41:51 2015
@@ -3406,7 +3406,7 @@ void CodeGenModule::AddDeferredUnusedCov
   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())

Added: cfe/trunk/test/CoverageMapping/decl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/decl.c?rev=243360&view=auto
==============================================================================
--- cfe/trunk/test/CoverageMapping/decl.c (added)
+++ cfe/trunk/test/CoverageMapping/decl.c Mon Jul 27 19:41:51 2015
@@ -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();





More information about the cfe-commits mailing list