28 using namespace clang;
29 using namespace arcmt;
30 using namespace trans;
33 std::vector<SourceLocation> &MacroLocs,
42 if (MacroLocs.empty())
46 std::vector<SourceLocation>::iterator
47 I = std::upper_bound(MacroLocs.begin(), MacroLocs.end(), SemiLoc,
54 if (AfterMacroLoc == SemiLoc)
71 return AfterMacroSemiLoc == SemiLoc;
78 class EmptyChecker :
public StmtVisitor<EmptyChecker, bool> {
80 std::vector<SourceLocation> &MacroLocs;
83 EmptyChecker(
ASTContext &ctx, std::vector<SourceLocation> ¯oLocs)
84 : Ctx(ctx), MacroLocs(macroLocs) { }
92 for (
auto *I : S->
body())
97 bool VisitIfStmt(
IfStmt *S) {
123 bool VisitDoStmt(
DoStmt *S) {
150 class EmptyStatementsRemover :
157 bool TraverseStmtExpr(
StmtExpr *E) {
169 for (
auto *I : S->
body())
177 void check(
Stmt *S) {
179 if (EmptyChecker(Pass.Ctx, Pass.ARCMTMacroLocs).Visit(S)) {
181 Pass.TA.removeStmt(S);
189 std::vector<SourceLocation> &MacroLocs) {
190 for (
auto *I : body->
body())
191 if (!EmptyChecker(Ctx, MacroLocs).Visit(I))
206 for (impl_iterator I = impl_iterator(DC->
decls_begin()),
207 E = impl_iterator(DC->
decls_end()); I != E; ++I) {
210 for (
auto *MD : I->instance_methods()) {
216 }
else if (MD->isInstanceMethod() && MD->getSelector() == FinalizeSel) {
232 }
else if (FinalizeM) {
249 for (
unsigned i = 0, e = pass.
ARCMTMacroLocs.size(); i != e; ++i) {
Defines the clang::ASTContext interface.
Smart pointer class that efficiently represents Objective-C method names.
bool hasLeadingEmptyMacro() const
CompoundStmt * getSubStmt()
Defines the SourceManager interface.
static StringRef getARCMTMacroName()
const Stmt * getElse() const
SourceLocation findSemiAfterLocation(SourceLocation loc, ASTContext &Ctx, bool IsDecl=false)
'Loc' is the end of a statement range. This returns the location of the semicolon following the state...
decl_iterator decls_end() const
SourceLocation getSelectorStartLoc() 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)
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
CompoundStmt * getCompoundBody()
A class that does preorder depth-first traversal on the entire Clang AST and visits each node...
decl_iterator decls_begin() const
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "while" statement, if any.
void removeEmptyStatementsAndDeallocFinalize(MigrationPass &pass)
TranslationUnitDecl * getTranslationUnitDecl() const
Compare two source locations.
SourceLocation getSemiLoc() const
SelectorTable & Selectors
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "if" statement, if any.
static void cleanupDeallocOrFinalize(MigrationPass &pass)
bool hasSideEffects(Expr *E, ASTContext &Ctx)
body_iterator body_begin()
const Stmt * getThen() const
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...
const Stmt * getSubStmt() const
Represents Objective-C's collection statement.
std::vector< SourceLocation > & ARCMTMacroLocs
SourceManager & getSourceManager()
const Expr * getCond() const
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.