[PATCH] D55662: [Sema][ObjC] Do not warn about repeated uses of weak variables when the variables are accessed in an unevaluated context.

2019-01-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Can we find a way to preserve the rewritten expression out of `DeduceAutoType` 
so that the initialization code just happens to never see a placeholder along 
this path?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55662/new/

https://reviews.llvm.org/D55662



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


r350506 - [X86] Update VBMI2 vshld/vshrd tests to use an immediate that doesn't require a modulo.

2019-01-06 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sun Jan  6 22:01:58 2019
New Revision: 350506

URL: http://llvm.org/viewvc/llvm-project?rev=350506=rev
Log:
[X86] Update VBMI2 vshld/vshrd tests to use an immediate that doesn't require a 
modulo.

Planning to replace these with funnel shift intrinsics which would mask out the 
extra bits. This will help minimize test diffs.

Modified:
cfe/trunk/test/CodeGen/avx512vbmi2-builtins.c
cfe/trunk/test/CodeGen/avx512vlvbmi2-builtins.c

Modified: cfe/trunk/test/CodeGen/avx512vbmi2-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512vbmi2-builtins.c?rev=350506=350505=350506=diff
==
--- cfe/trunk/test/CodeGen/avx512vbmi2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512vbmi2-builtins.c Sun Jan  6 22:01:58 2019
@@ -90,7 +90,7 @@ __m512i test_mm512_mask_shldi_epi64(__m5
   // CHECK-LABEL: @test_mm512_mask_shldi_epi64
   // CHECK: @llvm.x86.avx512.vpshld.q.512
   // CHECK: select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
-  return _mm512_mask_shldi_epi64(__S, __U, __A, __B, 127);
+  return _mm512_mask_shldi_epi64(__S, __U, __A, __B, 47);
 }
 
 __m512i test_mm512_maskz_shldi_epi64(__mmask8 __U, __m512i __A, __m512i __B) {
@@ -110,14 +110,14 @@ __m512i test_mm512_mask_shldi_epi32(__m5
   // CHECK-LABEL: @test_mm512_mask_shldi_epi32
   // CHECK: @llvm.x86.avx512.vpshld.d.512
   // CHECK: select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> %{{.*}}
-  return _mm512_mask_shldi_epi32(__S, __U, __A, __B, 127);
+  return _mm512_mask_shldi_epi32(__S, __U, __A, __B, 7);
 }
 
 __m512i test_mm512_maskz_shldi_epi32(__mmask16 __U, __m512i __A, __m512i __B) {
   // CHECK-LABEL: @test_mm512_maskz_shldi_epi32
   // CHECK: @llvm.x86.avx512.vpshld.d.512
   // CHECK: select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> %{{.*}}
-  return _mm512_maskz_shldi_epi32(__U, __A, __B, 63);
+  return _mm512_maskz_shldi_epi32(__U, __A, __B, 15);
 }
 
 __m512i test_mm512_shldi_epi32(__m512i __A, __m512i __B) {
@@ -130,27 +130,27 @@ __m512i test_mm512_mask_shldi_epi16(__m5
   // CHECK-LABEL: @test_mm512_mask_shldi_epi16
   // CHECK: @llvm.x86.avx512.vpshld.w.512
   // CHECK: select <32 x i1> %{{.*}}, <32 x i16> %{{.*}}, <32 x i16> %{{.*}}
-  return _mm512_mask_shldi_epi16(__S, __U, __A, __B, 127);
+  return _mm512_mask_shldi_epi16(__S, __U, __A, __B, 3);
 }
 
 __m512i test_mm512_maskz_shldi_epi16(__mmask32 __U, __m512i __A, __m512i __B) {
   // CHECK-LABEL: @test_mm512_maskz_shldi_epi16
   // CHECK: @llvm.x86.avx512.vpshld.w.512
   // CHECK: select <32 x i1> %{{.*}}, <32 x i16> %{{.*}}, <32 x i16> %{{.*}}
-  return _mm512_maskz_shldi_epi16(__U, __A, __B, 63);
+  return _mm512_maskz_shldi_epi16(__U, __A, __B, 7);
 }
 
 __m512i test_mm512_shldi_epi16(__m512i __A, __m512i __B) {
   // CHECK-LABEL: @test_mm512_shldi_epi16
   // CHECK: @llvm.x86.avx512.vpshld.w.512
-  return _mm512_shldi_epi16(__A, __B, 31);
+  return _mm512_shldi_epi16(__A, __B, 15);
 }
 
 __m512i test_mm512_mask_shrdi_epi64(__m512i __S, __mmask8 __U, __m512i __A, 
__m512i __B) {
   // CHECK-LABEL: @test_mm512_mask_shrdi_epi64
   // CHECK: @llvm.x86.avx512.vpshrd.q.512
   // CHECK: select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
-  return _mm512_mask_shrdi_epi64(__S, __U, __A, __B, 127);
+  return _mm512_mask_shrdi_epi64(__S, __U, __A, __B, 47);
 }
 
 __m512i test_mm512_maskz_shrdi_epi64(__mmask8 __U, __m512i __A, __m512i __B) {
@@ -170,14 +170,14 @@ __m512i test_mm512_mask_shrdi_epi32(__m5
   // CHECK-LABEL: @test_mm512_mask_shrdi_epi32
   // CHECK: @llvm.x86.avx512.vpshrd.d.512
   // CHECK: select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> %{{.*}}
-  return _mm512_mask_shrdi_epi32(__S, __U, __A, __B, 127);
+  return _mm512_mask_shrdi_epi32(__S, __U, __A, __B, 7);
 }
 
 __m512i test_mm512_maskz_shrdi_epi32(__mmask16 __U, __m512i __A, __m512i __B) {
   // CHECK-LABEL: @test_mm512_maskz_shrdi_epi32
   // CHECK: @llvm.x86.avx512.vpshrd.d.512
   // CHECK: select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> %{{.*}}
-  return _mm512_maskz_shrdi_epi32(__U, __A, __B, 63);
+  return _mm512_maskz_shrdi_epi32(__U, __A, __B, 15);
 }
 
 __m512i test_mm512_shrdi_epi32(__m512i __A, __m512i __B) {
@@ -190,14 +190,14 @@ __m512i test_mm512_mask_shrdi_epi16(__m5
   // CHECK-LABEL: @test_mm512_mask_shrdi_epi16
   // CHECK: @llvm.x86.avx512.vpshrd.w.512
   // CHECK: select <32 x i1> %{{.*}}, <32 x i16> %{{.*}}, <32 x i16> %{{.*}}
-  return _mm512_mask_shrdi_epi16(__S, __U, __A, __B, 127);
+  return _mm512_mask_shrdi_epi16(__S, __U, __A, __B, 3);
 }
 
 __m512i test_mm512_maskz_shrdi_epi16(__mmask32 __U, __m512i __A, __m512i __B) {
   // CHECK-LABEL: @test_mm512_maskz_shrdi_epi16
   // CHECK: @llvm.x86.avx512.vpshrd.w.512
   // CHECK: select <32 x i1> %{{.*}}, <32 x i16> %{{.*}}, <32 x i16> %{{.*}}
-  return _mm512_maskz_shrdi_epi16(__U, __A, __B, 63);
+  return _mm512_maskz_shrdi_epi16(__U, __A, __B, 15);
 }
 
 __m512i 

r350505 - DR674, PR38883, PR40238: Qualified friend lookup should look for a

2019-01-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun Jan  6 22:00:46 2019
New Revision: 350505

URL: http://llvm.org/viewvc/llvm-project?rev=350505=rev
Log:
DR674, PR38883, PR40238: Qualified friend lookup should look for a
template specialization if there is no matching non-template function.

This exposed a couple of related bugs:
 - we would sometimes substitute into a friend template instead of a
   suitable non-friend declaration; this would now crash because we'd
   decide the specialization of the friend is a redeclaration of itself
 - ADL failed to properly handle the case where an invisible local
   extern declaration redeclares an invisible friend

Both are fixed herein: in particular, we now never make invisible
friends or local extern declarations visible to name lookup unless
they are the only declaration of the entity. (We already mostly did
this for local extern declarations.)

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CXX/class.access/class.friend/p1.cpp
cfe/trunk/test/CXX/class.access/class.friend/p11.cpp
cfe/trunk/test/CXX/class/class.friend/p1.cpp
cfe/trunk/test/CXX/drs/dr1xx.cpp
cfe/trunk/test/CXX/drs/dr5xx.cpp
cfe/trunk/test/CXX/drs/dr6xx.cpp
cfe/trunk/test/SemaCXX/cxx1y-deduced-return-type.cpp
cfe/trunk/test/SemaCXX/friend.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=350505=350504=350505=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Jan  6 22:00:46 
2019
@@ -1298,8 +1298,8 @@ def ext_unelaborated_friend_type : ExtWa
 def warn_cxx98_compat_unelaborated_friend_type : Warning<
   "befriending %1 without '%select{struct|interface|union|class|enum}0' "
   "keyword is incompatible with C++98">, InGroup, DefaultIgnore;
-def err_qualified_friend_not_found : Error<
-  "no function named %0 with type %1 was found in the specified scope">;
+def err_qualified_friend_no_match : Error<
+  "friend declaration of %0 does not match any declaration in %1">;
 def err_introducing_special_friend : Error<
   "%plural{[0,2]:must use a qualified name when declaring|3:cannot declare}0"
   " a %select{constructor|destructor|conversion operator|deduction guide}0 "

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=350505=350504=350505=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sun Jan  6 22:00:46 2019
@@ -6356,9 +6356,9 @@ public:
 const TemplateArgumentListInfo ,
 LookupResult );
 
-  bool CheckFunctionTemplateSpecialization(FunctionDecl *FD,
- TemplateArgumentListInfo *ExplicitTemplateArgs,
-   LookupResult );
+  bool CheckFunctionTemplateSpecialization(
+  FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs,
+  LookupResult , bool QualifiedFriend = false);
   bool CheckMemberSpecialization(NamedDecl *Member, LookupResult );
   void CompleteMemberSpecialization(NamedDecl *Member, LookupResult );
 

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=350505=350504=350505=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Sun Jan  6 22:00:46 2019
@@ -1405,6 +1405,12 @@ static bool shouldBeHidden(NamedDecl *D)
   D->isTemplateParameter())
 return true;
 
+  // Skip friends and local extern declarations unless they're the first
+  // declaration of the entity.
+  if ((D->isLocalExternDecl() || D->getFriendObjectKind()) &&
+  D != D->getCanonicalDecl())
+return true;
+
   // Skip template specializations.
   // FIXME: This feels like a hack. Should DeclarationName support
   // template-ids, or is there a better way to keep specializations

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=350505=350504=350505=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Jan  6 22:00:46 2019
@@ -5518,15 +5518,8 @@ NamedDecl *Sema::HandleDeclarator(Scope
 
   

[PATCH] D56271: [SemaCXX] Fix ICE for unexpanded parameter pack

2019-01-06 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a comment.

Thank you for the review!


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56271/new/

https://reviews.llvm.org/D56271



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


[PATCH] D56271: [SemaCXX] Fix ICE for unexpanded parameter pack

2019-01-06 Thread Brian Gesiak via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350501: [SemaCXX] Fix ICE for unexpanded parameter pack 
(authored by modocache, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56271/new/

https://reviews.llvm.org/D56271

Files:
  cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
  cfe/trunk/test/SemaCXX/alias-template.cpp


Index: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
+++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
@@ -164,7 +164,7 @@
   // A function parameter pack is a pack expansion, so cannot contain
   // an unexpanded parameter pack. Likewise for a template parameter
   // pack that contains any references to other packs.
-  if (D->isParameterPack())
+  if (D && D->isParameterPack())
 return true;
 
   return inherited::TraverseDecl(D);
Index: cfe/trunk/test/SemaCXX/alias-template.cpp
===
--- cfe/trunk/test/SemaCXX/alias-template.cpp
+++ cfe/trunk/test/SemaCXX/alias-template.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -std=c++11 %s
+// RUN: %clang_cc1 -verify -std=c++14 -fcxx-exceptions %s
 
 namespace RedeclAliasTypedef {
   template using T = int;
@@ -189,3 +189,7 @@
 
 int g = sfinae_me(); // expected-error{{no matching function for call to 
'sfinae_me'}}
 }
+
+namespace NullExceptionDecl {
+template auto get = []() { try { } catch(...) {}; return I; }; // 
expected-error{{initializer contains unexpanded parameter pack 'I'}}
+}


Index: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
+++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
@@ -164,7 +164,7 @@
   // A function parameter pack is a pack expansion, so cannot contain
   // an unexpanded parameter pack. Likewise for a template parameter
   // pack that contains any references to other packs.
-  if (D->isParameterPack())
+  if (D && D->isParameterPack())
 return true;
 
   return inherited::TraverseDecl(D);
Index: cfe/trunk/test/SemaCXX/alias-template.cpp
===
--- cfe/trunk/test/SemaCXX/alias-template.cpp
+++ cfe/trunk/test/SemaCXX/alias-template.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -std=c++11 %s
+// RUN: %clang_cc1 -verify -std=c++14 -fcxx-exceptions %s
 
 namespace RedeclAliasTypedef {
   template using T = int;
@@ -189,3 +189,7 @@
 
 int g = sfinae_me(); // expected-error{{no matching function for call to 'sfinae_me'}}
 }
+
+namespace NullExceptionDecl {
+template auto get = []() { try { } catch(...) {}; return I; }; // expected-error{{initializer contains unexpanded parameter pack 'I'}}
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r350501 - [SemaCXX] Fix ICE for unexpanded parameter pack

2019-01-06 Thread Brian Gesiak via cfe-commits
Author: modocache
Date: Sun Jan  6 19:25:59 2019
New Revision: 350501

URL: http://llvm.org/viewvc/llvm-project?rev=350501=rev
Log:
[SemaCXX] Fix ICE for unexpanded parameter pack

Summary:
The documentation for RecursiveASTVisitor::TraverseDecl states that the
Decl being traversed may be null. In fact, this is the case when a
CXXCatchStmt with no exception decl is traversed. Because the visitor
for diagnosing unexpanded parameter packs does not check for null, it
ends up crashing when it attempts to call the Decl::isParameterPack
method on a null Decl pointer.

Add a null check to prevent an ICE, and a test case that would crash
otherwise. Also, because the test requires C++ exceptions and C++14,
change the test parameters for the entire test file. (Alternatively, I
thought about adding a new test file, but went with this approach for my
own convenience.)

Co-authored-by: Andreas Molzer 
Co-authored-by: Mara Bos 

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56271

Modified:
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/test/SemaCXX/alias-template.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp?rev=350501=350500=350501=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp Sun Jan  6 19:25:59 2019
@@ -164,7 +164,7 @@ namespace {
   // A function parameter pack is a pack expansion, so cannot contain
   // an unexpanded parameter pack. Likewise for a template parameter
   // pack that contains any references to other packs.
-  if (D->isParameterPack())
+  if (D && D->isParameterPack())
 return true;
 
   return inherited::TraverseDecl(D);

Modified: cfe/trunk/test/SemaCXX/alias-template.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/alias-template.cpp?rev=350501=350500=350501=diff
==
--- cfe/trunk/test/SemaCXX/alias-template.cpp (original)
+++ cfe/trunk/test/SemaCXX/alias-template.cpp Sun Jan  6 19:25:59 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -std=c++11 %s
+// RUN: %clang_cc1 -verify -std=c++14 -fcxx-exceptions %s
 
 namespace RedeclAliasTypedef {
   template using T = int;
@@ -189,3 +189,7 @@ int sfinae_me() { return 0; } // expecte
 
 int g = sfinae_me(); // expected-error{{no matching function for call to 
'sfinae_me'}}
 }
+
+namespace NullExceptionDecl {
+template auto get = []() { try { } catch(...) {}; return I; }; // 
expected-error{{initializer contains unexpanded parameter pack 'I'}}
+}


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


[PATCH] D56365: [X86] Use funnel shift intrinsics for the VBMI2 vshld/vshrd intrinsics.

2019-01-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 180429.
craig.topper added a comment.

Add select checks. Move masking for variable vpshld/vpshrd to the intrinsic 
header. So now we don't need different builtins for mask and maskz.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56365/new/

https://reviews.llvm.org/D56365

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/avx512vbmi2intrin.h
  lib/Headers/avx512vlvbmi2intrin.h
  test/CodeGen/avx512vbmi2-builtins.c
  test/CodeGen/avx512vlvbmi2-builtins.c

Index: test/CodeGen/avx512vlvbmi2-builtins.c
===
--- test/CodeGen/avx512vlvbmi2-builtins.c
+++ test/CodeGen/avx512vlvbmi2-builtins.c
@@ -172,457 +172,481 @@
 
 __m256i test_mm256_mask_shldi_epi64(__m256i __S, __mmask8 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_mask_shldi_epi64
-  // CHECK: @llvm.x86.avx512.vpshld.q.256
+  // CHECK: @llvm.fshl.v4i64(<4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> )
   // CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}}
   return _mm256_mask_shldi_epi64(__S, __U, __A, __B, 127);
 }
 
 __m256i test_mm256_maskz_shldi_epi64(__mmask8 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_maskz_shldi_epi64
-  // CHECK: @llvm.x86.avx512.vpshld.q.256
+  // CHECK: @llvm.fshl.v4i64(<4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> )
   // CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}}
   return _mm256_maskz_shldi_epi64(__U, __A, __B, 63);
 }
 
 __m256i test_mm256_shldi_epi64(__m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_shldi_epi64
-  // CHECK: @llvm.x86.avx512.vpshld.q.256
+  // CHECK: @llvm.fshl.v4i64(<4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> )
   return _mm256_shldi_epi64(__A, __B, 31);
 }
 
 __m128i test_mm_mask_shldi_epi64(__m128i __S, __mmask8 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_mask_shldi_epi64
-  // CHECK: @llvm.x86.avx512.vpshld.q.128
+  // CHECK: @llvm.fshl.v2i64(<2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> )
   // CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}
   return _mm_mask_shldi_epi64(__S, __U, __A, __B, 127);
 }
 
 __m128i test_mm_maskz_shldi_epi64(__mmask8 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_maskz_shldi_epi64
-  // CHECK: @llvm.x86.avx512.vpshld.q.128
+  // CHECK: @llvm.fshl.v2i64(<2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> )
   // CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}
   return _mm_maskz_shldi_epi64(__U, __A, __B, 63);
 }
 
 __m128i test_mm_shldi_epi64(__m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_shldi_epi64
-  // CHECK: @llvm.x86.avx512.vpshld.q.128
+  // CHECK: @llvm.fshl.v2i64(<2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> )
   return _mm_shldi_epi64(__A, __B, 31);
 }
 
 __m256i test_mm256_mask_shldi_epi32(__m256i __S, __mmask8 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_mask_shldi_epi32
-  // CHECK: @llvm.x86.avx512.vpshld.d.256
+  // CHECK: @llvm.fshl.v8i32(<8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> )
   // CHECK: select <8 x i1> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> %{{.*}}
   return _mm256_mask_shldi_epi32(__S, __U, __A, __B, 127);
 }
 
 __m256i test_mm256_maskz_shldi_epi32(__mmask8 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_maskz_shldi_epi32
-  // CHECK: @llvm.x86.avx512.vpshld.d.256
+  // CHECK: @llvm.fshl.v8i32(<8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> )
   // CHECK: select <8 x i1> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> %{{.*}}
   return _mm256_maskz_shldi_epi32(__U, __A, __B, 63);
 }
 
 __m256i test_mm256_shldi_epi32(__m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_shldi_epi32
-  // CHECK: @llvm.x86.avx512.vpshld.d.256
+  // CHECK: @llvm.fshl.v8i32(<8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> )
   return _mm256_shldi_epi32(__A, __B, 31);
 }
 
 __m128i test_mm_mask_shldi_epi32(__m128i __S, __mmask8 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_mask_shldi_epi32
-  // CHECK: @llvm.x86.avx512.vpshld.d.128
+  // CHECK: @llvm.fshl.v4i32(<4 x i32> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> )
   // CHECK: select <4 x i1> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> %{{.*}}
   return _mm_mask_shldi_epi32(__S, __U, __A, __B, 127);
 }
 
 __m128i test_mm_maskz_shldi_epi32(__mmask8 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_maskz_shldi_epi32
-  // CHECK: @llvm.x86.avx512.vpshld.d.128
+  // CHECK: @llvm.fshl.v4i32(<4 x i32> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> )
   // CHECK: select <4 x i1> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> %{{.*}}
   return _mm_maskz_shldi_epi32(__U, __A, __B, 63);
 }
 
 __m128i test_mm_shldi_epi32(__m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_shldi_epi32
-  // CHECK: @llvm.x86.avx512.vpshld.d.128
+  // CHECK: @llvm.fshl.v4i32(<4 x i32> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> )
   return _mm_shldi_epi32(__A, __B, 31);
 

[PATCH] D52610: [Esan] Port cache frag to FreeBSD

2019-01-06 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

Can you try to port this mutant thread-process in ESan to FreeBSD? I don't want 
to see changes in generic LLVM code.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D52610/new/

https://reviews.llvm.org/D52610



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


Re: r350340 - Validate -add-plugin arguments.

2019-01-06 Thread Nico Weber via cfe-commits
(Looks like the bot eventually cycled green:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/41779
)

On Fri, Jan 4, 2019 at 8:14 PM Nico Weber  wrote:

> Thanks for the note. 350451 will hopefully help.
>
> On Fri, Jan 4, 2019 at 2:18 PM Galina Kistanova via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Hello Nico,
>>
>> This commit broke tests on llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast
>> builder:
>>
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/41673
>>
>> . . .
>> Failing Tests (2):
>> Clang :: CodeGenCXX/debug-info-class-limited-plugin.test
>> Clang :: Frontend/plugin-vs-debug-info.cpp
>>
>> Please have a look ASAP?
>>
>> Thanks
>>
>> Galina
>>
>> On Thu, Jan 3, 2019 at 10:29 AM Nico Weber via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: nico
>>> Date: Thu Jan  3 10:26:06 2019
>>> New Revision: 350340
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=350340=rev
>>> Log:
>>> Validate -add-plugin arguments.
>>>
>>> -plugin already prints an error if the name of an unknown plugin is
>>> passed.
>>> -add-plugin used to silently ignore that, now it errors too.
>>>
>>> Differential Revision: https://reviews.llvm.org/D56273
>>>
>>> Added:
>>> cfe/trunk/test/Frontend/plugin-unknown.c
>>> Modified:
>>> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>>>
>>> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=350340=350339=350340=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
>>> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Jan  3 10:26:06
>>> 2019
>>> @@ -33,6 +33,7 @@
>>>  #include "clang/Frontend/DependencyOutputOptions.h"
>>>  #include "clang/Frontend/FrontendDiagnostic.h"
>>>  #include "clang/Frontend/FrontendOptions.h"
>>> +#include "clang/Frontend/FrontendPluginRegistry.h"
>>>  #include "clang/Frontend/LangStandard.h"
>>>  #include "clang/Frontend/MigratorOptions.h"
>>>  #include "clang/Frontend/PreprocessorOutputOptions.h"
>>> @@ -1663,7 +1664,20 @@ static InputKind ParseFrontendArgs(Front
>>>  Opts.ProgramAction = frontend::PluginAction;
>>>  Opts.ActionName = A->getValue();
>>>}
>>> -  Opts.AddPluginActions = Args.getAllArgValues(OPT_add_plugin);
>>> +  for (const std::string  : Args.getAllArgValues(OPT_add_plugin)) {
>>> +bool Found = false;
>>> +for (FrontendPluginRegistry::iterator it =
>>> FrontendPluginRegistry::begin(),
>>> +  ie =
>>> FrontendPluginRegistry::end();
>>> + it != ie; ++it) {
>>> +  if (it->getName() == Arg)
>>> +Found = true;
>>> +}
>>> +if (!Found) {
>>> +  Diags.Report(diag::err_fe_invalid_plugin_name) << Arg;
>>> +  continue;
>>> +}
>>> +Opts.AddPluginActions.push_back(Arg);
>>> +  }
>>>for (const auto *AA : Args.filtered(OPT_plugin_arg))
>>>  Opts.PluginArgs[AA->getValue(0)].emplace_back(AA->getValue(1));
>>>
>>>
>>> Added: cfe/trunk/test/Frontend/plugin-unknown.c
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/plugin-unknown.c?rev=350340=auto
>>>
>>> ==
>>> --- cfe/trunk/test/Frontend/plugin-unknown.c (added)
>>> +++ cfe/trunk/test/Frontend/plugin-unknown.c Thu Jan  3 10:26:06 2019
>>> @@ -0,0 +1,5 @@
>>> +// RUN: not %clang_cc1 -plugin asdf %s 2>&1 | FileCheck %s
>>> +// RUN: not %clang_cc1 -add-plugin asdf %s 2>&1 | FileCheck
>>> --check-prefix=ADD %s
>>> +
>>> +// CHECK: unable to find plugin 'asdf'
>>> +// ADD: unable to find plugin 'asdf'
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56160: [clang-tidy] modernize-use-trailing-return check

2019-01-06 Thread Bernhard Manfred Gruber via Phabricator via cfe-commits
bernhardmgruber marked 4 inline comments as done.
bernhardmgruber added inline comments.



Comment at: test/clang-tidy/modernize-use-trailing-return.cpp:173
+auto l1 = [](int arg) {};
+auto l2 = [](int arg) -> double {};

JonasToth wrote:
> you could figure out the return type of the lambda if it contains a return, 
> otherwise it should be `void`.
I am sorry, but I do not understand what you want. Lambdas have trailing return 
types by default (if it is not left out and deduced). Do you want to 
explicitely generate the deduced return type? This is not what I intended. I 
want to rewrite old return types on the left to be trailing.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56160/new/

https://reviews.llvm.org/D56160



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


[PATCH] D56160: [clang-tidy] modernize-use-trailing-return check

2019-01-06 Thread Bernhard Manfred Gruber via Phabricator via cfe-commits
bernhardmgruber updated this revision to Diff 180419.
bernhardmgruber added a comment.

Big thank you to @JonasToth for providing some macro test cases. I played a bit 
with macros and settled on the following behavior:

- if the closing parenthesis of the function is inside a macro, no FixIt will 
be created (I cannot relyably lex for subsequent CV and ref qualifiers and 
maybe we do not want to make changes in macros)
- if the return type is not CV qualified, i allow macros to be part of it 
because no lexing is required
- if the return type is CV qualified and contains macros, I provide no FixIt

I improved findTrailingReturnTypeSourceLocation() by discovering 
FunctionTypeLoc::getRParenLoc(). I still require some lexing for CV and ref 
qualifiers though.

I tried to improve findReturnTypeAndCVSourceRange() by finding a way to get the 
source range directly from the AST, but it seems the AST does not store source 
locations for CV qualifiers of types. I read that in the docs for 
QualifiedTypeLoc 
. 
So it seems I cannot circumvent finding the locations of const and volatile by 
my own.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56160/new/

https://reviews.llvm.org/D56160

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseTrailingReturnCheck.cpp
  clang-tidy/modernize/UseTrailingReturnCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-trailing-return.rst
  test/clang-tidy/modernize-use-trailing-return.cpp

Index: test/clang-tidy/modernize-use-trailing-return.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-trailing-return.cpp
@@ -0,0 +1,253 @@
+// RUN: %check_clang_tidy %s modernize-use-trailing-return %t -- -- --std=c++14
+
+namespace std {
+template 
+class vector;
+
+class string;
+}
+
+//
+// Functions
+//
+
+int f();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f() -> int;{{$}}
+int f(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int) -> int;{{$}}
+int f(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int arg) -> int;{{$}}
+int f(int arg1, int arg2, int arg3);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int arg1, int arg2, int arg3) -> int;{{$}}
+int f(int arg1, int arg2, int arg3, ...);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int arg1, int arg2, int arg3, ...) -> int;{{$}}
+template  int f(T t);
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}template  auto f(T t) -> int;{{$}}
+
+//
+// Functions with formatting
+//
+
+int a1() { return 42; }
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a1() -> int { return 42; }{{$}}
+int a2() {
+return 42;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a2() -> int {{{$}}
+int a3()
+{
+return 42;
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a3() -> int{{$}}
+int a4(int   arg   )   ;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a4(int   arg   ) -> int   ;{{$}}
+int a5
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a5{{$}}
+(int arg);
+// CHECK-FIXES: {{^}}(int arg) -> int;{{$}}
+
+//
+// Functions with qualifiers and specifiers
+//
+
+inline int d1(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}inline auto d1(int arg) -> int;{{$}}
+extern "C" int d2(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}extern "C" auto d2(int arg) -> int;{{$}}
+inline int d3(int arg) noexcept(true);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: 

[PATCH] D56368: [AST] Store the results in OverloadExpr in a trailing array

2019-01-06 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added a reviewer: rjmccall.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.

Use the newly available space in the bit-fields of `Stmt` to pack
`OverloadExpr`, `UnresolvedLookupExpr` and `UnresolvedMemberExpr`.

Additionally store the results in the overload set in a trailing array.
This saves 1 pointer + 8 bytes per `UnresolvedLookupExpr` and 
`UnresolvedMemberExpr`.


Repository:
  rC Clang

https://reviews.llvm.org/D56368

Files:
  include/clang/AST/ExprCXX.h
  include/clang/AST/Stmt.h
  lib/AST/ExprCXX.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp

Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -1625,25 +1625,23 @@
 void ASTStmtWriter::VisitOverloadExpr(OverloadExpr *E) {
   VisitExpr(E);
 
-  // Don't emit anything here, HasTemplateKWAndArgsInfo must be
-  // emitted first.
-
-  Record.push_back(E->HasTemplateKWAndArgsInfo);
-  if (E->HasTemplateKWAndArgsInfo) {
+  Record.push_back(E->getNumDecls());
+  Record.push_back(E->hasTemplateKWAndArgsInfo());
+  if (E->hasTemplateKWAndArgsInfo()) {
 const ASTTemplateKWAndArgsInfo  =
 *E->getTrailingASTTemplateKWAndArgsInfo();
 Record.push_back(ArgInfo.NumTemplateArgs);
 AddTemplateKWAndArgsInfo(ArgInfo, E->getTrailingTemplateArgumentLoc());
   }
 
-  Record.push_back(E->getNumDecls());
-  for (OverloadExpr::decls_iterator
- OvI = E->decls_begin(), OvE = E->decls_end(); OvI != OvE; ++OvI) {
+  for (OverloadExpr::decls_iterator OvI = E->decls_begin(),
+OvE = E->decls_end();
+   OvI != OvE; ++OvI) {
 Record.AddDeclRef(OvI.getDecl());
 Record.push_back(OvI.getAccess());
   }
 
-  Record.AddDeclarationNameInfo(E->NameInfo);
+  Record.AddDeclarationNameInfo(E->getNameInfo());
   Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
 }
 
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -1648,19 +1648,33 @@
 void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
   VisitExpr(E);
 
-  if (Record.readInt()) // HasTemplateKWAndArgsInfo
+  unsigned NumResults = Record.readInt();
+  bool HasTemplateKWAndArgsInfo = Record.readInt();
+  assert((E->getNumDecls() == NumResults) && "Wrong NumResults!");
+  assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&
+ "Wrong HasTemplateKWAndArgsInfo!");
+
+  if (HasTemplateKWAndArgsInfo) {
+unsigned NumTemplateArgs = Record.readInt();
 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
   E->getTrailingTemplateArgumentLoc(),
-  /*NumTemplateArgs=*/Record.readInt());
+  NumTemplateArgs);
+assert((E->getNumTemplateArgs() == NumTemplateArgs) &&
+   "Wrong NumTemplateArgs!");
+  }
 
-  unsigned NumDecls = Record.readInt();
   UnresolvedSet<8> Decls;
-  for (unsigned i = 0; i != NumDecls; ++i) {
+  for (unsigned I = 0; I != NumResults; ++I) {
 auto *D = ReadDeclAs();
 auto AS = (AccessSpecifier)Record.readInt();
 Decls.addDecl(D, AS);
   }
-  E->initializeResults(Record.getContext(), Decls.begin(), Decls.end());
+
+  DeclAccessPair *Results = E->getTrailingResults();
+  UnresolvedSetIterator Iter = Decls.begin();
+  for (unsigned I = 0; I != NumResults; ++I) {
+Results[I] = (Iter + I).getPair();
+  }
 
   ReadDeclarationNameInfo(E->NameInfo);
   E->QualifierLoc = Record.readNestedNameSpecifierLoc();
@@ -1668,8 +1682,8 @@
 
 void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
   VisitOverloadExpr(E);
-  E->IsArrow = Record.readInt();
-  E->HasUnresolvedUsing = Record.readInt();
+  E->UnresolvedMemberExprBits.IsArrow = Record.readInt();
+  E->UnresolvedMemberExprBits.HasUnresolvedUsing = Record.readInt();
   E->Base = Record.readSubExpr();
   E->BaseType = Record.readType();
   E->OperatorLoc = ReadSourceLocation();
@@ -1677,8 +1691,8 @@
 
 void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
   VisitOverloadExpr(E);
-  E->RequiresADL = Record.readInt();
-  E->Overloaded = Record.readInt();
+  E->UnresolvedLookupExprBits.RequiresADL = Record.readInt();
+  E->UnresolvedLookupExprBits.Overloaded = Record.readInt();
   E->NamingClass = ReadDeclAs();
 }
 
@@ -3261,19 +3275,25 @@
   break;
 
 case EXPR_CXX_UNRESOLVED_MEMBER:
-  S = UnresolvedMemberExpr::CreateEmpty(Context,
- /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
-  /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
-   ? Record[ASTStmtReader::NumExprFields + 1]
-   : 0);
+  S = 

[PATCH] D56367: [AST] Pack CXXDependentScopeMemberExpr

2019-01-06 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added a reviewer: rjmccall.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.

Use the newly available space in the bit-fields of `Stmt`. Additionally store 
`FirstQualifierFoundInScope`
as a trailing object since it is most of the time null (non-null for 2 of the 
35446 `CXXDependentScopeMemberExpr`
when parsing all of Boost).

It would be possible to move the data for the nested-name-specifier to a 
trailing object too to save
another 2 pointers, however doing so did actually regress the time taken to 
parse all of Boost slightly.

This saves 8 bytes + 1 pointer per `CXXDependentScopeMemberExpr` in the vast 
majority of cases.


Repository:
  rC Clang

https://reviews.llvm.org/D56367

Files:
  include/clang/AST/ExprCXX.h
  include/clang/AST/Stmt.h
  lib/AST/ExprCXX.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp

Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -1554,31 +1554,36 @@
   Code = serialization::EXPR_EXPR_WITH_CLEANUPS;
 }
 
-void
-ASTStmtWriter::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
+void ASTStmtWriter::VisitCXXDependentScopeMemberExpr(
+CXXDependentScopeMemberExpr *E) {
   VisitExpr(E);
 
-  // Don't emit anything here, HasTemplateKWAndArgsInfo must be
-  // emitted first.
+  // Don't emit anything here (or if you do you will have to update
+  // the corresponding deserialization function).
 
-  Record.push_back(E->HasTemplateKWAndArgsInfo);
-  if (E->HasTemplateKWAndArgsInfo) {
+  Record.push_back(E->hasTemplateKWAndArgsInfo());
+  Record.push_back(E->getNumTemplateArgs());
+  Record.push_back(E->hasFirstQualifierFoundInScope());
+
+  if (E->hasTemplateKWAndArgsInfo()) {
 const ASTTemplateKWAndArgsInfo  =
 *E->getTrailingObjects();
-Record.push_back(ArgInfo.NumTemplateArgs);
 AddTemplateKWAndArgsInfo(ArgInfo,
  E->getTrailingObjects());
   }
 
+  Record.push_back(E->isArrow());
+  Record.AddSourceLocation(E->getOperatorLoc());
+  Record.AddTypeRef(E->getBaseType());
+  Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
   if (!E->isImplicitAccess())
 Record.AddStmt(E->getBase());
   else
 Record.AddStmt(nullptr);
-  Record.AddTypeRef(E->getBaseType());
-  Record.push_back(E->isArrow());
-  Record.AddSourceLocation(E->getOperatorLoc());
-  Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
-  Record.AddDeclRef(E->getFirstQualifierFoundInScope());
+
+  if (E->hasFirstQualifierFoundInScope())
+Record.AddDeclRef(E->getFirstQualifierFoundInScope());
+
   Record.AddDeclarationNameInfo(E->MemberNameInfo);
   Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_MEMBER;
 }
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -1584,22 +1584,37 @@
   E->SubExpr = Record.readSubExpr();
 }
 
-void
-ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
+void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
+CXXDependentScopeMemberExpr *E) {
   VisitExpr(E);
 
-  if (Record.readInt()) // HasTemplateKWAndArgsInfo
+  bool HasTemplateKWAndArgsInfo = Record.readInt();
+  unsigned NumTemplateArgs = Record.readInt();
+  bool HasFirstQualifierFoundInScope = Record.readInt();
+
+  assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&
+ "Wrong HasTemplateKWAndArgsInfo!");
+  assert(
+  (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&
+  "Wrong HasFirstQualifierFoundInScope!");
+
+  if (HasTemplateKWAndArgsInfo)
 ReadTemplateKWAndArgsInfo(
 *E->getTrailingObjects(),
-E->getTrailingObjects(),
-/*NumTemplateArgs=*/Record.readInt());
+E->getTrailingObjects(), NumTemplateArgs);
 
-  E->Base = Record.readSubExpr();
+  assert((NumTemplateArgs == E->getNumTemplateArgs()) &&
+ "Wrong NumTemplateArgs!");
+
+  E->CXXDependentScopeMemberExprBits.IsArrow = Record.readInt();
+  E->CXXDependentScopeMemberExprBits.OperatorLoc = ReadSourceLocation();
   E->BaseType = Record.readType();
-  E->IsArrow = Record.readInt();
-  E->OperatorLoc = ReadSourceLocation();
   E->QualifierLoc = Record.readNestedNameSpecifierLoc();
-  E->FirstQualifierFoundInScope = ReadDeclAs();
+  E->Base = Record.readSubExpr();
+
+  if (HasFirstQualifierFoundInScope)
+*E->getTrailingObjects() = ReadDeclAs();
+
   ReadDeclarationNameInfo(E->MemberNameInfo);
 }
 
@@ -3224,11 +3239,12 @@
   break;
 
 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
-  S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
- /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
-  

[PATCH] D56134: [AST] Store some data of CXXNewExpr as trailing objects

2019-01-06 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno marked an inline comment as done.
riccibruno added inline comments.



Comment at: include/clang/AST/ExprCXX.h:1950
   /// The allocated type-source information, as written in the source.
   TypeSourceInfo *AllocatedTypeInfo;
 

rjmccall wrote:
> If you ever want a somewhat bigger refactoring project that might provide 
> major wins on C++ code, one idea I've had for awhile is to largely eliminate 
> `TypeSourceInfo` from the AST in favor of storing a `TypeLoc` in most places. 
>  A TSI is basically a TL that stores the location data in a trailing array; 
> it was convenient as a way to retrofit type-location information into the AST 
> without massive changes, and it saves a pointer (at the cost of an extra 
> indirection) when the TSI can be shared between parent nodes.  But I think 
> the TSI can rarely be shared between parent nodes (pretty much just template 
> instantiation of a non-dependent type), and the structure forces the location 
> data to be copied when the type changes (e.g. during template instantiation) 
> even if the location data would be the same.  It also means we can't use a 
> preallocated zero buffer in `getTrivialTypeSourceInfo` with a null 
> `SourceLocation`, and instead we have to allocate and initialize an 
> appropriately-sized zero'ed trailing array.
> 
> The win wouldn't be as large as it could be because `FunctionProtoTypeLoc` 
> includes `ParmVarDecl`s, which get cloned during template instantiation and 
> therefore would always require a new type-location buffer when e.g. 
> instantiating a function temploid.  But it might still be quite significant.
Thanks for the pointer; this type of hint is very useful. I will have to dig 
into this
a bit before commenting on it, but I will definitely keep this in mind.

If you have some time there are two last patches which deal with
`CXXDependentScopeMemberExpr` and `OverloadExpr`, but I don't
want to spam you (with arguably pretty boring patches).


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56134/new/

https://reviews.llvm.org/D56134



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


[PATCH] D56366: New warning call-to-virtual-from-ctor-dtor when calling a virtual function from a constructor or a destructor

2019-01-06 Thread Arnaud Bienner via Phabricator via cfe-commits
ArnaudBienner created this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D56366

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaOverload.cpp
  test/Analysis/ctor.mm
  test/Analysis/dtor.cpp
  test/Analysis/virtualcall.cpp
  test/SemaCXX/warn-virtual-call-from-ctor-dtor.cpp

Index: test/SemaCXX/warn-virtual-call-from-ctor-dtor.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-virtual-call-from-ctor-dtor.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -Wcall-to-virtual-from-ctor-dtor
+struct A {
+  A() { f(); } // expected-warning {{call to virtual member function 'f' from constructor of 'A' will not call overridden implementations}} expected-note {{qualify the call to silence this warning}}
+  ~A() { f(); } // expected-warning {{call to virtual member function 'f' from destructor of 'A' will not call overridden implementations}} expected-note {{qualify the call to silence this warning}}
+
+  virtual void f() {}
+};
+
+// Warns in classes inheriting from A too
+struct B : A {
+  B() { f(); } // expected-warning {{call to virtual member function 'f' from constructor of 'B' will not call overridden implementations}} expected-note {{qualify the call to silence this warning}}
+  ~B() { f(); } // expected-warning {{call to virtual member function 'f' from destructor of 'B' will not call overridden implementations}} expected-note {{qualify the call to silence this warning}}
+  void f() {}
+};
+
+// Don't warn if the class if final
+struct C final : A {
+  C() { f(); }
+  ~C() { f(); }
+};
+
+// Don't warn (or note) when calling the function on a pointer.
+struct D : A {
+  A *a;
+  D() { a->f(); };
+  ~D() { a->f(); };
+};
+
+// Don't warn if the call is fully qualified.
+struct E {
+  virtual void f() = 0;
+  E() {
+E::f();
+  }
+};
Index: test/Analysis/virtualcall.cpp
===
--- test/Analysis/virtualcall.cpp
+++ test/Analysis/virtualcall.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-output=text -verify -std=c++11 %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-output=text -Wno-call-to-virtual-from-ctor-dtor -verify -std=c++11 %s
 
-// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -analyzer-output=text -verify -std=c++11 %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -analyzer-output=text -Wno-call-to-virtual-from-ctor-dtor -verify -std=c++11 %s
 
 #include "virtualcall.h"
 
Index: test/Analysis/dtor.cpp
===
--- test/Analysis/dtor.cpp
+++ test/Analysis/dtor.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection,cplusplus -analyzer-config c++-inlining=destructors -Wno-null-dereference -Wno-inaccessible-base -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection,cplusplus -analyzer-config c++-inlining=destructors -Wno-null-dereference -Wno-inaccessible-base -Wno-call-to-virtual-from-ctor-dtor -verify -analyzer-config eagerly-assume=false %s
 
 void clang_analyzer_eval(bool);
 void clang_analyzer_checkInlined(bool);
Index: test/Analysis/ctor.mm
===
--- test/Analysis/ctor.mm
+++ test/Analysis/ctor.mm
@@ -1,7 +1,7 @@
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -DI386 -analyzer-checker=core,debug.ExprInspection -fobjc-arc -analyzer-config c++-inlining=constructors -Wno-null-dereference -std=c++11 -verify -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -DI386 -analyzer-checker=core,debug.ExprInspection -fobjc-arc -analyzer-config c++-inlining=constructors -Wno-null-dereference -std=c++11 -verify -DTEST_INLINABLE_ALLOCATORS -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin12 -analyzer-checker=core,debug.ExprInspection -fobjc-arc -analyzer-config c++-inlining=constructors -Wno-null-dereference -std=c++11 -verify -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin12 -analyzer-checker=core,debug.ExprInspection -fobjc-arc -analyzer-config c++-inlining=constructors -Wno-null-dereference -std=c++11 -verify -DTEST_INLINABLE_ALLOCATORS -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -DI386 -analyzer-checker=core,debug.ExprInspection -fobjc-arc 

[PATCH] D56365: [X86] Use funnel shift intrinsics for the VBMI2 vshld/vshrd intrinsics.

2019-01-06 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: test/CodeGen/avx512vlvbmi2-builtins.c:415
   // CHECK-LABEL: @test_mm256_mask_shldv_epi64
-  // CHECK: @llvm.x86.avx512.mask.vpshldv.q.256
+  // CHECK: @llvm.fshl.v4i64(<4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> 
%{{.*}})
   return _mm256_mask_shldv_epi64(__S, __U, __A, __B);

Missing CHECK for select? Same for other tests.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56365/new/

https://reviews.llvm.org/D56365



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


[PATCH] D56365: [X86] Use funnel shift intrinsics for the VBMI2 vshld/vshrd intrinsics.

2019-01-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: RKSimon, spatel.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D56365

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/avx512vbmi2-builtins.c
  test/CodeGen/avx512vlvbmi2-builtins.c

Index: test/CodeGen/avx512vlvbmi2-builtins.c
===
--- test/CodeGen/avx512vlvbmi2-builtins.c
+++ test/CodeGen/avx512vlvbmi2-builtins.c
@@ -172,457 +172,457 @@
 
 __m256i test_mm256_mask_shldi_epi64(__m256i __S, __mmask8 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_mask_shldi_epi64
-  // CHECK: @llvm.x86.avx512.vpshld.q.256
+  // CHECK: @llvm.fshl.v4i64(<4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> )
   // CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}}
   return _mm256_mask_shldi_epi64(__S, __U, __A, __B, 127);
 }
 
 __m256i test_mm256_maskz_shldi_epi64(__mmask8 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_maskz_shldi_epi64
-  // CHECK: @llvm.x86.avx512.vpshld.q.256
+  // CHECK: @llvm.fshl.v4i64(<4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> )
   // CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}}
   return _mm256_maskz_shldi_epi64(__U, __A, __B, 63);
 }
 
 __m256i test_mm256_shldi_epi64(__m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_shldi_epi64
-  // CHECK: @llvm.x86.avx512.vpshld.q.256
+  // CHECK: @llvm.fshl.v4i64(<4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> )
   return _mm256_shldi_epi64(__A, __B, 31);
 }
 
 __m128i test_mm_mask_shldi_epi64(__m128i __S, __mmask8 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_mask_shldi_epi64
-  // CHECK: @llvm.x86.avx512.vpshld.q.128
+  // CHECK: @llvm.fshl.v2i64(<2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> )
   // CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}
   return _mm_mask_shldi_epi64(__S, __U, __A, __B, 127);
 }
 
 __m128i test_mm_maskz_shldi_epi64(__mmask8 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_maskz_shldi_epi64
-  // CHECK: @llvm.x86.avx512.vpshld.q.128
+  // CHECK: @llvm.fshl.v2i64(<2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> )
   // CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}
   return _mm_maskz_shldi_epi64(__U, __A, __B, 63);
 }
 
 __m128i test_mm_shldi_epi64(__m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_shldi_epi64
-  // CHECK: @llvm.x86.avx512.vpshld.q.128
+  // CHECK: @llvm.fshl.v2i64(<2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> )
   return _mm_shldi_epi64(__A, __B, 31);
 }
 
 __m256i test_mm256_mask_shldi_epi32(__m256i __S, __mmask8 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_mask_shldi_epi32
-  // CHECK: @llvm.x86.avx512.vpshld.d.256
+  // CHECK: @llvm.fshl.v8i32(<8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> )
   // CHECK: select <8 x i1> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> %{{.*}}
   return _mm256_mask_shldi_epi32(__S, __U, __A, __B, 127);
 }
 
 __m256i test_mm256_maskz_shldi_epi32(__mmask8 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_maskz_shldi_epi32
-  // CHECK: @llvm.x86.avx512.vpshld.d.256
+  // CHECK: @llvm.fshl.v8i32(<8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> )
   // CHECK: select <8 x i1> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> %{{.*}}
   return _mm256_maskz_shldi_epi32(__U, __A, __B, 63);
 }
 
 __m256i test_mm256_shldi_epi32(__m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_shldi_epi32
-  // CHECK: @llvm.x86.avx512.vpshld.d.256
+  // CHECK: @llvm.fshl.v8i32(<8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> )
   return _mm256_shldi_epi32(__A, __B, 31);
 }
 
 __m128i test_mm_mask_shldi_epi32(__m128i __S, __mmask8 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_mask_shldi_epi32
-  // CHECK: @llvm.x86.avx512.vpshld.d.128
+  // CHECK: @llvm.fshl.v4i32(<4 x i32> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> )
   // CHECK: select <4 x i1> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> %{{.*}}
   return _mm_mask_shldi_epi32(__S, __U, __A, __B, 127);
 }
 
 __m128i test_mm_maskz_shldi_epi32(__mmask8 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_maskz_shldi_epi32
-  // CHECK: @llvm.x86.avx512.vpshld.d.128
+  // CHECK: @llvm.fshl.v4i32(<4 x i32> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> )
   // CHECK: select <4 x i1> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> %{{.*}}
   return _mm_maskz_shldi_epi32(__U, __A, __B, 63);
 }
 
 __m128i test_mm_shldi_epi32(__m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_shldi_epi32
-  // CHECK: @llvm.x86.avx512.vpshld.d.128
+  // CHECK: @llvm.fshl.v4i32(<4 x i32> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> )
   return _mm_shldi_epi32(__A, __B, 31);
 }
 
 __m256i test_mm256_mask_shldi_epi16(__m256i __S, __mmask16 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_mask_shldi_epi16
-  // CHECK: @llvm.x86.avx512.vpshld.w.256
+  // CHECK: @llvm.fshl.v16i16(<16 x i16> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> )
   // 

[PATCH] D37035: Implement __builtin_LINE() et. al. to support source location capture.

2019-01-06 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: include/clang/AST/Expr.h:4108
+public:
+  enum IdentType { Function, File, Line, Column };
+

`IdentType` -> `IdentKind` ?



Comment at: include/clang/AST/Expr.h:4147
+  SourceLocation getBeginLoc() const LLVM_READONLY { return BuiltinLoc; }
+  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
+

I don't think that `LLVM_READONLY` is useful here since it is just a simple 
getter.
Same remark for `getIdentType`, `isStringType` and `isIntType`.
And even for `getBuiltinStr` does it actually make a difference ?



Comment at: include/clang/AST/Stmt.h:657
 
+  class SourceLocExprBitfields {
+friend class SourceLocExpr;

Could you please put this in the same place as in
`StmtNodes.td` ? (ie just after `PseudoObjectExpr`)
At least not under "C++ coroutines TS bitfields classes"...



Comment at: lib/AST/ASTContext.cpp:10145
+   unsigned Length) const {
+  // A C++ string literal has a const-qualified element type (C++ 2.13.4p1).
+  EltTy = EltTy.withConst();

And what about C ? It seems to me that `getStringLiteralArrayType`
should be used systematically when the type of a string literal is needed.

(eg in `ActOnStringLiteral` but this is not the only place...)



Comment at: lib/AST/Expr.cpp:1961
+// A C++ string literal has a const-qualified element type (C++ 2.13.4p1).
+if (Ctx.getLangOpts().CPlusPlus || Ctx.getLangOpts().ConstStrings)
+  Ty = Ty.withConst();

Is it taking into account `adjustStringLiteralBaseType` as in 
`getStringLiteralArrayType` ?



Comment at: lib/AST/Expr.cpp:1978
+  BuiltinLoc(BLoc), RParenLoc(RParenLoc), ParentContext(ParentContext) {
+  SourceLocExprBits.Type = Type;
+}

The name `Type` here is really unfortunate imho.



Comment at: lib/AST/Expr.cpp:1992
+  }
+}
+

`llvm_unreachable("unexpected IdentType!")`



Comment at: lib/AST/Expr.cpp:2025
+  // If we have a simple identifier there is no need to cache the
+  // human readable name.
+  if (IdentifierInfo *II = FD->getDeclName().getAsIdentifierInfo())

This comment is strange since MkStr will call 
`getPredefinedStringLiteralFromCache`
when `FD->getDeclName()` is a simple identifier.



Comment at: lib/AST/Expr.cpp:2037
+llvm::APSInt IntVal(
+llvm::APInt(Ctx.getTargetInfo().getIntWidth(), LineOrCol));
+return APValue(IntVal);

Both `getLine`, `getColumn` and `APInt` take an unsigned.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D37035/new/

https://reviews.llvm.org/D37035



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


Re: r350404 - Refactor the way we handle diagnosing unused expression results.

2019-01-06 Thread Aaron Ballman via cfe-commits
On Sun, Jan 6, 2019 at 10:58 AM Nico Weber  wrote:
>
> On Sat, Jan 5, 2019 at 10:16 AM Aaron Ballman  wrote:
>>
>> On Fri, Jan 4, 2019 at 8:41 PM Richard Smith  wrote:
>> >
>> > On Fri, 4 Jan 2019 at 17:33, Nico Weber via cfe-commits 
>> >  wrote:
>> >>
>> >> Nice, this is finding bugs: 
>> >> https://bugs.chromium.org/p/chromium/issues/detail?id=919262
>> >>
>> >> However, I noticed that for that case, the same warning is printed twice:
>> >>
>> >> ../../third_party/crashpad/crashpad/util/win/process_info.cc(227,36):  
>> >> error: expression result unused [-Werror,-Wunused-value]
>> >>   NTSTATUS_LOG(ERROR, status), "NtQueryInformationProcess";
>> >>^~~
>> >> ../../third_party/crashpad/crashpad/util/win/process_info.cc(227,36):  
>> >> error: expression result unused [-Werror,-Wunused-value]
>> >>   NTSTATUS_LOG(ERROR, status), "NtQueryInformationProcess";
>> >>
>> >>
>> >> Is that expected?
>>
>> Yes and no. It's not unexpected, but it's not super helpful either. As
>> Richard points out below, this happens because of template
>> instantiation.
>>
>> > The first diagnostic appears when parsing the template, the second one 
>> > appears when instantiating it. In the complete diagnostic output:
>> >
>> > ../../third_party/crashpad/crashpad/util/win/process_info.cc(227,36):  
>> > error: expression result unused [-Werror,-Wunused-value]
>> >   NTSTATUS_LOG(ERROR, status), "NtQueryInformationProcess";
>> >^~~
>> >
>> > ../../third_party/crashpad/crashpad/util/win/process_info.cc(227,36):  
>> > error: expression result unused [-Werror,-Wunused-value]
>> >   NTSTATUS_LOG(ERROR, status), "NtQueryInformationProcess";
>> >^~~
>> > ../../third_party/crashpad/crashpad/util/win/process_info.cc(531,17):  
>> > note: in instantiation of function template specialization 
>> > 'crashpad::GetProcessBasicInformation'
>> >  requested here
>> >   bool result = 
>> > GetProcessBasicInformation(
>> > ^
>> >
>> > It'd be nice to suppress the diagnostic during instantiation if it 
>> > appeared during the initial parse (generally, not with something specific 
>> > to this warning).
>>
>> Agreed, though I don't have the time to work on that currently.
>> Hopefully the behavior here isn't too onerous for Chromium (or other
>> projects)?
>
>
> It wasn't a problem for us, no. The warning found a bug, we fixed the bug, 
> everyone's happy. Just thought I'd mention the diag looks strange; thanks for 
> the explanation (and the warning improvement) :-)

I'm glad to hear the refactoring is catching more issues, that's
great! I'm also glad the template instantiation stuff isn't causing
too much of a problem for you.

~Aaron

>
>>
>>
>> ~Aaron
>>
>> >
>> >> Code is here:
>> >> https://cs.chromium.org/chromium/src/third_party/crashpad/crashpad/util/win/process_info.cc?q=crashpad/util/win/process_info.cc=package:chromium=0=227
>> >> https://cs.chromium.org/chromium/src/third_party/crashpad/crashpad/util/win/ntstatus_logging.h?type=cs=NTSTATUS_LOG=package:chromium=0=63
>> >>
>> >>
>> >> On Fri, Jan 4, 2019 at 12:01 PM Aaron Ballman via cfe-commits 
>> >>  wrote:
>> >>>
>> >>> Author: aaronballman
>> >>> Date: Fri Jan  4 08:58:14 2019
>> >>> New Revision: 350404
>> >>>
>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=350404=rev
>> >>> Log:
>> >>> Refactor the way we handle diagnosing unused expression results.
>> >>>
>> >>> Rather than sprinkle calls to DiagnoseUnusedExprResult() around in 
>> >>> places where we want diagnostics, we now diagnose unused expression 
>> >>> statements and full expressions in a more generic way when acting on the 
>> >>> final expression statement. This results in more appropriate diagnostics 
>> >>> for [[nodiscard]] where we were previously lacking them, such as when 
>> >>> the body of a for loop is not a compound statement.
>> >>>
>> >>> This patch fixes PR39837.
>> >>>
>> >>> Modified:
>> >>> cfe/trunk/include/clang/Parse/Parser.h
>> >>> cfe/trunk/include/clang/Sema/Sema.h
>> >>> cfe/trunk/lib/Parse/ParseObjc.cpp
>> >>> cfe/trunk/lib/Parse/ParseOpenMP.cpp
>> >>> cfe/trunk/lib/Parse/ParseStmt.cpp
>> >>> cfe/trunk/lib/Sema/SemaCoroutine.cpp
>> >>> cfe/trunk/lib/Sema/SemaDecl.cpp
>> >>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> >>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> >>> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>> >>> cfe/trunk/lib/Sema/SemaLambda.cpp
>> >>> cfe/trunk/lib/Sema/SemaOpenMP.cpp
>> >>> cfe/trunk/lib/Sema/SemaStmt.cpp
>> >>> cfe/trunk/lib/Sema/TreeTransform.h
>> >>> cfe/trunk/test/CXX/stmt.stmt/stmt.select/p3.cpp
>> >>> cfe/trunk/test/CodeCompletion/pragma-macro-token-caching.c
>> >>> cfe/trunk/test/Parser/cxx1z-init-statement.cpp
>> >>> cfe/trunk/test/Parser/switch-recovery.cpp
>> >>> 

r350495 - Fix bug in test found by the diagnostic added in r350340.

2019-01-06 Thread Nico Weber via cfe-commits
Author: nico
Date: Sun Jan  6 07:57:18 2019
New Revision: 350495

URL: http://llvm.org/viewvc/llvm-project?rev=350495=rev
Log:
Fix bug in test found by the diagnostic added in r350340.

I meant to commit this change in 350341 but failed to do so (since it's
in test/CodeGenCXX, not in test/Frontend).

Modified:
cfe/trunk/test/CodeGenCXX/debug-info-class-limited-plugin.test

Modified: cfe/trunk/test/CodeGenCXX/debug-info-class-limited-plugin.test
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-class-limited-plugin.test?rev=350495=350494=350495=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-class-limited-plugin.test (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-class-limited-plugin.test Sun Jan  6 
07:57:18 2019
@@ -1,2 +1,2 @@
-RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -o - -load 
%llvmshlibdir/PrintFunctionNames%pluginext -add-plugin print-function-names 
%S/Inputs/debug-info-class-limited.cpp 2>&1 | FileCheck 
%S/Inputs/debug-info-class-limited.cpp
+RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -o - -load 
%llvmshlibdir/PrintFunctionNames%pluginext -add-plugin print-fns 
%S/Inputs/debug-info-class-limited.cpp 2>&1 | FileCheck 
%S/Inputs/debug-info-class-limited.cpp
 REQUIRES: plugins, examples


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


[PATCH] D56303: [clang-tidy] Handle case/default statements when simplifying boolean expressions

2019-01-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.cpp:386
 
-  bool BoolValue = Bool->getValue();
+  const bool BoolValue = Bool->getValue();
 

LegalizeAdulthood wrote:
> JonasToth wrote:
> > `const` on values is uncommon in clang-tidy code. Please keep that 
> > consistent.
> I can change the code, but I don't understand the push back.
> 
> "That's the way it's done elsewhere" just doesn't seem like good reasoning.
> 
> I write const on values to signify that they are computed once and only once. 
>  What is gained by removing that statement of once-and-only-once?
> "That's the way it's done elsewhere" just doesn't seem like good reasoning.

Keeping the code consistent with the vast majority of the remainder of the 
project is valid reasoning. I am echoing the request to drop the top-level 
const. We don't use this pattern for non-pointer/reference types and there's 
not a whole lot gained by using it inconsistently.



Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.cpp:533-540
+  switchStmt(has(
+  compoundStmt(
+  has(defaultStmt(hasDescendant(ifStmt(hasThen(returnsBool(Value)),
+   unless(hasElse(stmt(
+.bind(CompoundIfId)))
+  .bind(DefaultId)),
+  has(returnStmt(has(cxxBoolLiteral(equals(!Value))

LegalizeAdulthood wrote:
> aaron.ballman wrote:
> > The check duplication here is unfortunate -- can you factor out the 
> > `hasDescendant()` bits into a variable that is reused, and perhaps use 
> > `anyOf(caseStmt(stuff()), defaultStmt(stuff()))` rather than separate 
> > functions?
> I'm not a fan of duplication, either.
> 
> However, I have to know if it's a CaseStmt or DefaultStmt in the replacement 
> code and that's tied to the id, so I'm not sure how to collapse it further.
You can bind to the `castStmt()` and `defaultStmt()` matchers to see what you 
get back, no? e.g., `anyOf(caseStmt(stuff()).bind("which"), 
defaultStmt(stuff()).bind("which"))` and in the check, you can use `isa<>` on 
the node named `"which"` to see whether you matched the case or the default 
label.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56303/new/

https://reviews.llvm.org/D56303



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


[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

2019-01-06 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

libprotobuf still builds cleanly with just the one expected warning..despite 
adding over 500 [[nodiscards]]

F7800873: image.png 

I'll continue to look at other projects, but I'm happy at present that this 
gives us a good starting point.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55433/new/

https://reviews.llvm.org/D55433



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


[PATCH] D56050: [Sema] Diagnose array access preceding the array bounds even when the base type is incomplete.

2019-01-06 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

Friendly ping ?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56050/new/

https://reviews.llvm.org/D56050



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


[PATCH] D55405: [CMake] Use hidden visibility for static libc++ in Fuchsia

2019-01-06 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350491: [CMake] Use hidden visibility for static libc++ in 
Fuchsia (authored by phosek, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55405?vs=177092=180393#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55405/new/

https://reviews.llvm.org/D55405

Files:
  cfe/trunk/cmake/caches/Fuchsia-stage2.cmake


Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
@@ -119,6 +119,7 @@
 set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE 
BOOL "")
 
set(RUNTIMES_${target}-fuchsia_LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY OFF 
CACHE BOOL "")
+set(RUNTIMES_${target}-fuchsia_LIBCXX_HERMETIC_STATIC_LIBRARY ON CACHE 
BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXX_ABI_VERSION 2 CACHE STRING "")
   endforeach()
 


Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
@@ -119,6 +119,7 @@
 set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY OFF CACHE BOOL "")
+set(RUNTIMES_${target}-fuchsia_LIBCXX_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXX_ABI_VERSION 2 CACHE STRING "")
   endforeach()
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r350491 - [CMake] Use hidden visibility for static libc++ in Fuchsia

2019-01-06 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Sun Jan  6 00:23:56 2019
New Revision: 350491

URL: http://llvm.org/viewvc/llvm-project?rev=350491=rev
Log:
[CMake] Use hidden visibility for static libc++ in Fuchsia

This is enables the use of libc++ in contexts such as device drivers.

Differential Revision: https://reviews.llvm.org/D55405

Modified:
cfe/trunk/cmake/caches/Fuchsia-stage2.cmake

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=350491=350490=350491=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Sun Jan  6 00:23:56 2019
@@ -119,6 +119,7 @@ if(FUCHSIA_SDK)
 set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE 
BOOL "")
 
set(RUNTIMES_${target}-fuchsia_LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY OFF 
CACHE BOOL "")
+set(RUNTIMES_${target}-fuchsia_LIBCXX_HERMETIC_STATIC_LIBRARY ON CACHE 
BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXX_ABI_VERSION 2 CACHE STRING "")
   endforeach()
 


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