Revert "[Sema] Make getCurFunction() return null outside function parsing"
This reverts r326965. It seems to have caused repeating test failures in
clang/test/Sema/diagnose_if.c on some buildbots.
I cannot reproduce the problem, and it's not immediately obvious what
the problem is, so let's revert to green.
llvm-svn: 326974
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index d27f926..be51787 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -3572,7 +3572,7 @@
// longjmp() and throw() must not violate the entry/exit criteria.
CS->getCapturedDecl()->setNothrow();
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPParallelDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt,
DSAStack->isCancelRegion());
@@ -5281,7 +5281,7 @@
if (checkSimdlenSafelenSpecified(*this, Clauses))
return StmtError();
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPSimdDirective::Create(Context, StartLoc, EndLoc, NestedLoopCount,
Clauses, AStmt, B);
}
@@ -5317,7 +5317,7 @@
}
}
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPForDirective::Create(Context, StartLoc, EndLoc, NestedLoopCount,
Clauses, AStmt, B, DSAStack->isCancelRegion());
}
@@ -5357,7 +5357,7 @@
if (checkSimdlenSafelenSpecified(*this, Clauses))
return StmtError();
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPForSimdDirective::Create(Context, StartLoc, EndLoc, NestedLoopCount,
Clauses, AStmt, B);
}
@@ -5394,7 +5394,7 @@
return StmtError();
}
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPSectionsDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt,
DSAStack->isCancelRegion());
@@ -5408,7 +5408,7 @@
assert(isa<CapturedStmt>(AStmt) && "Captured statement expected");
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
DSAStack->setParentCancelRegion(DSAStack->isCancelRegion());
return OMPSectionDirective::Create(Context, StartLoc, EndLoc, AStmt,
@@ -5424,7 +5424,7 @@
assert(isa<CapturedStmt>(AStmt) && "Captured statement expected");
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
// OpenMP [2.7.3, single Construct, Restrictions]
// The copyprivate clause must not be used with the nowait clause.
@@ -5454,7 +5454,7 @@
assert(isa<CapturedStmt>(AStmt) && "Captured statement expected");
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPMasterDirective::Create(Context, StartLoc, EndLoc, AStmt);
}
@@ -5508,7 +5508,7 @@
}
}
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
auto *Dir = OMPCriticalDirective::Create(Context, DirName, StartLoc, EndLoc,
Clauses, AStmt);
@@ -5556,7 +5556,7 @@
}
}
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPParallelForDirective::Create(Context, StartLoc, EndLoc,
NestedLoopCount, Clauses, AStmt, B,
DSAStack->isCancelRegion());
@@ -5601,7 +5601,7 @@
if (checkSimdlenSafelenSpecified(*this, Clauses))
return StmtError();
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPParallelForSimdDirective::Create(
Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
}
@@ -5639,7 +5639,7 @@
return StmtError();
}
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPParallelSectionsDirective::Create(
Context, StartLoc, EndLoc, Clauses, AStmt, DSAStack->isCancelRegion());
@@ -5659,7 +5659,7 @@
// longjmp() and throw() must not violate the entry/exit criteria.
CS->getCapturedDecl()->setNothrow();
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPTaskDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt,
DSAStack->isCancelRegion());
@@ -5689,7 +5689,7 @@
assert(isa<CapturedStmt>(AStmt) && "Captured statement expected");
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPTaskgroupDirective::Create(Context, StartLoc, EndLoc, Clauses,
AStmt,
@@ -5772,7 +5772,7 @@
if (AStmt) {
assert(isa<CapturedStmt>(AStmt) && "Captured statement expected");
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
}
return OMPOrderedDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt);
@@ -6442,7 +6442,7 @@
}
}
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPAtomicDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt,
X, V, E, UE, IsXLHSInRHSPart,
@@ -6507,7 +6507,7 @@
}
}
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPTargetDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt);
}
@@ -6537,7 +6537,7 @@
CS->getCapturedDecl()->setNothrow();
}
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPTargetParallelDirective::Create(Context, StartLoc, EndLoc, Clauses,
AStmt);
@@ -6592,7 +6592,7 @@
}
}
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPTargetParallelForDirective::Create(Context, StartLoc, EndLoc,
NestedLoopCount, Clauses, AStmt,
B, DSAStack->isCancelRegion());
@@ -6629,7 +6629,7 @@
return StmtError();
}
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPTargetDataDirective::Create(Context, StartLoc, EndLoc, Clauses,
AStmt);
@@ -6756,7 +6756,7 @@
// longjmp() and throw() must not violate the entry/exit criteria.
CS->getCapturedDecl()->setNothrow();
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
DSAStack->setParentTeamsRegionLoc(StartLoc);
@@ -6879,7 +6879,7 @@
if (checkReductionClauseWithNogroup(*this, Clauses))
return StmtError();
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPTaskLoopDirective::Create(Context, StartLoc, EndLoc,
NestedLoopCount, Clauses, AStmt, B);
}
@@ -6929,7 +6929,7 @@
if (checkSimdlenSafelenSpecified(*this, Clauses))
return StmtError();
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPTaskLoopSimdDirective::Create(Context, StartLoc, EndLoc,
NestedLoopCount, Clauses, AStmt, B);
}
@@ -6955,7 +6955,7 @@
assert((CurContext->isDependentContext() || B.builtAll()) &&
"omp for loop exprs were not built");
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPDistributeDirective::Create(Context, StartLoc, EndLoc,
NestedLoopCount, Clauses, AStmt, B);
}
@@ -6999,7 +6999,7 @@
assert((CurContext->isDependentContext() || B.builtAll()) &&
"omp for loop exprs were not built");
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPDistributeParallelForDirective::Create(
Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B,
DSAStack->isCancelRegion());
@@ -7058,7 +7058,7 @@
if (checkSimdlenSafelenSpecified(*this, Clauses))
return StmtError();
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPDistributeParallelForSimdDirective::Create(
Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
}
@@ -7115,7 +7115,7 @@
if (checkSimdlenSafelenSpecified(*this, Clauses))
return StmtError();
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPDistributeSimdDirective::Create(Context, StartLoc, EndLoc,
NestedLoopCount, Clauses, AStmt, B);
}
@@ -7171,7 +7171,7 @@
if (checkSimdlenSafelenSpecified(*this, Clauses))
return StmtError();
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPTargetParallelForSimdDirective::Create(
Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
}
@@ -7228,7 +7228,7 @@
if (checkSimdlenSafelenSpecified(*this, Clauses))
return StmtError();
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPTargetSimdDirective::Create(Context, StartLoc, EndLoc,
NestedLoopCount, Clauses, AStmt, B);
}
@@ -7271,7 +7271,7 @@
assert((CurContext->isDependentContext() || B.builtAll()) &&
"omp teams distribute loop exprs were not built");
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
DSAStack->setParentTeamsRegionLoc(StartLoc);
@@ -7334,7 +7334,7 @@
if (checkSimdlenSafelenSpecified(*this, Clauses))
return StmtError();
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
DSAStack->setParentTeamsRegionLoc(StartLoc);
@@ -7397,7 +7397,7 @@
if (checkSimdlenSafelenSpecified(*this, Clauses))
return StmtError();
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
DSAStack->setParentTeamsRegionLoc(StartLoc);
@@ -7446,7 +7446,7 @@
assert((CurContext->isDependentContext() || B.builtAll()) &&
"omp for loop exprs were not built");
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
DSAStack->setParentTeamsRegionLoc(StartLoc);
@@ -7480,7 +7480,7 @@
// longjmp() and throw() must not violate the entry/exit criteria.
CS->getCapturedDecl()->setNothrow();
}
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPTargetTeamsDirective::Create(Context, StartLoc, EndLoc, Clauses,
AStmt);
@@ -7525,7 +7525,7 @@
assert((CurContext->isDependentContext() || B.builtAll()) &&
"omp target teams distribute loop exprs were not built");
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPTargetTeamsDistributeDirective::Create(
Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
}
@@ -7580,7 +7580,7 @@
}
}
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPTargetTeamsDistributeParallelForDirective::Create(
Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B,
DSAStack->isCancelRegion());
@@ -7641,7 +7641,7 @@
if (checkSimdlenSafelenSpecified(*this, Clauses))
return StmtError();
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPTargetTeamsDistributeParallelForSimdDirective::Create(
Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
}
@@ -7699,7 +7699,7 @@
if (checkSimdlenSafelenSpecified(*this, Clauses))
return StmtError();
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
return OMPTargetTeamsDistributeSimdDirective::Create(
Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
}
@@ -12450,7 +12450,7 @@
// Enter new function scope.
PushFunctionScope();
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
getCurFunction()->setHasOMPDeclareReductionCombiner();
if (S != nullptr)
@@ -12506,7 +12506,7 @@
// Enter new function scope.
PushFunctionScope();
- setFunctionHasBranchProtectedScope();
+ getCurFunction()->setHasBranchProtectedScope();
if (S != nullptr)
PushDeclContext(S, DRD);