]> granicus.if.org Git - clang/commitdiff
clang-format: Don't exit with failure on empty files.
authorDaniel Jasper <djasper@google.com>
Tue, 8 Oct 2013 15:54:36 +0000 (15:54 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 8 Oct 2013 15:54:36 +0000 (15:54 +0000)
Also let clang-format-diff.py detect errors based on clang-format's
return code. Otherwise messages like "Can't find usable .clang-format,
falling back to LLVM style" can make it fail, which might be undesired.

Patch by Alp Toker. Thank you!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192184 91177308-0d34-0410-b5e6-96231b3b80d8

tools/clang-format/ClangFormat.cpp
tools/clang-format/clang-format-diff.py

index e08aa2d5b8d63d097f2ea4b2e8aee4ef303ea448..2ca2bed61a4d1366721f28e4d3194511094ecea8 100644 (file)
@@ -186,7 +186,7 @@ static bool format(std::string FileName) {
     return true;
   }
   if (Code->getBufferSize() == 0)
-    return true; // Empty files are formatted correctly.
+    return false; // Empty files are formatted correctly.
   FileID ID = createInMemoryFile(FileName, Code.get(), Sources, Files);
   std::vector<CharSourceRange> Ranges;
   if (fillRanges(Sources, ID, Code.get(), Ranges))
index 90723d217b8915eae0782aae773143e8db6585d8..ca949b84ef9f46102568b4b4bc8851fabbf2b029 100755 (executable)
@@ -81,7 +81,8 @@ def main():
     stdout, stderr = p.communicate()
     if stderr:
       print stderr
-      return
+    if p.returncode != 0:
+      sys.exit(p.returncode);
 
 
 if __name__ == '__main__':