r182290 - Minor fix: don't crash on empty configuration file, consider empty configuration files invalid.

Chandler Carruth chandlerc at google.com
Mon May 20 11:20:40 PDT 2013


On Mon, May 20, 2013 at 6:17 PM, Alexander Kornienko <alexfh at google.com>wrote:

> Please take a look. Is this enough?
>

Does it trigger the crash before your fix?


>
> 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
>

Why not 'touch'?


Actually, I think all of these tests should change to not use 'echo' or
other shell commands to build up the configuration files, and instead the
configuration files should be directly added as files to the test suite
under the 'Inputs' directory. That makes them much more friendly to Windows
IIRC.


> +// 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/0d60f03b/attachment.html>


More information about the cfe-commits mailing list