Index: include/clang/Analysis/AnalysisContext.h =================================================================== --- include/clang/Analysis/AnalysisContext.h +++ include/clang/Analysis/AnalysisContext.h @@ -427,6 +427,7 @@ bool addInitializers = false, bool addTemporaryDtors = false, bool addLifetime = false, + bool addLoopExit = false, bool synthesizeBodies = false, bool addStaticInitBranches = false, bool addCXXNewAllocator = true, Index: include/clang/Analysis/CFG.h =================================================================== --- include/clang/Analysis/CFG.h +++ include/clang/Analysis/CFG.h @@ -59,6 +59,7 @@ Initializer, NewAllocator, LifetimeEnds, + LoopExit, // dtor kind AutomaticObjectDtor, DeleteDtor, @@ -168,6 +169,24 @@ } }; +/// Represents the point where a loop ends. +class CFGLoopExit : public CFGElement { +public: + explicit CFGLoopExit(const Stmt *stmt) + : CFGElement(LoopExit, stmt) {} + + const Stmt *getLoopStmt() const { + return static_cast(Data1.getPointer()); + } + +private: + friend class CFGElement; + CFGLoopExit() {} + static bool isKind(const CFGElement &elem) { + return elem.getKind() == LoopExit; + } +}; + /// Represents the point where the lifetime of an automatic object ends class CFGLifetimeEnds : public CFGElement { public: @@ -728,6 +747,10 @@ Elements.push_back(CFGLifetimeEnds(VD, S), C); } + void appendLoopExit(const Stmt *S, BumpVectorContext &C) { + Elements.push_back(CFGLoopExit(S), C); + } + void appendDeleteDtor(CXXRecordDecl *RD, CXXDeleteExpr *DE, BumpVectorContext &C) { Elements.push_back(CFGDeleteDtor(RD, DE), C); } @@ -794,6 +817,7 @@ bool AddInitializers; bool AddImplicitDtors; bool AddLifetime; + bool AddLoopExit; bool AddTemporaryDtors; bool AddStaticInitBranches; bool AddCXXNewAllocator; @@ -818,7 +842,7 @@ PruneTriviallyFalseEdges(true), AddEHEdges(false), AddInitializers(false), AddImplicitDtors(false), - AddLifetime(false), + AddLifetime(false), AddLoopExit(false), AddTemporaryDtors(false), AddStaticInitBranches(false), AddCXXNewAllocator(false), AddCXXDefaultInitExprInCtors(false) {} }; Index: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h =================================================================== --- include/clang/StaticAnalyzer/Core/AnalyzerOptions.h +++ include/clang/StaticAnalyzer/Core/AnalyzerOptions.h @@ -214,6 +214,9 @@ /// \sa IncludeLifetimeInCFG Optional IncludeLifetimeInCFG; + /// \sa IncludeLoopExitInCFG + Optional IncludeLoopExitInCFG; + /// \sa mayInlineCXXStandardLibrary Optional InlineCXXStandardLibrary; @@ -415,6 +418,13 @@ /// the values "true" and "false". bool includeLifetimeInCFG(); + /// Returns whether or not the end of the loop information should be included + /// in the CFG. + /// + /// This is controlled by the 'cfg-loopexit' config option, which accepts + /// the values "true" and "false". + bool includeLoopExitInCFG(); + /// Returns whether or not C++ standard library functions may be considered /// for inlining. /// Index: lib/Analysis/AnalysisDeclContext.cpp =================================================================== --- lib/Analysis/AnalysisDeclContext.cpp +++ lib/Analysis/AnalysisDeclContext.cpp @@ -68,6 +68,7 @@ bool addInitializers, bool addTemporaryDtors, bool addLifetime, + bool addLoopExit, bool synthesizeBodies, bool addStaticInitBranch, bool addCXXNewAllocator, @@ -79,6 +80,7 @@ cfgBuildOptions.AddInitializers = addInitializers; cfgBuildOptions.AddTemporaryDtors = addTemporaryDtors; cfgBuildOptions.AddLifetime = addLifetime; + cfgBuildOptions.AddLoopExit = addLoopExit; cfgBuildOptions.AddStaticInitBranches = addStaticInitBranch; cfgBuildOptions.AddCXXNewAllocator = addCXXNewAllocator; } Index: lib/Analysis/CFG.cpp =================================================================== --- lib/Analysis/CFG.cpp +++ lib/Analysis/CFG.cpp @@ -602,6 +602,7 @@ return Visit(S, AddStmtChoice::AlwaysAdd); } CFGBlock *addInitializer(CXXCtorInitializer *I); + void addLoopExit(const Stmt* LoopStmt); void addAutomaticObjDtors(LocalScope::const_iterator B, LocalScope::const_iterator E, Stmt *S); void addLifetimeEnds(LocalScope::const_iterator B, @@ -652,6 +653,10 @@ B->appendLifetimeEnds(VD, S, cfg->getBumpVectorContext()); } + void appendLoopExit(CFGBlock *B, const Stmt *S) { + B->appendLoopExit(S, cfg->getBumpVectorContext()); + } + void appendDeleteDtor(CFGBlock *B, CXXRecordDecl *RD, CXXDeleteExpr *DE) { B->appendDeleteDtor(RD, DE, cfg->getBumpVectorContext()); } @@ -1253,6 +1258,16 @@ return Init->getType(); } + +//TODO: Support adding LoopExit element to the CFG in case where the loop is +// ended by ReturnStmt. +void CFGBuilder::addLoopExit(const Stmt* LoopStmt){ + if(!BuildOpts.AddLoopExit) + return; + autoCreateBlock(); + appendLoopExit(Block, LoopStmt); +} + void CFGBuilder::addAutomaticObjHandling(LocalScope::const_iterator B, LocalScope::const_iterator E, Stmt *S) { @@ -1549,11 +1564,15 @@ CFGBlock *Blk, LocalScope::const_iterator B, LocalScope::const_iterator E) { if (!BuildOpts.AddLifetime) return; + llvm::errs() << "DudeTerminator\n"; BumpVectorContext &C = cfg->getBumpVectorContext(); CFGBlock::iterator InsertPos = Blk->beginLifetimeEndsInsert(Blk->end(), B.distance(E), C); - for (LocalScope::const_iterator I = B; I != E; ++I) + for (LocalScope::const_iterator I = B; I != E; ++I) { InsertPos = Blk->insertLifetimeEnds(InsertPos, *I, Blk->getTerminator()); + Blk->getTerminator()->dump(); + (*I)->dump(); + } } /// Visit - Walk the subtree of a statement and add extra /// blocks for ternary operators, &&, and ||. We also process "," and @@ -2543,6 +2562,8 @@ addAutomaticObjHandling(ScopePos, save_scope_pos.get(), F); + addLoopExit(F); + // "for" is a control-flow statement. Thus we stop processing the current // block. if (Block) { @@ -2882,6 +2903,7 @@ addLocalScopeForVarDecl(VD); addAutomaticObjHandling(ScopePos, LoopBeginScopePos, W); } + addLoopExit(W); // "while" is a control-flow statement. Thus we stop processing the current // block. @@ -2896,6 +2918,8 @@ CFGBlock *BodyBlock = nullptr, *TransitionBlock = nullptr; + + // Process the loop body. { assert(W->getBody()); @@ -3045,6 +3069,8 @@ CFGBlock *CFGBuilder::VisitDoStmt(DoStmt *D) { CFGBlock *LoopSuccessor = nullptr; + addLoopExit(D); + // "do...while" is a control-flow statement. Thus we stop processing the // current block. if (Block) { @@ -4025,6 +4051,7 @@ case CFGElement::Statement: case CFGElement::Initializer: case CFGElement::NewAllocator: + case CFGElement::LoopExit: case CFGElement::LifetimeEnds: llvm_unreachable("getDestructorDecl should only be used with " "ImplicitDtors"); @@ -4442,6 +4469,9 @@ OS << " (Lifetime ends)\n"; + } else if (Optional LE = E.getAs()) { + const Stmt *LoopStmt = LE->getLoopStmt(); + OS << LoopStmt->getStmtClassName() << " (LoopExit)\n"; } else if (Optional NE = E.getAs()) { OS << "CFGNewAllocator("; if (const CXXNewExpr *AllocExpr = NE->getAllocatorExpr()) Index: lib/StaticAnalyzer/Core/AnalysisManager.cpp =================================================================== --- lib/StaticAnalyzer/Core/AnalysisManager.cpp +++ lib/StaticAnalyzer/Core/AnalysisManager.cpp @@ -26,7 +26,8 @@ Options.includeImplicitDtorsInCFG(), /*AddInitializers=*/true, Options.includeTemporaryDtorsInCFG(), - Options.includeLifetimeInCFG(), + Options.includeLifetimeInCFG(), + Options.includeLoopExitInCFG(), Options.shouldSynthesizeBodies(), Options.shouldConditionalizeStaticInitializers(), /*addCXXNewAllocator=*/true, Index: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp =================================================================== --- lib/StaticAnalyzer/Core/AnalyzerOptions.cpp +++ lib/StaticAnalyzer/Core/AnalyzerOptions.cpp @@ -183,6 +183,11 @@ /* Default = */ false); } +bool AnalyzerOptions::includeLoopExitInCFG() { + return getBooleanOption(IncludeLoopExitInCFG, "cfg-loopexit", + /* Default = */ false); +} + bool AnalyzerOptions::mayInlineCXXStandardLibrary() { return getBooleanOption(InlineCXXStandardLibrary, "c++-stdlib-inlining", Index: lib/StaticAnalyzer/Core/ExprEngine.cpp =================================================================== --- lib/StaticAnalyzer/Core/ExprEngine.cpp +++ lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -363,6 +363,7 @@ ProcessImplicitDtor(E.castAs(), Pred); return; case CFGElement::LifetimeEnds: + case CFGElement::LoopExit: return; } } Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp =================================================================== --- lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp @@ -579,6 +579,7 @@ case CFGElement::TemporaryDtor: case CFGElement::NewAllocator: case CFGElement::LifetimeEnds: + case CFGElement::LoopExit: llvm_unreachable("not yet implemented!"); } Index: test/Analysis/analyzer-config.c =================================================================== --- test/Analysis/analyzer-config.c +++ test/Analysis/analyzer-config.c @@ -14,6 +14,7 @@ // CHECK-NEXT: cfg-conditional-static-initializers = true // CHECK-NEXT: cfg-implicit-dtors = true // CHECK-NEXT: cfg-lifetime = false +// CHECK-NEXT: cfg-loopexit = false // CHECK-NEXT: cfg-temporary-dtors = false // CHECK-NEXT: faux-bodies = true // CHECK-NEXT: graph-trim-interval = 1000 @@ -29,4 +30,4 @@ // CHECK-NEXT: region-store-small-struct-limit = 2 // CHECK-NEXT: widen-loops = false // CHECK-NEXT: [stats] -// CHECK-NEXT: num-entries = 17 +// CHECK-NEXT: num-entries = 18 Index: test/Analysis/analyzer-config.cpp =================================================================== --- test/Analysis/analyzer-config.cpp +++ test/Analysis/analyzer-config.cpp @@ -25,6 +25,7 @@ // CHECK-NEXT: cfg-conditional-static-initializers = true // CHECK-NEXT: cfg-implicit-dtors = true // CHECK-NEXT: cfg-lifetime = false +// CHECK-NEXT: cfg-loopexit = false // CHECK-NEXT: cfg-temporary-dtors = false // CHECK-NEXT: faux-bodies = true // CHECK-NEXT: graph-trim-interval = 1000 @@ -40,4 +41,4 @@ // CHECK-NEXT: region-store-small-struct-limit = 2 // CHECK-NEXT: widen-loops = false // CHECK-NEXT: [stats] -// CHECK-NEXT: num-entries = 22 +// CHECK-NEXT: num-entries = 23 Index: test/Analysis/loopexit-cfg-output.cpp =================================================================== --- /dev/null +++ test/Analysis/loopexit-cfg-output.cpp @@ -0,0 +1,351 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-loopexit=true %s > %t 2>&1 +// RUN: FileCheck --input-file=%t %s + +// CHECK: [B6 (ENTRY)] +// CHECK-NEXT: Succs (1): B5 + +// CHECK: [B1] +// CHECK-NEXT: 1: ForStmt (LoopExit) +// CHECK-NEXT: 2: return; +// CHECK-NEXT: Preds (1): B4 +// CHECK-NEXT: Succs (1): B0 + +// CHECK: [B2] +// CHECK-NEXT: 1: i +// CHECK-NEXT: 2: [B2.1]++ +// CHECK-NEXT: Preds (1): B3 +// CHECK-NEXT: Succs (1): B4 + +// CHECK: [B3] +// CHECK-NEXT: 1: i +// CHECK-NEXT: 2: [B3.1]++ +// CHECK-NEXT: Preds (1): B4 +// CHECK-NEXT: Succs (1): B2 + +// CHECK: [B4] +// CHECK-NEXT: 1: i +// CHECK-NEXT: 2: [B4.1] (ImplicitCastExpr, LValueToRValue, int) +// CHECK-NEXT: 3: 12 +// CHECK-NEXT: 4: [B4.2] < [B4.3] +// CHECK-NEXT: T: for (...; [B4.4]; ...) +// CHECK-NEXT: Preds (2): B2 B5 +// CHECK-NEXT: Succs (2): B3 B1 + +// CHECK: [B5] +// CHECK-NEXT: 1: 0 +// CHECK-NEXT: 2: int i = 0; +// CHECK-NEXT: Preds (1): B6 +// CHECK-NEXT: Succs (1): B4 + +// CHECK: [B0 (EXIT)] +// CHECK-NEXT: Preds (1): B1 +void check_forloop1() { + for (int i = 0; i < 12; i++) { + i++; + } + return; +} + +// CHECK: [B4 (ENTRY)] +// CHECK-NEXT: Succs (1): B3 + +// CHECK: [B1] +// CHECK-NEXT: 1: ForStmt (LoopExit) +// CHECK-NEXT: Succs (1): B0 + +// CHECK: [B2] +// CHECK-NEXT: Preds (1): B3 +// CHECK-NEXT: Succs (1): B3 + +// CHECK: [B3] +// CHECK-NEXT: T: for (; ; ) +// CHECK-NEXT: Preds (2): B2 B4 +// CHECK-NEXT: Succs (2): B2 NULL + +// CHECK: [B0 (EXIT)] +// CHECK-NEXT: Preds (1): B1 +void check_forloop2() { + for (;;) + ; +} + +// CHECK: [B5 (ENTRY)] +// CHECK-NEXT: Succs (1): B4 + +// CHECK: [B1] +// CHECK-NEXT: 1: WhileStmt (LoopExit) +// CHECK-NEXT: Succs (1): B0 + +// CHECK: [B2] +// CHECK-NEXT: Preds (1): B3 +// CHECK-NEXT: Succs (1): B4 + +// CHECK: [B3] +// CHECK-NEXT: 1: int i; +// CHECK-NEXT: Preds (1): B4 +// CHECK-NEXT: Succs (1): B2 + +// CHECK: [B4] +// CHECK-NEXT: 1: true +// CHECK-NEXT: T: while [B4.1] +// CHECK-NEXT: Preds (2): B2 B5 +// CHECK-NEXT: Succs (2): B3 NULL + +// CHECK: [B0 (EXIT)] +// CHECK-NEXT: Preds (1): B1 +void check_while1() { + while (true) { + int i; + } +} + +// CHECK: [B5 (ENTRY)] +// CHECK-NEXT: Succs (1): B4 + +// CHECK: [B1] +// CHECK-NEXT: 1: WhileStmt (LoopExit) +// CHECK-NEXT: 2: 2 +// CHECK-NEXT: 3: int k = 2; +// CHECK-NEXT: 4: return; +// CHECK-NEXT: Preds (1): B3 +// CHECK-NEXT: Succs (1): B0 + +// CHECK: [B2] +// CHECK-NEXT: Preds (1): B3 +// CHECK-NEXT: Succs (1): B3 + +// CHECK: [B3] +// CHECK-NEXT: 1: l +// CHECK-NEXT: 2: [B3.1] (ImplicitCastExpr, LValueToRValue, int) +// CHECK-NEXT: 3: 42 +// CHECK-NEXT: 4: [B3.2] < [B3.3] +// CHECK-NEXT: T: while [B3.4] +// CHECK-NEXT: Preds (2): B2 B4 +// CHECK-NEXT: Succs (2): B2 B1 + +// CHECK: [B4] +// CHECK-NEXT: 1: int l; +// CHECK-NEXT: Preds (1): B5 +// CHECK-NEXT: Succs (1): B3 + +// CHECK: [B0 (EXIT)] +// CHECK-NEXT: Preds (1): B1 +void check_while2() { + int l; + while (l < 42) + ; + int k = 2; + return; +} + +// CHECK: [B4 (ENTRY)] +// CHECK-NEXT: Succs (1): B2 + +// CHECK: [B1] +// CHECK-NEXT: 1: DoStmt (LoopExit) +// CHECK-NEXT: Preds (1): B2 +// CHECK-NEXT: Succs (1): B0 + +// CHECK: [B2] +// CHECK-NEXT: 1: false +// CHECK-NEXT: T: do ... while [B2.1] +// CHECK-NEXT: Preds (2): B3 B4 +// CHECK-NEXT: Succs (2): NULL B1 + +// CHECK: [B3] +// CHECK-NEXT: Succs (1): B2 + +// CHECK: [B0 (EXIT)] +// CHECK-NEXT: Preds (1): B1 +void check_dowhile1() { + do { + } while (false); +} + +// CHECK: [B6 (ENTRY)] +// CHECK-NEXT: Succs (1): B5 + +// CHECK: [B1] +// CHECK-NEXT: 1: DoStmt (LoopExit) +// CHECK-NEXT: 2: j +// CHECK-NEXT: 3: [B1.2]-- +// CHECK-NEXT: 4: return; +// CHECK-NEXT: Preds (1): B2 +// CHECK-NEXT: Succs (1): B0 + +// CHECK: [B2] +// CHECK-NEXT: 1: j +// CHECK-NEXT: 2: [B2.1] (ImplicitCastExpr, LValueToRValue, int) +// CHECK-NEXT: 3: 20 +// CHECK-NEXT: 4: [B2.2] < [B2.3] +// CHECK-NEXT: T: do ... while [B2.4] +// CHECK-NEXT: Preds (1): B3 +// CHECK-NEXT: Succs (2): B4 B1 + +// CHECK: [B3] +// CHECK-NEXT: 1: j +// CHECK-NEXT: 2: 2 +// CHECK-NEXT: 3: [B3.1] += [B3.2] +// CHECK-NEXT: Preds (2): B4 B5 +// CHECK-NEXT: Succs (1): B2 + +// CHECK: [B4] +// CHECK-NEXT: Preds (1): B2 +// CHECK-NEXT: Succs (1): B3 + +// CHECK: [B5] +// CHECK-NEXT: 1: 2 +// CHECK-NEXT: 2: int j = 2; +// CHECK-NEXT: Preds (1): B6 +// CHECK-NEXT: Succs (1): B3 + +// CHECK: [B0 (EXIT)] +// CHECK-NEXT: Preds (1): B1 +void check_dowhile2() { + int j = 2; + do { + j += 2; + } while (j < 20); + j--; + return; +} + +// CHECK: [B10 (ENTRY)] +// CHECK-NEXT: Succs (1): B9 + +// CHECK: [B1] +// CHECK-NEXT: 1: WhileStmt (LoopExit) +// CHECK-NEXT: Preds (1): B8 +// CHECK-NEXT: Succs (1): B0 + +// CHECK: [B2] +// CHECK-NEXT: Preds (1): B3 +// CHECK-NEXT: Succs (1): B8 + +// CHECK: [B3] +// CHECK-NEXT: 1: ForStmt (LoopExit) +// CHECK-NEXT: Preds (1): B6 +// CHECK-NEXT: Succs (1): B2 + +// CHECK: [B4] +// CHECK-NEXT: 1: j +// CHECK-NEXT: 2: [B4.1]++ +// CHECK-NEXT: Preds (1): B5 +// CHECK-NEXT: Succs (1): B6 + +// CHECK: [B5] +// CHECK-NEXT: 1: i +// CHECK-NEXT: 2: [B5.1]++ +// CHECK-NEXT: Preds (1): B6 +// CHECK-NEXT: Succs (1): B4 + +// CHECK: [B6] +// CHECK-NEXT: 1: j +// CHECK-NEXT: 2: [B6.1] (ImplicitCastExpr, LValueToRValue, int) +// CHECK-NEXT: 3: 6 +// CHECK-NEXT: 4: [B6.2] < [B6.3] +// CHECK-NEXT: T: for (...; [B6.4]; ...) +// CHECK-NEXT: Preds (2): B4 B7 +// CHECK-NEXT: Succs (2): B5 B3 + +// CHECK: [B7] +// CHECK-NEXT: 1: 1 +// CHECK-NEXT: 2: int j = 1; +// CHECK-NEXT: Preds (1): B8 +// CHECK-NEXT: Succs (1): B6 + +// CHECK: [B8] +// CHECK-NEXT: 1: i +// CHECK-NEXT: 2: [B8.1] (ImplicitCastExpr, LValueToRValue, int) +// CHECK-NEXT: 3: 2 +// CHECK-NEXT: 4: [B8.2] < [B8.3] +// CHECK-NEXT: T: while [B8.4] +// CHECK-NEXT: Preds (2): B2 B9 +// CHECK-NEXT: Succs (2): B7 B1 + +// CHECK: [B9] +// CHECK-NEXT: 1: 40 +// CHECK-NEXT: 2: -[B9.1] +// CHECK-NEXT: 3: int i = -40; +// CHECK-NEXT: Preds (1): B10 +// CHECK-NEXT: Succs (1): B8 + +// CHECK: [B0 (EXIT)] +// CHECK-NEXT: Preds (1): B1 +void nested_loops1() { + int i = -40; + while (i < 2) { + for (int j = 1; j < 6; j++) + i++; + } +} + +// CHECK: [B9 (ENTRY)] +// CHECK-NEXT: Succs (1): B8 + +// CHECK: [B1] +// CHECK-NEXT: 1: ForStmt (LoopExit) +// CHECK-NEXT: Preds (1): B7 +// CHECK-NEXT: Succs (1): B0 + +// CHECK: [B2] +// CHECK-NEXT: 1: j +// CHECK-NEXT: 2: [B2.1]++ +// CHECK-NEXT: Preds (1): B3 +// CHECK-NEXT: Succs (1): B7 + +// CHECK: [B3] +// CHECK-NEXT: 1: DoStmt (LoopExit) +// CHECK-NEXT: 2: i +// CHECK-NEXT: 3: [B3.2]-- +// CHECK-NEXT: Preds (1): B4 +// CHECK-NEXT: Succs (1): B2 + +// CHECK: [B4] +// CHECK-NEXT: 1: i +// CHECK-NEXT: 2: [B4.1] (ImplicitCastExpr, LValueToRValue, int) +// CHECK-NEXT: 3: 2 +// CHECK-NEXT: 4: [B4.2] < [B4.3] +// CHECK-NEXT: T: do ... while [B4.4] +// CHECK-NEXT: Preds (1): B5 +// CHECK-NEXT: Succs (2): B6 B3 + +// CHECK: [B5] +// CHECK-NEXT: 1: i +// CHECK-NEXT: 2: [B5.1]++ +// CHECK-NEXT: Preds (2): B6 B7 +// CHECK-NEXT: Succs (1): B4 + +// CHECK: [B6] +// CHECK-NEXT: Preds (1): B4 +// CHECK-NEXT: Succs (1): B5 + +// CHECK: [B7] +// CHECK-NEXT: 1: j +// CHECK-NEXT: 2: [B7.1] (ImplicitCastExpr, LValueToRValue, int) +// CHECK-NEXT: 3: 6 +// CHECK-NEXT: 4: [B7.2] < [B7.3] +// CHECK-NEXT: T: for (...; [B7.4]; ...) +// CHECK-NEXT: Preds (2): B2 B8 +// CHECK-NEXT: Succs (2): B5 B1 + +// CHECK: [B8] +// CHECK-NEXT: 1: 40 +// CHECK-NEXT: 2: -[B8.1] +// CHECK-NEXT: 3: int i = -40; +// CHECK-NEXT: 4: 1 +// CHECK-NEXT: 5: int j = 1; +// CHECK-NEXT: Preds (1): B9 +// CHECK-NEXT: Succs (1): B7 + +// CHECK: [B0 (EXIT)] +// CHECK-NEXT: Preds (1): B1 +void nested_loops2() { + int i = -40; + for (int j = 1; j < 6; j++) { + do { + i++; + } while (i < 2); + i--; + } +}