[cfe-commits] r53039 - in /cfe/trunk/Driver: ASTConsumers.cpp ASTConsumers.h AnalysisConsumer.cpp AnalysisConsumer.h clang.cpp
Ted Kremenek
kremenek at apple.com
Wed Jul 2 11:11:32 PDT 2008
Author: kremenek
Date: Wed Jul 2 13:11:29 2008
New Revision: 53039
URL: http://llvm.org/viewvc/llvm-project?rev=53039&view=rev
Log:
Move -dump-live-variables logic to AnalysisConsumer.
Modified:
cfe/trunk/Driver/ASTConsumers.cpp
cfe/trunk/Driver/ASTConsumers.h
cfe/trunk/Driver/AnalysisConsumer.cpp
cfe/trunk/Driver/AnalysisConsumer.h
cfe/trunk/Driver/clang.cpp
Modified: cfe/trunk/Driver/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=53039&r1=53038&r2=53039&view=diff
==============================================================================
--- cfe/trunk/Driver/ASTConsumers.cpp (original)
+++ cfe/trunk/Driver/ASTConsumers.cpp Wed Jul 2 13:11:29 2008
@@ -20,11 +20,6 @@
#include "clang/AST/AST.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/CFG.h"
-#include "clang/AST/ParentMap.h"
-#include "clang/Analysis/Analyses/LiveVariables.h"
-#include "clang/Analysis/LocalCheckers.h"
-#include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
-#include "clang/Analysis/PathSensitive/GRExprEngine.h"
#include "llvm/Support/Streams.h"
#include "llvm/Support/Timer.h"
#include "llvm/ADT/OwningPtr.h"
@@ -610,31 +605,6 @@
}
//===----------------------------------------------------------------------===//
-// AnalyzeLiveVariables - perform live variable analysis and dump results
-
-namespace {
- class LivenessVisitor : public CFGVisitor {
- SourceManager *SM;
- public:
- LivenessVisitor(const std::string& fname) : CFGVisitor(fname) {}
-
- virtual void Initialize(ASTContext &Context) {
- SM = &Context.getSourceManager();
- }
-
- virtual void VisitCFG(CFG& C, Decl& CD) {
- LiveVariables L(C);
- L.runOnCFG(C);
- L.dumpBlockLiveness(*SM);
- }
- };
-} // end anonymous namespace
-
-ASTConsumer *clang::CreateLiveVarAnalyzer(const std::string& fname) {
- return new LivenessVisitor(fname);
-}
-
-//===----------------------------------------------------------------------===//
// AST Serializer
namespace {
Modified: cfe/trunk/Driver/ASTConsumers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.h?rev=53039&r1=53038&r2=53039&view=diff
==============================================================================
--- cfe/trunk/Driver/ASTConsumers.h (original)
+++ cfe/trunk/Driver/ASTConsumers.h Wed Jul 2 13:11:29 2008
@@ -38,8 +38,6 @@
ASTConsumer *CreateCFGDumper(bool ViewGraphs, const std::string& FName);
-ASTConsumer *CreateLiveVarAnalyzer(const std::string& fname);
-
ASTConsumer *CreateCodeRewriterTest(const std::string& InFile,
const std::string& OutFile,
Diagnostic &Diags,
Modified: cfe/trunk/Driver/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/AnalysisConsumer.cpp?rev=53039&r1=53038&r2=53039&view=diff
==============================================================================
--- cfe/trunk/Driver/AnalysisConsumer.cpp (original)
+++ cfe/trunk/Driver/AnalysisConsumer.cpp Wed Jul 2 13:11:29 2008
@@ -131,6 +131,10 @@
return *C.Ctx;
}
+ SourceManager& getSourceManager() {
+ return getContext().getSourceManager();
+ }
+
Diagnostic& getDiagnostic() {
return C.Diags;
}
@@ -147,7 +151,10 @@
}
LiveVariables* getLiveVariables() {
- if (!liveness) liveness.reset(new LiveVariables(*getCFG()));
+ if (!liveness) {
+ liveness.reset(new LiveVariables(*getCFG()));
+ liveness->runOnCFG(*getCFG());
+ }
return liveness.get();
}
@@ -200,6 +207,10 @@
switch (D->getKind()) {
case Decl::Function: {
FunctionDecl* FD = cast<FunctionDecl>(D);
+
+ if (FName.size() > 0 && FName != FD->getIdentifier()->getName())
+ break;
+
Stmt* Body = FD->getBody();
if (Body) HandleCode(FD, Body, FunctionActions);
break;
@@ -207,6 +218,10 @@
case Decl::ObjCMethod: {
ObjCMethodDecl* MD = cast<ObjCMethodDecl>(D);
+
+ if (FName.size() > 0 && FName != MD->getSelector().getName())
+ return;
+
Stmt* Body = MD->getBody();
if (Body) HandleCode(MD, Body, ObjCMethodActions);
break;
@@ -317,6 +332,11 @@
ActionGRExprEngine(mgr, MakeGRSimpleValsTF());
}
+static void ActionLiveness(AnalysisManager& mgr) {
+ mgr.DisplayFunction();
+ mgr.getLiveVariables()->dumpBlockLiveness(mgr.getSourceManager());
+}
+
//===----------------------------------------------------------------------===//
// AnalysisConsumer creation.
//===----------------------------------------------------------------------===//
@@ -343,6 +363,10 @@
case WarnUninitVals:
C->addCodeAction(&ActionUninitVals);
break;
+
+ case DisplayLiveVariables:
+ C->addCodeAction(&ActionLiveness);
+ break;
case CheckerCFRef:
C->addCodeAction(&ActionRefLeakChecker);
Modified: cfe/trunk/Driver/AnalysisConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/AnalysisConsumer.h?rev=53039&r1=53038&r2=53039&view=diff
==============================================================================
--- cfe/trunk/Driver/AnalysisConsumer.h (original)
+++ cfe/trunk/Driver/AnalysisConsumer.h Wed Jul 2 13:11:29 2008
@@ -19,6 +19,7 @@
enum Analyses {
WarnDeadStores,
WarnUninitVals,
+ DisplayLiveVariables,
CheckerCFRef,
CheckerSimple
};
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=53039&r1=53038&r2=53039&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Wed Jul 2 13:11:29 2008
@@ -74,7 +74,6 @@
ASTView, // Parse ASTs and view them in Graphviz.
ParseCFGDump, // Parse ASTS. Build CFGs. Print CFGs.
ParseCFGView, // Parse ASTS. Build CFGs. View CFGs.
- AnalysisLiveVariables, // Print results of live-variable analysis.
TestSerialization, // Run experimental serialization code.
ParsePrintCallbacks, // Parse and print each callback.
ParseSyntaxOnly, // Parse and perform semantic analysis.
@@ -113,8 +112,6 @@
"Run parser, then build and print CFGs"),
clEnumValN(ParseCFGView, "view-cfg",
"Run parser, then build and view CFGs with Graphviz"),
- clEnumValN(AnalysisLiveVariables, "dump-live-variables",
- "Print results of live variable analysis"),
clEnumValN(TestSerialization, "test-pickling",
"Run prototype serialization code"),
clEnumValN(EmitLLVM, "emit-llvm",
@@ -171,6 +168,8 @@
static llvm::cl::list<Analyses>
AnalysisList(llvm::cl::desc("Available Source Code Analyses:"),
llvm::cl::values(
+clEnumValN(DisplayLiveVariables, "dump-live-variables",
+ "Print results of live variable analysis"),
clEnumValN(WarnDeadStores, "warn-dead-stores",
"Flag warnings of stores to dead variables"),
clEnumValN(WarnUninitVals, "warn-uninit-values",
@@ -1196,9 +1195,6 @@
return CreateCFGDumper(ProgAction == ParseCFGView,
AnalyzeSpecificFunction);
- case AnalysisLiveVariables:
- return CreateLiveVarAnalyzer(AnalyzeSpecificFunction);
-
case TestSerialization:
return CreateSerializationTest(Diag, FileMgr);
More information about the cfe-commits
mailing list