r312000 - [clang-format] Refactor likely xml a bit, NFC

Krasimir Georgiev via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 29 06:57:31 PDT 2017


Author: krasimir
Date: Tue Aug 29 06:57:31 2017
New Revision: 312000

URL: http://llvm.org/viewvc/llvm-project?rev=312000&view=rev
Log:
[clang-format] Refactor likely xml a bit, NFC

Modified:
    cfe/trunk/lib/Format/Format.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=312000&r1=311999&r2=312000&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue Aug 29 06:57:31 2017
@@ -1539,7 +1539,7 @@ bool isMpegTS(StringRef Code) {
   return Code.size() > 188 && Code[0] == 0x47 && Code[188] == 0x47;
 }
 
-bool likelyXml(StringRef Code) {
+bool isLikelyXml(StringRef Code) {
   return Code.ltrim().startswith("<");
 }
 
@@ -1549,9 +1549,10 @@ tooling::Replacements sortIncludes(const
   tooling::Replacements Replaces;
   if (!Style.SortIncludes)
     return Replaces;
-  if (likelyXml(Code) ||
-      (Style.Language == FormatStyle::LanguageKind::LK_JavaScript &&
-       isMpegTS(Code)))
+  if (isLikelyXml(Code))
+    return Replaces;
+  if (Style.Language == FormatStyle::LanguageKind::LK_JavaScript &&
+      isMpegTS(Code))
     return Replaces;
   if (Style.Language == FormatStyle::LanguageKind::LK_JavaScript)
     return sortJavaScriptImports(Style, Code, Ranges, FileName);
@@ -1899,8 +1900,9 @@ tooling::Replacements reformat(const For
   FormatStyle Expanded = expandPresets(Style);
   if (Expanded.DisableFormat)
     return tooling::Replacements();
-  if (likelyXml(Code) ||
-      (Expanded.Language == FormatStyle::LK_JavaScript && isMpegTS(Code)))
+  if (isLikelyXml(Code))
+    return tooling::Replacements();
+  if (Expanded.Language == FormatStyle::LK_JavaScript && isMpegTS(Code))
     return tooling::Replacements();
 
   typedef std::function<tooling::Replacements(const Environment &)>




More information about the cfe-commits mailing list