[clang-tools-extra] r213647 - [clang-tidy] Add a check for RAII temporaries.

Alexander Kornienko alexfh at google.com
Wed Jul 23 01:04:18 PDT 2014


On Wed, Jul 23, 2014 at 2:40 AM, Richard Smith <richard at metafoo.co.uk>
wrote:

> On Tue, Jul 22, 2014 at 5:30 AM, Benjamin Kramer <benny.kra at googlemail.com
> > wrote:
>
>> ...
>> Added: clang-tools-extra/trunk/test/clang-tidy/misc-unused-raii.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-raii.cpp?rev=213647&view=auto
>>
>> ==============================================================================
>> --- clang-tools-extra/trunk/test/clang-tidy/misc-unused-raii.cpp (added)
>> +++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-raii.cpp Tue Jul
>> 22 07:30:35 2014
>> @@ -0,0 +1,61 @@
>> +// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-unused-raii %t
>> +// REQUIRES: shell
>> +
>> +struct Foo {
>> +  Foo();
>> +  Foo(int);
>> +  Foo(int, int);
>> +  ~Foo();
>> +};
>> +
>> +struct Bar {
>> +  Bar();
>> +  Foo f;
>> +};
>> +
>> +template <typename T>
>> +void qux() {
>> +  T(42);
>> +}
>> +
>> +template <typename T>
>> +struct TFoo {
>> +  TFoo(T);
>> +  ~TFoo();
>> +};
>> +
>> +Foo f();
>> +
>> +struct Ctor {
>> +  Ctor(int);
>> +  Ctor() {
>> +    Ctor(0); // TODO: warn here.
>> +  }
>> +};
>> +
>> +void test() {
>> +  Foo(42);
>> +// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: object destroyed immediately
>> after creation; did you mean to name the object?
>> +// CHECK-FIXES: Foo give_me_a_name(42);
>> +  Foo(23, 42);
>> +// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: object destroyed immediately
>> after creation; did you mean to name the object?
>> +// CHECK-FIXES: Foo give_me_a_name(23, 42);
>> +  Foo();
>> +// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: object destroyed immediately
>> after creation; did you mean to name the object?
>> +// CHECK-FIXES: Foo give_me_a_name;
>> +  TFoo<int>(23);
>> +// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: object destroyed immediately
>> after creation; did you mean to name the object?
>> +// CHECK-FIXES: TFoo<int> give_me_a_name(23);
>>
>
> This test is failing on one of our bots:
>

The "on one of our bots" part could be more specific, ideally with a link.
Benjamin, can you reproduce the failure? I gather, the buildbot should have
sent you a personal mail?


>
> misc-unused-raii.cpp:39:17: error: expected string not found in input
> // CHECK-FIXES: Foo give_me_a_name(42);
>                 ^
> misc-unused-raii.cpp.tmp.cpp:1:1: note: scanning from here
> //
> ^
> misc-unused-raii.cpp.tmp.cpp:37:3: note: possible intended match here
>   Foo(42);
>   ^
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140723/49c973ea/attachment.html>


More information about the cfe-commits mailing list