@@ -1886,13 +1886,13 @@ UPCStandalonePointerGadget::getFixits(const FixitStrategy &S) const {
1886
1886
return FixItList{{FixItHint::CreateInsertion (*EndOfOperand, " .data()" )}};
1887
1887
// FIXME: Points inside a macro expansion.
1888
1888
break ;
1889
- }
1890
- case FixitStrategy::Kind::Wontfix:
1891
- case FixitStrategy::Kind::Iterator:
1892
- case FixitStrategy::Kind::Array:
1893
- return std::nullopt;
1894
- case FixitStrategy::Kind::Vector:
1895
- llvm_unreachable (" unsupported strategies for FixableGadgets" );
1889
+ }
1890
+ case FixitStrategy::Kind::Wontfix:
1891
+ case FixitStrategy::Kind::Iterator:
1892
+ case FixitStrategy::Kind::Array:
1893
+ return std::nullopt;
1894
+ case FixitStrategy::Kind::Vector:
1895
+ llvm_unreachable (" unsupported strategies for FixableGadgets" );
1896
1896
}
1897
1897
1898
1898
return std::nullopt;
@@ -2008,7 +2008,6 @@ UPCPreIncrementGadget::getFixits(const FixitStrategy &S) const {
2008
2008
return std::nullopt; // Not in the cases that we can handle for now, give up.
2009
2009
}
2010
2010
2011
-
2012
2011
// For a non-null initializer `Init` of `T *` type, this function returns
2013
2012
// `FixItHint`s producing a list initializer `{Init, S}` as a part of a fix-it
2014
2013
// to output stream.
@@ -2497,22 +2496,30 @@ static FixItList fixVarDeclWithArray(const VarDecl *D, const ASTContext &Ctx,
2497
2496
2498
2497
const SourceLocation IdentifierLoc = getVarDeclIdentifierLoc (D);
2499
2498
2500
- // Get the spelling of the element type as written in the source file (including macros, etc.).
2501
- auto MaybeElemTypeTxt = getRangeText ({D->getBeginLoc (), IdentifierLoc}, Ctx.getSourceManager (), Ctx.getLangOpts ());
2499
+ // Get the spelling of the element type as written in the source file
2500
+ // (including macros, etc.).
2501
+ auto MaybeElemTypeTxt =
2502
+ getRangeText ({D->getBeginLoc (), IdentifierLoc}, Ctx.getSourceManager (),
2503
+ Ctx.getLangOpts ());
2502
2504
if (!MaybeElemTypeTxt)
2503
2505
return {};
2504
2506
const llvm::StringRef ElemTypeTxt = MaybeElemTypeTxt->trim ();
2505
2507
2506
2508
// Find the '[' token.
2507
- std::optional<Token> NextTok = Lexer::findNextToken (IdentifierLoc, Ctx.getSourceManager (), Ctx.getLangOpts ());
2509
+ std::optional<Token> NextTok = Lexer::findNextToken (
2510
+ IdentifierLoc, Ctx.getSourceManager (), Ctx.getLangOpts ());
2508
2511
while (NextTok && !NextTok->is (tok::l_square))
2509
- NextTok = Lexer::findNextToken (NextTok->getLocation (), Ctx.getSourceManager (), Ctx.getLangOpts ());
2512
+ NextTok = Lexer::findNextToken (NextTok->getLocation (),
2513
+ Ctx.getSourceManager (), Ctx.getLangOpts ());
2510
2514
if (!NextTok)
2511
2515
return {};
2512
2516
const SourceLocation LSqBracketLoc = NextTok->getLocation ();
2513
2517
2514
- // Get the spelling of the array size as written in the source file (including macros, etc.).
2515
- auto MaybeArraySizeTxt = getRangeText ({LSqBracketLoc.getLocWithOffset (1 ), D->getTypeSpecEndLoc ()}, Ctx.getSourceManager (), Ctx.getLangOpts ());
2518
+ // Get the spelling of the array size as written in the source file
2519
+ // (including macros, etc.).
2520
+ auto MaybeArraySizeTxt = getRangeText (
2521
+ {LSqBracketLoc.getLocWithOffset (1 ), D->getTypeSpecEndLoc ()},
2522
+ Ctx.getSourceManager (), Ctx.getLangOpts ());
2516
2523
if (!MaybeArraySizeTxt)
2517
2524
return {};
2518
2525
const llvm::StringRef ArraySizeTxt = MaybeArraySizeTxt->trim ();
@@ -2521,7 +2528,8 @@ static FixItList fixVarDeclWithArray(const VarDecl *D, const ASTContext &Ctx,
2521
2528
// Examples:
2522
2529
// int arr1[] = {0, 1, 2};
2523
2530
// int arr2{3, 4, 5};
2524
- // We might be able to preserve the non-specified size with `auto` and `std::to_array`:
2531
+ // We might be able to preserve the non-specified size with `auto` and
2532
+ // `std::to_array`:
2525
2533
// auto arr1 = std::to_array<int>({0, 1, 2});
2526
2534
return {};
2527
2535
}
@@ -2536,8 +2544,8 @@ static FixItList fixVarDeclWithArray(const VarDecl *D, const ASTContext &Ctx,
2536
2544
2537
2545
SmallString<32 > Replacement;
2538
2546
raw_svector_ostream OS (Replacement);
2539
- OS << " std::array<" << ElemTypeTxt << " , "
2540
- << ArraySizeTxt << " > " << IdentText->str ();
2547
+ OS << " std::array<" << ElemTypeTxt << " , " << ArraySizeTxt << " > "
2548
+ << IdentText->str ();
2541
2549
2542
2550
FixIts.push_back (FixItHint::CreateReplacement (
2543
2551
SourceRange{D->getBeginLoc (), D->getTypeSpecEndLoc ()}, OS.str ()));
0 commit comments