[cfe-commits] r110087 - in /cfe/trunk: include/clang/Analysis/AnalysisContext.h include/clang/Checker/PathSensitive/AnalysisManager.h include/clang/Driver/CC1Options.td include/clang/Frontend/AnalyzerOptions.h lib/Analysis/AnalysisContext.cpp lib/Checker/AnalysisConsumer.cpp lib/Checker/GRCoreEngine.cpp lib/Frontend/CompilerInvocation.cpp
Ted Kremenek
kremenek at apple.com
Mon Aug 2 17:09:51 PDT 2010
Author: kremenek
Date: Mon Aug 2 19:09:51 2010
New Revision: 110087
URL: http://llvm.org/viewvc/llvm-project?rev=110087&view=rev
Log:
Add -cc1 option '-unoptimized-cfg' to toggle using a CFG (for static analysis) that doesn't prune CFG edges.
Modified:
cfe/trunk/include/clang/Analysis/AnalysisContext.h
cfe/trunk/include/clang/Checker/PathSensitive/AnalysisManager.h
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/AnalyzerOptions.h
cfe/trunk/lib/Analysis/AnalysisContext.cpp
cfe/trunk/lib/Checker/AnalysisConsumer.cpp
cfe/trunk/lib/Checker/GRCoreEngine.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
Modified: cfe/trunk/include/clang/Analysis/AnalysisContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/AnalysisContext.h?rev=110087&r1=110086&r2=110087&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/AnalysisContext.h (original)
+++ cfe/trunk/include/clang/Analysis/AnalysisContext.h Mon Aug 2 19:09:51 2010
@@ -51,14 +51,17 @@
ParentMap *PM;
llvm::DenseMap<const BlockDecl*,void*> *ReferencedBlockVars;
llvm::BumpPtrAllocator A;
+ bool UseUnoptimizedCFG;
bool AddEHEdges;
public:
AnalysisContext(const Decl *d, idx::TranslationUnit *tu,
+ bool useUnoptimizedCFG = false,
bool addehedges = false)
: D(d), TU(tu), cfg(0), completeCFG(0),
builtCFG(false), builtCompleteCFG(false),
liveness(0), PM(0),
- ReferencedBlockVars(0), AddEHEdges(addehedges) {}
+ ReferencedBlockVars(0), UseUnoptimizedCFG(useUnoptimizedCFG),
+ AddEHEdges(addehedges) {}
~AnalysisContext();
@@ -72,6 +75,9 @@
/// reachable from them can appear to be dead in the CFG, analysis passes must
/// cope with that.
bool getAddEHEdges() const { return AddEHEdges; }
+
+ bool getUseUnoptimizedCFG() const { return UseUnoptimizedCFG; }
+
Stmt *getBody();
CFG *getCFG();
@@ -94,11 +100,17 @@
class AnalysisContextManager {
typedef llvm::DenseMap<const Decl*, AnalysisContext*> ContextMap;
ContextMap Contexts;
+ bool UseUnoptimizedCFG;
public:
+ AnalysisContextManager(bool useUnoptimizedCFG = false)
+ : UseUnoptimizedCFG(useUnoptimizedCFG) {}
+
~AnalysisContextManager();
AnalysisContext *getContext(const Decl *D, idx::TranslationUnit *TU = 0);
+ bool getUseUnoptimizedCFG() const { return UseUnoptimizedCFG; }
+
// Discard all previously created AnalysisContexts.
void clear();
};
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=110087&r1=110086&r2=110087&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/AnalysisManager.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/AnalysisManager.h Mon Aug 2 19:09:51 2010
@@ -76,9 +76,10 @@
idx::Indexer *idxer,
unsigned maxnodes, unsigned maxloop,
bool vizdot, bool vizubi, bool purge, bool eager, bool trim,
- bool inlinecall)
+ bool inlinecall, bool useUnoptimizedCFG)
- : Ctx(ctx), Diags(diags), LangInfo(lang), PD(pd),
+ : AnaCtxMgr(useUnoptimizedCFG), Ctx(ctx), Diags(diags), LangInfo(lang),
+ PD(pd),
CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr),Idxer(idxer),
AScope(ScopeDecl), MaxNodes(maxnodes), MaxLoop(maxloop),
VisualizeEGDot(vizdot), VisualizeEGUbi(vizubi), PurgeDead(purge),
@@ -90,6 +91,10 @@
LocCtxMgr.clear();
AnaCtxMgr.clear();
}
+
+ AnalysisContextManager& getAnalysisContextManager() {
+ return AnaCtxMgr;
+ }
StoreManagerCreator getStoreManagerCreator() {
return CreateStoreMgr;
Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=110087&r1=110086&r2=110087&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Aug 2 19:09:51 2010
@@ -38,6 +38,8 @@
HelpText<"Display Control-Flow Graphs">;
def analysis_CFGView : Flag<"-cfg-view">,
HelpText<"View Control-Flow Graphs using GraphViz">;
+def analysis_UnoptimizedCFG : Flag<"-unoptimized-cfg">,
+ HelpText<"View Control-Flow Graphs using GraphViz">;
def analysis_DisplayLiveVariables : Flag<"-dump-live-variables">,
HelpText<"Print results of live variable analysis">;
def analysis_LLVMConventionChecker : Flag<"-analyzer-check-llvm-conventions">,
Modified: cfe/trunk/include/clang/Frontend/AnalyzerOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/AnalyzerOptions.h?rev=110087&r1=110086&r2=110087&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/AnalyzerOptions.h Mon Aug 2 19:09:51 2010
@@ -74,6 +74,7 @@
unsigned EnableExperimentalInternalChecks : 1;
unsigned EnableIdempotentOperationChecker : 1;
unsigned InlineCall : 1;
+ unsigned UnoptimizedCFG : 1;
public:
AnalyzerOptions() {
@@ -90,6 +91,7 @@
VisualizeEGUbi = 0;
EnableExperimentalChecks = 0;
EnableExperimentalInternalChecks = 0;
+ UnoptimizedCFG = 0;
}
};
Modified: cfe/trunk/lib/Analysis/AnalysisContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/AnalysisContext.cpp?rev=110087&r1=110086&r2=110087&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/AnalysisContext.cpp (original)
+++ cfe/trunk/lib/Analysis/AnalysisContext.cpp Mon Aug 2 19:09:51 2010
@@ -54,6 +54,9 @@
}
CFG *AnalysisContext::getCFG() {
+ if (UseUnoptimizedCFG)
+ return getUnoptimizedCFG();
+
if (!builtCFG) {
cfg = CFG::buildCFG(D, getBody(), &D->getASTContext(), true, AddEHEdges);
// Even when the cfg is not successfully built, we don't
@@ -98,7 +101,7 @@
idx::TranslationUnit *TU) {
AnalysisContext *&AC = Contexts[D];
if (!AC)
- AC = new AnalysisContext(D, TU);
+ AC = new AnalysisContext(D, TU, UseUnoptimizedCFG);
return AC;
}
Modified: cfe/trunk/lib/Checker/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/AnalysisConsumer.cpp?rev=110087&r1=110086&r2=110087&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/Checker/AnalysisConsumer.cpp Mon Aug 2 19:09:51 2010
@@ -177,7 +177,8 @@
Opts.MaxNodes, Opts.MaxLoop,
Opts.VisualizeEGDot, Opts.VisualizeEGUbi,
Opts.PurgeDead, Opts.EagerlyAssume,
- Opts.TrimGraph, Opts.InlineCall));
+ Opts.TrimGraph, Opts.InlineCall,
+ Opts.UnoptimizedCFG));
}
virtual void HandleTranslationUnit(ASTContext &C);
Modified: cfe/trunk/lib/Checker/GRCoreEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRCoreEngine.cpp?rev=110087&r1=110086&r2=110087&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRCoreEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRCoreEngine.cpp Mon Aug 2 19:09:51 2010
@@ -708,7 +708,8 @@
OldMgr.shouldPurgeDead(),
OldMgr.shouldEagerlyAssume(),
OldMgr.shouldTrimGraph(),
- OldMgr.shouldInlineCall());
+ OldMgr.shouldInlineCall(),
+ OldMgr.getAnalysisContextManager().getUseUnoptimizedCFG());
llvm::OwningPtr<GRTransferFuncs> TF(MakeCFRefCountTF(AMgr.getASTContext(),
/* GCEnabled */ false,
AMgr.getLangOptions()));
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=110087&r1=110086&r2=110087&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Aug 2 19:09:51 2010
@@ -786,6 +786,7 @@
Opts.PurgeDead = !Args.hasArg(OPT_analyzer_no_purge_dead);
Opts.EagerlyAssume = Args.hasArg(OPT_analyzer_eagerly_assume);
Opts.AnalyzeSpecificFunction = Args.getLastArgValue(OPT_analyze_function);
+ Opts.UnoptimizedCFG = Args.hasArg(OPT_analysis_UnoptimizedCFG);
Opts.EnableExperimentalChecks = Args.hasArg(OPT_analyzer_experimental_checks);
Opts.EnableExperimentalInternalChecks =
Args.hasArg(OPT_analyzer_experimental_internal_checks);
More information about the cfe-commits
mailing list