[PATCH] D153228: [clang-format] Fixed bad performance with enabled qualifier fixer.
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 21 17:23:30 PDT 2023
owenpan added inline comments.
================
Comment at: clang/lib/Format/Format.cpp:3476-3477
+
+ // Regarding the 16: Note that multiple passes are added in
+ // addQualifierAlignmentFixerPasses().
+ SmallVector<AnalyzerPass, 16> Passes;
----------------
This comment is unnecessary and too verbose IMO. I suggest that it be deleted.
================
Comment at: clang/lib/Format/Format.cpp:3571-3585
+ // Don't make replacements that replace nothing. This can affect e.g. the
+ // output of clang-format with the --output-replacements-xml option.
+ tooling::Replacements NonNoOpFixes;
+ for (const tooling::Replacement &Fix : Fixes) {
+ StringRef OriginalCode = Code.substr(Fix.getOffset(), Fix.getLength());
+ if (!OriginalCode.equals(Fix.getReplacementText())) {
+ auto Err = NonNoOpFixes.add(Fix);
----------------
You only need this for the `QualifierAlignment` passes as others (e.g. `IntegerLiteralSeparatorFixer`) already skip no-op replacements.
================
Comment at: clang/lib/Format/QualifierAlignmentFixer.cpp:29
+void addQualifierAlignmentFixerPasses(const FormatStyle &Style,
+ SmallVector<AnalyzerPass, 16> &Passes) {
std::vector<std::string> LeftOrder;
----------------
Ditto.
================
Comment at: clang/lib/Format/QualifierAlignmentFixer.h:29
+void addQualifierAlignmentFixerPasses(const FormatStyle &Style,
+ SmallVector<AnalyzerPass, 16> &Passes);
----------------
See https://llvm.org/docs/ProgrammersManual.html#llvm-adt-smallvector-h.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153228/new/
https://reviews.llvm.org/D153228
More information about the cfe-commits
mailing list