[cfe-commits] r96146 - /cfe/trunk/lib/Frontend/AnalysisConsumer.cpp
Ted Kremenek
kremenek at apple.com
Sat Feb 13 18:44:53 PST 2010
Author: kremenek
Date: Sat Feb 13 20:44:52 2010
New Revision: 96146
URL: http://llvm.org/viewvc/llvm-project?rev=96146&view=rev
Log:
Two changes to AnalysisConsumer::HandleTopLevelSingleDecl():
(1) Since CXXMethodDecl subclasses FunctionDecl (and CXXDestructorDecl
and CXXConversion subclass CXXMethodDecl), refactor switch statement
to handle them all in one spot.
(2) Use 'DeclarationName::getAsString()' to handle all functions that
don't have simple identifiers (fixing a null dereference when scanning
for specific functions).
Modified:
cfe/trunk/lib/Frontend/AnalysisConsumer.cpp
Modified: cfe/trunk/lib/Frontend/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/AnalysisConsumer.cpp?rev=96146&r1=96145&r2=96146&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/Frontend/AnalysisConsumer.cpp Sat Feb 13 20:44:52 2010
@@ -205,42 +205,30 @@
void AnalysisConsumer::HandleTopLevelSingleDecl(Decl *D) {
switch (D->getKind()) {
+ case Decl::CXXConstructor:
+ case Decl::CXXDestructor:
+ case Decl::CXXConversion:
+ case Decl::CXXMethod:
case Decl::Function: {
FunctionDecl* FD = cast<FunctionDecl>(D);
-
if (!Opts.AnalyzeSpecificFunction.empty() &&
- Opts.AnalyzeSpecificFunction != FD->getIdentifier()->getName())
- break;
+ FD->getDeclName().getAsString() != Opts.AnalyzeSpecificFunction)
+ break;
- Stmt* Body = FD->getBody();
- if (Body) HandleCode(FD, Body, FunctionActions);
+ if (Stmt *Body = FD->getBody())
+ HandleCode(FD, Body, FunctionActions);
break;
}
case Decl::ObjCMethod: {
ObjCMethodDecl* MD = cast<ObjCMethodDecl>(D);
- if (Opts.AnalyzeSpecificFunction.size() > 0 &&
+ if (!Opts.AnalyzeSpecificFunction.empty() &&
Opts.AnalyzeSpecificFunction != MD->getSelector().getAsString())
return;
- Stmt* Body = MD->getBody();
- if (Body) HandleCode(MD, Body, ObjCMethodActions);
- break;
- }
-
- case Decl::CXXConstructor:
- case Decl::CXXDestructor:
- case Decl::CXXConversion:
- case Decl::CXXMethod: {
- CXXMethodDecl *CXXMD = cast<CXXMethodDecl>(D);
-
- if (Opts.AnalyzeSpecificFunction.size() > 0 &&
- Opts.AnalyzeSpecificFunction != CXXMD->getName())
- return;
-
- Stmt *Body = CXXMD->getBody();
- if (Body) HandleCode(CXXMD, Body, FunctionActions);
+ if (Stmt* Body = MD->getBody())
+ HandleCode(MD, Body, ObjCMethodActions);
break;
}
More information about the cfe-commits
mailing list