From a6bf8b86f490ebce4b6978ce2ae373b865dd33e5 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 18 Apr 2014 13:13:15 +0000 Subject: [PATCH] Updating to use more range-based for loops, nullptr and auto. No functional changes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206590 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ThreadSafety.cpp | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/lib/Analysis/ThreadSafety.cpp b/lib/Analysis/ThreadSafety.cpp index 63063e02c6..94d8e7025c 100644 --- a/lib/Analysis/ThreadSafety.cpp +++ b/lib/Analysis/ThreadSafety.cpp @@ -2420,23 +2420,22 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) { StringRef CapDiagKind = "mutex"; SourceLocation Loc = D->getLocation(); - for (unsigned i = 0; i < ArgAttrs.size(); ++i) { - Attr *Attr = ArgAttrs[i]; + for (const auto *Attr : ArgAttrs) { Loc = Attr->getLocation(); - if (RequiresCapabilityAttr *A = dyn_cast(Attr)) { + if (const auto *A = dyn_cast(Attr)) { getMutexIDs(A->isShared() ? SharedLocksToAdd : ExclusiveLocksToAdd, A, 0, D); CapDiagKind = ClassifyDiagnostic(A); - } else if (auto *A = dyn_cast(Attr)) { + } else if (const auto *A = dyn_cast(Attr)) { // UNLOCK_FUNCTION() is used to hide the underlying lock implementation. // We must ignore such methods. if (A->args_size() == 0) return; // FIXME -- deal with exclusive vs. shared unlock functions? - getMutexIDs(ExclusiveLocksToAdd, A, (Expr*) 0, D); - getMutexIDs(LocksReleased, A, (Expr*) 0, D); + getMutexIDs(ExclusiveLocksToAdd, A, nullptr, D); + getMutexIDs(LocksReleased, A, nullptr, D); CapDiagKind = ClassifyDiagnostic(A); - } else if (auto *A = dyn_cast(Attr)) { + } else if (const auto *A = dyn_cast(Attr)) { if (A->args_size() == 0) return; getMutexIDs(A->isShared() ? SharedLocksAcquired @@ -2487,7 +2486,7 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) { PE = CurrBlock->pred_end(); PI != PE; ++PI) { // if *PI -> CurrBlock is a back edge - if (*PI == 0 || !VisitedBlocks.alreadySet(*PI)) + if (*PI == nullptr || !VisitedBlocks.alreadySet(*PI)) continue; int PrevBlockID = (*PI)->getBlockID(); @@ -2530,9 +2529,7 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) { // Process continue and break blocks. Assume that the lockset for the // resulting block is unaffected by any discrepancies in them. - for (unsigned SpecialI = 0, SpecialN = SpecialBlocks.size(); - SpecialI < SpecialN; ++SpecialI) { - CFGBlock *PrevBlock = SpecialBlocks[SpecialI]; + for (const auto *PrevBlock : SpecialBlocks) { int PrevBlockID = PrevBlock->getBlockID(); CFGBlockInfo *PrevBlockInfo = &BlockInfo[PrevBlockID]; @@ -2628,17 +2625,14 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) { // by *-LOCK_FUNCTION and UNLOCK_FUNCTION. The intersect below will then // issue the appropriate warning. // FIXME: the location here is not quite right. - for (unsigned i=0,n=ExclusiveLocksAcquired.size(); igetLocation(), LK_Exclusive)); - } - for (unsigned i=0,n=SharedLocksAcquired.size(); igetLocation(), LK_Shared)); - } - for (unsigned i=0,n=LocksReleased.size(); iExitSet, -- 2.40.0