Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -2973,172 +2973,173 @@ } } - static std::string getNodeLabel(const ExplodedNode *N, void*){ - std::string sbuf; - llvm::raw_string_ostream Out(sbuf); - - // Program Location. - ProgramPoint Loc = N->getLocation(); - + static void dumpProgramPoint(ProgramPoint Loc, + llvm::raw_string_ostream &Out) { switch (Loc.getKind()) { - case ProgramPoint::BlockEntranceKind: - Out << "Block Entrance: B" - << Loc.castAs().getBlock()->getBlockID(); - break; + case ProgramPoint::BlockEntranceKind: + Out << "Block Entrance: B" + << Loc.castAs().getBlock()->getBlockID(); + break; - case ProgramPoint::BlockExitKind: - assert(false); - break; + case ProgramPoint::BlockExitKind: + assert(false); + break; - case ProgramPoint::CallEnterKind: - Out << "CallEnter"; - break; + case ProgramPoint::CallEnterKind: + Out << "CallEnter"; + break; - case ProgramPoint::CallExitBeginKind: - Out << "CallExitBegin"; - break; + case ProgramPoint::CallExitBeginKind: + Out << "CallExitBegin"; + break; - case ProgramPoint::CallExitEndKind: - Out << "CallExitEnd"; - break; + case ProgramPoint::CallExitEndKind: + Out << "CallExitEnd"; + break; - case ProgramPoint::PostStmtPurgeDeadSymbolsKind: - Out << "PostStmtPurgeDeadSymbols"; - break; + case ProgramPoint::PostStmtPurgeDeadSymbolsKind: + Out << "PostStmtPurgeDeadSymbols"; + break; - case ProgramPoint::PreStmtPurgeDeadSymbolsKind: - Out << "PreStmtPurgeDeadSymbols"; - break; + case ProgramPoint::PreStmtPurgeDeadSymbolsKind: + Out << "PreStmtPurgeDeadSymbols"; + break; - case ProgramPoint::EpsilonKind: - Out << "Epsilon Point"; - break; + case ProgramPoint::EpsilonKind: + Out << "Epsilon Point"; + break; - case ProgramPoint::LoopExitKind: { - LoopExit LE = Loc.castAs(); - Out << "LoopExit: " << LE.getLoopStmt()->getStmtClassName(); - break; - } + case ProgramPoint::LoopExitKind: { + LoopExit LE = Loc.castAs(); + Out << "LoopExit: " << LE.getLoopStmt()->getStmtClassName(); + break; + } - case ProgramPoint::PreImplicitCallKind: { - ImplicitCallPoint PC = Loc.castAs(); - Out << "PreCall: "; + case ProgramPoint::PreImplicitCallKind: { + ImplicitCallPoint PC = Loc.castAs(); + Out << "PreCall: "; - // FIXME: Get proper printing options. - PC.getDecl()->print(Out, LangOptions()); - printLocation(Out, PC.getLocation()); - break; - } + // FIXME: Get proper printing options. + PC.getDecl()->print(Out, LangOptions()); + printLocation(Out, PC.getLocation()); + break; + } - case ProgramPoint::PostImplicitCallKind: { - ImplicitCallPoint PC = Loc.castAs(); - Out << "PostCall: "; + case ProgramPoint::PostImplicitCallKind: { + ImplicitCallPoint PC = Loc.castAs(); + Out << "PostCall: "; - // FIXME: Get proper printing options. - PC.getDecl()->print(Out, LangOptions()); - printLocation(Out, PC.getLocation()); - break; - } + // FIXME: Get proper printing options. + PC.getDecl()->print(Out, LangOptions()); + printLocation(Out, PC.getLocation()); + break; + } - case ProgramPoint::PostInitializerKind: { - Out << "PostInitializer: "; - const CXXCtorInitializer *Init = + case ProgramPoint::PostInitializerKind: { + Out << "PostInitializer: "; + const CXXCtorInitializer *Init = Loc.castAs().getInitializer(); - if (const FieldDecl *FD = Init->getAnyMember()) - Out << *FD; - else { - QualType Ty = Init->getTypeSourceInfo()->getType(); - Ty = Ty.getLocalUnqualifiedType(); - LangOptions LO; // FIXME. - Ty.print(Out, LO); - } - break; + if (const FieldDecl *FD = Init->getAnyMember()) + Out << *FD; + else { + QualType Ty = Init->getTypeSourceInfo()->getType(); + Ty = Ty.getLocalUnqualifiedType(); + LangOptions LO; // FIXME. + Ty.print(Out, LO); } + break; + } - case ProgramPoint::BlockEdgeKind: { - const BlockEdge &E = Loc.castAs(); - Out << "Edge: (B" << E.getSrc()->getBlockID() << ", B" - << E.getDst()->getBlockID() << ')'; + case ProgramPoint::BlockEdgeKind: { + const BlockEdge &E = Loc.castAs(); + Out << "Edge: (B" << E.getSrc()->getBlockID() << ", B" + << E.getDst()->getBlockID() << ')'; - if (const Stmt *T = E.getSrc()->getTerminator()) { - SourceLocation SLoc = T->getBeginLoc(); + if (const Stmt *T = E.getSrc()->getTerminator()) { + SourceLocation SLoc = T->getBeginLoc(); - Out << "\\|Terminator: "; - LangOptions LO; // FIXME. - E.getSrc()->printTerminator(Out, LO); + Out << "\\|Terminator: "; + LangOptions LO; // FIXME. + E.getSrc()->printTerminator(Out, LO); - if (SLoc.isFileID()) { - Out << "\\lline=" + if (SLoc.isFileID()) { + Out << "\\lline=" << GraphPrintSourceManager->getExpansionLineNumber(SLoc) << " col=" << GraphPrintSourceManager->getExpansionColumnNumber(SLoc); - } - - if (isa(T)) { - const Stmt *Label = E.getDst()->getLabel(); + } - if (Label) { - if (const auto *C = dyn_cast(Label)) { - Out << "\\lcase "; - LangOptions LO; // FIXME. - if (C->getLHS()) - C->getLHS()->printPretty(Out, nullptr, PrintingPolicy(LO)); + if (isa(T)) { + const Stmt *Label = E.getDst()->getLabel(); - if (const Stmt *RHS = C->getRHS()) { - Out << " .. "; - RHS->printPretty(Out, nullptr, PrintingPolicy(LO)); - } + if (Label) { + if (const auto *C = dyn_cast(Label)) { + Out << "\\lcase "; + LangOptions LO; // FIXME. + if (C->getLHS()) + C->getLHS()->printPretty(Out, nullptr, PrintingPolicy(LO)); - Out << ":"; - } - else { - assert(isa(Label)); - Out << "\\ldefault:"; + if (const Stmt *RHS = C->getRHS()) { + Out << " .. "; + RHS->printPretty(Out, nullptr, PrintingPolicy(LO)); } - } - else - Out << "\\l(implicit) default:"; - } - else if (isa(T)) { - // FIXME - } - else { - Out << "\\lCondition: "; - if (*E.getSrc()->succ_begin() == E.getDst()) - Out << "true"; - else - Out << "false"; - } - Out << "\\l"; + Out << ":"; + } else { + assert(isa(Label)); + Out << "\\ldefault:"; + } + } else + Out << "\\l(implicit) default:"; + } else if (isa(T)) { + // FIXME + } else { + Out << "\\lCondition: "; + if (*E.getSrc()->succ_begin() == E.getDst()) + Out << "true"; + else + Out << "false"; } - break; + Out << "\\l"; } - default: { - const Stmt *S = Loc.castAs().getStmt(); - assert(S != nullptr && "Expecting non-null Stmt"); + break; + } - Out << S->getStmtClassName() << ' ' << (const void*) S << ' '; - LangOptions LO; // FIXME. - S->printPretty(Out, nullptr, PrintingPolicy(LO)); - printLocation(Out, S->getBeginLoc()); - - if (Loc.getAs()) - Out << "\\lPreStmt\\l;"; - else if (Loc.getAs()) - Out << "\\lPostLoad\\l;"; - else if (Loc.getAs()) - Out << "\\lPostStore\\l"; - else if (Loc.getAs()) - Out << "\\lPostLValue\\l"; - else if (Loc.getAs()) - Out << "\\lPostAllocatorCall\\l"; + default: { + const Stmt *S = Loc.castAs().getStmt(); + assert(S != nullptr && "Expecting non-null Stmt"); + + Out << S->getStmtClassName() << ' ' << (const void *)S << ' '; + LangOptions LO; // FIXME. + S->printPretty(Out, nullptr, PrintingPolicy(LO)); + printLocation(Out, S->getBeginLoc()); + + if (Loc.getAs()) + Out << "\\lPreStmt\\l;"; + else if (Loc.getAs()) + Out << "\\lPostLoad\\l;"; + else if (Loc.getAs()) + Out << "\\lPostStore\\l"; + else if (Loc.getAs()) + Out << "\\lPostLValue\\l"; + else if (Loc.getAs()) + Out << "\\lPostAllocatorCall\\l"; - break; - } + break; } + } + } + + static std::string getNodeLabel(const ExplodedNode *N, void*){ + std::string sbuf; + llvm::raw_string_ostream Out(sbuf); + + // Program Location. + ProgramPoint Loc = N->getLocation(); + + dumpProgramPoint(Loc, Out); ProgramStateRef state = N->getState(); ExplodedGraph &Graph =