r182290 - Minor fix: don't crash on empty configuration file, consider empty configuration files invalid.
Alexander Kornienko
alexfh at google.com
Mon May 20 11:17:17 PDT 2013
Please take a look. Is this enough?
Index: test/Format/style-on-command-line.cpp
===================================================================
--- test/Format/style-on-command-line.cpp (revision 182291)
+++ test/Format/style-on-command-line.cpp (working copy)
@@ -5,8 +5,10 @@
// RUN: clang-format -style="{lsjd}" %t.cpp 2>&1 | FileCheck
-strict-whitespace -check-prefix=CHECK4 %s
// RUN: [ ! -e %T/.clang-format ] || rm %T/.clang-format
// RUN: clang-format -style=file %t.cpp 2>&1 | FileCheck
-strict-whitespace -check-prefix=CHECK5 %s
+// RUN: echo -e "\n" > %T/.clang-format
+// RUN: clang-format -style=file %t.cpp 2>&1 | FileCheck
-strict-whitespace -check-prefix=CHECK6 %s
// RUN: echo -e "BasedOnStyle: google\nIndentWidth: 5" > %T/.clang-format
-// RUN: clang-format -style=file %t.cpp 2>&1 | FileCheck
-strict-whitespace -check-prefix=CHECK6 %s
+// RUN: clang-format -style=file %t.cpp 2>&1 | FileCheck
-strict-whitespace -check-prefix=CHECK7 %s
void f() {
// CHECK1: {{^ int\* i;$}}
// CHECK2: {{^ int \*i;$}}
@@ -17,7 +19,9 @@
// CHECK4: {{^ int \*i;$}}
// CHECK5: Can't find usable .clang-format, using LLVM style
// CHECK5: {{^ int \*i;$}}
-// CHECK6: {{^ int\* i;$}}
+// CHECK6: Can't find usable .clang-format, using LLVM style
+// CHECK6: {{^ int \*i;$}}
+// CHECK7: {{^ int\* i;$}}
int*i;
int j;
}
On Mon, May 20, 2013 at 8:00 PM, Chandler Carruth <chandlerc at google.com>wrote:
> On Mon, May 20, 2013 at 3:18 PM, Alexander Kornienko <alexfh at google.com>wrote:
>
>> Author: alexfh
>> Date: Mon May 20 10:18:01 2013
>> New Revision: 182290
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=182290&view=rev
>> Log:
>> Minor fix: don't crash on empty configuration file, consider empty
>> configuration files invalid.
>>
>
> Test case please!
>
>
>>
>> Modified:
>> cfe/trunk/lib/Format/Format.cpp
>>
>> Modified: cfe/trunk/lib/Format/Format.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=182290&r1=182289&r2=182290&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Format/Format.cpp (original)
>> +++ cfe/trunk/lib/Format/Format.cpp Mon May 20 10:18:01 2013
>> @@ -201,6 +201,8 @@ bool getPredefinedStyle(StringRef Name,
>> }
>>
>> llvm::error_code parseConfiguration(StringRef Text, FormatStyle *Style) {
>> + if (Text.trim().empty())
>> + return llvm::make_error_code(llvm::errc::invalid_argument);
>> llvm::yaml::Input Input(Text);
>> Input >> *Style;
>> return Input.error();
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
--
Alexander Kornienko | Software Engineer | alexfh at google.com | +49 151 221
77 957
Google Germany GmbH | Dienerstr. 12 | 80331 München
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130520/4edba1c4/attachment.html>
More information about the cfe-commits
mailing list