зеркало из https://github.com/microsoft/clang-1.git
Added two new command line arguments:
-cfg-add-implicit-dtors - sets CFG::BuildOptions::AddImplicitDtors for AnalysisCosumer to true, -cfg-add-initializers - sets CFG::BuildOptions::AddInitializers for AnalysisCosumer to true. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115142 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
4f2b10b24b
Коммит
9121ba2329
|
@ -56,15 +56,20 @@ class AnalysisContext {
|
|||
llvm::BumpPtrAllocator A;
|
||||
bool UseUnoptimizedCFG;
|
||||
bool AddEHEdges;
|
||||
bool AddImplicitDtors;
|
||||
bool AddInitializers;
|
||||
public:
|
||||
AnalysisContext(const Decl *d, idx::TranslationUnit *tu,
|
||||
bool useUnoptimizedCFG = false,
|
||||
bool addehedges = false)
|
||||
bool addehedges = false,
|
||||
bool addImplicitDtors = false,
|
||||
bool addInitializers = false)
|
||||
: D(d), TU(tu), cfg(0), completeCFG(0),
|
||||
builtCFG(false), builtCompleteCFG(false),
|
||||
liveness(0), relaxedLiveness(0), PM(0), PCA(0),
|
||||
ReferencedBlockVars(0), UseUnoptimizedCFG(useUnoptimizedCFG),
|
||||
AddEHEdges(addehedges) {}
|
||||
AddEHEdges(addehedges), AddImplicitDtors(addImplicitDtors),
|
||||
AddInitializers(addInitializers) {}
|
||||
|
||||
~AnalysisContext();
|
||||
|
||||
|
@ -80,6 +85,8 @@ public:
|
|||
bool getAddEHEdges() const { return AddEHEdges; }
|
||||
|
||||
bool getUseUnoptimizedCFG() const { return UseUnoptimizedCFG; }
|
||||
bool getAddImplicitDtors() const { return AddImplicitDtors; }
|
||||
bool getAddInitializers() const { return AddInitializers; }
|
||||
|
||||
Stmt *getBody();
|
||||
CFG *getCFG();
|
||||
|
@ -106,15 +113,21 @@ class AnalysisContextManager {
|
|||
typedef llvm::DenseMap<const Decl*, AnalysisContext*> ContextMap;
|
||||
ContextMap Contexts;
|
||||
bool UseUnoptimizedCFG;
|
||||
bool AddImplicitDtors;
|
||||
bool AddInitializers;
|
||||
public:
|
||||
AnalysisContextManager(bool useUnoptimizedCFG = false)
|
||||
: UseUnoptimizedCFG(useUnoptimizedCFG) {}
|
||||
AnalysisContextManager(bool useUnoptimizedCFG = false,
|
||||
bool addImplicitDtors = false, bool addInitializers = false)
|
||||
: UseUnoptimizedCFG(useUnoptimizedCFG), AddImplicitDtors(addImplicitDtors),
|
||||
AddInitializers(addInitializers) {}
|
||||
|
||||
~AnalysisContextManager();
|
||||
|
||||
AnalysisContext *getContext(const Decl *D, idx::TranslationUnit *TU = 0);
|
||||
|
||||
bool getUseUnoptimizedCFG() const { return UseUnoptimizedCFG; }
|
||||
bool getAddImplicitDtors() const { return AddImplicitDtors; }
|
||||
bool getAddInitializers() const { return AddInitializers; }
|
||||
|
||||
// Discard all previously created AnalysisContexts.
|
||||
void clear();
|
||||
|
|
|
@ -76,10 +76,11 @@ public:
|
|||
idx::Indexer *idxer,
|
||||
unsigned maxnodes, unsigned maxvisit,
|
||||
bool vizdot, bool vizubi, bool purge, bool eager, bool trim,
|
||||
bool inlinecall, bool useUnoptimizedCFG)
|
||||
bool inlinecall, bool useUnoptimizedCFG,
|
||||
bool addImplicitDtors, bool addInitializers)
|
||||
|
||||
: AnaCtxMgr(useUnoptimizedCFG), Ctx(ctx), Diags(diags), LangInfo(lang),
|
||||
PD(pd),
|
||||
: AnaCtxMgr(useUnoptimizedCFG, addImplicitDtors, addInitializers),
|
||||
Ctx(ctx), Diags(diags), LangInfo(lang), PD(pd),
|
||||
CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr),Idxer(idxer),
|
||||
AScope(ScopeDecl), MaxNodes(maxnodes), MaxVisit(maxvisit),
|
||||
VisualizeEGDot(vizdot), VisualizeEGUbi(vizubi), PurgeDead(purge),
|
||||
|
|
|
@ -42,6 +42,10 @@ def analysis_CFGView : Flag<"-cfg-view">,
|
|||
HelpText<"View Control-Flow Graphs using GraphViz">;
|
||||
def analysis_UnoptimizedCFG : Flag<"-unoptimized-cfg">,
|
||||
HelpText<"Generate unoptimized CFGs for all analyses">;
|
||||
def analysis_CFGAddImplicitDtors : Flag<"-cfg-add-implicit-dtors">,
|
||||
HelpText<"Add C++ implicit destructors to CFGs for all analyses">;
|
||||
def analysis_CFGAddInitializers : Flag<"-cfg-add-initializers">,
|
||||
HelpText<"Add C++ initializers to CFGs for all analyses">;
|
||||
def analysis_DisplayLiveVariables : Flag<"-dump-live-variables">,
|
||||
HelpText<"Print results of live variable analysis">;
|
||||
def analysis_LLVMConventionChecker : Flag<"-analyzer-check-llvm-conventions">,
|
||||
|
|
|
@ -76,6 +76,8 @@ public:
|
|||
unsigned EnableExperimentalInternalChecks : 1;
|
||||
unsigned InlineCall : 1;
|
||||
unsigned UnoptimizedCFG : 1;
|
||||
unsigned CFGAddImplicitDtors : 1;
|
||||
unsigned CFGAddInitializers : 1;
|
||||
|
||||
public:
|
||||
AnalyzerOptions() {
|
||||
|
@ -94,6 +96,8 @@ public:
|
|||
EnableExperimentalChecks = 0;
|
||||
EnableExperimentalInternalChecks = 0;
|
||||
UnoptimizedCFG = 0;
|
||||
CFGAddImplicitDtors = 0;
|
||||
CFGAddInitializers = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -61,6 +61,8 @@ CFG *AnalysisContext::getCFG() {
|
|||
if (!builtCFG) {
|
||||
CFG::BuildOptions B;
|
||||
B.AddEHEdges = AddEHEdges;
|
||||
B.AddImplicitDtors = AddImplicitDtors;
|
||||
B.AddInitializers = AddInitializers;
|
||||
cfg = CFG::buildCFG(D, getBody(), &D->getASTContext(), B);
|
||||
// Even when the cfg is not successfully built, we don't
|
||||
// want to try building it again.
|
||||
|
@ -74,6 +76,8 @@ CFG *AnalysisContext::getUnoptimizedCFG() {
|
|||
CFG::BuildOptions B;
|
||||
B.PruneTriviallyFalseEdges = false;
|
||||
B.AddEHEdges = AddEHEdges;
|
||||
B.AddImplicitDtors = AddImplicitDtors;
|
||||
B.AddInitializers = AddInitializers;
|
||||
completeCFG = CFG::buildCFG(D, getBody(), &D->getASTContext(), B);
|
||||
// Even when the cfg is not successfully built, we don't
|
||||
// want to try building it again.
|
||||
|
@ -126,7 +130,8 @@ AnalysisContext *AnalysisContextManager::getContext(const Decl *D,
|
|||
idx::TranslationUnit *TU) {
|
||||
AnalysisContext *&AC = Contexts[D];
|
||||
if (!AC)
|
||||
AC = new AnalysisContext(D, TU, UseUnoptimizedCFG);
|
||||
AC = new AnalysisContext(D, TU, UseUnoptimizedCFG, false,
|
||||
AddImplicitDtors, AddInitializers);
|
||||
|
||||
return AC;
|
||||
}
|
||||
|
|
|
@ -179,7 +179,8 @@ public:
|
|||
Opts.VisualizeEGDot, Opts.VisualizeEGUbi,
|
||||
Opts.PurgeDead, Opts.EagerlyAssume,
|
||||
Opts.TrimGraph, Opts.InlineCall,
|
||||
Opts.UnoptimizedCFG));
|
||||
Opts.UnoptimizedCFG, Opts.CFGAddImplicitDtors,
|
||||
Opts.CFGAddInitializers));
|
||||
}
|
||||
|
||||
virtual void HandleTranslationUnit(ASTContext &C);
|
||||
|
|
|
@ -718,7 +718,9 @@ void GRCallEnterNodeBuilder::GenerateNode(const GRState *state,
|
|||
OldMgr.shouldEagerlyAssume(),
|
||||
OldMgr.shouldTrimGraph(),
|
||||
OldMgr.shouldInlineCall(),
|
||||
OldMgr.getAnalysisContextManager().getUseUnoptimizedCFG());
|
||||
OldMgr.getAnalysisContextManager().getUseUnoptimizedCFG(),
|
||||
OldMgr.getAnalysisContextManager().getAddImplicitDtors(),
|
||||
OldMgr.getAnalysisContextManager().getAddInitializers());
|
||||
llvm::OwningPtr<GRTransferFuncs> TF(MakeCFRefCountTF(AMgr.getASTContext(),
|
||||
/* GCEnabled */ false,
|
||||
AMgr.getLangOptions()));
|
||||
|
|
|
@ -827,6 +827,8 @@ static void ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
|
|||
Opts.EagerlyAssume = Args.hasArg(OPT_analyzer_eagerly_assume);
|
||||
Opts.AnalyzeSpecificFunction = Args.getLastArgValue(OPT_analyze_function);
|
||||
Opts.UnoptimizedCFG = Args.hasArg(OPT_analysis_UnoptimizedCFG);
|
||||
Opts.CFGAddImplicitDtors = Args.hasArg(OPT_analysis_CFGAddImplicitDtors);
|
||||
Opts.CFGAddInitializers = Args.hasArg(OPT_analysis_CFGAddInitializers);
|
||||
Opts.EnableExperimentalChecks = Args.hasArg(OPT_analyzer_experimental_checks);
|
||||
Opts.EnableExperimentalInternalChecks =
|
||||
Args.hasArg(OPT_analyzer_experimental_internal_checks);
|
||||
|
|
Загрузка…
Ссылка в новой задаче