From: Justin Bogner Date: Thu, 23 Apr 2015 00:31:16 +0000 (+0000) Subject: InstrProf: Fix a shadowing error that would break length of profile names X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=606e494fb80f29bf4908a055b70347b3b017f7f4;p=clang InstrProf: Fix a shadowing error that would break length of profile names We try to use the member variable "FuncName" here, but we've also used that name as a parameter. This ends with us getting the length of the function name wrong when we generate the coverage data. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235565 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CodeGenPGO.cpp b/lib/CodeGen/CodeGenPGO.cpp index cc6ac20dd7..00f849b999 100644 --- a/lib/CodeGen/CodeGenPGO.cpp +++ b/lib/CodeGen/CodeGenPGO.cpp @@ -729,7 +729,7 @@ void CodeGenPGO::emitCounterRegionMapping(const Decl *D) { } void -CodeGenPGO::emitEmptyCounterMapping(const Decl *D, StringRef FuncName, +CodeGenPGO::emitEmptyCounterMapping(const Decl *D, StringRef Name, llvm::GlobalValue::LinkageTypes Linkage) { if (SkipCoverageMapping) return; @@ -749,7 +749,7 @@ CodeGenPGO::emitEmptyCounterMapping(const Decl *D, StringRef FuncName, if (CoverageMapping.empty()) return; - setFuncName(FuncName, Linkage); + setFuncName(Name, Linkage); CGM.getCoverageMapping()->addFunctionMappingRecord( FuncNameVar, FuncName, FunctionHash, CoverageMapping); } diff --git a/test/CoverageMapping/unused_names.c b/test/CoverageMapping/unused_names.c index 8a57957378..d229492eca 100644 --- a/test/CoverageMapping/unused_names.c +++ b/test/CoverageMapping/unused_names.c @@ -4,9 +4,9 @@ // Since foo is never emitted, there should not be a profile name for it. -// CHECK-DAG: @__llvm_profile_name_bar = {{.*}} section "{{.*}}__llvm_prf_names" -// CHECK-DAG: @__llvm_profile_name_baz = {{.*}} section "{{.*}}__llvm_prf_names" -// CHECK-DAG: @"__llvm_profile_name_unused_names.c:qux" = {{.*}} section "{{.*}}__llvm_prf_names" +// CHECK-DAG: @__llvm_profile_name_bar = {{.*}} [3 x i8] c"bar", section "{{.*}}__llvm_prf_names" +// CHECK-DAG: @__llvm_profile_name_baz = {{.*}} [3 x i8] c"baz", section "{{.*}}__llvm_prf_names" +// CHECK-DAG: @"__llvm_profile_name_unused_names.c:qux" = {{.*}} [18 x i8] c"unused_names.c:qux", section "{{.*}}__llvm_prf_names" // SYSHEADER-NOT: @__llvm_profile_name_foo =