[PATCH] D33833: Fix Clang assertion on template destructor declaration

2017-06-02 Thread Kuang He via Phabricator via cfe-commits
kuang_he created this revision.

This patch aim to fix bug reported at 
https://bugs.llvm.org/show_bug.cgi?id=33189. Clang hit assertion on template 
destructor declaration


https://reviews.llvm.org/D33833

Files:
  lib/AST/DeclCXX.cpp
  test/SemaCXX/PR33189.cpp


Index: test/SemaCXX/PR33189.cpp
===
--- /dev/null
+++ test/SemaCXX/PR33189.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+class U
+{
+  template 
+  ~U() { } // expected-error{{destructor cannot be declared as a template}}
+};
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1417,7 +1417,7 @@
   Context.getCanonicalType(ClassType));
 
   DeclContext::lookup_result R = lookup(Name);
-  if (R.empty())
+  if (R.empty() || !isa(R.front()))
 return nullptr;
 
   CXXDestructorDecl *Dtor = cast(R.front());


Index: test/SemaCXX/PR33189.cpp
===
--- /dev/null
+++ test/SemaCXX/PR33189.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+class U
+{
+  template 
+  ~U() { } // expected-error{{destructor cannot be declared as a template}}
+};
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1417,7 +1417,7 @@
   Context.getCanonicalType(ClassType));
 
   DeclContext::lookup_result R = lookup(Name);
-  if (R.empty())
+  if (R.empty() || !isa(R.front()))
 return nullptr;
 
   CXXDestructorDecl *Dtor = cast(R.front());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33833: Fix PR 33189: Clang assertion on template destructor declaration

2017-06-06 Thread Kuang He via Phabricator via cfe-commits
kuang_he updated this revision to Diff 101601.
kuang_he added a comment.

Patch updated addressing comment.


https://reviews.llvm.org/D33833

Files:
  lib/AST/DeclCXX.cpp
  test/SemaCXX/PR33189.cpp


Index: test/SemaCXX/PR33189.cpp
===
--- /dev/null
+++ test/SemaCXX/PR33189.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+class U
+{
+  template 
+  ~U() { } // expected-error{{destructor cannot be declared as a template}}
+};
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1417,11 +1417,8 @@
   Context.getCanonicalType(ClassType));
 
   DeclContext::lookup_result R = lookup(Name);
-  if (R.empty())
-return nullptr;
 
-  CXXDestructorDecl *Dtor = cast(R.front());
-  return Dtor;
+  return R.empty() ? nullptr : dyn_cast(R.front());
 }
 
 bool CXXRecordDecl::isAnyDestructorNoReturn() const {


Index: test/SemaCXX/PR33189.cpp
===
--- /dev/null
+++ test/SemaCXX/PR33189.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+class U
+{
+  template 
+  ~U() { } // expected-error{{destructor cannot be declared as a template}}
+};
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1417,11 +1417,8 @@
   Context.getCanonicalType(ClassType));
 
   DeclContext::lookup_result R = lookup(Name);
-  if (R.empty())
-return nullptr;
 
-  CXXDestructorDecl *Dtor = cast(R.front());
-  return Dtor;
+  return R.empty() ? nullptr : dyn_cast(R.front());
 }
 
 bool CXXRecordDecl::isAnyDestructorNoReturn() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33833: Fix PR 33189: Clang assertion on template destructor declaration

2017-06-13 Thread Kuang He via Phabricator via cfe-commits
kuang_he added a comment.

Can we have this patch reviewed?


https://reviews.llvm.org/D33833



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33833: Fix PR 33189: Clang assertion on template destructor declaration

2017-06-23 Thread Kuang He via Phabricator via cfe-commits
kuang_he added a comment.

Can we get this patch reviewed by any chance?


https://reviews.llvm.org/D33833



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30415: Fix -mno-altivec cannot overwrite -maltivec option

2017-03-27 Thread Kuang He via Phabricator via cfe-commits
kuang_he abandoned this revision.
kuang_he added a comment.

In https://reviews.llvm.org/D30415#703652, @uweigand wrote:

> In https://reviews.llvm.org/D30415#703442, @hfinkel wrote:
>
> > In https://reviews.llvm.org/D30415#703398, @echristo wrote:
> >
> > > Different suggestion:
> > >
> > > Remove the faltivec option. Even gcc doesn't support it anymore afaict.
> >
> >
> > What are you suggesting? Always having the language extensions on? Or 
> > explicitly tying the language extensions to the underlying target feature?
>
>
> I'm a bit confused by this discussion.  -faltivec and -maltivec are simply 
> aliases, they do exactly the same thing; the clang-internal variable 
> OPT_faltivec indicates the use of either -faltivec or -maltivec.
>
> Is the suggestion to remove that flag completely, i.e. both -maltivec and 
> -faltivec?   This seems strange to me since -maltivec is used in many 
> Makefiles etc. that would break if clang suddenly refused to accept the 
> option.
>
> Or is the suggestion to simply remove the alias -faltivec, and leave 
> -maltivec as-is?  I'd be less opposed to this since it probably breaks fewer 
> users ... but I'm still not quite sure what it actually buys us.   And in any 
> case the patch currently under discussion here would still be necessary then, 
> to fix -maltivec -mno-altivec ...





https://reviews.llvm.org/D30415



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33833: Fix PR 33189: Clang assertion on template destructor declaration

2017-06-26 Thread Kuang He via Phabricator via cfe-commits
kuang_he updated this revision to Diff 104018.

https://reviews.llvm.org/D33833

Files:
  lib/AST/DeclCXX.cpp
  test/SemaTemplate/destructor-template.cpp


Index: test/SemaTemplate/destructor-template.cpp
===
--- test/SemaTemplate/destructor-template.cpp
+++ test/SemaTemplate/destructor-template.cpp
@@ -86,3 +86,9 @@
   template decltype(S().~S()) f(); // expected-note {{candidate 
template ignored: couldn't infer template argument 'T'}}
   void g() { f(); } // expected-error {{no matching function for call to 'f'}}
 }
+
+class PR33189
+{
+  template 
+  ~PR33189() { } // expected-error{{destructor cannot be declared as a 
template}}
+};
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1417,11 +1417,8 @@
   Context.getCanonicalType(ClassType));
 
   DeclContext::lookup_result R = lookup(Name);
-  if (R.empty())
-return nullptr;
 
-  CXXDestructorDecl *Dtor = cast(R.front());
-  return Dtor;
+  return R.empty() ? nullptr : dyn_cast(R.front());
 }
 
 bool CXXRecordDecl::isAnyDestructorNoReturn() const {


Index: test/SemaTemplate/destructor-template.cpp
===
--- test/SemaTemplate/destructor-template.cpp
+++ test/SemaTemplate/destructor-template.cpp
@@ -86,3 +86,9 @@
   template decltype(S().~S()) f(); // expected-note {{candidate template ignored: couldn't infer template argument 'T'}}
   void g() { f(); } // expected-error {{no matching function for call to 'f'}}
 }
+
+class PR33189
+{
+  template 
+  ~PR33189() { } // expected-error{{destructor cannot be declared as a template}}
+};
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1417,11 +1417,8 @@
   Context.getCanonicalType(ClassType));
 
   DeclContext::lookup_result R = lookup(Name);
-  if (R.empty())
-return nullptr;
 
-  CXXDestructorDecl *Dtor = cast(R.front());
-  return Dtor;
+  return R.empty() ? nullptr : dyn_cast(R.front());
 }
 
 bool CXXRecordDecl::isAnyDestructorNoReturn() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30415: Fix -mno-altivec cannot overwrite -maltivec option

2017-03-07 Thread Kuang He via Phabricator via cfe-commits
kuang_he updated this revision to Diff 90927.
kuang_he edited the summary of this revision.
kuang_he added a comment.

Add fix and update test case for -fzvector option.


https://reviews.llvm.org/D30415

Files:
  lib/Driver/Tools.cpp
  test/Driver/ppc-features.cpp
  test/Driver/systemz-features.cpp

Index: test/Driver/systemz-features.cpp
===
--- test/Driver/systemz-features.cpp
+++ test/Driver/systemz-features.cpp
@@ -24,3 +24,9 @@
 // RUN: %clang -target s390x-unknown-linux-gnu %s -mvx -mno-vx -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOVX %s
 // CHECK-NOVX: "-target-feature" "-vector"
 // CHECK-NOVX-NOT: "-target-feature" "+vector"
+//
+// RUN: %clang -target s390x-unknown-linux-gnu %s -fzvector -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-ZVECTOR %s
+// CHECK-ZVECTOR: "-fzvector"
+//
+// RUN: %clang -target s390x-unknown-linux-gnu %s -fzvector -fno-zvector -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NO-ZVECTOR %s
+// CHECK-NO-ZVECTOR-NOT: "-fzvector"
Index: test/Driver/ppc-features.cpp
===
--- test/Driver/ppc-features.cpp
+++ test/Driver/ppc-features.cpp
@@ -63,51 +63,67 @@
 
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-1 %s
 // CHECK-1: "-target-feature" "-altivec"
+// CHECK-1-NOT: "-faltivec"
 
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-altivec -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-2 %s
 // CHECK-2: "-target-feature" "-altivec"
+// CHECK-2-NOT: "-faltivec"
 
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -faltivec -mno-altivec -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-3 %s
 // CHECK-3: "-target-feature" "-altivec"
+// CHECK-3-NOT: "-faltivec"
 
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -maltivec -fno-altivec -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-4 %s
 // CHECK-4: "-target-feature" "-altivec"
+// CHECK-4-NOT: "-faltivec"
 
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-altivec -faltivec -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-5 %s
-// CHECK-5-NOT: "-target-feature" "-altivec"
+// CHECK-5: "-target-feature" "+altivec"
+// CHECK-5: "-faltivec"
 
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -maltivec -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-6 %s
-// CHECK-6-NOT: "-target-feature" "-altivec"
+// CHECK-6: "-target-feature" "+altivec"
+// CHECK-6: "-faltivec"
 
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=7400 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-7 %s
 // CHECK-7: "-target-feature" "-altivec"
+// CHECK-7-NOT: "-faltivec"
 
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=g4 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-8 %s
 // CHECK-8: "-target-feature" "-altivec"
+// CHECK-8-NOT: "-faltivec"
 
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=7450 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-9 %s
 // CHECK-9: "-target-feature" "-altivec"
+// CHECK-9-NOT: "-faltivec"
 
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=g4+ -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-10 %s
 // CHECK-10: "-target-feature" "-altivec"
+// CHECK-10-NOT: "-faltivec"
 
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=970 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-11 %s
 // CHECK-11: "-target-feature" "-altivec"
+// CHECK-11-NOT: "-faltivec"
 
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=g5 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-12 %s
 // CHECK-12: "-target-feature" "-altivec"
+// CHECK-12-NOT: "-faltivec"
 
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=pwr6 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-13 %s
 // CHECK-13: "-target-feature" "-altivec"
+// CHECK-13-NOT: "-faltivec"
 
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=pwr7 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-14 %s
 // CHECK-14: "-target-feature" "-altivec"
+// CHECK-14-NOT: "-faltivec"
 
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=pwr8 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-15 %s
 // CHECK-15: "-target-feature" "-altivec"
+// CHECK-15-NOT: "-faltivec"
 
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=ppc64 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-16 %s
 // CHECK-16: "-target-feature" "-altivec"
+// CHECK-16-NOT: "-faltivec"
 
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-qpx -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOQPX %s
 // CHECK-NOQPX: "-target-feature" "-qpx"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4207,8 +4207,13 @@
 CmdArgs.push_