<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, May 20, 2015 at 3:19 PM, Ismail Pazarbasi <span dir="ltr"><<a href="mailto:ismail.pazarbasi@gmail.com" target="_blank">ismail.pazarbasi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think I put it there after reading:<br>
test/PCH/cxx_exprs.cpp:4:// Test with pch. Use '-ast-dump' to force<br>
deserialization of function bodies.<br></blockquote><div><br></div><div>That test is wrong; -ast-dump doesn't force deserialization any more.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have made a patch to address this issue, but it will need a review.<br>
<div class="HOEnZb"><div class="h5"><br>
On Wed, May 20, 2015 at 7:46 PM, Richard Trieu <<a href="mailto:rtrieu@google.com">rtrieu@google.com</a>> wrote:<br>
>><br>
>> Modified: cfe/trunk/test/SemaCXX/delete.cpp<br>
>> URL:<br>
>> <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_SemaCXX_delete.cpp-3Frev-3D237608-26r1-3D237607-26r2-3D237608-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=Tf7_WGwojPogrIPcZqVbWkPpm5E8QCufqzewR8eXUF0&s=rQpx5C9mXz7ULWe_I_yHRJVUpzljeBk6K7pA3e8pAFk&e=" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/delete.cpp?rev=237608&r1=237607&r2=237608&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/SemaCXX/delete.cpp (original)<br>
>> +++ cfe/trunk/test/SemaCXX/delete.cpp Mon May 18 14:59:11 2015<br>
>> @@ -1,9 +1,130 @@<br>
>> -// RUN: %clang_cc1 -fsyntax-only -verify %s<br>
>> -// RUN: cp %s %t<br>
>> -// RUN: %clang_cc1 -fixit -x c++ %t<br>
>> -// RUN: %clang_cc1 -E -o - %t | FileCheck %s<br>
>> +// Test without PCH<br>
>> +// RUN: %clang_cc1 -fsyntax-only -include %S/delete-mismatch.h<br>
>> -fdiagnostics-parseable-fixits -std=c++11 %s 2>&1 | FileCheck %s<br>
>> +<br>
>> +// Test with PCH<br>
>> +// RUN: %clang_cc1 -x c++-header -std=c++11 -emit-pch -o %t<br>
>> %S/delete-mismatch.h<br>
>> +// RUN: %clang_cc1 -std=c++11 -include-pch %t -DWITH_PCH -fsyntax-only<br>
>> -verify %s -ast-dump<br>
><br>
> Why is an AST dump being performed here?<br>
>><br>
>><br>
>>  void f(int a[10][20]) {<br>
>> -  // CHECK: delete[] a;<br>
>>    delete a; // expected-warning {{'delete' applied to a pointer-to-array<br>
>> type}}<br>
>> +  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:9}:"[]"<br>
>> +}<br>
>> +namespace MemberCheck {<br>
>> +struct S {<br>
>> +  int *a = new int[5]; // expected-note4 {{allocated with 'new[]' here}}<br>
>> +  int *b;<br>
>> +  int *c;<br>
>> +  static int *d;<br>
>> +  S();<br>
>> +  S(int);<br>
>> +  ~S() {<br>
>> +    delete a; // expected-warning {{'delete' applied to a pointer that<br>
>> was allocated with 'new[]'; did you mean 'delete[]'?}}<br>
>> +    delete b;   // expected-warning {{'delete' applied to a pointer that<br>
>> was allocated with 'new[]'; did you mean 'delete[]'?}}<br>
>> +    delete[] c; // expected-warning {{'delete[]' applied to a pointer<br>
>> that was allocated with 'new'; did you mean 'delete'?}}<br>
>> +  }<br>
>> +  void f();<br>
>> +};<br>
>> +<br>
>> +void S::f()<br>
>> +{<br>
>> +  delete a; // expected-warning {{'delete' applied to a pointer that was<br>
>> allocated with 'new[]'; did you mean 'delete[]'?}}<br>
>> +  delete b; // expected-warning {{'delete' applied to a pointer that was<br>
>> allocated with 'new[]'; did you mean 'delete[]'?}}<br>
>> +}<br>
>> +<br>
>> +S::S()<br>
>> +: b(new int[1]), c(new int) {} // expected-note3 {{allocated with 'new[]'<br>
>> here}}<br>
>> +// expected-note@-1 {{allocated with 'new' here}}<br>
>> +<br>
>> +S::S(int i)<br>
>> +: b(new int[i]), c(new int) {} // expected-note3 {{allocated with 'new[]'<br>
>> here}}<br>
>> +// expected-note@-1 {{allocated with 'new' here}}<br>
>> +<br>
>> +struct S2 : S {<br>
>> +  ~S2() {<br>
>> +    delete a; // expected-warning {{'delete' applied to a pointer that<br>
>> was allocated with 'new[]'; did you mean 'delete[]'?}}<br>
>> +  }<br>
>> +};<br>
>> +int *S::d = new int[42]; // expected-note {{allocated with 'new[]' here}}<br>
>> +void f(S *s) {<br>
>> +  int *a = new int[1]; // expected-note {{allocated with 'new[]' here}}<br>
>> +  delete a; // expected-warning {{'delete' applied to a pointer that was<br>
>> allocated with 'new[]'; did you mean 'delete[]'?}}<br>
>> +  delete s->a; // expected-warning {{'delete' applied to a pointer that<br>
>> was allocated with 'new[]'; did you mean 'delete[]'?}}<br>
>> +  delete s->b; // expected-warning {{'delete' applied to a pointer that<br>
>> was allocated with 'new[]'; did you mean 'delete[]'?}}<br>
>> +  delete s->c;<br>
>> +  delete s->d;<br>
>> +  delete S::d; // expected-warning {{'delete' applied to a pointer that<br>
>> was allocated with 'new[]'; did you mean 'delete[]'?}}<br>
>> +}<br>
>> +<br>
>> +// At least one constructor initializes field with matching form of<br>
>> 'new'.<br>
>> +struct MatchingNewIsOK {<br>
>> +  int *p;<br>
>> +  bool is_array_;<br>
>> +  MatchingNewIsOK() : p{new int}, is_array_(false) {}<br>
>> +  explicit MatchingNewIsOK(unsigned c) : p{new int[c]}, is_array_(true)<br>
>> {}<br>
>> +  ~MatchingNewIsOK() {<br>
>> +    if (is_array_)<br>
>> +      delete[] p;<br>
>> +    else<br>
>> +      delete p;<br>
>> +  }<br>
>> +};<br>
>> +<br>
>> +// At least one constructor's body is missing; no proof of mismatch.<br>
>> +struct CantProve_MissingCtorDefinition {<br>
>> +  int *p;<br>
>> +  CantProve_MissingCtorDefinition();<br>
>> +  CantProve_MissingCtorDefinition(int);<br>
>> +  ~CantProve_MissingCtorDefinition();<br>
>> +};<br>
>> +<br>
>> +CantProve_MissingCtorDefinition::CantProve_MissingCtorDefinition()<br>
>> +  : p(new int)<br>
>> +{ }<br>
>> +<br>
>> +CantProve_MissingCtorDefinition::~CantProve_MissingCtorDefinition()<br>
>> +{<br>
>> +  delete[] p;<br>
>> +}<br>
>> +<br>
>> +struct base {};<br>
>> +struct derived : base {};<br>
>> +struct InitList {<br>
>> +  base *p, *p2 = nullptr, *p3{nullptr}, *p4;<br>
>> +  InitList(unsigned c) : p(new derived[c]), p4(nullptr) {}  //<br>
>> expected-note {{allocated with 'new[]' here}}<br>
>> +  InitList(unsigned c, unsigned) : p{new derived[c]}, p4{nullptr} {} //<br>
>> expected-note {{allocated with 'new[]' here}}<br>
>> +  ~InitList() {<br>
>> +    delete p; // expected-warning {{'delete' applied to a pointer that<br>
>> was allocated with 'new[]'; did you mean 'delete[]'?}}<br>
>> +    delete [] p;<br>
>> +    delete p2;<br>
>> +    delete [] p3;<br>
>> +    delete p4;<br>
>> +  }<br>
>> +};<br>
>> +}<br>
>> +<br>
>> +namespace NonMemberCheck {<br>
>> +#define DELETE_ARRAY(x) delete[] (x)<br>
>> +#define DELETE(x) delete (x)<br>
>> +void f() {<br>
>> +  int *a = new int(5); // expected-note2 {{allocated with 'new' here}}<br>
>> +  delete[] a;          // expected-warning {{'delete[]' applied to a<br>
>> pointer that was allocated with 'new'; did you mean 'delete'?}}<br>
>> +  int *b = new int;<br>
>> +  delete b;<br>
>> +  int *c{new int};    // expected-note {{allocated with 'new' here}}<br>
>> +  int *d{new int[1]}; // expected-note2 {{allocated with 'new[]' here}}<br>
>> +  delete  [    ] c;   // expected-warning {{'delete[]' applied to a<br>
>> pointer that was allocated with 'new'; did you mean 'delete'?}}<br>
>> +  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:17}:""<br>
>> +  delete d;           // expected-warning {{'delete' applied to a pointer<br>
>> that was allocated with 'new[]'; did you mean 'delete[]'?}}<br>
>> +  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:9}:"[]"<br>
>> +  DELETE_ARRAY(a);    // expected-warning {{'delete[]' applied to a<br>
>> pointer that was allocated with 'new'; did you mean 'delete'?}}<br>
>> +  DELETE(d);          // expected-warning {{'delete' applied to a pointer<br>
>> that was allocated with 'new[]'; did you mean 'delete[]'?}}<br>
>> +}<br>
>>  }<br>
>> +#ifndef WITH_PCH<br>
>> +pch_test::X::X()<br>
>> +  : a(new int[1])  // expected-note{{allocated with 'new[]' here}}<br>
>> +{ }<br>
>> +pch_test::X::X(int i)<br>
>> +  : a(new int[i])  // expected-note{{allocated with 'new[]' here}}<br>
>> +{ }<br>
>> +#endif<br>
>><br>
>><br>
>> _______________________________________________<br>
>> cfe-commits mailing list<br>
>> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
><br>
><br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div>