summaryrefslogtreecommitdiffstats
path: root/clang/test/CoverageMapping/default-method.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2018-11-28 20:48:07 +0000
committerVedant Kumar <vsk@apple.com>2018-11-28 20:48:07 +0000
commit7225a2617660a84002c64b495c1b5a5fe6c800cf (patch)
tree79b13b72f355735e62664b5efb509119ce7a6d1b /clang/test/CoverageMapping/default-method.cpp
parent1742eced55a932f539e4a54b5ab2c0ec9780f456 (diff)
downloadbcm5719-llvm-7225a2617660a84002c64b495c1b5a5fe6c800cf.tar.gz
bcm5719-llvm-7225a2617660a84002c64b495c1b5a5fe6c800cf.zip
[Coverage] Do not visit artificial stmts in defaulted methods (PR39822)
There is no reason to emit coverage mappings for artificial statements contained within defaulted methods, as these statements are not visible to users. Only emit a mapping for the body of the defaulted method (clang treats the text of the "default" keyword as the body when reporting locations). This allows users to see how often the default method is called, but trims down the coverage mapping by skipping visitation of the children of the method. The immediate motivation for this change is that the lexer's getPreciseTokenLocEnd API cannot return the correct location when given an artificial statement (with a somewhat made-up location) as an input. Test by Orivej Desh! Fixes llvm.org/PR39822. llvm-svn: 347803
Diffstat (limited to 'clang/test/CoverageMapping/default-method.cpp')
-rw-r--r--clang/test/CoverageMapping/default-method.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/test/CoverageMapping/default-method.cpp b/clang/test/CoverageMapping/default-method.cpp
new file mode 100644
index 00000000000..e097a168bb4
--- /dev/null
+++ b/clang/test/CoverageMapping/default-method.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++17 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name default-method.cpp -w %s | FileCheck %s -implicit-check-not="->"
+
+namespace PR39822 {
+ struct unique_ptr {
+ unique_ptr &operator=(unique_ptr &);
+ };
+
+ class foo {
+ foo &operator=(foo &);
+ unique_ptr convertable_values_[2];
+ };
+
+ // CHECK: _ZN7PR398223fooaSERS0_:
+ // CHECK-NEXT: File 0, [[@LINE+1]]:28 -> [[@LINE+1]]:29 = #0
+ foo &foo::operator=(foo &) = default;
+} // namespace PR39822
+
OpenPOWER on IntegriCloud