30bool isSemicolonRequiredAfter(
const Stmt *S) {
31 if (isa<CompoundStmt>(S))
33 if (
const auto *
If = dyn_cast<IfStmt>(S))
34 return isSemicolonRequiredAfter(
If->getElse() ?
If->getElse()
36 if (
const auto *While = dyn_cast<WhileStmt>(S))
37 return isSemicolonRequiredAfter(While->getBody());
38 if (
const auto *For = dyn_cast<ForStmt>(S))
39 return isSemicolonRequiredAfter(For->getBody());
40 if (
const auto *CXXFor = dyn_cast<CXXForRangeStmt>(S))
41 return isSemicolonRequiredAfter(CXXFor->getBody());
42 if (
const auto *ObjCFor = dyn_cast<ObjCForCollectionStmt>(S))
43 return isSemicolonRequiredAfter(ObjCFor->getBody());
44 if(
const auto *
Switch = dyn_cast<SwitchStmt>(S))
45 return isSemicolonRequiredAfter(
Switch->getBody());
46 if(
const auto *Case = dyn_cast<SwitchCase>(S))
47 return isSemicolonRequiredAfter(Case->getSubStmt());
48 switch (S->getStmtClass()) {
49 case Stmt::DeclStmtClass:
50 case Stmt::CXXTryStmtClass:
51 case Stmt::ObjCAtSynchronizedStmtClass:
52 case Stmt::ObjCAutoreleasePoolStmtClass:
53 case Stmt::ObjCAtTryStmtClass:
64 SM.getSpellingLineNumber(Loc1) ==
SM.getSpellingLineNumber(Loc2);
72ExtractionSemicolonPolicy
76 auto neededInExtractedFunction = []() {
79 auto neededInOriginalFunction = []() {
87 return neededInExtractedFunction();
92 bool NeedsSemi = isSemicolonRequiredAfter(S);
94 return neededInOriginalFunction();
99 if (isSemicolonAtLocation(End,
SM, LangOpts))
100 return neededInOriginalFunction();
105 if (NextToken && NextToken->is(tok::semi) &&
106 areOnSameLine(NextToken->getLocation(), End,
SM)) {
107 ExtractedRange.
setEnd(NextToken->getLocation());
108 return neededInOriginalFunction();
Defines the SourceManager interface.
Defines the Objective-C statement AST node classes.
static CharSourceRange getTokenRange(SourceRange R)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
static std::optional< Token > findNextToken(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
Finds the token that comes right after the given location.
Encodes a location in the source.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
void setEnd(SourceLocation e)
Stmt - This represents one statement.
The JSON file list parser is used to communicate input to InstallAPI.
@ If
'if' clause, allowed on all the Compute Constructs, Data Constructs, Executable Constructs,...