28 using namespace clang;
29 using namespace arcmt;
30 using namespace trans;
33 std::vector<SourceLocation> &MacroLocs,
42 if (MacroLocs.empty())
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) {
121 bool VisitDoStmt(
DoStmt *S) {
148 class EmptyStatementsRemover :
167 for (
auto *
I : S->
body())
175 void check(
Stmt *S) {
177 if (EmptyChecker(Pass.Ctx, Pass.ARCMTMacroLocs).Visit(S)) {
179 Pass.TA.removeStmt(S);
187 std::vector<SourceLocation> &MacroLocs) {
188 for (
auto *
I : body->
body())
189 if (!EmptyChecker(Ctx, MacroLocs).Visit(
I))
204 for (impl_iterator
I = impl_iterator(DC->
decls_begin()),
208 for (
auto *MD :
I->instance_methods()) {
214 }
else if (MD->isInstanceMethod() && MD->getSelector() == FinalizeSel) {
230 }
else if (FinalizeM) {
247 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()
IfStmt - This represents an if/then/else.
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.
ObjCMethodDecl - Represents an instance or class method declaration.
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 preordor or postorder depth-first traversal on the entire Clang AST and visits each...
decl_iterator decls_begin() const
detail::InMemoryDirectory::const_iterator I
CompoundStmt - This represents a group of statements like { stmt stmt }.
Expr - This represents one expression.
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
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.
const TemplateArgument * iterator
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
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "if" statement, if any.
NullStmt - This is the null statement ";": C99 6.8.3p3.
static void cleanupDeallocOrFinalize(MigrationPass &pass)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool hasSideEffects(Expr *E, ASTContext &Ctx)
detail::InMemoryDirectory::const_iterator E
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).
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()
WhileStmt - This represents a 'while' stmt.
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.