Index: cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h =================================================================== --- cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h +++ cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h @@ -227,17 +227,23 @@ AnalysisDeclContext *Ctx; const LocationContext *Parent; + int64_t ID; protected: LocationContext(ContextKind k, AnalysisDeclContext *ctx, - const LocationContext *parent) - : Kind(k), Ctx(ctx), Parent(parent) {} + const LocationContext *parent, + int64_t ID) + : Kind(k), Ctx(ctx), Parent(parent), ID(ID) {} public: virtual ~LocationContext(); ContextKind getKind() const { return Kind; } + int64_t getID() const { + return ID; + } + AnalysisDeclContext *getAnalysisDeclContext() const { return Ctx; } const LocationContext *getParent() const { return Parent; } @@ -297,8 +303,9 @@ StackFrameContext(AnalysisDeclContext *ctx, const LocationContext *parent, const Stmt *s, const CFGBlock *blk, - unsigned idx) - : LocationContext(StackFrame, ctx, parent), CallSite(s), + unsigned idx, + int64_t ID) + : LocationContext(StackFrame, ctx, parent, ID), CallSite(s), Block(blk), Index(idx) {} public: @@ -334,8 +341,8 @@ const Stmt *Enter; ScopeContext(AnalysisDeclContext *ctx, const LocationContext *parent, - const Stmt *s) - : LocationContext(Scope, ctx, parent), Enter(s) {} + const Stmt *s, int64_t ID) + : LocationContext(Scope, ctx, parent, ID), Enter(s) {} public: ~ScopeContext() override = default; @@ -361,9 +368,10 @@ const void *ContextData; BlockInvocationContext(AnalysisDeclContext *ctx, - const LocationContext *parent, - const BlockDecl *bd, const void *contextData) - : LocationContext(Block, ctx, parent), BD(bd), ContextData(contextData) {} + const LocationContext *parent, const BlockDecl *bd, + const void *contextData, int64_t ID) + : LocationContext(Block, ctx, parent, ID), BD(bd), + ContextData(contextData) {} public: ~BlockInvocationContext() override = default; @@ -389,6 +397,9 @@ class LocationContextManager { llvm::FoldingSet Contexts; + /// ID used for generating a new location context. + int64_t NewID = 0; + public: ~LocationContextManager(); Index: cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp =================================================================== --- cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp +++ cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp @@ -385,7 +385,7 @@ LOC *L = cast_or_null(Contexts.FindNodeOrInsertPos(ID, InsertPos)); if (!L) { - L = new LOC(ctx, parent, d); + L = new LOC(ctx, parent, d, ++NewID); Contexts.InsertNode(L, InsertPos); } return L; @@ -402,7 +402,7 @@ auto *L = cast_or_null(Contexts.FindNodeOrInsertPos(ID, InsertPos)); if (!L) { - L = new StackFrameContext(ctx, parent, s, blk, idx); + L = new StackFrameContext(ctx, parent, s, blk, idx, ++NewID); Contexts.InsertNode(L, InsertPos); } return L; @@ -427,7 +427,7 @@ cast_or_null(Contexts.FindNodeOrInsertPos(ID, InsertPos)); if (!L) { - L = new BlockInvocationContext(ctx, parent, BD, ContextData); + L = new BlockInvocationContext(ctx, parent, BD, ContextData, ++NewID); Contexts.InsertNode(L, InsertPos); } return L; Index: cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp @@ -235,8 +235,8 @@ const Stmt *S = I.first.getStmt(); assert(S != nullptr && "Expected non-null Stmt"); - Out << "(LC" << (const void *)LC << ", S" << S->getID(Context) << " <" - << (const void *)S << "> ) "; + Out << "(LC " << LC->getID() << " <" << (const void *)LC << ">, S " + << S->getID(Context) << " <" << (const void *)S << ">) "; S->printPretty(Out, /*Helper=*/nullptr, PP); Out << " : " << I.second << NL; }