50 CaseInfo() : SC(nullptr), State(St_Unchecked) {}
61 : PMap(PMap), Cases(Cases) { }
71 if (getCaseParent(Curr) !=
Parent)
77 Curr = S->getSwitchCaseList();
96class ProtectedScopeFixer {
104 : Pass(BodyCtx.getMigrationContext().Pass),
105 SM(Pass.Ctx.getSourceManager()) {
109 LocalRefsCollector(LocalRefs).TraverseStmt(BodyCtx.
getTopStmt());
118 I = StoredDiags.begin(),
E = StoredDiags.end();
120 if (I->getID() == diag::err_switch_into_protected_scope &&
121 isInRange(I->getLocation(), BodyRange)) {
122 handleProtectedScopeError(I,
E);
129 void handleProtectedScopeError(
133 assert(DiagI->getID() == diag::err_switch_into_protected_scope);
135 bool handledAllNotes =
true;
139 if (!handleProtectedNote(*DiagI))
140 handledAllNotes =
false;
150 for (
unsigned i = 0; i != Cases.size(); i++) {
151 CaseInfo &info = Cases[i];
152 if (isInRange(
Diag.getLocation(), info.Range)) {
154 if (info.State == CaseInfo::St_Unchecked)
156 assert(info.State != CaseInfo::St_Unchecked);
158 if (info.State == CaseInfo::St_Fixed) {
169 void tryFixing(CaseInfo &info) {
170 assert(info.State == CaseInfo::St_Unchecked);
171 if (hasVarReferencedOutside(info)) {
172 info.State = CaseInfo::St_CannotFix;
177 Pass.
TA.
insert(info.Range.getEnd(),
"}\n");
178 info.State = CaseInfo::St_Fixed;
181 bool hasVarReferencedOutside(CaseInfo &info) {
182 for (
unsigned i = 0, e = LocalRefs.size(); i != e; ++i) {
202 ProtectedScopeFixer Fix(BodyCtx);
Defines the clang::ASTContext interface.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Defines the SourceManager interface.
TextDiagnosticBuffer::DiagList DiagList
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool isFunctionOrMethod() const
A reference to a declared variable, function, enum, etc.
SourceLocation getLocation() const
SourceLocation getLocation() const
DeclContext * getDeclContext()
Stmt * getParent(Stmt *) const
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
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
SourceLocation getBegin() const
Stmt - This represents one statement.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Represents a diagnostic in a form that can be retained until its corresponding source manager is dest...
SourceLocation getBeginLoc() const
const SwitchCase * getNextSwitchCase() const
SwitchStmt - This represents a 'switch' stmt.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
const CapturedDiagList & getDiags() const
ParentMap & getParentMap()
void traverseBody(BodyContext &BodyCtx) override
The JSON file list parser is used to communicate input to InstallAPI.