32 std::vector<SourceLocation> &MacroLocs,
34 if (!S->hasLeadingEmptyMacro())
41 if (MacroLocs.empty())
45 std::vector<SourceLocation>::iterator
I = llvm::upper_bound(
52 if (AfterMacroLoc == SemiLoc)
56 if (!
SM.isInSameSLocAddrSpace(AfterMacroLoc, SemiLoc, &RelOffs))
69 return AfterMacroSemiLoc == SemiLoc;
76class 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) {
96 if (S->getConditionVariable())
98 Expr *condE = S->getCond();
103 if (!S->getThen() || !Visit(S->getThen()))
105 return !S->getElse() ||
Visit(S->getElse());
108 if (S->getConditionVariable())
110 Expr *condE = S->getCond();
117 return Visit(S->getBody());
119 bool VisitDoStmt(
DoStmt *S) {
120 Expr *condE = S->getCond();
127 return Visit(S->getBody());
130 Expr *Exp = S->getCollection();
137 return Visit(S->getBody());
140 if (!S->getSubStmt())
142 return Visit(S->getSubStmt());
146class EmptyStatementsRemover :
156 I = S->body_begin(),
E = S->body_end();
I !=
E; ++
I) {
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()),
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.
Defines the SourceManager interface.
static bool isEmptyARCMTMacroStatement(NullStmt *S, std::vector< SourceLocation > &MacroLocs, ASTContext &Ctx)
static bool isBodyEmpty(CompoundStmt *body, ASTContext &Ctx, std::vector< SourceLocation > &MacroLocs)
static void cleanupDeallocOrFinalize(MigrationPass &pass)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
TranslationUnitDecl * getTranslationUnitDecl() const
SelectorTable & Selectors
Comparison function object.
CompoundStmt - This represents a group of statements like { stmt stmt }.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
decl_iterator decls_end() const
decl_iterator decls_begin() const
DoStmt - This represents a 'do/while' stmt.
This represents one expression.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
IfStmt - This represents an if/then/else.
NullStmt - This is the null statement ";": C99 6.8.3p3.
Represents Objective-C's @autoreleasepool Statement.
Represents Objective-C's collection statement.
ObjCMethodDecl - Represents an instance or class method declaration.
CompoundStmt * getCompoundBody()
SourceLocation getSelectorStartLoc() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
bool TraverseStmt(Stmt *S, DataRecursionQueue *Queue=nullptr)
Recursively visit a statement or expression, by dispatching to Traverse*() based on the argument's dy...
Selector getNullarySelector(const IdentifierInfo *ID)
Smart pointer class that efficiently represents Objective-C method names.
Encodes a location in the source.
This class handles loading and caching of source files into memory.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
RetTy Visit(PTR(Stmt) S, ParamTys... P)
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Stmt - This represents one statement.
WhileStmt - This represents a 'while' stmt.
std::vector< SourceLocation > & ARCMTMacroLocs
bool hasSideEffects(Expr *E, ASTContext &Ctx)
void removeEmptyStatementsAndDeallocFinalize(MigrationPass &pass)
SourceLocation findSemiAfterLocation(SourceLocation loc, ASTContext &Ctx, bool IsDecl=false)
'Loc' is the end of a statement range.
static StringRef getARCMTMacroName()
The JSON file list parser is used to communicate input to InstallAPI.