16 using namespace clang;
29 bool isSemicolonRequiredAfter(
const Stmt *S) {
30 if (isa<CompoundStmt>(S))
32 if (
const auto *If = dyn_cast<IfStmt>(S))
33 return isSemicolonRequiredAfter(If->getElse() ? If->getElse()
35 if (
const auto *While = dyn_cast<WhileStmt>(S))
36 return isSemicolonRequiredAfter(While->getBody());
37 if (
const auto *For = dyn_cast<ForStmt>(S))
38 return isSemicolonRequiredAfter(For->getBody());
39 if (
const auto *CXXFor = dyn_cast<CXXForRangeStmt>(S))
40 return isSemicolonRequiredAfter(CXXFor->getBody());
41 if (
const auto *ObjCFor = dyn_cast<ObjCForCollectionStmt>(S))
42 return isSemicolonRequiredAfter(ObjCFor->getBody());
44 case Stmt::SwitchStmtClass:
45 case Stmt::CXXTryStmtClass:
46 case Stmt::ObjCAtSynchronizedStmtClass:
47 case Stmt::ObjCAutoreleasePoolStmtClass:
48 case Stmt::ObjCAtTryStmtClass:
67 ExtractionSemicolonPolicy
71 auto neededInExtractedFunction = []() {
74 auto neededInOriginalFunction = []() {
82 return neededInExtractedFunction();
87 bool NeedsSemi = isSemicolonRequiredAfter(S);
89 return neededInOriginalFunction();
94 if (isSemicolonAtLocation(End, SM, LangOpts))
95 return neededInOriginalFunction();
100 if (NextToken && NextToken->is(tok::semi) &&
101 areOnSameLine(NextToken->getLocation(),
End,
SM)) {
102 ExtractedRange.
setEnd(NextToken->getLocation());
103 return neededInOriginalFunction();
Stmt - This represents one statement.
Defines the SourceManager interface.
static CharSourceRange getTokenRange(SourceRange R)
Defines the Objective-C statement AST node classes.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
unsigned getSpellingLineNumber(SourceLocation Loc, bool *Invalid=nullptr) const
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
SourceLocation getEnd() const
Encodes a location in the source.
static Optional< Token > findNextToken(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
Finds the token that comes right after the given location.
Dataflow Directional Tag Classes.
StmtClass getStmtClass() const
void setEnd(SourceLocation e)
A trivial tuple used to represent a source range.
This class handles loading and caching of source files into memory.