diff options
author | Daniel Jasper <djasper@google.com> | 2013-10-08 15:54:36 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-10-08 15:54:36 +0000 |
commit | e8845ad4c5f8ae7b7775743d82f35cfd4c71e419 (patch) | |
tree | c7084e2baed679a8eced2c46e19d9f5c2bffda72 /clang | |
parent | 7f1146c4945a3bad3dafebd39cb62b97d6fbdd53 (diff) | |
download | llvm-e8845ad4c5f8ae7b7775743d82f35cfd4c71e419.zip llvm-e8845ad4c5f8ae7b7775743d82f35cfd4c71e419.tar.gz llvm-e8845ad4c5f8ae7b7775743d82f35cfd4c71e419.tar.bz2 |
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
Diffstat (limited to 'clang')
-rw-r--r-- | clang/tools/clang-format/ClangFormat.cpp | 2 | ||||
-rwxr-xr-x | clang/tools/clang-format/clang-format-diff.py | 3 |
2 files changed, 3 insertions, 2 deletions
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<CharSourceRange> 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__': |