r192184 - clang-format: Don't exit with failure on empty files.
Daniel Jasper
djasper at google.com
Tue Oct 8 08:54:36 PDT 2013
Author: djasper
Date: Tue Oct 8 10:54:36 2013
New Revision: 192184
URL: http://llvm.org/viewvc/llvm-project?rev=192184&view=rev
Log:
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!
Modified:
cfe/trunk/tools/clang-format/ClangFormat.cpp
cfe/trunk/tools/clang-format/clang-format-diff.py
Modified: cfe/trunk/tools/clang-format/ClangFormat.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/ClangFormat.cpp?rev=192184&r1=192183&r2=192184&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/ClangFormat.cpp (original)
+++ cfe/trunk/tools/clang-format/ClangFormat.cpp Tue Oct 8 10:54:36 2013
@@ -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))
Modified: cfe/trunk/tools/clang-format/clang-format-diff.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format-diff.py?rev=192184&r1=192183&r2=192184&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/clang-format-diff.py (original)
+++ cfe/trunk/tools/clang-format/clang-format-diff.py Tue Oct 8 10:54:36 2013
@@ -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__':
More information about the cfe-commits
mailing list