SamMaier created this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. SamMaier added a reviewer: thakis.
Previously, in order to have clang-format //not// format something, you had to give both: SortIncludes: false DisableFormat: true This is confusing to users, who would expect that DisableFormat does what it says, and prevents clang-format from editing any files it applies to. See https://stackoverflow.com/questions/55833838/clang-format-still-formatting-with-disableformat-true for example. Repository: rC Clang https://reviews.llvm.org/D67843 Files: clang/lib/Format/Format.cpp clang/test/Format/disable-format.cpp Index: clang/test/Format/disable-format.cpp =================================================================== --- clang/test/Format/disable-format.cpp +++ clang/test/Format/disable-format.cpp @@ -1,5 +1,9 @@ // RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style=none \ // RUN: | FileCheck -strict-whitespace %s -// CHECK: int i; +// CHECK: #include <b> +// CHECK-NEXT: #include <a> +// CHECK-NEXT: int i; +#include <b> +#include <a> int i; Index: clang/lib/Format/Format.cpp =================================================================== --- clang/lib/Format/Format.cpp +++ clang/lib/Format/Format.cpp @@ -1062,8 +1062,6 @@ FormatStyle getNoStyle() { FormatStyle NoStyle = getLLVMStyle(); NoStyle.DisableFormat = true; - NoStyle.SortIncludes = false; - NoStyle.SortUsingDeclarations = false; return NoStyle; } @@ -2130,7 +2128,7 @@ ArrayRef<tooling::Range> Ranges, StringRef FileName, unsigned *Cursor) { tooling::Replacements Replaces; - if (!Style.SortIncludes) + if (!Style.SortIncludes || Style.DisableFormat) return Replaces; if (isLikelyXml(Code)) return Replaces;
Index: clang/test/Format/disable-format.cpp =================================================================== --- clang/test/Format/disable-format.cpp +++ clang/test/Format/disable-format.cpp @@ -1,5 +1,9 @@ // RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style=none \ // RUN: | FileCheck -strict-whitespace %s -// CHECK: int i; +// CHECK: #include <b> +// CHECK-NEXT: #include <a> +// CHECK-NEXT: int i; +#include <b> +#include <a> int i; Index: clang/lib/Format/Format.cpp =================================================================== --- clang/lib/Format/Format.cpp +++ clang/lib/Format/Format.cpp @@ -1062,8 +1062,6 @@ FormatStyle getNoStyle() { FormatStyle NoStyle = getLLVMStyle(); NoStyle.DisableFormat = true; - NoStyle.SortIncludes = false; - NoStyle.SortUsingDeclarations = false; return NoStyle; } @@ -2130,7 +2128,7 @@ ArrayRef<tooling::Range> Ranges, StringRef FileName, unsigned *Cursor) { tooling::Replacements Replaces; - if (!Style.SortIncludes) + if (!Style.SortIncludes || Style.DisableFormat) return Replaces; if (isLikelyXml(Code)) return Replaces;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits