From e8845ad4c5f8ae7b7775743d82f35cfd4c71e419 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 8 Oct 2013 15:54:36 +0000 Subject: clang-format: Don't exit with failure on empty files. 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! llvm-svn: 192184 --- clang/tools/clang-format/ClangFormat.cpp | 2 +- clang/tools/clang-format/clang-format-diff.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'clang') diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index e08aa2d..2ca2bed 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -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 Ranges; if (fillRanges(Sources, ID, Code.get(), Ranges)) diff --git a/clang/tools/clang-format/clang-format-diff.py b/clang/tools/clang-format/clang-format-diff.py index 90723d2..ca949b8 100755 --- a/clang/tools/clang-format/clang-format-diff.py +++ b/clang/tools/clang-format/clang-format-diff.py @@ -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__': -- cgit v1.1