class BracesInserter : public TokenAnalyzer {
public:
BracesInserter(const Environment &Env, const FormatStyle &Style)
- : TokenAnalyzer(Env, Style) {
- this->Style.RemoveBracesLLVM = false;
- }
+ : TokenAnalyzer(Env, Style) {}
std::pair<tooling::Replacements, unsigned>
analyze(TokenAnnotator &Annotator,
class BracesRemover : public TokenAnalyzer {
public:
BracesRemover(const Environment &Env, const FormatStyle &Style)
- : TokenAnalyzer(Env, Style) {
- this->Style.InsertBraces = false;
- }
+ : TokenAnalyzer(Env, Style) {}
std::pair<tooling::Replacements, unsigned>
analyze(TokenAnnotator &Annotator,
FormatStyle Expanded = Style;
expandPresetsBraceWrapping(Expanded);
expandPresetsSpaceBeforeParens(Expanded);
+ Expanded.InsertBraces = false;
+ Expanded.RemoveBracesLLVM = false;
+ Expanded.RemoveSemicolon = false;
switch (Expanded.RequiresClausePosition) {
case FormatStyle::RCPS_SingleLine:
case FormatStyle::RCPS_WithPreceding:
}
if (Style.InsertBraces) {
+ FormatStyle S = Expanded;
+ S.InsertBraces = true;
Passes.emplace_back([&](const Environment &Env) {
- return BracesInserter(Env, Expanded).process(/*SkipAnnotation=*/true);
+ return BracesInserter(Env, S).process(/*SkipAnnotation=*/true);
});
}
if (Style.RemoveBracesLLVM) {
+ FormatStyle S = Expanded;
+ S.RemoveBracesLLVM = true;
Passes.emplace_back([&](const Environment &Env) {
- return BracesRemover(Env, Expanded).process(/*SkipAnnotation=*/true);
+ return BracesRemover(Env, S).process(/*SkipAnnotation=*/true);
});
}
if (Style.RemoveSemicolon) {
+ FormatStyle S = Expanded;
+ S.RemoveSemicolon = true;
Passes.emplace_back([&](const Environment &Env) {
- return SemiRemover(Env, Expanded).process(/*SkipAnnotation=*/true);
+ return SemiRemover(Env, S).process(/*SkipAnnotation=*/true);
});
}