Fixed. Thanks! On Mon, Jul 19, 2010 at 3:31 PM, Daniel Dunbar <[email protected]> wrote: > FYI: > -- > /Users/ddunbar/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp:390:25: > warning: initialization of pointer of type 'idx::TranslationUnit const > *' from literal 'false' [-Wbool-conversions] > AnalysisContext AC(D, false); > ^ > -- > > - Daniel > > On Sun, Jul 18, 2010 at 6:31 PM, Zhongxing Xu <[email protected]> wrote: >> Author: zhongxingxu >> Date: Sun Jul 18 20:31:21 2010 >> New Revision: 108668 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=108668&view=rev >> Log: >> Reapply r108617. >> >> Added: >> cfe/trunk/lib/Checker/AnalysisManager.cpp >> Modified: >> cfe/trunk/examples/wpa/clang-wpa.cpp >> cfe/trunk/include/clang/Analysis/AnalysisContext.h >> cfe/trunk/include/clang/Analysis/ProgramPoint.h >> cfe/trunk/include/clang/Checker/PathSensitive/AnalysisManager.h >> cfe/trunk/include/clang/Checker/PathSensitive/GRCoreEngine.h >> cfe/trunk/lib/Analysis/AnalysisContext.cpp >> cfe/trunk/lib/Checker/AnalysisConsumer.cpp >> cfe/trunk/lib/Checker/CMakeLists.txt >> cfe/trunk/lib/Checker/CallInliner.cpp >> cfe/trunk/lib/Checker/GRCXXExprEngine.cpp >> cfe/trunk/lib/Checker/GRCoreEngine.cpp >> cfe/trunk/lib/Checker/GRExprEngine.cpp >> cfe/trunk/tools/driver/Makefile >> >> Modified: cfe/trunk/examples/wpa/clang-wpa.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/wpa/clang-wpa.cpp?rev=108668&r1=108667&r2=108668&view=diff >> ============================================================================== >> --- cfe/trunk/examples/wpa/clang-wpa.cpp (original) >> +++ cfe/trunk/examples/wpa/clang-wpa.cpp Sun Jul 18 20:31:21 2010 >> @@ -129,7 +129,7 @@ >> AnalysisManager AMgr(TU->getASTContext(), PP.getDiagnostics(), >> PP.getLangOptions(), /* PathDiagnostic */ 0, >> CreateRegionStoreManager, >> - CreateRangeConstraintManager, >> + CreateRangeConstraintManager, &Idxer, >> /* MaxNodes */ 300000, /* MaxLoop */ 3, >> /* VisualizeEG */ false, /* VisualizeEGUbi */ false, >> /* PurgeDead */ true, /* EagerlyAssume */ false, >> @@ -139,7 +139,7 @@ >> AMgr.getLangOptions()); >> GRExprEngine Eng(AMgr, TF); >> >> - Eng.ExecuteWorkList(AMgr.getStackFrame(FD), AMgr.getMaxNodes()); >> + Eng.ExecuteWorkList(AMgr.getStackFrame(FD, TU), AMgr.getMaxNodes()); >> >> return 0; >> } >> >> Modified: cfe/trunk/include/clang/Analysis/AnalysisContext.h >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/AnalysisContext.h?rev=108668&r1=108667&r2=108668&view=diff >> ============================================================================== >> --- cfe/trunk/include/clang/Analysis/AnalysisContext.h (original) >> +++ cfe/trunk/include/clang/Analysis/AnalysisContext.h Sun Jul 18 20:31:21 >> 2010 >> @@ -34,11 +34,16 @@ >> class LocationContextManager; >> class StackFrameContext; >> >> +namespace idx { class TranslationUnit; } >> + >> /// AnalysisContext contains the context data for the function or method >> under >> /// analysis. >> class AnalysisContext { >> const Decl *D; >> >> + // TranslationUnit is NULL if we don't have multiple translation units. >> + const idx::TranslationUnit *TU; >> + >> // AnalysisContext owns the following data. >> CFG *cfg; >> bool builtCFG; >> @@ -48,14 +53,18 @@ >> llvm::BumpPtrAllocator A; >> bool AddEHEdges; >> public: >> - AnalysisContext(const Decl *d, bool addehedges = false) >> - : D(d), cfg(0), builtCFG(false), liveness(0), PM(0), >> + AnalysisContext(const Decl *d, const idx::TranslationUnit *tu, >> + bool addehedges = false) >> + : D(d), TU(tu), cfg(0), builtCFG(false), liveness(0), PM(0), >> ReferencedBlockVars(0), AddEHEdges(addehedges) {} >> >> ~AnalysisContext(); >> >> ASTContext &getASTContext() { return D->getASTContext(); } >> - const Decl *getDecl() { return D; } >> + const Decl *getDecl() const { return D; } >> + >> + const idx::TranslationUnit *getTranslationUnit() const { return TU; } >> + >> /// getAddEHEdges - Return true iff we are adding exceptional edges from >> /// callExprs. If this is false, then try/catch statements and blocks >> /// reachable from them can appear to be dead in the CFG, analysis passes >> must >> @@ -82,7 +91,7 @@ >> public: >> ~AnalysisContextManager(); >> >> - AnalysisContext *getContext(const Decl *D); >> + AnalysisContext *getContext(const Decl *D,const idx::TranslationUnit *TU >> = 0); >> >> // Discard all previously created AnalysisContexts. >> void clear(); >> @@ -109,6 +118,10 @@ >> >> AnalysisContext *getAnalysisContext() const { return Ctx; } >> >> + const idx::TranslationUnit *getTranslationUnit() const { >> + return Ctx->getTranslationUnit(); >> + } >> + >> const LocationContext *getParent() const { return Parent; } >> >> bool isParentOf(const LocationContext *LC) const; >> >> Modified: cfe/trunk/include/clang/Analysis/ProgramPoint.h >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/ProgramPoint.h?rev=108668&r1=108667&r2=108668&view=diff >> ============================================================================== >> --- cfe/trunk/include/clang/Analysis/ProgramPoint.h (original) >> +++ cfe/trunk/include/clang/Analysis/ProgramPoint.h Sun Jul 18 20:31:21 2010 >> @@ -15,6 +15,7 @@ >> #ifndef LLVM_CLANG_ANALYSIS_PROGRAM_POINT >> #define LLVM_CLANG_ANALYSIS_PROGRAM_POINT >> >> +#include "clang/Analysis/AnalysisContext.h" >> #include "clang/Analysis/CFG.h" >> #include "llvm/System/DataTypes.h" >> #include "llvm/ADT/DenseMap.h" >> @@ -26,6 +27,7 @@ >> namespace clang { >> >> class LocationContext; >> +class AnalysisContext; >> class FunctionDecl; >> >> class ProgramPoint { >> @@ -313,16 +315,16 @@ >> >> class CallEnter : public StmtPoint { >> public: >> - // CallEnter uses the caller's location context. >> - CallEnter(const Stmt *S, const FunctionDecl *fd, const LocationContext *L) >> - : StmtPoint(S, fd, CallEnterKind, L, 0) {} >> + // L is caller's location context. AC is callee's AnalysisContext. >> + CallEnter(const Stmt *S, const AnalysisContext *AC, const LocationContext >> *L) >> + : StmtPoint(S, AC, CallEnterKind, L, 0) {} >> >> const Stmt *getCallExpr() const { >> return static_cast<const Stmt *>(getData1()); >> } >> >> - const FunctionDecl *getCallee() const { >> - return static_cast<const FunctionDecl *>(getData2()); >> + const AnalysisContext *getCalleeContext() const { >> + return static_cast<const AnalysisContext *>(getData2()); >> } >> >> static bool classof(const ProgramPoint *Location) { >> >> Modified: cfe/trunk/include/clang/Checker/PathSensitive/AnalysisManager.h >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/AnalysisManager.h?rev=108668&r1=108667&r2=108668&view=diff >> ============================================================================== >> --- cfe/trunk/include/clang/Checker/PathSensitive/AnalysisManager.h >> (original) >> +++ cfe/trunk/include/clang/Checker/PathSensitive/AnalysisManager.h Sun Jul >> 18 20:31:21 2010 >> @@ -21,6 +21,11 @@ >> >> namespace clang { >> >> +namespace idx { >> + class Indexer; >> + class TranslationUnit; >> +} >> + >> class AnalysisManager : public BugReporterData { >> AnalysisContextManager AnaCtxMgr; >> LocationContextManager LocCtxMgr; >> @@ -35,6 +40,11 @@ >> StoreManagerCreator CreateStoreMgr; >> ConstraintManagerCreator CreateConstraintMgr; >> >> + /// \brief Provide function definitions in other translation units. This >> is >> + /// NULL if we don't have multiple translation units. AnalysisManager does >> + /// not own the Indexer. >> + idx::Indexer *Idxer; >> + >> enum AnalysisScope { ScopeTU, ScopeDecl } AScope; >> >> // The maximum number of exploded nodes the analyzer will generate. >> @@ -62,13 +72,14 @@ >> AnalysisManager(ASTContext &ctx, Diagnostic &diags, >> const LangOptions &lang, PathDiagnosticClient *pd, >> StoreManagerCreator storemgr, >> - ConstraintManagerCreator constraintmgr, unsigned maxnodes, >> - unsigned maxloop, >> + ConstraintManagerCreator constraintmgr, >> + idx::Indexer *idxer, >> + unsigned maxnodes, unsigned maxloop, >> bool vizdot, bool vizubi, bool purge, bool eager, bool >> trim, >> bool inlinecall) >> >> : Ctx(ctx), Diags(diags), LangInfo(lang), PD(pd), >> - CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr), >> + CreateStoreMgr(storemgr), >> CreateConstraintMgr(constraintmgr),Idxer(idxer), >> AScope(ScopeDecl), MaxNodes(maxnodes), MaxLoop(maxloop), >> VisualizeEGDot(vizdot), VisualizeEGUbi(vizubi), PurgeDead(purge), >> EagerlyAssume(eager), TrimGraph(trim), InlineCall(inlinecall) {} >> @@ -133,6 +144,10 @@ >> >> bool shouldInlineCall() const { return InlineCall; } >> >> + bool hasIndexer() const { return Idxer != 0; } >> + >> + const AnalysisContext *getAnalysisContextInAnotherTU(const Decl *D); >> + >> CFG *getCFG(Decl const *D) { >> return AnaCtxMgr.getContext(D)->getCFG(); >> } >> @@ -145,9 +160,21 @@ >> return AnaCtxMgr.getContext(D)->getParentMap(); >> } >> >> + const AnalysisContext *getAnalysisContext(const Decl *D) { >> + return AnaCtxMgr.getContext(D); >> + } >> + >> + const StackFrameContext *getStackFrame(AnalysisContext *Ctx, >> + LocationContext const *Parent, >> + Stmt const *S, const CFGBlock *Blk, >> + unsigned Idx) { >> + return LocCtxMgr.getStackFrame(Ctx, Parent, S, Blk, Idx); >> + } >> + >> // Get the top level stack frame. >> - const StackFrameContext *getStackFrame(Decl const *D) { >> - return LocCtxMgr.getStackFrame(AnaCtxMgr.getContext(D), 0, 0, 0, 0); >> + const StackFrameContext *getStackFrame(Decl const *D, >> + const idx::TranslationUnit *TU) { >> + return LocCtxMgr.getStackFrame(AnaCtxMgr.getContext(D, TU), 0, 0, 0, 0); >> } >> >> // Get a stack frame with parent. >> >> Modified: cfe/trunk/include/clang/Checker/PathSensitive/GRCoreEngine.h >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/GRCoreEngine.h?rev=108668&r1=108667&r2=108668&view=diff >> ============================================================================== >> --- cfe/trunk/include/clang/Checker/PathSensitive/GRCoreEngine.h (original) >> +++ cfe/trunk/include/clang/Checker/PathSensitive/GRCoreEngine.h Sun Jul 18 >> 20:31:21 2010 >> @@ -442,8 +442,8 @@ >> // The call site. >> const Stmt *CE; >> >> - // The definition of callee. >> - const FunctionDecl *FD; >> + // The AnalysisContext of the callee. >> + const AnalysisContext *CalleeCtx; >> >> // The parent block of the CallExpr. >> const CFGBlock *Block; >> @@ -453,9 +453,9 @@ >> >> public: >> GRCallEnterNodeBuilder(GRCoreEngine &eng, const ExplodedNode *pred, >> - const Stmt *s, const FunctionDecl *fd, >> + const Stmt *s, const AnalysisContext *callee, >> const CFGBlock *blk, unsigned idx) >> - : Eng(eng), Pred(pred), CE(s), FD(fd), Block(blk), Index(idx) {} >> + : Eng(eng), Pred(pred), CE(s), CalleeCtx(callee), Block(blk), >> Index(idx) {} >> >> const GRState *getState() const { return Pred->getState(); } >> >> @@ -465,7 +465,7 @@ >> >> const Stmt *getCallExpr() const { return CE; } >> >> - const FunctionDecl *getCallee() const { return FD; } >> + const AnalysisContext *getCalleeContext() const { return CalleeCtx; } >> >> const CFGBlock *getBlock() const { return Block; } >> >> >> Modified: cfe/trunk/lib/Analysis/AnalysisContext.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/AnalysisContext.cpp?rev=108668&r1=108667&r2=108668&view=diff >> ============================================================================== >> --- cfe/trunk/lib/Analysis/AnalysisContext.cpp (original) >> +++ cfe/trunk/lib/Analysis/AnalysisContext.cpp Sun Jul 18 20:31:21 2010 >> @@ -83,10 +83,11 @@ >> return liveness; >> } >> >> -AnalysisContext *AnalysisContextManager::getContext(const Decl *D) { >> +AnalysisContext *AnalysisContextManager::getContext(const Decl *D, >> + const idx::TranslationUnit >> *TU) { >> AnalysisContext *&AC = Contexts[D]; >> if (!AC) >> - AC = new AnalysisContext(D); >> + AC = new AnalysisContext(D, TU); >> >> return AC; >> } >> >> Modified: cfe/trunk/lib/Checker/AnalysisConsumer.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/AnalysisConsumer.cpp?rev=108668&r1=108667&r2=108668&view=diff >> ============================================================================== >> --- cfe/trunk/lib/Checker/AnalysisConsumer.cpp (original) >> +++ cfe/trunk/lib/Checker/AnalysisConsumer.cpp Sun Jul 18 20:31:21 2010 >> @@ -173,6 +173,7 @@ >> Mgr.reset(new AnalysisManager(*Ctx, PP.getDiagnostics(), >> PP.getLangOptions(), PD, >> CreateStoreMgr, CreateConstraintMgr, >> + /* Indexer */ 0, >> Opts.MaxNodes, Opts.MaxLoop, >> Opts.VisualizeEGDot, Opts.VisualizeEGUbi, >> Opts.PurgeDead, Opts.EagerlyAssume, >> @@ -349,7 +350,7 @@ >> } >> >> // Execute the worklist algorithm. >> - Eng.ExecuteWorkList(mgr.getStackFrame(D), mgr.getMaxNodes()); >> + Eng.ExecuteWorkList(mgr.getStackFrame(D, 0), mgr.getMaxNodes()); >> >> // Release the auditor (if any) so that it doesn't monitor the graph >> // created BugReporter. >> >> Added: cfe/trunk/lib/Checker/AnalysisManager.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/AnalysisManager.cpp?rev=108668&view=auto >> ============================================================================== >> --- cfe/trunk/lib/Checker/AnalysisManager.cpp (added) >> +++ cfe/trunk/lib/Checker/AnalysisManager.cpp Sun Jul 18 20:31:21 2010 >> @@ -0,0 +1,31 @@ >> +//===-- AnalysisManager.cpp -------------------------------------*- C++ >> -*-===// >> +// >> +// The LLVM Compiler Infrastructure >> +// >> +// This file is distributed under the University of Illinois Open Source >> +// License. See LICENSE.TXT for details. >> +// >> +//===----------------------------------------------------------------------===// >> + >> +#include "clang/Checker/PathSensitive/AnalysisManager.h" >> +#include "clang/Index/Entity.h" >> +#include "clang/Index/Indexer.h" >> + >> +using namespace clang; >> + >> +const AnalysisContext * >> +AnalysisManager::getAnalysisContextInAnotherTU(const Decl *D) { >> + idx::Entity Ent = idx::Entity::get(const_cast<Decl *>(D), >> + Idxer->getProgram()); >> + FunctionDecl *FuncDef; >> + idx::TranslationUnit *TU; >> + llvm::tie(FuncDef, TU) = Idxer->getDefinitionFor(Ent); >> + >> + if (FuncDef == 0) >> + return 0; >> + >> + // This AnalysisContext wraps function definition in another translation >> unit. >> + // But it is still owned by the AnalysisManager associated with the >> current >> + // translation unit. >> + return AnaCtxMgr.getContext(FuncDef, TU); >> +} >> >> Modified: cfe/trunk/lib/Checker/CMakeLists.txt >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/CMakeLists.txt?rev=108668&r1=108667&r2=108668&view=diff >> ============================================================================== >> --- cfe/trunk/lib/Checker/CMakeLists.txt (original) >> +++ cfe/trunk/lib/Checker/CMakeLists.txt Sun Jul 18 20:31:21 2010 >> @@ -4,6 +4,7 @@ >> AdjustedReturnValueChecker.cpp >> AggExprVisitor.cpp >> AnalysisConsumer.cpp >> + AnalysisManager.cpp >> ArrayBoundChecker.cpp >> AttrNonNullChecker.cpp >> BasicConstraintManager.cpp >> @@ -15,7 +16,6 @@ >> BuiltinFunctionChecker.cpp >> CFRefCount.cpp >> CallAndMessageChecker.cpp >> - CallInliner.cpp >> CastSizeChecker.cpp >> CastToStructChecker.cpp >> CheckDeadStores.cpp >> >> Modified: cfe/trunk/lib/Checker/CallInliner.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/CallInliner.cpp?rev=108668&r1=108667&r2=108668&view=diff >> ============================================================================== >> --- cfe/trunk/lib/Checker/CallInliner.cpp (original) >> +++ cfe/trunk/lib/Checker/CallInliner.cpp Sun Jul 18 20:31:21 2010 >> @@ -1,54 +0,0 @@ >> -//===--- CallInliner.cpp - Transfer function that inlines callee >> ----------===// >> -// >> -// The LLVM Compiler Infrastructure >> -// >> -// This file is distributed under the University of Illinois Open Source >> -// License. See LICENSE.TXT for details. >> -// >> -//===----------------------------------------------------------------------===// >> -// >> -// This file implements the callee inlining transfer function. >> -// >> -//===----------------------------------------------------------------------===// >> - >> -#include "clang/Checker/PathSensitive/CheckerVisitor.h" >> -#include "clang/Checker/PathSensitive/GRState.h" >> -#include "clang/Checker/Checkers/LocalCheckers.h" >> - >> -using namespace clang; >> - >> -namespace { >> -class CallInliner : public Checker { >> -public: >> - static void *getTag() { >> - static int x; >> - return &x; >> - } >> - >> - virtual bool EvalCallExpr(CheckerContext &C, const CallExpr *CE); >> -}; >> -} >> - >> -void clang::RegisterCallInliner(GRExprEngine &Eng) { >> - Eng.registerCheck(new CallInliner()); >> -} >> - >> -bool CallInliner::EvalCallExpr(CheckerContext &C, const CallExpr *CE) { >> - const GRState *state = C.getState(); >> - const Expr *Callee = CE->getCallee(); >> - SVal L = state->getSVal(Callee); >> - >> - const FunctionDecl *FD = L.getAsFunctionDecl(); >> - if (!FD) >> - return false; >> - >> - if (!FD->hasBody(FD)) >> - return false; >> - >> - // Now we have the definition of the callee, create a CallEnter node. >> - CallEnter Loc(CE, FD, C.getPredecessor()->getLocationContext()); >> - C.addTransition(state, Loc); >> - >> - return true; >> -} >> - >> >> Modified: cfe/trunk/lib/Checker/GRCXXExprEngine.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRCXXExprEngine.cpp?rev=108668&r1=108667&r2=108668&view=diff >> ============================================================================== >> --- cfe/trunk/lib/Checker/GRCXXExprEngine.cpp (original) >> +++ cfe/trunk/lib/Checker/GRCXXExprEngine.cpp Sun Jul 18 20:31:21 2010 >> @@ -104,7 +104,7 @@ >> >> const CXXThisRegion *ThisR = getCXXThisRegion(E->getConstructor(), SFC); >> >> - CallEnter Loc(E, CD, Pred->getLocationContext()); >> + CallEnter Loc(E, SFC->getAnalysisContext(), Pred->getLocationContext()); >> for (ExplodedNodeSet::iterator NI = ArgsEvaluated.begin(), >> NE = ArgsEvaluated.end(); NI != NE; ++NI) { >> const GRState *state = GetState(*NI); >> @@ -157,7 +157,7 @@ >> Builder->getBlock(), >> Builder->getIndex()); >> const CXXThisRegion *ThisR = getCXXThisRegion(MD, SFC); >> - CallEnter Loc(MCE, MD, Pred->getLocationContext()); >> + CallEnter Loc(MCE, SFC->getAnalysisContext(), Pred->getLocationContext()); >> for (ExplodedNodeSet::iterator I = AllArgsEvaluated.begin(), >> E = AllArgsEvaluated.end(); I != E; ++I) { >> // Set up 'this' region. >> >> Modified: cfe/trunk/lib/Checker/GRCoreEngine.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRCoreEngine.cpp?rev=108668&r1=108667&r2=108668&view=diff >> ============================================================================== >> --- cfe/trunk/lib/Checker/GRCoreEngine.cpp (original) >> +++ cfe/trunk/lib/Checker/GRCoreEngine.cpp Sun Jul 18 20:31:21 2010 >> @@ -227,8 +227,8 @@ >> >> void GRCoreEngine::HandleCallEnter(const CallEnter &L, const CFGBlock >> *Block, >> unsigned Index, ExplodedNode *Pred) { >> - GRCallEnterNodeBuilder Builder(*this, Pred, L.getCallExpr(), >> L.getCallee(), >> - Block, Index); >> + GRCallEnterNodeBuilder Builder(*this, Pred, L.getCallExpr(), >> + L.getCalleeContext(), Block, Index); >> ProcessCallEnter(Builder); >> } >> >> @@ -692,6 +692,12 @@ >> >> void GRCallEnterNodeBuilder::GenerateNode(const GRState *state, >> const LocationContext *LocCtx) { >> + // Check if the callee is in the same translation unit. >> + if (CalleeCtx->getTranslationUnit() != >> + Pred->getLocationContext()->getTranslationUnit()) { >> + assert(0 && "to be implemented"); >> + } >> + >> // Get the callee entry block. >> const CFGBlock *Entry = &(LocCtx->getCFG()->getEntry()); >> assert(Entry->empty()); >> >> Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=108668&r1=108667&r2=108668&view=diff >> ============================================================================== >> --- cfe/trunk/lib/Checker/GRExprEngine.cpp (original) >> +++ cfe/trunk/lib/Checker/GRExprEngine.cpp Sun Jul 18 20:31:21 2010 >> @@ -1441,12 +1441,12 @@ >> } >> >> void GRExprEngine::ProcessCallEnter(GRCallEnterNodeBuilder &B) { >> - const FunctionDecl *FD = B.getCallee(); >> - const StackFrameContext *LocCtx = AMgr.getStackFrame(FD, >> - >> B.getLocationContext(), >> - B.getCallExpr(), >> - B.getBlock(), >> - B.getIndex()); >> + const StackFrameContext *LocCtx >> + = AMgr.getStackFrame(const_cast<AnalysisContext >> *>(B.getCalleeContext()), >> + B.getLocationContext(), >> + B.getCallExpr(), >> + B.getBlock(), >> + B.getIndex()); >> >> const GRState *state = B.getState(); >> state = getStoreManager().EnterStackFrame(state, LocCtx); >> @@ -1886,16 +1886,29 @@ >> if (!FD) >> return false; >> >> - if (!FD->hasBody(FD)) >> - return false; >> + // Check if the function definition is in the same translation unit. >> + if (FD->hasBody(FD)) { >> + // Now we have the definition of the callee, create a CallEnter node. >> + CallEnter Loc(CE, AMgr.getAnalysisContext(FD), >> Pred->getLocationContext()); >> + >> + ExplodedNode *N = Builder->generateNode(Loc, state, Pred); >> + Dst.Add(N); >> + return true; >> + } >> >> - // Now we have the definition of the callee, create a CallEnter node. >> - CallEnter Loc(CE, FD, Pred->getLocationContext()); >> + // Check if we can find the function definition in other translation >> units. >> + if (AMgr.hasIndexer()) { >> + const AnalysisContext *C = AMgr.getAnalysisContextInAnotherTU(FD); >> + if (C == 0) >> + return false; >> >> - ExplodedNode *N = Builder->generateNode(Loc, state, Pred); >> - if (N) >> + CallEnter Loc(CE, C, Pred->getLocationContext()); >> + ExplodedNode *N = Builder->generateNode(Loc, state, Pred); >> Dst.Add(N); >> - return true; >> + return true; >> + } >> + >> + return false; >> } >> >> void GRExprEngine::VisitCall(CallExpr* CE, ExplodedNode* Pred, >> >> Modified: cfe/trunk/tools/driver/Makefile >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/Makefile?rev=108668&r1=108667&r2=108668&view=diff >> ============================================================================== >> --- cfe/trunk/tools/driver/Makefile (original) >> +++ cfe/trunk/tools/driver/Makefile Sun Jul 18 20:31:21 2010 >> @@ -28,8 +28,8 @@ >> LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader bitwriter >> codegen \ >> ipo selectiondag >> USEDLIBS = clangFrontend.a clangDriver.a clangCodeGen.a clangSema.a \ >> - clangChecker.a clangAnalysis.a clangRewrite.a clangAST.a \ >> - clangParse.a clangLex.a clangBasic.a >> + clangChecker.a clangAnalysis.a clangIndex.a clangRewrite.a \ >> + clangAST.a clangParse.a clangLex.a clangBasic.a >> >> include $(CLANG_LEVEL)/Makefile >> >> >> >> _______________________________________________ >> cfe-commits mailing list >> [email protected] >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >> >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
