]> granicus.if.org Git - clang/commitdiff
[OPENMP] Fix PR38256: Fix locations of the artificial conditional op.
authorAlexey Bataev <a.bataev@hotmail.com>
Wed, 25 Jul 2018 14:40:26 +0000 (14:40 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Wed, 25 Jul 2018 14:40:26 +0000 (14:40 +0000)
Fixed the source locations of the conditional op so that they don'r
crash coverage pass.

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

lib/Sema/SemaOpenMP.cpp
test/CoverageMapping/openmp.c [new file with mode: 0644]

index f5a1d0b222e8b6f1bb03027621251c22b7c08124..e1a4c420d4024625e83e728e66b92454600577f4 100644 (file)
@@ -4909,7 +4909,8 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
     ExprResult IsUBGreater = SemaRef.BuildBinOp(CurScope, InitLoc, BO_GT,
                                                 UB.get(), LastIteration.get());
     ExprResult CondOp = SemaRef.ActOnConditionalOp(
-        InitLoc, InitLoc, IsUBGreater.get(), LastIteration.get(), UB.get());
+        LastIteration.get()->getExprLoc(), InitLoc, IsUBGreater.get(),
+        LastIteration.get(), UB.get());
     EUB = SemaRef.BuildBinOp(CurScope, InitLoc, BO_Assign, UB.get(),
                              CondOp.get());
     EUB = SemaRef.ActOnFinishFullExpr(EUB.get());
diff --git a/test/CoverageMapping/openmp.c b/test/CoverageMapping/openmp.c
new file mode 100644 (file)
index 0000000..1ac1262
--- /dev/null
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fopenmp -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name openmp.c %s | FileCheck %s
+
+// CHECK: openmp.c:{{.+}}omp_outlined{{.+}}:
+// CHECK: File 0, 10:3 -> 10:31
+// CHECK: File 0, 10:19 -> 10:24
+// CHECK: File 0, 10:26 -> 10:29
+// CHECK: File 0, 10:30 -> 10:31
+int foo(int time, int n) {
+#pragma omp parallel for default(shared) schedule(dynamic, 1) reduction(+ : time)
+  for (int i = 1; i < n; ++i);
+  return 0;
+}