Skip to content

Commit c809051

Browse files
authored
[NFC] Preparatory work for D153131 (#66750)
1 parent 91f46ec commit c809051

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

clang/lib/Analysis/ThreadSafety.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,8 +2265,11 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
22652265
const PostOrderCFGView *SortedGraph = walker.getSortedGraph();
22662266
PostOrderCFGView::CFGBlockSet VisitedBlocks(CFGraph);
22672267

2268+
CFGBlockInfo &Initial = BlockInfo[CFGraph->getEntry().getBlockID()];
2269+
CFGBlockInfo &Final = BlockInfo[CFGraph->getExit().getBlockID()];
2270+
22682271
// Mark entry block as reachable
2269-
BlockInfo[CFGraph->getEntry().getBlockID()].Reachable = true;
2272+
Initial.Reachable = true;
22702273

22712274
// Compute SSA names for local variables
22722275
LocalVarMap.traverseCFG(CFGraph, SortedGraph, BlockInfo);
@@ -2282,8 +2285,8 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
22822285
// to initial lockset. Also turn off checking for lock and unlock functions.
22832286
// FIXME: is there a more intelligent way to check lock/unlock functions?
22842287
if (!SortedGraph->empty() && D->hasAttrs()) {
2285-
const CFGBlock *FirstBlock = *SortedGraph->begin();
2286-
FactSet &InitialLockset = BlockInfo[FirstBlock->getBlockID()].EntrySet;
2288+
assert(*SortedGraph->begin() == &CFGraph->getEntry());
2289+
FactSet &InitialLockset = Initial.EntrySet;
22872290

22882291
CapExprSet ExclusiveLocksToAdd;
22892292
CapExprSet SharedLocksToAdd;
@@ -2455,15 +2458,12 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
24552458
}
24562459
}
24572460

2458-
CFGBlockInfo *Initial = &BlockInfo[CFGraph->getEntry().getBlockID()];
2459-
CFGBlockInfo *Final = &BlockInfo[CFGraph->getExit().getBlockID()];
2460-
24612461
// Skip the final check if the exit block is unreachable.
2462-
if (!Final->Reachable)
2462+
if (!Final.Reachable)
24632463
return;
24642464

24652465
// By default, we expect all locks held on entry to be held on exit.
2466-
FactSet ExpectedExitSet = Initial->EntrySet;
2466+
FactSet ExpectedExitSet = Initial.EntrySet;
24672467

24682468
// Adjust the expected exit set by adding or removing locks, as declared
24692469
// by *-LOCK_FUNCTION and UNLOCK_FUNCTION. The intersect below will then
@@ -2479,7 +2479,7 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
24792479
ExpectedExitSet.removeLock(FactMan, Lock);
24802480

24812481
// FIXME: Should we call this function for all blocks which exit the function?
2482-
intersectAndWarn(ExpectedExitSet, Final->ExitSet, Final->ExitLoc,
2482+
intersectAndWarn(ExpectedExitSet, Final.ExitSet, Final.ExitLoc,
24832483
LEK_LockedAtEndOfFunction, LEK_NotLockedAtEndOfFunction);
24842484

24852485
Handler.leaveFunction(CurrentFunction);

0 commit comments

Comments
 (0)