From f7d9e63858138134953e713f948b20a8b8c9a872 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 8 Oct 2013 15:54:36 +0000 Subject: [PATCH] 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! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192184 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/clang-format/ClangFormat.cpp | 2 +- tools/clang-format/clang-format-diff.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/clang-format/ClangFormat.cpp b/tools/clang-format/ClangFormat.cpp index e08aa2d5b8..2ca2bed61a 100644 --- a/tools/clang-format/ClangFormat.cpp +++ b/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/tools/clang-format/clang-format-diff.py b/tools/clang-format/clang-format-diff.py index 90723d217b..ca949b84ef 100755 --- a/tools/clang-format/clang-format-diff.py +++ b/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__': -- 2.40.0