From 82aa23b8983443aff02cd830ec9ba31d0495a9b5 Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Wed, 20 Aug 2014 17:10:56 +0000 Subject: [PATCH] Coverage mapping: fix mapping for objective-c message expression git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216081 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CoverageMappingGen.cpp | 10 ++++++++++ test/CoverageMapping/objc.m | 11 +++++++++++ 2 files changed, 21 insertions(+) create mode 100644 test/CoverageMapping/objc.m diff --git a/lib/CodeGen/CoverageMappingGen.cpp b/lib/CodeGen/CoverageMappingGen.cpp index 836d09f734..4c5f375116 100644 --- a/lib/CodeGen/CoverageMappingGen.cpp +++ b/lib/CodeGen/CoverageMappingGen.cpp @@ -1042,6 +1042,16 @@ struct CounterCoverageMappingBuilder void VisitImaginaryLiteral(const ImaginaryLiteral *E) { mapToken(E->getLocStart()); } + + void VisitObjCMessageExpr(const ObjCMessageExpr *E) { + mapToken(E->getLeftLoc()); + for (Stmt::const_child_range I = static_cast(E)->children(); I; + ++I) { + if (*I) + this->Visit(*I); + } + mapToken(E->getRightLoc()); + } }; } diff --git a/test/CoverageMapping/objc.m b/test/CoverageMapping/objc.m new file mode 100644 index 0000000000..e14caa9bdb --- /dev/null +++ b/test/CoverageMapping/objc.m @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name objc.m -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 %s | FileCheck %s + +@interface A +- (void)bork:(int)msg; +@end + + // CHECK: func +void func(A *a) { // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+3]]:2 = #0 (HasCodeBefore = 0) + if (a) + [a bork: 20 ]; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:20 = #1 (HasCodeBefore = 0) +} -- 2.40.0