27 using namespace clang;
28 using namespace arcmt;
29 using namespace trans;
32 std::vector<SourceLocation> &MacroLocs,
41 if (MacroLocs.empty())
45 std::vector<SourceLocation>::iterator I = llvm::upper_bound(
52 if (AfterMacroLoc == SemiLoc)
69 return AfterMacroSemiLoc == SemiLoc;
76 class EmptyChecker :
public StmtVisitor<EmptyChecker, bool> {
78 std::vector<SourceLocation> &MacroLocs;
81 EmptyChecker(
ASTContext &ctx, std::vector<SourceLocation> ¯oLocs)
82 : Ctx(ctx), MacroLocs(macroLocs) { }
90 for (
auto *I : S->
body())
95 bool VisitIfStmt(
IfStmt *S) {
119 bool VisitDoStmt(
DoStmt *S) {
146 class EmptyStatementsRemover :
153 bool TraverseStmtExpr(
StmtExpr *E) {
165 for (
auto *I : S->
body())
173 void check(
Stmt *S) {
185 std::vector<SourceLocation> &MacroLocs) {
186 for (
auto *I : body->
body())
187 if (!EmptyChecker(Ctx, MacroLocs).Visit(I))
202 for (impl_iterator I = impl_iterator(DC->
decls_begin()),
203 E = impl_iterator(DC->
decls_end()); I != E; ++I) {
206 for (
auto *MD : I->instance_methods()) {
212 }
else if (MD->isInstanceMethod() && MD->getSelector() == FinalizeSel) {
228 }
else if (FinalizeM) {
245 for (
unsigned i = 0, e = pass.
ARCMTMacroLocs.size(); i != e; ++i) {
Defines the clang::ASTContext interface.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
Smart pointer class that efficiently represents Objective-C method names.
CompoundStmt * getSubStmt()
Stmt - This represents one statement.
IfStmt - This represents an if/then/else.
Defines the SourceManager interface.
static StringRef getARCMTMacroName()
bool hasLeadingEmptyMacro() const
SourceLocation findSemiAfterLocation(SourceLocation loc, ASTContext &Ctx, bool IsDecl=false)
'Loc' is the end of a statement range.
bool isInSameSLocAddrSpace(SourceLocation LHS, SourceLocation RHS, int *RelativeOffset) const
Return true if both LHS and RHS are in the local source location address space or the loaded one...
ObjCMethodDecl - Represents an instance or class method declaration.
const Stmt * getSubStmt() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Selector getNullarySelector(IdentifierInfo *ID)
static bool isBodyEmpty(CompoundStmt *body, ASTContext &Ctx, std::vector< SourceLocation > &MacroLocs)
CompoundStmt * getCompoundBody()
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
CompoundStmt - This represents a group of statements like { stmt stmt }.
This represents one expression.
void removeEmptyStatementsAndDeallocFinalize(MigrationPass &pass)
SourceLocation getSelectorStartLoc() const
Compare two source locations.
DoStmt - This represents a 'do/while' stmt.
SelectorTable & Selectors
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
decl_iterator decls_begin() const
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
NullStmt - This is the null statement ";": C99 6.8.3p3.
static void cleanupDeallocOrFinalize(MigrationPass &pass)
Dataflow Directional Tag Classes.
VarDecl * getConditionVariable()
Retrieve the variable declared in this "while" statement, if any.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool hasSideEffects(Expr *E, ASTContext &Ctx)
SourceLocation getSemiLoc() const
body_iterator body_begin()
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
Represents Objective-C's collection statement.
std::vector< SourceLocation > & ARCMTMacroLocs
SourceManager & getSourceManager()
VarDecl * getConditionVariable()
Retrieve the variable declared in this "if" statement, if any.
TranslationUnitDecl * getTranslationUnitDecl() const
WhileStmt - This represents a 'while' stmt.
static bool isEmptyARCMTMacroStatement(NullStmt *S, std::vector< SourceLocation > &MacroLocs, ASTContext &Ctx)
Represents Objective-C's @autoreleasepool Statement.
This class handles loading and caching of source files into memory.
decl_iterator decls_end() const