Bug 1814134 - Fix clang plugin to build with recent clang trunk. r=firefox-build-system-reviewers,ahochheiden

Clang trunk recently removed Optional (replaced with std::optional).

Differential Revision: https://phabricator.services.mozilla.com/D168406
This commit is contained in:
Mike Hommey 2023-01-31 17:18:03 +00:00
parent 2fe409322f
commit 1248412d66
5 changed files with 13 additions and 4 deletions

View File

@ -113,7 +113,7 @@ bool MustReturnFromCallerChecker::immediatelyReturns(
}
for (size_t I = FromIdx; I < Block->size(); ++I) {
Optional<CFGStmt> S = (*Block)[I].getAs<CFGStmt>();
auto S = (*Block)[I].getAs<CFGStmt>();
if (!S) {
continue;
}

View File

@ -53,7 +53,7 @@ public:
: Context(TheContext) {
for (const auto *B : *TheCFG) {
for (size_t I = 0; I < B->size(); ++I) {
if (Optional<CFGStmt> S = (*B)[I].getAs<CFGStmt>()) {
if (auto S = (*B)[I].getAs<CFGStmt>()) {
Map[S->getStmt()] = std::make_pair(B, I);
}
}

View File

@ -25,7 +25,7 @@ std::vector<const Stmt *> getUsageAsRvalue(const ValueDecl *ValueDeclaration,
for (auto &Block : *StatementCFG) {
// We iterate through all the statements of the block.
for (auto &BlockItem : *Block) {
Optional<CFGStmt> CFGStatement = BlockItem.getAs<CFGStmt>();
auto CFGStatement = BlockItem.getAs<CFGStmt>();
if (!CFGStatement) {
continue;
}

View File

@ -37,7 +37,11 @@ void NonStdMoveChecker::registerMatchers(MatchFinder *AstMatcher) {
this);
}
#if CLANG_VERSION_FULL >= 1600
std::optional<FixItHint>
#else
Optional<FixItHint>
#endif
NonStdMoveChecker::makeFixItHint(const MatchFinder::MatchResult &Result,
const Expr *const TargetExpr) {
const auto *MaterializeExpr = Result.Nodes.getNodeAs<Expr>(kMaterializeExpr);

View File

@ -17,7 +17,12 @@ public:
private:
CompilerInstance *CI;
static Optional<FixItHint>
static
#if CLANG_VERSION_FULL >= 1600
std::optional<FixItHint>
#else
Optional<FixItHint>
#endif
makeFixItHint(const MatchFinder::MatchResult &Result, const Expr *TargetExpr);
};