[clang] e616a42 - [SyntaxTree] Test for '\' inside token.

2020-09-20 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-09-21T06:56:14Z
New Revision: e616a4259889b55ed1bf5bf095f0e59658c6e311

URL: 
https://github.com/llvm/llvm-project/commit/e616a4259889b55ed1bf5bf095f0e59658c6e311
DIFF: 
https://github.com/llvm/llvm-project/commit/e616a4259889b55ed1bf5bf095f0e59658c6e311.diff

LOG: [SyntaxTree] Test for '\' inside token.

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

Added: 


Modified: 
clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp 
b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
index 95ebeb2c5940..52bd5988b44e 100644
--- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -167,6 +167,23 @@ TranslationUnit Detached
 )txt"));
 }
 
+TEST_P(BuildSyntaxTreeTest, Simple_BackslashInsideToken) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+in\
+t a;
+)cpp",
+  R"txt(
+TranslationUnit Detached
+`-SimpleDeclaration
+  |-'in\
+t'
+  |-SimpleDeclarator Declarator
+  | `-'a'
+  `-';'
+)txt"));
+}
+
 TEST_P(BuildSyntaxTreeTest, If) {
   EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(



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


[PATCH] D87895: [SyntaxTree] Test for '\' inside token.

2020-09-20 Thread Eduardo Caldas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe616a4259889: [SyntaxTree] Test for '\' inside 
token. (authored by eduucaldas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87895

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp


Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -167,6 +167,23 @@
 )txt"));
 }
 
+TEST_P(BuildSyntaxTreeTest, Simple_BackslashInsideToken) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+in\
+t a;
+)cpp",
+  R"txt(
+TranslationUnit Detached
+`-SimpleDeclaration
+  |-'in\
+t'
+  |-SimpleDeclarator Declarator
+  | `-'a'
+  `-';'
+)txt"));
+}
+
 TEST_P(BuildSyntaxTreeTest, If) {
   EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(


Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -167,6 +167,23 @@
 )txt"));
 }
 
+TEST_P(BuildSyntaxTreeTest, Simple_BackslashInsideToken) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+in\
+t a;
+)cpp",
+  R"txt(
+TranslationUnit Detached
+`-SimpleDeclaration
+  |-'in\
+t'
+  |-SimpleDeclarator Declarator
+  | `-'a'
+  `-';'
+)txt"));
+}
+
 TEST_P(BuildSyntaxTreeTest, If) {
   EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87382: [AST] Fix dependence-bits for CXXDefaultInitExpr.

2020-09-20 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf8f1e5fb39d2: [AST] Fix dependence-bits for 
CXXDefaultInitExpr. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87382

Files:
  clang/include/clang/AST/ComputeDependence.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/test/SemaCXX/invalid-constructor-init.cpp


Index: clang/test/SemaCXX/invalid-constructor-init.cpp
===
--- clang/test/SemaCXX/invalid-constructor-init.cpp
+++ clang/test/SemaCXX/invalid-constructor-init.cpp
@@ -9,8 +9,7 @@
 constexpr int Z = X().Y; // expected-error {{constexpr variable 'Z' must be 
initialized by a constant expression}}
 
 struct X2 {
-  int Y = foo();// expected-error {{use of undeclared identifier 'foo'}} \
- // expected-note {{subexpression not valid in a constant 
expression}}
+  int Y = foo();// expected-error {{use of undeclared identifier 'foo'}}
   constexpr X2() {} // expected-error {{constexpr constructor never produces a 
constant expression}}
 };
 
@@ -27,3 +26,9 @@
   // no bogus "delegation cycle" diagnostic
   CycleDelegate(float) : CycleDelegate(1) {}
 };
+
+struct X4 {
+  int* p = new int(invalid()); // expected-error {{use of undeclared 
identifier}}
+};
+// no crash on evaluating the CXXDefaultInitExpr.
+constexpr int* s = X4().p; // expected-error {{must be initialized by}}
Index: clang/lib/AST/ExprCXX.cpp
===
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -959,7 +959,7 @@
   CXXDefaultInitExprBits.Loc = Loc;
   assert(Field->hasInClassInitializer());
 
-  setDependence(ExprDependence::None);
+  setDependence(computeDependence(this));
 }
 
 CXXTemporary *CXXTemporary::Create(const ASTContext &C,
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -694,6 +694,10 @@
   return D;
 }
 
+ExprDependence clang::computeDependence(CXXDefaultInitExpr *E) {
+  return E->getExpr()->getDependence();
+}
+
 ExprDependence clang::computeDependence(LambdaExpr *E,
 bool ContainsUnexpandedParameterPack) {
   auto D = toExprDependence(E->getType()->getDependence());
Index: clang/include/clang/AST/ComputeDependence.h
===
--- clang/include/clang/AST/ComputeDependence.h
+++ clang/include/clang/AST/ComputeDependence.h
@@ -70,6 +70,7 @@
 class OverloadExpr;
 class DependentScopeDeclRefExpr;
 class CXXConstructExpr;
+class CXXDefaultInitExpr;
 class LambdaExpr;
 class CXXUnresolvedConstructExpr;
 class CXXDependentScopeMemberExpr;
@@ -153,6 +154,7 @@
  bool KnownContainsUnexpandedParameterPack);
 ExprDependence computeDependence(DependentScopeDeclRefExpr *E);
 ExprDependence computeDependence(CXXConstructExpr *E);
+ExprDependence computeDependence(CXXDefaultInitExpr *E);
 ExprDependence computeDependence(LambdaExpr *E,
  bool ContainsUnexpandedParameterPack);
 ExprDependence computeDependence(CXXUnresolvedConstructExpr *E);


Index: clang/test/SemaCXX/invalid-constructor-init.cpp
===
--- clang/test/SemaCXX/invalid-constructor-init.cpp
+++ clang/test/SemaCXX/invalid-constructor-init.cpp
@@ -9,8 +9,7 @@
 constexpr int Z = X().Y; // expected-error {{constexpr variable 'Z' must be initialized by a constant expression}}
 
 struct X2 {
-  int Y = foo();// expected-error {{use of undeclared identifier 'foo'}} \
- // expected-note {{subexpression not valid in a constant expression}}
+  int Y = foo();// expected-error {{use of undeclared identifier 'foo'}}
   constexpr X2() {} // expected-error {{constexpr constructor never produces a constant expression}}
 };
 
@@ -27,3 +26,9 @@
   // no bogus "delegation cycle" diagnostic
   CycleDelegate(float) : CycleDelegate(1) {}
 };
+
+struct X4 {
+  int* p = new int(invalid()); // expected-error {{use of undeclared identifier}}
+};
+// no crash on evaluating the CXXDefaultInitExpr.
+constexpr int* s = X4().p; // expected-error {{must be initialized by}}
Index: clang/lib/AST/ExprCXX.cpp
===
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -959,7 +959,7 @@
   CXXDefaultInitExprBits.Loc = Loc;
   assert(Field->hasInClassInitializer());
 
-  setDependence(ExprDependence::None);
+  setDependence(computeDependence(this));
 }
 
 CXXTemporary *CXXTemporary::Create(const ASTContext &C,
Index: clang/lib/AST/ComputeDependence.cpp
===
--- cla

[clang] f8f1e5f - [AST] Fix dependence-bits for CXXDefaultInitExpr.

2020-09-20 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-09-21T08:47:01+02:00
New Revision: f8f1e5fb39d20985974658fb3d4401a80c0fcccd

URL: 
https://github.com/llvm/llvm-project/commit/f8f1e5fb39d20985974658fb3d4401a80c0fcccd
DIFF: 
https://github.com/llvm/llvm-project/commit/f8f1e5fb39d20985974658fb3d4401a80c0fcccd.diff

LOG: [AST] Fix dependence-bits for CXXDefaultInitExpr.

Reviewed By: sammccall

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

Added: 


Modified: 
clang/include/clang/AST/ComputeDependence.h
clang/lib/AST/ComputeDependence.cpp
clang/lib/AST/ExprCXX.cpp
clang/test/SemaCXX/invalid-constructor-init.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ComputeDependence.h 
b/clang/include/clang/AST/ComputeDependence.h
index ac2daf9eb95a..6af0e4604b63 100644
--- a/clang/include/clang/AST/ComputeDependence.h
+++ b/clang/include/clang/AST/ComputeDependence.h
@@ -70,6 +70,7 @@ class CXXPseudoDestructorExpr;
 class OverloadExpr;
 class DependentScopeDeclRefExpr;
 class CXXConstructExpr;
+class CXXDefaultInitExpr;
 class LambdaExpr;
 class CXXUnresolvedConstructExpr;
 class CXXDependentScopeMemberExpr;
@@ -153,6 +154,7 @@ ExprDependence computeDependence(OverloadExpr *E, bool 
KnownDependent,
  bool KnownContainsUnexpandedParameterPack);
 ExprDependence computeDependence(DependentScopeDeclRefExpr *E);
 ExprDependence computeDependence(CXXConstructExpr *E);
+ExprDependence computeDependence(CXXDefaultInitExpr *E);
 ExprDependence computeDependence(LambdaExpr *E,
  bool ContainsUnexpandedParameterPack);
 ExprDependence computeDependence(CXXUnresolvedConstructExpr *E);

diff  --git a/clang/lib/AST/ComputeDependence.cpp 
b/clang/lib/AST/ComputeDependence.cpp
index c3a209026662..320025e5fc82 100644
--- a/clang/lib/AST/ComputeDependence.cpp
+++ b/clang/lib/AST/ComputeDependence.cpp
@@ -694,6 +694,10 @@ ExprDependence clang::computeDependence(CXXConstructExpr 
*E) {
   return D;
 }
 
+ExprDependence clang::computeDependence(CXXDefaultInitExpr *E) {
+  return E->getExpr()->getDependence();
+}
+
 ExprDependence clang::computeDependence(LambdaExpr *E,
 bool ContainsUnexpandedParameterPack) {
   auto D = toExprDependence(E->getType()->getDependence());

diff  --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 1fd2b8e3b4e2..fe2de4b8cbce 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -959,7 +959,7 @@ CXXDefaultInitExpr::CXXDefaultInitExpr(const ASTContext 
&Ctx,
   CXXDefaultInitExprBits.Loc = Loc;
   assert(Field->hasInClassInitializer());
 
-  setDependence(ExprDependence::None);
+  setDependence(computeDependence(this));
 }
 
 CXXTemporary *CXXTemporary::Create(const ASTContext &C,

diff  --git a/clang/test/SemaCXX/invalid-constructor-init.cpp 
b/clang/test/SemaCXX/invalid-constructor-init.cpp
index df10afb1d726..3e0c8b59c1bb 100644
--- a/clang/test/SemaCXX/invalid-constructor-init.cpp
+++ b/clang/test/SemaCXX/invalid-constructor-init.cpp
@@ -9,8 +9,7 @@ struct X {
 constexpr int Z = X().Y; // expected-error {{constexpr variable 'Z' must be 
initialized by a constant expression}}
 
 struct X2 {
-  int Y = foo();// expected-error {{use of undeclared identifier 'foo'}} \
- // expected-note {{subexpression not valid in a constant 
expression}}
+  int Y = foo();// expected-error {{use of undeclared identifier 'foo'}}
   constexpr X2() {} // expected-error {{constexpr constructor never produces a 
constant expression}}
 };
 
@@ -27,3 +26,9 @@ struct CycleDelegate {
   // no bogus "delegation cycle" diagnostic
   CycleDelegate(float) : CycleDelegate(1) {}
 };
+
+struct X4 {
+  int* p = new int(invalid()); // expected-error {{use of undeclared 
identifier}}
+};
+// no crash on evaluating the CXXDefaultInitExpr.
+constexpr int* s = X4().p; // expected-error {{must be initialized by}}



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


[PATCH] D81272: [clang-tidy] New check `bugprone-redundant-branch-condition`

2020-09-20 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D81272#2276342 , @sylvestre.ledru 
wrote:

> Thanks for this checker. FYI, it found (at least) 3 defects in Firefox code 
> (fixed with the autofix):
> https://hg.mozilla.org/mozilla-central/rev/651e68f628d0
>
> https://bugzilla.mozilla.org/show_bug.cgi?id=1664747
> (unlikely that it was causing any actual bugs in the product)

Thank you for your info. These defects do not cause any bug directly, but they 
make code understanding harder which may cause bugs in the future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81272

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


[PATCH] D87896: [SyntaxTree][Synthesis] Improve testing `createLeaf`

2020-09-20 Thread Eduardo Caldas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbb5b28f12fbd: [SyntaxTree][Synthesis] Improve testing 
`createLeaf` (authored by eduucaldas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87896

Files:
  clang/unittests/Tooling/Syntax/SynthesisTest.cpp


Index: clang/unittests/Tooling/Syntax/SynthesisTest.cpp
===
--- clang/unittests/Tooling/Syntax/SynthesisTest.cpp
+++ clang/unittests/Tooling/Syntax/SynthesisTest.cpp
@@ -51,6 +51,19 @@
   )txt"));
 }
 
+TEST_P(SynthesisTest, Leaf_Punctuation_CXX) {
+  if (!GetParam().isCXX())
+return;
+
+  buildTree("", GetParam());
+
+  auto *Leaf = createLeaf(*Arena, tok::coloncolon);
+
+  EXPECT_TRUE(treeDumpEqual(Leaf, R"txt(
+'::' Detached synthesized
+  )txt"));
+}
+
 TEST_P(SynthesisTest, Leaf_Keyword) {
   buildTree("", GetParam());
 
@@ -61,6 +74,19 @@
   )txt"));
 }
 
+TEST_P(SynthesisTest, Leaf_Keyword_CXX11) {
+  if (!GetParam().isCXX11OrLater())
+return;
+
+  buildTree("", GetParam());
+
+  auto *Leaf = createLeaf(*Arena, tok::kw_nullptr);
+
+  EXPECT_TRUE(treeDumpEqual(Leaf, R"txt(
+'nullptr' Detached synthesized
+  )txt"));
+}
+
 TEST_P(SynthesisTest, Leaf_Identifier) {
   buildTree("", GetParam());
 


Index: clang/unittests/Tooling/Syntax/SynthesisTest.cpp
===
--- clang/unittests/Tooling/Syntax/SynthesisTest.cpp
+++ clang/unittests/Tooling/Syntax/SynthesisTest.cpp
@@ -51,6 +51,19 @@
   )txt"));
 }
 
+TEST_P(SynthesisTest, Leaf_Punctuation_CXX) {
+  if (!GetParam().isCXX())
+return;
+
+  buildTree("", GetParam());
+
+  auto *Leaf = createLeaf(*Arena, tok::coloncolon);
+
+  EXPECT_TRUE(treeDumpEqual(Leaf, R"txt(
+'::' Detached synthesized
+  )txt"));
+}
+
 TEST_P(SynthesisTest, Leaf_Keyword) {
   buildTree("", GetParam());
 
@@ -61,6 +74,19 @@
   )txt"));
 }
 
+TEST_P(SynthesisTest, Leaf_Keyword_CXX11) {
+  if (!GetParam().isCXX11OrLater())
+return;
+
+  buildTree("", GetParam());
+
+  auto *Leaf = createLeaf(*Arena, tok::kw_nullptr);
+
+  EXPECT_TRUE(treeDumpEqual(Leaf, R"txt(
+'nullptr' Detached synthesized
+  )txt"));
+}
+
 TEST_P(SynthesisTest, Leaf_Identifier) {
   buildTree("", GetParam());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] bb5b28f - [SyntaxTree][Synthesis] Improve testing `createLeaf`

2020-09-20 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-09-21T06:11:46Z
New Revision: bb5b28f12fbd029773dc93d18a82ef42f4889b2a

URL: 
https://github.com/llvm/llvm-project/commit/bb5b28f12fbd029773dc93d18a82ef42f4889b2a
DIFF: 
https://github.com/llvm/llvm-project/commit/bb5b28f12fbd029773dc93d18a82ef42f4889b2a.diff

LOG: [SyntaxTree][Synthesis] Improve testing `createLeaf`

The new test shows that `createLeaf` depends on the C++ version.

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

Added: 


Modified: 
clang/unittests/Tooling/Syntax/SynthesisTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/SynthesisTest.cpp 
b/clang/unittests/Tooling/Syntax/SynthesisTest.cpp
index a882714ccf33..8d9fb706eac3 100644
--- a/clang/unittests/Tooling/Syntax/SynthesisTest.cpp
+++ b/clang/unittests/Tooling/Syntax/SynthesisTest.cpp
@@ -51,6 +51,19 @@ TEST_P(SynthesisTest, Leaf_Punctuation) {
   )txt"));
 }
 
+TEST_P(SynthesisTest, Leaf_Punctuation_CXX) {
+  if (!GetParam().isCXX())
+return;
+
+  buildTree("", GetParam());
+
+  auto *Leaf = createLeaf(*Arena, tok::coloncolon);
+
+  EXPECT_TRUE(treeDumpEqual(Leaf, R"txt(
+'::' Detached synthesized
+  )txt"));
+}
+
 TEST_P(SynthesisTest, Leaf_Keyword) {
   buildTree("", GetParam());
 
@@ -61,6 +74,19 @@ TEST_P(SynthesisTest, Leaf_Keyword) {
   )txt"));
 }
 
+TEST_P(SynthesisTest, Leaf_Keyword_CXX11) {
+  if (!GetParam().isCXX11OrLater())
+return;
+
+  buildTree("", GetParam());
+
+  auto *Leaf = createLeaf(*Arena, tok::kw_nullptr);
+
+  EXPECT_TRUE(treeDumpEqual(Leaf, R"txt(
+'nullptr' Detached synthesized
+  )txt"));
+}
+
 TEST_P(SynthesisTest, Leaf_Identifier) {
   buildTree("", GetParam());
 



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


[PATCH] D87394: [PowerPC][Power10] Implementation of 128-bit Binary Vector Mod and Sign Extend builtins

2020-09-20 Thread Albion Fung via Phabricator via cfe-commits
Conanap added inline comments.



Comment at: clang/lib/Headers/altivec.h:17394
+static __inline__ vector signed __int128 __ATTRS_o_ai
+vec_mod(vector signed __int128 __a, vector signed __int128 __b) {
+  return __builtin_altivec_vmodsq(__a, __b);

Conanap wrote:
> amyk wrote:
> > nit: Move these under the existing `vec_mod` builtins.
> > Also, is it possible for these to be open coded instead? We have `vec_mod` 
> > for other types that are open coded. 
> > 
> Probably? Although the downsteram impementation is actually not open coded. 
> We can still change it though.
> Probably? Although the downsteram impementation is actually not open coded. 
> We can still change it though.




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

https://reviews.llvm.org/D87394

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


[PATCH] D87394: [PowerPC][Power10] Implementation of 128-bit Binary Vector Mod and Sign Extend builtins

2020-09-20 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 293076.
Conanap added a comment.

Open Coded instead


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

https://reviews.llvm.org/D87394

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  clang/test/CodeGen/builtins-ppc-p9vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCInstrAltivec.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-vector-modulo.ll
  llvm/test/CodeGen/PowerPC/p10-vector-sign-extend.ll

Index: llvm/test/CodeGen/PowerPC/p10-vector-sign-extend.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/p10-vector-sign-extend.ll
@@ -0,0 +1,67 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+
+; This test case aims to test vector sign extend builtins.
+
+declare <4 x i32> @llvm.ppc.altivec.vextsb2w(<16 x i8>) nounwind readnone
+declare <2 x i64> @llvm.ppc.altivec.vextsb2d(<16 x i8>) nounwind readnone
+declare <4 x i32> @llvm.ppc.altivec.vextsh2w(<8 x i16>) nounwind readnone
+declare <2 x i64> @llvm.ppc.altivec.vextsh2d(<8 x i16>) nounwind readnone
+declare <2 x i64> @llvm.ppc.altivec.vextsw2d(<4 x i32>) nounwind readnone
+declare <1 x i128> @llvm.ppc.altivec.vextsd2q(<2 x i64>) nounwind readnone
+
+define <4 x i32> @test_vextsb2w(<16 x i8> %x) nounwind readnone {
+; CHECK-LABEL: test_vextsb2w:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vextsb2w v2, v2
+; CHECK-NEXT:blr
+  %tmp = tail call <4 x i32> @llvm.ppc.altivec.vextsb2w(<16 x i8> %x)
+  ret <4 x i32> %tmp
+}
+
+define <2 x i64> @test_vextsb2d(<16 x i8> %x) nounwind readnone {
+; CHECK-LABEL: test_vextsb2d:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vextsb2d v2, v2
+; CHECK-NEXT:blr
+  %tmp = tail call <2 x i64> @llvm.ppc.altivec.vextsb2d(<16 x i8> %x)
+  ret <2 x i64> %tmp
+}
+
+define <4 x i32> @test_vextsh2w(<8 x i16> %x) nounwind readnone {
+; CHECK-LABEL: test_vextsh2w:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vextsh2w v2, v2
+; CHECK-NEXT:blr
+  %tmp = tail call <4 x i32> @llvm.ppc.altivec.vextsh2w(<8 x i16> %x)
+  ret <4 x i32> %tmp
+}
+
+define <2 x i64> @test_vextsh2d(<8 x i16> %x) nounwind readnone {
+; CHECK-LABEL: test_vextsh2d:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vextsh2d v2, v2
+; CHECK-NEXT:blr
+  %tmp = tail call <2 x i64> @llvm.ppc.altivec.vextsh2d(<8 x i16> %x)
+  ret <2 x i64> %tmp
+}
+
+define <2 x i64> @test_vextsw2d(<4 x i32> %x) nounwind readnone {
+; CHECK-LABEL: test_vextsw2d:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vextsw2d v2, v2
+; CHECK-NEXT:blr
+  %tmp = tail call <2 x i64> @llvm.ppc.altivec.vextsw2d(<4 x i32> %x)
+  ret <2 x i64> %tmp
+}
+
+define <1 x i128> @test_vextsd2q(<2 x i64> %x) nounwind readnone {
+; CHECK-LABEL: test_vextsd2q:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vextsd2q v2, v2
+; CHECK-NEXT:blr
+  %tmp = tail call <1 x i128> @llvm.ppc.altivec.vextsd2q(<2 x i64> %x)
+  ret <1 x i128> %tmp
+}
Index: llvm/test/CodeGen/PowerPC/p10-vector-modulo.ll
===
--- llvm/test/CodeGen/PowerPC/p10-vector-modulo.ll
+++ llvm/test/CodeGen/PowerPC/p10-vector-modulo.ll
@@ -10,6 +10,28 @@
 ; The vector modulo instructions operate on signed and unsigned words
 ; and doublewords.
 
+; The vector modulo instructions operate on signed and unsigned words,
+; doublewords and 128-bit values.
+
+
+define <1 x i128> @test_vmodsq(<1 x i128> %x, <1 x i128> %y) nounwind readnone {
+; CHECK-LABEL: test_vmodsq:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vmodsq v2, v2, v3
+; CHECK-NEXT:blr
+  %tmp = srem <1 x i128> %x, %y
+  ret <1 x i128> %tmp
+}
+
+define <1 x i128> @test_vmoduq(<1 x i128> %x, <1 x i128> %y) nounwind readnone {
+; CHECK-LABEL: test_vmoduq:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vmoduq v2, v2, v3
+; CHECK-NEXT:blr
+  %tmp = urem <1 x i128> %x, %y
+  ret <1 x i128> %tmp
+}
+
 define <2 x i64> @test_vmodud(<2 x i64> %a, <2 x i64> %b) {
 ; CHECK-LABEL: test_vmodud:
 ; CHECK:   # %bb.0: # %entry
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -1338,11 +1338,14 @@
   def VCMPGTSQ_rec : VCMPo <903, "vcmpgtsq. $vD, $vA, $vB" , v1i128>;
   def VCMPGTUQ_rec : VCMPo <647, "vcmpgtuq. $vD, $vA, $vB" , v1i128>;
   def VMODSQ : VXForm_1<1803, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
-"vmodsq $vD, $vA, $vB", IIC_VecGeneral, []>;
+"vmodsq $vD, $vA, $vB", IIC_VecGeneral,
+[(set v1i128:$vD

[clang] aa76935 - [c++20] Consistent with the intent to allow all plausible types in

2020-09-20 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-09-20T23:09:26-07:00
New Revision: aa769358d8c80d06963d7bc529dd6edd76d3f0de

URL: 
https://github.com/llvm/llvm-project/commit/aa769358d8c80d06963d7bc529dd6edd76d3f0de
DIFF: 
https://github.com/llvm/llvm-project/commit/aa769358d8c80d06963d7bc529dd6edd76d3f0de.diff

LOG: [c++20] Consistent with the intent to allow all plausible types in
non-type template parameters, permit vector types.

Added: 


Modified: 
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/Type.cpp
clang/test/CXX/temp/temp.param/p7.cpp

Removed: 




diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 88ca7cf11606..84a0be5ee199 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -1345,7 +1345,7 @@ void CXXRecordDecl::addedMember(Decl *D) {
   //   types of all non-static data members are structural types or
   //   (possibly multidimensional) array thereof
   // We deal with class types elsewhere.
-  if (!T->isScalarType() && !T->isLValueReferenceType())
+  if (!T->isStructuralType())
 data().StructuralIfLiteral = false;
 }
 

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 8a47b75ac88a..1e31ba76cca4 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2600,7 +2600,8 @@ bool Type::isStructuralType() const {
   // C++20 [temp.param]p6:
   //   A structural type is one of the following:
   //   -- a scalar type; or
-  if (isScalarType())
+  //   -- a vector type [Clang extension]; or
+  if (isScalarType() || isVectorType())
 return true;
   //   -- an lvalue reference type; or
   if (isLValueReferenceType())

diff  --git a/clang/test/CXX/temp/temp.param/p7.cpp 
b/clang/test/CXX/temp/temp.param/p7.cpp
index bc203a8ad2ff..ae78af7a016c 100644
--- a/clang/test/CXX/temp/temp.param/p7.cpp
+++ b/clang/test/CXX/temp/temp.param/p7.cpp
@@ -32,15 +32,15 @@ template<_Complex float ci> struct ComplexFloat; // 
cxx17-error {{cannot have ty
 template<_Complex int ci> struct ComplexInt; // cxx17-error {{cannot have type 
'_Complex int' before C++20}}
 template<_ExtInt(42) ei> struct ExtInt;
 
-// atomic and vector types aren't scalar types
-// FIXME: Consider permitting vector types here.
+// atomic types aren't scalar types
 template<_Atomic float ci> struct AtomicFloat; // expected-error {{cannot have 
type '_Atomic(float)'}}
 template<_Atomic int ci> struct AtomicInt; // expected-error {{cannot have 
type '_Atomic(int)'}}
 
+// we allow vector types as an extension
 typedef __attribute__((ext_vector_type(4))) int VI4;
 typedef __attribute__((ext_vector_type(4))) float VF4;
-template struct VectorInt; // expected-error {{cannot have type 'VI4'}}
-template struct VectorFloat; // expected-error {{cannot have type 'VF4'}}
+template struct VectorInt; // cxx17-error {{cannot have type 'VI4'}}
+template struct VectorFloat; // cxx17-error {{cannot have type 'VF4'}}
 
 struct A2 {};
 
@@ -64,6 +64,8 @@ struct B : A, public A2 {
   _Complex int ci;
   _Complex float cf;
   _ExtInt(42) ei;
+  VI4 vi4;
+  VF4 vf4;
 };
 
 template struct ClassNTTP {}; // cxx17-error {{cannot have type 'B'}}
@@ -119,8 +121,6 @@ struct MutableField {
 };
 template struct WithMutableField {}; // cxx17-error {{cannot 
have type}} cxx20-error {{is not a structural type}}
 
-template struct BadExtType { T t; }; // cxx20-note 4{{has a 
non-static data member of non-structural type}}
+template struct BadExtType { T t; }; // cxx20-note 2{{has a 
non-static data member of non-structural type}}
 template > struct AtomicFloatField; // cxx17-error 
{{cannot have type}} cxx20-error {{is not a structural type}}
 template > struct AtomicInt; // cxx17-error {{cannot 
have type}} cxx20-error {{is not a structural type}}
-template > struct VectorInt; // cxx17-error {{cannot have 
type}} cxx20-error {{is not a structural type}}
-template > struct VectorFloat; // cxx17-error {{cannot have 
type}} cxx20-error {{is not a structural type}}



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


[PATCH] D87942: [Analyzer] GNU named variadic macros in Plister

2020-09-20 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

The fix is great, thank you so much! The test seems to be annoying, it might be 
worth looking into it some other time, but that is definitely orthogonal to 
this patch.




Comment at: clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:1211-1212
 
-  while (
-  !(ParenthesesDepth == 1 &&
-(CurrParamII == __VA_ARGS__II ? false : TheTok.is(tok::comma {
+  while (CurrParamII == VariadicParamII || ParenthesesDepth != 1 ||
+ !TheTok.is(tok::comma)) {
 assert(TheTok.isNot(tok::eof) &&

That looks so much better.



Comment at: clang/test/Analysis/plist-macros-with-expansion.cpp:529-531
 // FIXME: Stringify and escape __VA_ARGS__ correctly.
 // CHECK: nameSTRINGIFIED_VA_ARGS
 // CHECK-NEXT: expansionvariadicCFunction(x, 
"Additional supply depots required.", ")";x = 0;

These FileCheck lines are great, because the plist file on its own is not very 
readable, could you include them for the new test as well? Side note, we're 
already thinking that removing the plist file might be a good idea (its a mess 
to keep up-to-date, and doesn't test all that much).



Comment at: clang/test/Analysis/plist-macros-with-expansion.cpp:536
+  do {   \
+  } while (0)
+

chrish_ericsson_atx wrote:
> Seems the do {} while (0) idiom is a problem, because the plist output gets 
> formatted differently on windows than it does on Linux.   (Extra space).  
Oh that is a real shame, we absolutely shouldn't do that! Can we somehow 
provoke a warning through some other way? (null pointer dereference)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87942

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


[PATCH] D80531: [clang-tidy]: Added modernize-replace-disallow-copy-and-assign-macro

2020-09-20 Thread Konrad Kleine via Phabricator via cfe-commits
kkleine added a comment.

Hi @dblaikie . I did run `ninja check-all` and `/bin/llvm-lit -av 
../clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp`
 on this very new revision (abd70fb3983f342bc1c90f9c70a7b59790ad5206 
) manually 
but I don't see this error coming up. Can you please try to test if you see the 
error on a fresh build?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80531

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


[PATCH] D71524: [analyzer] Support tainted objects in GenericTaintChecker

2020-09-20 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

I figured you're still working on this, sorry! I'd really like to chat about my 
earlier comment D71524#1917251 , as it 
kind of challenges the high level idea.


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

https://reviews.llvm.org/D71524

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


[PATCH] D80531: [clang-tidy]: Added modernize-replace-disallow-copy-and-assign-macro

2020-09-20 Thread Konrad Kleine via Phabricator via cfe-commits
kkleine added a comment.

@dblaikie sorry for not getting to it for so long. I'm taking a look at the 
problem you've described now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80531

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


[clang] 0cd73db - [c++20] For P1907R1: Add checking for structural types for non-type

2020-09-20 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-09-20T20:20:52-07:00
New Revision: 0cd73dbe2c0d169ec2cdd9a8264f4ee1695b53b7

URL: 
https://github.com/llvm/llvm-project/commit/0cd73dbe2c0d169ec2cdd9a8264f4ee1695b53b7
DIFF: 
https://github.com/llvm/llvm-project/commit/0cd73dbe2c0d169ec2cdd9a8264f4ee1695b53b7.diff

LOG: [c++20] For P1907R1: Add checking for structural types for non-type
template parameters.

No support for the new kinds of non-type template argument yet.

This is not entirely NFC for prior language modes: we have historically
incorrectly accepted rvalue references as the types of non-type template
parameters. Such invalid code is now rejected.

Added: 
clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp

Modified: 
clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/Type.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/Type.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/CXX/temp/temp.param/p7.cpp
clang/test/CodeGenCXX/debug-info-template.cpp
clang/test/SemaCXX/invalid-template-params.cpp

Removed: 




diff  --git a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def 
b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
index 33e65f8ebf44..4ce6771259d9 100644
--- a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
+++ b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
@@ -210,6 +210,9 @@ FIELD(DefaultedDestructorIsConstexpr, 1, NO_MERGE)
 /// member or base class of non-literal or volatile type.
 FIELD(HasNonLiteralTypeFieldsOrBases, 1, NO_MERGE)
 
+/// True if this class is a structural type, assuming it is a literal type.
+FIELD(StructuralIfLiteral, 1, NO_MERGE)
+
 /// Whether we have a C++11 user-provided default constructor (not
 /// explicitly deleted or defaulted).
 FIELD(UserProvidedDefaultConstructor, 1, NO_MERGE)

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 20f058b87e7f..da5ae0fa999d 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1396,6 +1396,11 @@ class CXXRecordDecl : public RecordDecl {
 hasTrivialDefaultConstructor());
   }
 
+  /// Determine whether this is a structural type.
+  bool isStructural() const {
+return isLiteral() && data().StructuralIfLiteral;
+  }
+
   /// If this record is an instantiation of a member class,
   /// retrieves the member class from which it was instantiated.
   ///

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index d8eece10475a..d16edf8a6b12 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1927,6 +1927,9 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
   /// (C++11 [basic.types]p10)
   bool isLiteralType(const ASTContext &Ctx) const;
 
+  /// Determine if this type is a structural type, per C++20 [temp.param]p7.
+  bool isStructuralType() const;
+
   /// Test if this type is a standard-layout type.
   /// (C++0x [basic.type]p9)
   bool isStandardLayoutType() const;

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 2e265e114191..053aae7a6afa 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4423,6 +4423,28 @@ def note_template_nontype_parm_prev_declaration : Note<
   "previous non-type template parameter with type %0 is here">;
 def err_template_nontype_parm_bad_type : Error<
   "a non-type template parameter cannot have type %0">;
+def err_template_nontype_parm_bad_structural_type : Error<
+  "a non-type template parameter cannot have type %0 before C++20">;
+def err_template_nontype_parm_incomplete : Error<
+  "non-type template parameter has incomplete type %0">;
+def err_template_nontype_parm_not_literal : Error<
+  "non-type template parameter has non-literal type %0">;
+def err_template_nontype_parm_rvalue_ref : Error<
+  "non-type template parameter has rvalue reference type %0">;
+def err_template_nontype_parm_not_structural : Error<
+  "type %0 of non-type template parameter is not a structural type">;
+def note_not_structural_non_public : Note<
+  "%0 is not a structural type because it has a "
+  "%select{non-static data member|base class}1 that is not public">;
+def note_not_structural_mutable_field : Note<
+  "%0 is not a structural type because it has a mutable "
+  "non-static data member">;
+def note_not_structural_rvalue_ref_field : Note<
+  "%0 is not a structural type because it has a non-static data member "
+  "of rvalue reference type">;
+def note_not_structural_subobject : Note<
+  "%0 is not a structural type because it has a "
+  "%select{non-static data member|base class}1 of non-structural type %2">;
 def warn_cxx14_compat_templa

[PATCH] D87981: [X86] AMX programming model prototype.

2020-09-20 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke updated this revision to Diff 293051.
LuoYuanke added a comment.
Herald added a subscriber: nikic.

Updating D87981 : [X86] AMX programming model 
prototype.
 Fixed lit test case failure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87981

Files:
  clang/include/clang/Basic/BuiltinsX86_64.def
  clang/lib/Headers/amxintrin.h
  clang/test/CodeGen/AMX/amx_api.c
  llvm/include/llvm/CodeGen/LiveIntervalUnion.h
  llvm/include/llvm/CodeGen/LiveRegMatrix.h
  llvm/include/llvm/CodeGen/Passes.h
  llvm/include/llvm/CodeGen/TileShapeInfo.h
  llvm/include/llvm/CodeGen/VirtRegMap.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/lib/CodeGen/InlineSpiller.cpp
  llvm/lib/CodeGen/LiveIntervalUnion.cpp
  llvm/lib/CodeGen/LiveRegMatrix.cpp
  llvm/lib/CodeGen/VirtRegMap.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86ExpandPseudo.cpp
  llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86InstrAMX.td
  llvm/lib/Target/X86/X86InstrInfo.cpp
  llvm/lib/Target/X86/X86LowerAMXType.cpp
  llvm/lib/Target/X86/X86MachineFunctionInfo.h
  llvm/lib/Target/X86/X86RegisterInfo.cpp
  llvm/lib/Target/X86/X86RegisterInfo.h
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/lib/Target/X86/X86TileConfig.cpp
  llvm/test/CodeGen/X86/AMX/amx-config.ll
  llvm/test/CodeGen/X86/AMX/amx-spill.ll
  llvm/test/CodeGen/X86/AMX/amx-type.ll
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/opt-pipeline.ll
  llvm/utils/TableGen/IntrinsicEmitter.cpp

Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
===
--- llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp
@@ -246,7 +246,8 @@
   IIT_SUBDIVIDE4_ARG = 45,
   IIT_VEC_OF_BITCASTS_TO_INT = 46,
   IIT_V128 = 47,
-  IIT_BF16 = 48
+  IIT_BF16 = 48,
+  IIT_V256 = 49
 };
 
 static void EncodeFixedValueType(MVT::SimpleValueType VT,
@@ -384,6 +385,7 @@
 case 32: Sig.push_back(IIT_V32); break;
 case 64: Sig.push_back(IIT_V64); break;
 case 128: Sig.push_back(IIT_V128); break;
+case 256: Sig.push_back(IIT_V256); break;
 case 512: Sig.push_back(IIT_V512); break;
 case 1024: Sig.push_back(IIT_V1024); break;
 }
Index: llvm/test/CodeGen/X86/opt-pipeline.ll
===
--- llvm/test/CodeGen/X86/opt-pipeline.ll
+++ llvm/test/CodeGen/X86/opt-pipeline.ll
@@ -24,6 +24,7 @@
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Expand Atomic instructions
+; CHECK-NEXT:   Lower AMX type for load/store
 ; CHECK-NEXT:   Module Verifier
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Basic Alias Analysis (stateless AA impl)
@@ -141,6 +142,7 @@
 ; CHECK-NEXT:   Lazy Machine Block Frequency Analysis
 ; CHECK-NEXT:   Machine Optimization Remark Emitter
 ; CHECK-NEXT:   Greedy Register Allocator
+; CHECK-NEXT:   Tile Register Configure
 ; CHECK-NEXT:   Virtual Register Rewriter
 ; CHECK-NEXT:   Stack Slot Coloring
 ; CHECK-NEXT:   Machine Copy Propagation Pass
Index: llvm/test/CodeGen/X86/O0-pipeline.ll
===
--- llvm/test/CodeGen/X86/O0-pipeline.ll
+++ llvm/test/CodeGen/X86/O0-pipeline.ll
@@ -18,6 +18,7 @@
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Expand Atomic instructions
+; CHECK-NEXT:   Lower AMX type for load/store
 ; CHECK-NEXT:   Module Verifier
 ; CHECK-NEXT:   Lower Garbage Collection Instructions
 ; CHECK-NEXT:   Shadow Stack GC Lowering
Index: llvm/test/CodeGen/X86/AMX/amx-type.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/AMX/amx-type.ll
@@ -0,0 +1,143 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -lower-amx-type %s -S | FileCheck %s
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%struct.__tile_str = type { i16, i16, <256 x i32> }
+
+@buf = dso_local global [1024 x i8] zeroinitializer, align 16
+@buf2 = dso_local global [1024 x i8] zeroinitializer, align 16
+
+define dso_local void @test_load(i8* %in, i8* %out) local_unnamed_addr #2 {
+; CHECK-LABEL: @test_load(
+; CHECK-NEXT:[[TMP1:%.*]] = bitcast i8* [[IN:%.*]] to <256 x i32>*
+; CHECK-NEXT:[[TMP2:%.*]] = bitcast i8* [[OUT:%.*]] to <256 x i32>*
+; CHECK-NEXT:[[TMP3:%.*]] = bitcast <256 x i32>* [[TMP1]] to <128 x i32>*
+; CHECK-NEXT:[[TMP4:%.*]] = load <128 

[PATCH] D87225: [clangd] When finding refs for a template specialization, do not return refs to other specializations

2020-09-20 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 293047.
nridge added a comment.

Take a different fix approach, as suggested in the issue discussion


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87225

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1582,6 +1582,13 @@
   f.[[^~]]Foo();
 }
   )cpp",
+  R"cpp(// Renaming alias
+template  class Vector {};
+using [[^X]] = Vector;
+[[X]] x1;
+Vector x2;
+Vector y;
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1140,11 +1140,18 @@
   } else {
 // Handle references to Decls.
 
-// We also show references to the targets of using-decls, so we include
-// DeclRelation::Underlying.
-DeclRelationSet Relations = DeclRelation::TemplatePattern |
-DeclRelation::Alias | DeclRelation::Underlying;
+DeclRelationSet Relations =
+DeclRelation::TemplatePattern | DeclRelation::Alias;
 auto Decls = getDeclAtPosition(AST, *CurLoc, Relations);
+// If the results include a *non-renaming* alias, get its
+// underlying decls as well. (See similar logic in locateASTReferent()).
+for (const NamedDecl *D : Decls) {
+  if (llvm::isa(D) || llvm::isa(D)) {
+Decls = getDeclAtPosition(AST, *CurLoc,
+  Relations | DeclRelation::Underlying);
+break;
+  }
+}
 
 // We traverse the AST to find references in the main file.
 auto MainFileRefs = findRefs(Decls, AST);


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1582,6 +1582,13 @@
   f.[[^~]]Foo();
 }
   )cpp",
+  R"cpp(// Renaming alias
+template  class Vector {};
+using [[^X]] = Vector;
+[[X]] x1;
+Vector x2;
+Vector y;
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1140,11 +1140,18 @@
   } else {
 // Handle references to Decls.
 
-// We also show references to the targets of using-decls, so we include
-// DeclRelation::Underlying.
-DeclRelationSet Relations = DeclRelation::TemplatePattern |
-DeclRelation::Alias | DeclRelation::Underlying;
+DeclRelationSet Relations =
+DeclRelation::TemplatePattern | DeclRelation::Alias;
 auto Decls = getDeclAtPosition(AST, *CurLoc, Relations);
+// If the results include a *non-renaming* alias, get its
+// underlying decls as well. (See similar logic in locateASTReferent()).
+for (const NamedDecl *D : Decls) {
+  if (llvm::isa(D) || llvm::isa(D)) {
+Decls = getDeclAtPosition(AST, *CurLoc,
+  Relations | DeclRelation::Underlying);
+break;
+  }
+}
 
 // We traverse the AST to find references in the main file.
 auto MainFileRefs = findRefs(Decls, AST);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87256: [clangd] Avoid relations being overwritten in a header shard

2020-09-20 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 293045.
nridge added a comment.
Herald added a subscriber: mgrang.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87256

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp

Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -547,6 +547,8 @@
   Sym2.CanonicalDeclaration.FileURI = BHeaderUri.c_str();
   Sym2.Definition.FileURI = BSourceUri.c_str();
 
+  auto Sym3 = symbol("3"); // not stored
+
   IndexFileIn IF;
   {
 SymbolSlab::Builder B;
@@ -562,12 +564,12 @@
   }
   {
 RelationSlab::Builder B;
-// Should be stored in a.h
+// Should be stored in a.h and b.h
 B.insert(Relation{Sym1.ID, RelationKind::BaseOf, Sym2.ID});
-// Should be stored in b.h
+// Should be stored in a.h and b.h
 B.insert(Relation{Sym2.ID, RelationKind::BaseOf, Sym1.ID});
-// Dangling relation should be dropped.
-B.insert(Relation{symbol("3").ID, RelationKind::BaseOf, Sym1.ID});
+// Should be stored in a.h even though it's dangling
+B.insert(Relation{Sym3.ID, RelationKind::BaseOf, Sym1.ID});
 IF.Relations.emplace(std::move(B).build());
   }
 
@@ -605,7 +607,9 @@
 EXPECT_THAT(*Shard->Refs, IsEmpty());
 EXPECT_THAT(
 *Shard->Relations,
-UnorderedElementsAre(Relation{Sym1.ID, RelationKind::BaseOf, Sym2.ID}));
+UnorderedElementsAre(Relation{Sym1.ID, RelationKind::BaseOf, Sym2.ID},
+ Relation{Sym2.ID, RelationKind::BaseOf, Sym1.ID},
+ Relation{Sym3.ID, RelationKind::BaseOf, Sym1.ID}));
 ASSERT_THAT(Shard->Sources->keys(), UnorderedElementsAre(AHeaderUri));
 EXPECT_THAT(Shard->Sources->lookup(AHeaderUri).DirectIncludes, IsEmpty());
 EXPECT_TRUE(Shard->Cmd.hasValue());
@@ -617,7 +621,8 @@
 EXPECT_THAT(*Shard->Refs, IsEmpty());
 EXPECT_THAT(
 *Shard->Relations,
-UnorderedElementsAre(Relation{Sym2.ID, RelationKind::BaseOf, Sym1.ID}));
+UnorderedElementsAre(Relation{Sym1.ID, RelationKind::BaseOf, Sym2.ID},
+ Relation{Sym2.ID, RelationKind::BaseOf, Sym1.ID}));
 ASSERT_THAT(Shard->Sources->keys(),
 UnorderedElementsAre(BHeaderUri, AHeaderUri));
 EXPECT_THAT(Shard->Sources->lookup(BHeaderUri).DirectIncludes,
Index: clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -229,6 +229,49 @@
FileURI("unittest:///root/B.cc")}));
 }
 
+TEST_F(BackgroundIndexTest, RelationsMultiFile) {
+  MockFS FS;
+  FS.Files[testPath("root/RAV.h")] = "template  class RAV {};";
+  FS.Files[testPath("root/A.cc")] = R"cpp(
+#include "RAV.h"
+class A : public RAV {};
+  )cpp";
+  FS.Files[testPath("root/B.cc")] = R"cpp(
+#include "RAV.h"
+class B : public RAV {};
+  )cpp";
+
+  llvm::StringMap Storage;
+  size_t CacheHits = 0;
+  MemoryShardStorage MSS(Storage, CacheHits);
+  OverlayCDB CDB(/*Base=*/nullptr);
+  BackgroundIndex Index(FS, CDB, [&](llvm::StringRef) { return &MSS; },
+/*Opts=*/{});
+
+  tooling::CompileCommand Cmd;
+  Cmd.Filename = testPath("root/A.cc");
+  Cmd.Directory = testPath("root");
+  Cmd.CommandLine = {"clang++", Cmd.Filename};
+  CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
+  ASSERT_TRUE(Index.blockUntilIdleForTest());
+
+  Cmd.Filename = testPath("root/B.cc");
+  Cmd.CommandLine = {"clang++", Cmd.Filename};
+  CDB.setCompileCommand(testPath("root/B.cc"), Cmd);
+  ASSERT_TRUE(Index.blockUntilIdleForTest());
+
+  auto HeaderShard = MSS.loadShard(testPath("root/RAV.h"));
+  EXPECT_NE(HeaderShard, nullptr);
+  SymbolID RAV = findSymbol(*HeaderShard->Symbols, "RAV").ID;
+
+  RelationsRequest Req;
+  Req.Subjects.insert(RAV);
+  Req.Predicate = RelationKind::BaseOf;
+  uint32_t Results = 0;
+  Index.relations(Req, [&](const SymbolID &, const Symbol &) { ++Results; });
+  EXPECT_EQ(Results, 2u);
+}
+
 TEST_F(BackgroundIndexTest, MainFileRefs) {
   MockFS FS;
   FS.Files[testPath("root/A.h")] = R"cpp(
@@ -345,14 +388,15 @@
 EXPECT_THAT(Ref.second,
 UnorderedElementsAre(FileURI("unittest:///root/A.cc")));
 
-  // The BaseOf relationship between A_CC and B_CC is stored in the file
-  // containing the definition of the subject (A_CC)
+  // The BaseOf relationship between A_CC and B_CC is stored in both the file
+  // containing the definition of the subject (A_CC) and the file cont

[clang-tools-extra] 90a8c44 - [clangd] Fix typo in field name

2020-09-20 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2020-09-20T19:52:39-04:00
New Revision: 90a8c44d92b217eccba2467a11d0658675b5fe80

URL: 
https://github.com/llvm/llvm-project/commit/90a8c44d92b217eccba2467a11d0658675b5fe80
DIFF: 
https://github.com/llvm/llvm-project/commit/90a8c44d92b217eccba2467a11d0658675b5fe80.diff

LOG: [clangd] Fix typo in field name

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

Added: 


Modified: 
clang-tools-extra/clangd/index/FileIndex.cpp
clang-tools-extra/clangd/index/FileIndex.h

Removed: 




diff  --git a/clang-tools-extra/clangd/index/FileIndex.cpp 
b/clang-tools-extra/clangd/index/FileIndex.cpp
index dafec6742c2c..155e09ca1e97 100644
--- a/clang-tools-extra/clangd/index/FileIndex.cpp
+++ b/clang-tools-extra/clangd/index/FileIndex.cpp
@@ -245,9 +245,9 @@ void FileSymbols::update(llvm::StringRef Key,
 RefsSnapshot[Key] = std::move(Item);
   }
   if (!Relations)
-RelatiosSnapshot.erase(Key);
+RelationsSnapshot.erase(Key);
   else
-RelatiosSnapshot[Key] = std::move(Relations);
+RelationsSnapshot[Key] = std::move(Relations);
 }
 
 std::unique_ptr
@@ -266,7 +266,7 @@ FileSymbols::buildIndex(IndexType Type, DuplicateHandling 
DuplicateHandle,
   if (FileAndRefs.second.CountReferences)
 MainFileRefs.push_back(RefSlabs.back().get());
 }
-for (const auto &FileAndRelations : RelatiosSnapshot)
+for (const auto &FileAndRelations : RelationsSnapshot)
   RelationSlabs.push_back(FileAndRelations.second);
 
 if (Version)

diff  --git a/clang-tools-extra/clangd/index/FileIndex.h 
b/clang-tools-extra/clangd/index/FileIndex.h
index c7bc855bcb8e..127203c84c48 100644
--- a/clang-tools-extra/clangd/index/FileIndex.h
+++ b/clang-tools-extra/clangd/index/FileIndex.h
@@ -97,7 +97,7 @@ class FileSymbols {
   size_t Version = 0;
   llvm::StringMap> SymbolsSnapshot;
   llvm::StringMap RefsSnapshot;
-  llvm::StringMap> RelatiosSnapshot;
+  llvm::StringMap> RelationsSnapshot;
 };
 
 /// This manages symbols from files and an in-memory index on all symbols.



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


[PATCH] D87995: [clangd] Fix typo in field name

2020-09-20 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG90a8c44d92b2: [clangd] Fix typo in field name (authored by 
nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87995

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h


Index: clang-tools-extra/clangd/index/FileIndex.h
===
--- clang-tools-extra/clangd/index/FileIndex.h
+++ clang-tools-extra/clangd/index/FileIndex.h
@@ -97,7 +97,7 @@
   size_t Version = 0;
   llvm::StringMap> SymbolsSnapshot;
   llvm::StringMap RefsSnapshot;
-  llvm::StringMap> RelatiosSnapshot;
+  llvm::StringMap> RelationsSnapshot;
 };
 
 /// This manages symbols from files and an in-memory index on all symbols.
Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -245,9 +245,9 @@
 RefsSnapshot[Key] = std::move(Item);
   }
   if (!Relations)
-RelatiosSnapshot.erase(Key);
+RelationsSnapshot.erase(Key);
   else
-RelatiosSnapshot[Key] = std::move(Relations);
+RelationsSnapshot[Key] = std::move(Relations);
 }
 
 std::unique_ptr
@@ -266,7 +266,7 @@
   if (FileAndRefs.second.CountReferences)
 MainFileRefs.push_back(RefSlabs.back().get());
 }
-for (const auto &FileAndRelations : RelatiosSnapshot)
+for (const auto &FileAndRelations : RelationsSnapshot)
   RelationSlabs.push_back(FileAndRelations.second);
 
 if (Version)


Index: clang-tools-extra/clangd/index/FileIndex.h
===
--- clang-tools-extra/clangd/index/FileIndex.h
+++ clang-tools-extra/clangd/index/FileIndex.h
@@ -97,7 +97,7 @@
   size_t Version = 0;
   llvm::StringMap> SymbolsSnapshot;
   llvm::StringMap RefsSnapshot;
-  llvm::StringMap> RelatiosSnapshot;
+  llvm::StringMap> RelationsSnapshot;
 };
 
 /// This manages symbols from files and an in-memory index on all symbols.
Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -245,9 +245,9 @@
 RefsSnapshot[Key] = std::move(Item);
   }
   if (!Relations)
-RelatiosSnapshot.erase(Key);
+RelationsSnapshot.erase(Key);
   else
-RelatiosSnapshot[Key] = std::move(Relations);
+RelationsSnapshot[Key] = std::move(Relations);
 }
 
 std::unique_ptr
@@ -266,7 +266,7 @@
   if (FileAndRefs.second.CountReferences)
 MainFileRefs.push_back(RefSlabs.back().get());
 }
-for (const auto &FileAndRelations : RelatiosSnapshot)
+for (const auto &FileAndRelations : RelationsSnapshot)
   RelationSlabs.push_back(FileAndRelations.second);
 
 if (Version)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87995: [clangd] Fix typo in field name

2020-09-20 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous.
Herald added a project: clang.
nridge requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87995

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h


Index: clang-tools-extra/clangd/index/FileIndex.h
===
--- clang-tools-extra/clangd/index/FileIndex.h
+++ clang-tools-extra/clangd/index/FileIndex.h
@@ -97,7 +97,7 @@
   size_t Version = 0;
   llvm::StringMap> SymbolsSnapshot;
   llvm::StringMap RefsSnapshot;
-  llvm::StringMap> RelatiosSnapshot;
+  llvm::StringMap> RelationsSnapshot;
 };
 
 /// This manages symbols from files and an in-memory index on all symbols.
Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -249,9 +249,9 @@
 RefsSnapshot[Key] = std::move(Item);
   }
   if (!Relations)
-RelatiosSnapshot.erase(Key);
+RelationsSnapshot.erase(Key);
   else
-RelatiosSnapshot[Key] = std::move(Relations);
+RelationsSnapshot[Key] = std::move(Relations);
 }
 
 std::unique_ptr
@@ -270,7 +270,7 @@
   if (FileAndRefs.second.CountReferences)
 MainFileRefs.push_back(RefSlabs.back().get());
 }
-for (const auto &FileAndRelations : RelatiosSnapshot)
+for (const auto &FileAndRelations : RelationsSnapshot)
   RelationSlabs.push_back(FileAndRelations.second);
 
 if (Version)


Index: clang-tools-extra/clangd/index/FileIndex.h
===
--- clang-tools-extra/clangd/index/FileIndex.h
+++ clang-tools-extra/clangd/index/FileIndex.h
@@ -97,7 +97,7 @@
   size_t Version = 0;
   llvm::StringMap> SymbolsSnapshot;
   llvm::StringMap RefsSnapshot;
-  llvm::StringMap> RelatiosSnapshot;
+  llvm::StringMap> RelationsSnapshot;
 };
 
 /// This manages symbols from files and an in-memory index on all symbols.
Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -249,9 +249,9 @@
 RefsSnapshot[Key] = std::move(Item);
   }
   if (!Relations)
-RelatiosSnapshot.erase(Key);
+RelationsSnapshot.erase(Key);
   else
-RelatiosSnapshot[Key] = std::move(Relations);
+RelationsSnapshot[Key] = std::move(Relations);
 }
 
 std::unique_ptr
@@ -270,7 +270,7 @@
   if (FileAndRefs.second.CountReferences)
 MainFileRefs.push_back(RefSlabs.back().get());
 }
-for (const auto &FileAndRelations : RelatiosSnapshot)
+for (const auto &FileAndRelations : RelationsSnapshot)
   RelationSlabs.push_back(FileAndRelations.second);
 
 if (Version)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87257: [clang] Traverse init-captures while indexing

2020-09-20 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 293040.
nridge added a comment.

Add clang test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87257

Files:
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/lib/Index/IndexBody.cpp
  clang/test/Index/cxx14-lambdas.cpp


Index: clang/test/Index/cxx14-lambdas.cpp
===
--- clang/test/Index/cxx14-lambdas.cpp
+++ clang/test/Index/cxx14-lambdas.cpp
@@ -28,7 +28,9 @@
 // CHECK-LOAD: cxx14-lambdas.cpp:8:7: ReturnStmt= Extent=[8:7 - 8:29]
 
 // RUN: env CINDEXTEST_INDEXLOCALSYMBOLS=1 c-index-test -index-file -std=c++14 
%s | FileCheck -check-prefix=CHECK-INDEX %s
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localA | USR: 
c:cxx14-lambdas.cpp@100@S@X@F@f#@localA | lang: C | cursor: 
DeclRefExpr=localA:6:9 | loc: 7:27
 // CHECK-INDEX: [indexEntityReference]: kind: variable | name: ptr | USR: 
c:cxx14-lambdas.cpp@139@S@X@F@f#@Sa@F@operator()#I#1@ptr | lang: C | cursor: 
VariableRef=ptr:7:20 | loc: 7:20
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localB | USR: 
c:cxx14-lambdas.cpp@100@S@X@F@f#@localB | lang: C | cursor: 
DeclRefExpr=localB:6:17 | loc: 7:42
 // CHECK-INDEX: [indexEntityReference]: kind: variable | name: copy | USR: 
c:cxx14-lambdas.cpp@154@S@X@F@f#@Sa@F@operator()#I#1@copy | lang: C | cursor: 
VariableRef=copy:7:35 | loc: 7:35
 // CHECK-INDEX: [indexDeclaration]: kind: variable | name: x | USR: 
c:cxx14-lambdas.cpp@170@S@X@F@f#@Sa@F@operator()#I#1@x | lang: C | cursor: 
ParmDecl=x:7:59 (Definition) | loc: 7:59
 // CHECK-INDEX: [indexEntityReference]: kind: typedef | name: Integer | USR: 
c:cxx14-lambdas.cpp@T@Integer | lang: C | cursor: TypeRef=Integer:3:13 | loc: 
7:51
Index: clang/lib/Index/IndexBody.cpp
===
--- clang/lib/Index/IndexBody.cpp
+++ clang/lib/Index/IndexBody.cpp
@@ -391,11 +391,13 @@
 if (C->capturesThis() || C->capturesVLAType())
   return true;
 
+if (!base::TraverseStmt(Init))
+  return false;
+
 if (C->capturesVariable() && IndexCtx.shouldIndexFunctionLocalSymbols())
   return IndexCtx.handleReference(C->getCapturedVar(), C->getLocation(),
   Parent, ParentDC, SymbolRoleSet());
 
-// FIXME: Lambda init-captures.
 return true;
   }
 
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1589,6 +1589,12 @@
 [[Vector]] x2;
 Vector y;
   )cpp",
+  R"cpp(// Lambda capture initializer
+void foo() {
+  int [[w^aldo]] = 42;
+  auto lambda = [x = [[waldo]]](){};
+}
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);


Index: clang/test/Index/cxx14-lambdas.cpp
===
--- clang/test/Index/cxx14-lambdas.cpp
+++ clang/test/Index/cxx14-lambdas.cpp
@@ -28,7 +28,9 @@
 // CHECK-LOAD: cxx14-lambdas.cpp:8:7: ReturnStmt= Extent=[8:7 - 8:29]
 
 // RUN: env CINDEXTEST_INDEXLOCALSYMBOLS=1 c-index-test -index-file -std=c++14 %s | FileCheck -check-prefix=CHECK-INDEX %s
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localA | USR: c:cxx14-lambdas.cpp@100@S@X@F@f#@localA | lang: C | cursor: DeclRefExpr=localA:6:9 | loc: 7:27
 // CHECK-INDEX: [indexEntityReference]: kind: variable | name: ptr | USR: c:cxx14-lambdas.cpp@139@S@X@F@f#@Sa@F@operator()#I#1@ptr | lang: C | cursor: VariableRef=ptr:7:20 | loc: 7:20
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localB | USR: c:cxx14-lambdas.cpp@100@S@X@F@f#@localB | lang: C | cursor: DeclRefExpr=localB:6:17 | loc: 7:42
 // CHECK-INDEX: [indexEntityReference]: kind: variable | name: copy | USR: c:cxx14-lambdas.cpp@154@S@X@F@f#@Sa@F@operator()#I#1@copy | lang: C | cursor: VariableRef=copy:7:35 | loc: 7:35
 // CHECK-INDEX: [indexDeclaration]: kind: variable | name: x | USR: c:cxx14-lambdas.cpp@170@S@X@F@f#@Sa@F@operator()#I#1@x | lang: C | cursor: ParmDecl=x:7:59 (Definition) | loc: 7:59
 // CHECK-INDEX: [indexEntityReference]: kind: typedef | name: Integer | USR: c:cxx14-lambdas.cpp@T@Integer | lang: C | cursor: TypeRef=Integer:3:13 | loc: 7:51
Index: clang/lib/Index/IndexBody.cpp
===
--- clang/lib/Index/IndexBody.cpp
+++ clang/lib/Index/IndexBody.cpp
@@ -391,11 +391,13 @@
 if (C->capturesThis() || C->capturesVLAType())
   return true;
 
+if (!base::TraverseStmt(Init))
+  return false;
+
 if (C->capturesVariable() && IndexCtx.shouldIndexFunctionLocalSymbols())
   return IndexCtx.handleReference(C->getCapturedVar(), C->getLocation(),
   

[PATCH] D87257: [clang] Traverse init-captures while indexing

2020-09-20 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D87257#2260499 , @hokein wrote:

> In D87257#2260022 , @nridge wrote:
>
>> I did try to add a test to `clang/test/Index/Core/index-source.cpp`, however 
>> the output of `c-index-test` does not seem to be changed by adding this 
>> reference.
>
> Could you check `clang/test/Index/cxx14-lambdas.cpp`, looks like that file is 
> testing lambda.

Thank you for the suggestion, I was able to make the test work with 
cxx14-lambdas.cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87257

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


[PATCH] D87080: [AST] Reduce the size of TemplateArgumentLocInfo.

2020-09-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/include/clang/AST/TemplateBase.h:421
 
-public:
-  constexpr TemplateArgumentLocInfo() : Template({nullptr, nullptr, 0, 0}) {}
-
-  TemplateArgumentLocInfo(TypeSourceInfo *TInfo) : Declarator(TInfo) {}
+  T *getTemplate() const {
+assert(Pointer.is());

If you're going to add more uses of the name `T`, we should rename it to 
something more descriptive. Maybe `TemplateTemplateArgLocInfo` or something 
like that?



Comment at: clang/include/clang/AST/TemplateBase.h:435-441
+T *Template = new (Ctx) T;
+Template->Qualifier = QualifierLoc.getNestedNameSpecifier();
+Template->QualifierLocData = QualifierLoc.getOpaqueData();
+Template->TemplateNameLoc = TemplateNameLoc.getRawEncoding();
+Template->EllipsisLoc = EllipsisLoc.getRawEncoding();
+Pointer = Template;
   }

I think this is just about complex enough to be worth moving to the .cpp file.



Comment at: clang/include/clang/AST/TemplateBase.h:444
   TypeSourceInfo *getAsTypeSourceInfo() const {
-return Declarator;
+assert(Pointer.is());
+return Pointer.get();

This is redundant (here and below): `get` does this assert for you.



Comment at: clang/include/clang/AST/TemplateBase.h:43
+// the dependency.
+template <> struct PointerLikeTypeTraits {
+  static inline void *getAsVoidPointer(clang::Expr *P) { return P; }

hokein wrote:
> sammccall wrote:
> > At first glance this is unsafe: you could have two different definitions of 
> > the same specialization in different files.
> > 
> > In fact it's OK, the default one can now never be instantiated, because 
> > Expr.h includes this file and so anyone that can see the definition can see 
> > this specialization.
> > 
> > But this is subtle/fragile: at least it needs to be spelled out explicitly 
> > in the comment.
> > I'd also suggest adding a static assert below the definition of Expr that 
> > it is compatible with this specialization (because it is sufficiently 
> > aligned).
> > 
> > (I can't think of a better alternative - use of PointerUnion is a win, 
> > partly *because* it validates the alignment)
> yes, exactly. 
> 
> do you have a better idea on how the static_assert should look like? The way 
> I can think of is to add a new flag in this specialization, and use 
> `static_assert(PointerLikeTypeTraits::flag, "...")`.
This may be included from `Expr.h` right now, but really doesn't seem like the 
right header to hold this specialization. Perhaps we should consider adding 
something like an `AST/ForwardDecls.h`, containing forward declarations and 
specializations such as this one, and include that from `Expr.h` and from here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87080

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


[PATCH] D87983: [Sema] Split special builtin type lookups into a separate function

2020-09-20 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks.  Minor improvement and then LGTM.




Comment at: clang/lib/Sema/SemaLookup.cpp:924
+void Sema::LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID) {
+  if (getLangOpts().ObjC && ID == Builtin::BIobjc_msgSendSuper)
+LookupPredefedObjCSuperType(*this, S);

I'm pretty sure this builtin only exists in ObjC mode, so there's no need to 
separately check the language mode.  (Even if you did want to check it, it 
would be better to check the builtin mode first, as that's a very trivial 
check.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87983

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


[PATCH] D75791: [clang-format] Added new option IndentExternBlock

2020-09-20 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 added a comment.

In D75791#2283961 , @sylvestre.ledru 
wrote:

> Any chance this changes could have caused this regression 
> https://bugs.llvm.org/show_bug.cgi?id=47589 ?

I don't think so, but I can double check the style defaults for the various 
types, and make the code harder to mess up in a min, currently I'm working on 
Clang's libSema so it might take a few days.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75791

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


[PATCH] D87080: [AST] Reduce the size of TemplateArgumentLocInfo.

2020-09-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

> Would it be possible to compile some big file in LLVM (probably doesn't 
> matter much which, Sema something?) and observe if there's a significant 
> change in overall ASTContext size?

~3% saving (measuring the `ASTContext::.getASTAllocatedMemory`)

|  | Before   | After   |
| SemaDecl.cpp | 255.5 MB | 247.5MB |
| SemaExpr.cpp | 293.5 MB | 283.5MB |




Comment at: clang/include/clang/AST/TemplateBase.h:43
+// the dependency.
+template <> struct PointerLikeTypeTraits {
+  static inline void *getAsVoidPointer(clang::Expr *P) { return P; }

sammccall wrote:
> At first glance this is unsafe: you could have two different definitions of 
> the same specialization in different files.
> 
> In fact it's OK, the default one can now never be instantiated, because 
> Expr.h includes this file and so anyone that can see the definition can see 
> this specialization.
> 
> But this is subtle/fragile: at least it needs to be spelled out explicitly in 
> the comment.
> I'd also suggest adding a static assert below the definition of Expr that it 
> is compatible with this specialization (because it is sufficiently aligned).
> 
> (I can't think of a better alternative - use of PointerUnion is a win, partly 
> *because* it validates the alignment)
yes, exactly. 

do you have a better idea on how the static_assert should look like? The way I 
can think of is to add a new flag in this specialization, and use 
`static_assert(PointerLikeTypeTraits::flag, "...")`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87080

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


[PATCH] D87080: [AST] Reduce the size of TemplateArgumentLocInfo.

2020-09-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 293029.
hokein marked an inline comment as done.
hokein added a comment.

address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87080

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/TemplateBase.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp

Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -7095,15 +7095,15 @@
 NestedNameSpecifierLoc QualifierLoc =
   readNestedNameSpecifierLoc();
 SourceLocation TemplateNameLoc = readSourceLocation();
-return TemplateArgumentLocInfo(QualifierLoc, TemplateNameLoc,
-   SourceLocation());
+return TemplateArgumentLocInfo(getASTContext(), QualifierLoc,
+   TemplateNameLoc, SourceLocation());
   }
   case TemplateArgument::TemplateExpansion: {
 NestedNameSpecifierLoc QualifierLoc = readNestedNameSpecifierLoc();
 SourceLocation TemplateNameLoc = readSourceLocation();
 SourceLocation EllipsisLoc = readSourceLocation();
-return TemplateArgumentLocInfo(QualifierLoc, TemplateNameLoc,
-   EllipsisLoc);
+return TemplateArgumentLocInfo(getASTContext(), QualifierLoc,
+   TemplateNameLoc, EllipsisLoc);
   }
   case TemplateArgument::Null:
   case TemplateArgument::Integral:
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -3546,12 +3546,12 @@
 }
 
 case TemplateArgument::Template:
-  return TemplateArgumentLoc(TemplateArgument(
-  Pattern.getArgument().getAsTemplate(),
-  NumExpansions),
- Pattern.getTemplateQualifierLoc(),
- Pattern.getTemplateNameLoc(),
- EllipsisLoc);
+  return TemplateArgumentLoc(
+  SemaRef.Context,
+  TemplateArgument(Pattern.getArgument().getAsTemplate(),
+   NumExpansions),
+  Pattern.getTemplateQualifierLoc(), Pattern.getTemplateNameLoc(),
+  EllipsisLoc);
 
 case TemplateArgument::Null:
 case TemplateArgument::Integral:
@@ -4289,8 +4289,8 @@
 if (Template.isNull())
   return true;
 
-Output = TemplateArgumentLoc(TemplateArgument(Template), QualifierLoc,
- Input.getTemplateNameLoc());
+Output = TemplateArgumentLoc(SemaRef.Context, TemplateArgument(Template),
+ QualifierLoc, Input.getTemplateNameLoc());
 return false;
   }
 
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1095,7 +1095,7 @@
   case TemplateArgument::TemplateExpansion:
 Ellipsis = OrigLoc.getTemplateEllipsisLoc();
 NumExpansions = Argument.getNumTemplateExpansions();
-return TemplateArgumentLoc(Argument.getPackExpansionPattern(),
+return TemplateArgumentLoc(Context, Argument.getPackExpansionPattern(),
OrigLoc.getTemplateQualifierLoc(),
OrigLoc.getTemplateNameLoc());
 
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2915,7 +2915,7 @@
 if (!TName.isNull())
   Param->setDefaultArgument(
   SemaRef.Context,
-  TemplateArgumentLoc(TemplateArgument(TName),
+  TemplateArgumentLoc(SemaRef.Context, TemplateArgument(TName),
   D->getDefaultArgument().getTemplateQualifierLoc(),
   D->getDefaultArgument().getTemplateNameLoc()));
   }
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -2670,11 +2670,11 @@
 Builder.MakeTrivial(Context, QTN->getQualifier(), Loc);
 
   if (Arg.getKind() == TemplateArgument::Template)
-return TemplateArgumentLoc(Arg, Builder.getWithLocInContext(Context),
-   Loc);
+return Template

[PATCH] D71524: [analyzer] Support tainted objects in GenericTaintChecker

2020-09-20 Thread Borsik Gábor via Phabricator via cfe-commits
boga95 marked 9 inline comments as done.
boga95 added a comment.

Ping




Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:289-293
+  {"c_str", {"std::__cxx11::basic_string", {{0}, {ReturnValueIndex,
+  {"data", {"std::__cxx11::basic_string", {{0}, {ReturnValueIndex,
+  {"size", {"std::__cxx11::basic_string", {{0}, {ReturnValueIndex,
+  {"length", {"std::__cxx11::basic_string", {{0}, {ReturnValueIndex,
+  {"getline", {"std::", {{0}, {1, ReturnValueIndex};

NoQ wrote:
> Szelethus wrote:
> > Hmm, is this the appropriate place to put these? It seems like this job is 
> > handled in `getTaintPropagationRule`. I thought `CustomPropagations` are 
> > reserved for the config file.
> So `0` stands for `this`? Can we have a named constant please? ^.^
We are planning to move all of the propagation rules into a configuration file.


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

https://reviews.llvm.org/D71524

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


[PATCH] D87974: Summary: [Builtin] Add __builtin_zero_non_value_bits.

2020-09-20 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added inline comments.



Comment at: clang/test/CodeGenCXX/builtin-zero-non-value-bits.cpp:160
+
+int main() {
+  testAllForType<32, 16, char>(11, 22, 33, 44);

jfb wrote:
> Usually CodeGen tests will use lit to check the emitted IR matches 
> expectations. I think that's what you want to do here.
> 
> Remember to test `volatile` qualified pointers, as well as address spaces too.
What's a good place for me to put this end-to-end test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87974

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


[PATCH] D87561: [Sema] List conversion validate character array

2020-09-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/test/CXX/drs/dr14xx.cpp:411-414
+  void f(const char[4]);
+  void f(const wchar_t[4]);
+  void f(const char16_t[4]);
+  void f(const char32_t[4]);

rsmith wrote:
> Mordante wrote:
> > rsmith wrote:
> > > These should presumably be references to arrays, rather than arrays, or 
> > > the parameter type is as if you wrote (for example) `void f(const char 
> > > *)`, which shouldn't get the special treatment here.
> > > 
> > > [over.ics.list]p4 mentions this in its footnote:
> > > 
> > > "Otherwise, if the parameter type is a character array [Footnote: Since 
> > > there are no parameters of array type, this will only occur as the 
> > > referenced type of a reference parameter.] and the initializer list has a 
> > > single element that is an appropriately-typed string-literal (9.4.3), the 
> > > implicit conversion sequence is the identity conversion."
> > Ah I missed that footnote. I reread the standard and can you confirm some 
> > cases?
> > ```
> > namespace A { 
> >   void f(const char(&)[4]);
> >   void g() { f({"abc"}); }
> > }
> > namespace B { 
> >   void f(const char(&&)[4]);
> >   void g() { f({"abc"}); }
> > } 
> > ```
> > both should work and with P0388 the array without bounds will also work.
> > 
> > I ask since this is my interpretation of the standard, but it seems there's 
> > a difference between implementations and `void f(const char(&&)[4]);` fails 
> > for "abc" but works for "ab".
> > It seems ICC and consider "abc" an lvalue in this case and not when using 
> > "ab".
> > 
> > Here's a gotbolt link with the examples https://godbolt.org/z/r1TKfx
> That's a really interesting example :)
> 
> The initializer is a list containing an lvalue of type `const char[4]`. Per 
> [dcl.init.list]/3.9 and /3.10, the behavior depends on whether the referenced 
> type is reference-related to `const char[4]` -- if so, then the reference can 
> only bind directly and a `&&` reference will be invalid, because it's binding 
> an rvalue reference to an lvalue, and if not, then we create an array 
> temporary and the `&&` binding is fine.
> 
> Per [dcl.init.ref]/4, `const char[???]` is reference-related to `const 
> char[4]` if they are similar types, and per [conv.qual]/2, the types are 
> similar if `???` is omitted or `4`, and not similar otherwise.
> 
> So:
> * `const char (&&r)[4] = {"abc"}` is ill-formed (types are the same, binds 
> rvalue reference to lvalue)
> * `const char (&&)[] = {"abc"}` is ill-formed (types are similar, binds 
> rvalue reference to lvalue)
> * `const char (&&r)[5] = {"abc"}` is OK (types are not similar, creates 
> temporary)
> 
> That seems like a very surprising outcome to me. Perhaps we should probably 
> ignore array bounds entirely when determining whether two types are 
> reference-related. I'll take this to CWG for discussion.
I think that's only an answer to half of your question. The other half is that 
[over.ics.list]p4 does not apply (directly) to either of your testcases, 
because the "parameter type" is a reference type, not an array type. For:

```
namespace A { 
  void f(const char(&)[4]);
  void g() { f({"abc"}); }
}
```

... we reach [over.ics.list]p9, which says to use the rules in [over.ics.ref]. 
Those rules say that if the reference binds directly to an argument expression 
(ignore the "expression" here; this is very old wording that predates braced 
initializers), then we form an identity conversion. So that's what happens in 
this case.

For

```
namespace B { 
  void f(const char(&&)[4]);
  void g() { f({"abc"}); }
}
```

the same thing happens, but now [over.ics.ref]p3 says "an implicit conversion 
sequence cannot be formed if it requires binding an lvalue reference other than 
a reference to a non-volatile const type to an rvalue or binding an rvalue 
reference to an lvalue other than a function lvalue", so the candidate is not 
viable.

If the array bound were omitted or were not 4, then the reference would not 
bind directly, and we would instead consider initializing a temporary. 
[over.ics.ref]p2 says "When a parameter of reference type is not bound directly 
to an argument expression, the conversion sequence is the one required to 
convert the argument expression to the referenced type according to 12.4.4.2.", 
which takes us back around to [over.ics.list] with the "parameter type" now 
being the array type. That's how we can reach [over.ics.list]p4 and consider 
string literal -> array initialization.

So I think that, according to the current rules, for

```
void f(const char (&&)[4]); // #1
void f(const char (&&)[5]); // #2
```

... a call to `f({"abc"})` remarkably calls #2, because #1 is not viable (would 
bind rvalue reference to lvalue string literal), but #2 is, just like `const 
char (&&r)[4] = {"abc"};` is ill-formed but `const char (&&r)[5] = {"abc"};` is 
valid.


Repository:
  rG LLVM Github Monorepo

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

[PATCH] D87989: [Flang][Driver] Add InputOutputTest frontend action with new -test-IO flag

2020-09-20 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto updated this revision to Diff 293024.
CarolineConcatto added a comment.

- remove changes from cmakefiles


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87989

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/Types.cpp
  flang/include/flang/Frontend/CompilerInstance.h
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/include/flang/Frontend/FrontendAction.h
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/include/flang/FrontendTool/Utils.h
  flang/lib/Frontend/CMakeLists.txt
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendAction.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/Frontend/FrontendOptions.cpp
  flang/lib/FrontendTool/CMakeLists.txt
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/emit-obj.f90
  flang/test/Frontend/Inputs/empty-file.f90
  flang/test/Frontend/input-output-file.f90
  flang/test/Frontend/multiple-input-files.f90
  flang/test/lit.cfg.py
  flang/tools/flang-driver/fc1_main.cpp
  flang/unittests/Frontend/CMakeLists.txt
  flang/unittests/Frontend/CompilerInstanceTest.cpp
  flang/unittests/Frontend/InputOutputTest.cpp

Index: flang/unittests/Frontend/InputOutputTest.cpp
===
--- /dev/null
+++ flang/unittests/Frontend/InputOutputTest.cpp
@@ -0,0 +1,65 @@
+//===- unittests/Frontend/OutputStreamTest.cpp --- FrontendAction tests --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "flang/Frontend/CompilerInstance.h"
+#include "flang/Frontend/FrontendOptions.h"
+#include "flang/FrontendTool/Utils.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
+
+#include 
+
+using namespace Fortran::frontend;
+
+namespace {
+
+TEST(FrontendOutputTests, TestInputOutputStreamOwned) {
+  // 1. Prepare the input file to be used by IO
+  // Create the file to be used by AllSources
+  // Flang function 'FortranAllSources.Open' needs a physical file
+  // and the full path to work with
+  std::string inputFilename = "io-file-test.f";
+  std::error_code ec;
+  std::unique_ptr os{
+  new llvm::raw_fd_ostream(inputFilename, ec, llvm::sys::fs::OF_None)};
+  if (ec)
+llvm::errs() << "Fail to create the file need by the test";
+  *(os) << "End Program arithmetic";
+  os.reset();
+  std::string getFileFullPath = std::filesystem::current_path().c_str();
+  getFileFullPath = getFileFullPath + "/" + inputFilename;
+
+  // 2. Prepare the compiler (Invocation + Instance)
+  CompilerInstance compInst;
+  compInst.CreateDiagnostics();
+  auto invocation = std::make_shared();
+  invocation->GetFrontendOpts().programAction_ = InputOutputTest;
+  compInst.SetInvocation(std::move(invocation));
+  compInst.GetFrontendOpts().inputs_.push_back(
+  FrontendInputFile(/*File=*/getFileFullPath, Language::Fortran));
+
+  // 3. Set-up the output stream. Using output buffer wrapped as an output
+  // stream, as opposed to an actual file (or a file descriptor).
+  llvm::SmallVector outputFileBuffer;
+  std::unique_ptr outputFileStream(
+  new llvm::raw_svector_ostream(outputFileBuffer));
+  compInst.SetOutputStream(std::move(outputFileStream));
+
+  // 4. Run the earlier defined FrontendAction
+  bool success = ExecuteCompilerInvocation(&compInst);
+
+  EXPECT_TRUE(success);
+  EXPECT_TRUE(!outputFileBuffer.empty());
+  EXPECT_TRUE(llvm::StringRef(outputFileBuffer.data())
+  .startswith("End Program arithmetic"));
+
+  // 5. Remove files
+  compInst.ClearOutputFiles(/*EraseFiles=*/false);
+}
+} // namespace
\ No newline at end of file
Index: flang/unittests/Frontend/CompilerInstanceTest.cpp
===
--- flang/unittests/Frontend/CompilerInstanceTest.cpp
+++ flang/unittests/Frontend/CompilerInstanceTest.cpp
@@ -7,12 +7,13 @@
 //===--===//
 
 #include "flang/Frontend/CompilerInstance.h"
-#include "gtest/gtest.h"
 #include "flang/Frontend/CompilerInvocation.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Driver/Options.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
 
 #include 
 using namespace llvm;
@@ -20,6 +21,42 @@
 
 namespace {
 
+TEST(CompilerInstance, SanityCheckForInputFile) {
+  // 1. Prepare the input to b

[PATCH] D87561: [Sema] List conversion validate character array

2020-09-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/test/CXX/drs/dr14xx.cpp:411-414
+  void f(const char[4]);
+  void f(const wchar_t[4]);
+  void f(const char16_t[4]);
+  void f(const char32_t[4]);

Mordante wrote:
> rsmith wrote:
> > These should presumably be references to arrays, rather than arrays, or the 
> > parameter type is as if you wrote (for example) `void f(const char *)`, 
> > which shouldn't get the special treatment here.
> > 
> > [over.ics.list]p4 mentions this in its footnote:
> > 
> > "Otherwise, if the parameter type is a character array [Footnote: Since 
> > there are no parameters of array type, this will only occur as the 
> > referenced type of a reference parameter.] and the initializer list has a 
> > single element that is an appropriately-typed string-literal (9.4.3), the 
> > implicit conversion sequence is the identity conversion."
> Ah I missed that footnote. I reread the standard and can you confirm some 
> cases?
> ```
> namespace A { 
>   void f(const char(&)[4]);
>   void g() { f({"abc"}); }
> }
> namespace B { 
>   void f(const char(&&)[4]);
>   void g() { f({"abc"}); }
> } 
> ```
> both should work and with P0388 the array without bounds will also work.
> 
> I ask since this is my interpretation of the standard, but it seems there's a 
> difference between implementations and `void f(const char(&&)[4]);` fails for 
> "abc" but works for "ab".
> It seems ICC and consider "abc" an lvalue in this case and not when using 
> "ab".
> 
> Here's a gotbolt link with the examples https://godbolt.org/z/r1TKfx
That's a really interesting example :)

The initializer is a list containing an lvalue of type `const char[4]`. Per 
[dcl.init.list]/3.9 and /3.10, the behavior depends on whether the referenced 
type is reference-related to `const char[4]` -- if so, then the reference can 
only bind directly and a `&&` reference will be invalid, because it's binding 
an rvalue reference to an lvalue, and if not, then we create an array temporary 
and the `&&` binding is fine.

Per [dcl.init.ref]/4, `const char[???]` is reference-related to `const char[4]` 
if they are similar types, and per [conv.qual]/2, the types are similar if 
`???` is omitted or `4`, and not similar otherwise.

So:
* `const char (&&r)[4] = {"abc"}` is ill-formed (types are the same, binds 
rvalue reference to lvalue)
* `const char (&&)[] = {"abc"}` is ill-formed (types are similar, binds rvalue 
reference to lvalue)
* `const char (&&r)[5] = {"abc"}` is OK (types are not similar, creates 
temporary)

That seems like a very surprising outcome to me. Perhaps we should probably 
ignore array bounds entirely when determining whether two types are 
reference-related. I'll take this to CWG for discussion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87561

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


[PATCH] D87953: [xray] Function coverage groups

2020-09-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:814
+auto FuncGroups = CGM.getCodeGenOpts().XRayTotalFunctionGroups;
+if (FuncGroups > 1) {
+  auto FuncName = ArrayRef(CurFn->getName().bytes_begin(),

kyulee wrote:
> MaskRay wrote:
> > For one group, the branch is skipped, which does not seem correct
> Should we check or assert `XRaySelectedFunctionGroups > 0` && 
> `XRaySelectedFunctionGroup < XRaySelectedFunctionGroups` or the former at 
> minimum?
Such checks are usually done in Driver. In CodeGen, as long as it doesn't 
crash, there is no need imposing stricter checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87953

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


Re: [clang] 2ae1822 - [Diagnostics] Fixed -Wsizeof-array-div false positive when divisor is sizeof reference type (PR47495)

2020-09-20 Thread Dávid Bolvanský via cfe-commits
Thanks,

I uploaded https://reviews.llvm.org/D87990 to fix this issue.

ne 20. 9. 2020 o 19:58 Richard Smith  napísal(a):
>
> On Sun, 20 Sep 2020 at 08:43, Dávid Bolvanský via cfe-commits 
>  wrote:
>>
>> Author: Dávid Bolvanský
>> Date: 2020-09-20T17:43:06+02:00
>> New Revision: 2ae182258c49724e4daaae196de829ea65c116e8
>>
>> URL: 
>> https://github.com/llvm/llvm-project/commit/2ae182258c49724e4daaae196de829ea65c116e8
>> DIFF: 
>> https://github.com/llvm/llvm-project/commit/2ae182258c49724e4daaae196de829ea65c116e8.diff
>>
>> LOG: [Diagnostics] Fixed -Wsizeof-array-div false positive when divisor is 
>> sizeof reference type (PR47495)
>>
>> Added:
>>
>>
>> Modified:
>> clang/lib/Sema/SemaExpr.cpp
>> clang/test/Sema/div-sizeof-array.cpp
>>
>> Removed:
>>
>>
>>
>> 
>> diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
>> index 501e1aed1509..736a6c166eb3 100644
>> --- a/clang/lib/Sema/SemaExpr.cpp
>> +++ b/clang/lib/Sema/SemaExpr.cpp
>> @@ -10038,7 +10038,7 @@ static void 
>> DiagnoseDivisionSizeofPointerOrArray(Sema &S, Expr *LHS, Expr *RHS,
>>  QualType ArrayElemTy = ArrayTy->getElementType();
>>  if (ArrayElemTy != S.Context.getBaseElementType(ArrayTy) ||
>>  ArrayElemTy->isDependentType() || RHSTy->isDependentType() ||
>> -ArrayElemTy->isCharType() ||
>> +RHSTy->isReferenceType() || ArrayElemTy->isCharType() ||
>
>
> Instead of skipping the check for a reference type, could we instead replace 
> RHSTy with its referenced type for the purpose of the check when RHSTy is a 
> reference type? I think we do want to diagnose (for example) sizeof(array) / 
> sizeof(decltype(*array[0])) for an array of pointers.
>
>>
>>  S.Context.getTypeSize(ArrayElemTy) == S.Context.getTypeSize(RHSTy))
>>return;
>>  S.Diag(Loc, diag::warn_division_sizeof_array)
>>
>> diff  --git a/clang/test/Sema/div-sizeof-array.cpp 
>> b/clang/test/Sema/div-sizeof-array.cpp
>> index e295a9dec6d8..898ff42a7bd4 100644
>> --- a/clang/test/Sema/div-sizeof-array.cpp
>> +++ b/clang/test/Sema/div-sizeof-array.cpp
>> @@ -42,4 +42,8 @@ void test(void) {
>>
>>float m[4][4];
>>int d1 = sizeof(m) / sizeof(**m);
>> +
>> +  int array[10];
>> +  int narray = sizeof(array) / sizeof(int &);
>> +  int narray2 = sizeof(array) / sizeof(decltype(array[0]));
>>  }
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87953: [xray] Function coverage groups

2020-09-20 Thread Kyungwoo Lee via Phabricator via cfe-commits
kyulee added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:814
+auto FuncGroups = CGM.getCodeGenOpts().XRayTotalFunctionGroups;
+if (FuncGroups > 1) {
+  auto FuncName = ArrayRef(CurFn->getName().bytes_begin(),

MaskRay wrote:
> For one group, the branch is skipped, which does not seem correct
Should we check or assert `XRaySelectedFunctionGroups > 0` && 
`XRaySelectedFunctionGroup < XRaySelectedFunctionGroups` or the former at 
minimum?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87953

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


[PATCH] D87989: [Flang][Driver] Add InputOutputTest frontend action with new -test-IO flag

2020-09-20 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto created this revision.
Herald added subscribers: cfe-commits, dang, mgorny.
Herald added a reviewer: DavidTruby.
Herald added a reviewer: sscalpone.
Herald added a project: clang.
CarolineConcatto requested review of this revision.

The sole purpose of this action is to read a file from the command line and
 print it either to stdout or the output file. This action runs by using the
`-test-IO` flag introduced in this patch:
`flang-new -test-IO` or `flang-new -fc1 -test-IO`

With this patch, `flang-new -test-IO input-file.f90` will read `input-file.f90` 
and
print it in the output file.

This action has been introduced to facilitate testing. It is hidden from users,
not being shown with `--help`.  It is visible with `--help-hidden`, and only
available for FlangOption and FC1Options in Option.td.

`-IO `is used to run the InputOutputTest action in the Flang frontend driver.
This patch makes sure that "flang-new" will forward it to "flang-new -fc1".
In Flang.cpp -test-IO is passed to "flang-new -fc1",  without `-E` so that the
preprocessor is _not_ run.

This patch introduces the dependencies required to read and manage input files
provided by the command line option. It also adds the structure to create and
write in output files.  The output is sent to either stdout or a file
(specified with -o output_file).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87989

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/Types.cpp
  flang/CMakeLists.txt
  flang/include/flang/Frontend/CompilerInstance.h
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/include/flang/Frontend/FrontendAction.h
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/include/flang/FrontendTool/Utils.h
  flang/lib/Frontend/CMakeLists.txt
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendAction.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/Frontend/FrontendOptions.cpp
  flang/lib/FrontendTool/CMakeLists.txt
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/emit-obj.f90
  flang/test/Frontend/Inputs/empty-file.f90
  flang/test/Frontend/input-output-file.f90
  flang/test/Frontend/multiple-input-files.f90
  flang/test/lit.cfg.py
  flang/tools/flang-driver/fc1_main.cpp
  flang/unittests/Frontend/CMakeLists.txt
  flang/unittests/Frontend/CompilerInstanceTest.cpp
  flang/unittests/Frontend/InputOutputTest.cpp

Index: flang/unittests/Frontend/InputOutputTest.cpp
===
--- /dev/null
+++ flang/unittests/Frontend/InputOutputTest.cpp
@@ -0,0 +1,65 @@
+//===- unittests/Frontend/OutputStreamTest.cpp --- FrontendAction tests --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "flang/Frontend/CompilerInstance.h"
+#include "flang/Frontend/FrontendOptions.h"
+#include "flang/FrontendTool/Utils.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
+
+#include 
+
+using namespace Fortran::frontend;
+
+namespace {
+
+TEST(FrontendOutputTests, TestInputOutputStreamOwned) {
+  // 1. Prepare the input file to be used by IO
+  // Create the file to be used by AllSources
+  // Flang function 'FortranAllSources.Open' needs a physical file
+  // and the full path to work with
+  std::string inputFilename = "io-file-test.f";
+  std::error_code ec;
+  std::unique_ptr os{
+  new llvm::raw_fd_ostream(inputFilename, ec, llvm::sys::fs::OF_None)};
+  if (ec)
+llvm::errs() << "Fail to create the file need by the test";
+  *(os) << "End Program arithmetic";
+  os.reset();
+  std::string getFileFullPath = std::filesystem::current_path().c_str();
+  getFileFullPath = getFileFullPath + "/" + inputFilename;
+
+  // 2. Prepare the compiler (Invocation + Instance)
+  CompilerInstance compInst;
+  compInst.CreateDiagnostics();
+  auto invocation = std::make_shared();
+  invocation->GetFrontendOpts().programAction_ = InputOutputTest;
+  compInst.SetInvocation(std::move(invocation));
+  compInst.GetFrontendOpts().inputs_.push_back(
+  FrontendInputFile(/*File=*/getFileFullPath, Language::Fortran));
+
+  // 3. Set-up the output stream. Using output buffer wrapped as an output
+  // stream, as opposed to an actual file (or a file descriptor).
+  llvm::SmallVector outputFileBuffer;
+  std::unique_ptr outputFileStream(
+  new llvm::raw_svector_ostream(outputFileBuffer));
+  compInst.SetOutputStream(std::move(outputFileStream));
+
+  // 4. Run the earlier defined FrontendAction
+  bool success = ExecuteCo

Re: [clang] 2ae1822 - [Diagnostics] Fixed -Wsizeof-array-div false positive when divisor is sizeof reference type (PR47495)

2020-09-20 Thread Richard Smith via cfe-commits
On Sun, 20 Sep 2020 at 08:43, Dávid Bolvanský via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: Dávid Bolvanský
> Date: 2020-09-20T17:43:06+02:00
> New Revision: 2ae182258c49724e4daaae196de829ea65c116e8
>
> URL:
> https://github.com/llvm/llvm-project/commit/2ae182258c49724e4daaae196de829ea65c116e8
> DIFF:
> https://github.com/llvm/llvm-project/commit/2ae182258c49724e4daaae196de829ea65c116e8.diff
>
> LOG: [Diagnostics] Fixed -Wsizeof-array-div false positive when divisor is
> sizeof reference type (PR47495)
>
> Added:
>
>
> Modified:
> clang/lib/Sema/SemaExpr.cpp
> clang/test/Sema/div-sizeof-array.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
> index 501e1aed1509..736a6c166eb3 100644
> --- a/clang/lib/Sema/SemaExpr.cpp
> +++ b/clang/lib/Sema/SemaExpr.cpp
> @@ -10038,7 +10038,7 @@ static void
> DiagnoseDivisionSizeofPointerOrArray(Sema &S, Expr *LHS, Expr *RHS,
>  QualType ArrayElemTy = ArrayTy->getElementType();
>  if (ArrayElemTy != S.Context.getBaseElementType(ArrayTy) ||
>  ArrayElemTy->isDependentType() || RHSTy->isDependentType() ||
> -ArrayElemTy->isCharType() ||
> +RHSTy->isReferenceType() || ArrayElemTy->isCharType() ||
>

Instead of skipping the check for a reference type, could we instead
replace RHSTy with its referenced type for the purpose of the check when
RHSTy is a reference type? I think we do want to diagnose (for example)
sizeof(array) / sizeof(decltype(*array[0])) for an array of pointers.


>  S.Context.getTypeSize(ArrayElemTy) ==
> S.Context.getTypeSize(RHSTy))
>return;
>  S.Diag(Loc, diag::warn_division_sizeof_array)
>
> diff  --git a/clang/test/Sema/div-sizeof-array.cpp
> b/clang/test/Sema/div-sizeof-array.cpp
> index e295a9dec6d8..898ff42a7bd4 100644
> --- a/clang/test/Sema/div-sizeof-array.cpp
> +++ b/clang/test/Sema/div-sizeof-array.cpp
> @@ -42,4 +42,8 @@ void test(void) {
>
>float m[4][4];
>int d1 = sizeof(m) / sizeof(**m);
> +
> +  int array[10];
> +  int narray = sizeof(array) / sizeof(int &);
> +  int narray2 = sizeof(array) / sizeof(decltype(array[0]));
>  }
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87972: [OldPM] Pass manager: run SROA after (simple) loop unrolling

2020-09-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D87972#2284064 , @xbolva00 wrote:

> In D87972#2284060 , @MaskRay wrote:
>
>> I have tested this patch internally and seen gains and losses. On one 
>> document search related benchmark 3~5% improvement. One zippy (snappy) there 
>> is 3~5% regression. Perhaps we do need a conditional extra SROA run.
>
> Snappy  - you mean public https://github.com/google/snappy?
>
> Well, it should be possible to analyze it...



> @lebedev.ri any perf data from testsuite/rawspeed?

I did look. F13016699: sroa-after-unroll.rsbench.txt 

This suggests that geomean is `-0.8%` runtime improvement,
with ups&downs. F13016722: image.png 

But as i have said in the patch's description, i stumbled into this when 
writing new code, where the effect is //much// larger.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87972

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


[PATCH] D86547: [compiler-rt][builtins] Use c[tl]zsi macro instead of __builtin_c[tl]z

2020-09-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

The `(aWidth - 1) - clzsi(a)` change is correct, but why is the ctz change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86547

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


[PATCH] D70378: [LLD][COFF] Cover usage of LLD as a library

2020-09-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

@rnk @amccarth Do you have more comments? ☺️


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70378

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


[PATCH] D86671: [clang-tidy] Add new case type to check variables with Hungarian notation

2020-09-20 Thread Douglas Chen via Phabricator via cfe-commits
dougpuob added a comment.

Hi @aaron.ballman
About changing  `size_t nLength` to `cbLength`. I searched MSVC folders with 
`size_t`, many names of variable start with `n`, or `i` in MFC related files. 
So I prefer to keep it starts with `n`. Another side to name starts with `cb`, 
I found variables like cbXxx are defined with ULONG, DWORD, or UCHAR type.

Maybe make them as options in config (.clang-tidy) is more practical. The 
prefixes in the default table follows its abbreviation or acronym of data type.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86671

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


[PATCH] D87953: [xray] Function coverage groups

2020-09-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

The idea seems fine.

> By selecting different groups over time you could cover the entire 
> application incrementally with lower overhead than instrumenting the entire 
> application at once.

How large the overhead is? This is somewhat surprising to me.




Comment at: clang/include/clang/Driver/Options.td:1343
+def fxray_function_groups :
+  JoinedOrSeparate<["-"], "fxray-function-groups=">,
+  Group, Flags<[CC1Option]>,

Joined.

Separate is for a space between the option name and its value.



Comment at: clang/include/clang/Driver/Options.td:1345
+  Group, Flags<[CC1Option]>,
+  HelpText<"Only instrument 1 of N functions">;
+

It is "N groups", not "N functions".



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:814
+auto FuncGroups = CGM.getCodeGenOpts().XRayTotalFunctionGroups;
+if (FuncGroups > 1) {
+  auto FuncName = ArrayRef(CurFn->getName().bytes_begin(),

For one group, the branch is skipped, which does not seem correct



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:815
+if (FuncGroups > 1) {
+  auto FuncName = ArrayRef(CurFn->getName().bytes_begin(),
+CurFn->getName().bytes_end());

`const ArrayRef FuncName(..., ...)`



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:820
+  !AlwaysXRayAttr) {
+Fn->addFnAttr("function-instrument", "xray-never");
+  }

Omit braces around one-line simple statements.



Comment at: clang/test/CodeGen/xray-function-groups.cpp:4
+// RUN:-fxray-selected-function-group=0 \
+// RUN:-x c++ -std=c++11 -emit-llvm -o - %s \
+// RUN:-triple x86_64-unknown-linux-gnu | FileCheck 
--check-prefix=GROUP0 %s

You can omit `-x c++ -std=c++11 `. They are insignificant. 

Then consider packing more options on one line to reduce the total number of 
lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87953

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


[PATCH] D87972: [OldPM] Pass manager: run SROA after (simple) loop unrolling

2020-09-20 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

In D87972#2284060 , @MaskRay wrote:

> I have tested this patch internally and seen gains and losses. On one 
> document search related benchmark 3~5% improvement. One zippy (snappy) there 
> is 3~5% regression. Perhaps we do need a conditional extra SROA run.

Snappy  - you mean public https://github.com/google/snappy?

Well, it should be possible to analyze it...

@lebedev.ri any perf data from testsuite/rawspeed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87972

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


[PATCH] D87972: [OldPM] Pass manager: run SROA after (simple) loop unrolling

2020-09-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

(I'm guessing that we are talking about run-time performance here.)

In D87972#2284060 , @MaskRay wrote:

> I have tested this patch internally and seen gains and losses. On one 
> document search related benchmark 3~5% improvement. One zippy (snappy) there 
> is 3~5% regression.

Yep, as usual.

> Perhaps we do need a conditional extra SROA run.

I think i don't understand the gist

If we don't run it in the cases we expect it wouldn't do anything,
it should still be run in the cases where it *does* do something,
so i'm not sure how conditioning it's run helps with anything.
(well, other than compile-time)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87972

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


[PATCH] D87972: [OldPM] Pass manager: run SROA after (simple) loop unrolling

2020-09-20 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

In D87972#2284060 , @MaskRay wrote:

> I have tested this patch internally and seen gains and losses. On one 
> document search related benchmark 3~5% improvement. One zippy (snappy) there 
> is 3~5% regression. Perhaps we do need a conditional extra SROA run.

Should be same story for NPM since NPM also enables SROA after unrolling.

A) Commit this patch and start working on general solution for LPM and NPM.

B) Ignore this patch. But after LLVM switches to NPM, you have same issue to 
solve anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87972

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


[PATCH] D87972: [OldPM] Pass manager: run SROA after (simple) loop unrolling

2020-09-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I have tested this patch internally and seen gains and losses. On one document 
search related benchmark 3~5% improvement. One zippy (snappy) there is 3~5% 
regression. Perhaps we do need a conditional extra SROA run.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87972

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


[clang] 2ae1822 - [Diagnostics] Fixed -Wsizeof-array-div false positive when divisor is sizeof reference type (PR47495)

2020-09-20 Thread Dávid Bolvanský via cfe-commits

Author: Dávid Bolvanský
Date: 2020-09-20T17:43:06+02:00
New Revision: 2ae182258c49724e4daaae196de829ea65c116e8

URL: 
https://github.com/llvm/llvm-project/commit/2ae182258c49724e4daaae196de829ea65c116e8
DIFF: 
https://github.com/llvm/llvm-project/commit/2ae182258c49724e4daaae196de829ea65c116e8.diff

LOG: [Diagnostics] Fixed -Wsizeof-array-div false positive when divisor is 
sizeof reference type (PR47495)

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/div-sizeof-array.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 501e1aed1509..736a6c166eb3 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -10038,7 +10038,7 @@ static void DiagnoseDivisionSizeofPointerOrArray(Sema 
&S, Expr *LHS, Expr *RHS,
 QualType ArrayElemTy = ArrayTy->getElementType();
 if (ArrayElemTy != S.Context.getBaseElementType(ArrayTy) ||
 ArrayElemTy->isDependentType() || RHSTy->isDependentType() ||
-ArrayElemTy->isCharType() ||
+RHSTy->isReferenceType() || ArrayElemTy->isCharType() ||
 S.Context.getTypeSize(ArrayElemTy) == S.Context.getTypeSize(RHSTy))
   return;
 S.Diag(Loc, diag::warn_division_sizeof_array)

diff  --git a/clang/test/Sema/div-sizeof-array.cpp 
b/clang/test/Sema/div-sizeof-array.cpp
index e295a9dec6d8..898ff42a7bd4 100644
--- a/clang/test/Sema/div-sizeof-array.cpp
+++ b/clang/test/Sema/div-sizeof-array.cpp
@@ -42,4 +42,8 @@ void test(void) {
 
   float m[4][4];
   int d1 = sizeof(m) / sizeof(**m);
+
+  int array[10];
+  int narray = sizeof(array) / sizeof(int &);
+  int narray2 = sizeof(array) / sizeof(decltype(array[0]));
 }



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


[PATCH] D87540: [clang-tidy] Fix false positive issue in performance-unnecessary-value-param for arguments being moved in the function body.

2020-09-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp:66
 
+bool isPassedToStdMove(const ParmVarDecl &Param, ASTContext &Context) {
+  // Check if the parameter has a name, in case of functions like -

sukraat91 wrote:
> aaron.ballman wrote:
> > Can `Context` be `const ASTContext &`?
> Unfortunately, no. This is because match() does not have an overload for 
> `const ASTContext&`.
I kind of wondered if that was the case, oh well. Thank you for checking!



Comment at: 
clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp:74
+  // parmVarDecl picked up by this checker. It will be an empty string and will
+  // lead to an assertion failure when using hasName(std::string) being used
+  // in the matcher below. If empty then exit indicating no move calls present

riccibruno wrote:
> aaron.ballman wrote:
> > This may be a bigger issue with `hasName()` as this strikes me as possibly 
> > being a bug. I would expect `hasName("")` to return `false` for any AST 
> > node which has a nonempty name, and `true` for any AST node without a name.
> When I was looking at the `hasName` matcher I was surprised that this is not 
> the case (see `getNodeName` in `ASTMatchers/ASTMatchersInternal.cpp`). For 
> example an unnamed enumeration can be matched with `(anonymous enum)` (which 
> should be `unnamed` instead). For an other example a constructor can be 
> matched with the name of the class despite the fact that the constructor is 
> formally unnamed (because `DeclarationName::getDeclName` and 
> `NamedDecl::printName` are used).
> 
> I think that the `hasName` matcher is mixing two different concepts: the 
> formal name of the AST node and the name for diagnostic purposes. One 
> possible fix would be to add a matcher `hasFormalName` which would match the 
> name as per the specification, and then modify the `hasName` matcher to use 
> the name for diagnostic purposes (without the extra location information).
> 
> Not hard-coding the logic in `getNodeName` would have the additional benefit 
> of being more consistent with the use of `anonymous`/`unnamed` terminology.
+1, I think that's the better fix to make here. I don't have the impression 
that matching names for diagnostic purposes was really intended for this API (I 
don't recall discussions about it). Based on that, I think `hasName()` should 
probably be the one that handles the identifier used by the AST node and we can 
add `hasDiagnosticName()` to handle matching things like anonymous enums by 
name when we find there's a need for it.


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

https://reviews.llvm.org/D87540

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


[clang] a735d6e - JSONCompilationDatabase.cpp - cleanup key parsing error checks. NFCI.

2020-09-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-09-20T13:55:29+01:00
New Revision: a735d6eae2847b039d12c75d4c794862dad59bc1

URL: 
https://github.com/llvm/llvm-project/commit/a735d6eae2847b039d12c75d4c794862dad59bc1
DIFF: 
https://github.com/llvm/llvm-project/commit/a735d6eae2847b039d12c75d4c794862dad59bc1.diff

LOG: JSONCompilationDatabase.cpp - cleanup key parsing error checks. NFCI.

Merge the key + sequence/value checks with the key handling code.

Reduces the number of key string comparisons and avoids a number of clang 
static analyzer null dereference warnings.

Added: 


Modified: 
clang/lib/Tooling/JSONCompilationDatabase.cpp

Removed: 




diff  --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp 
b/clang/lib/Tooling/JSONCompilationDatabase.cpp
index 4af361f538cb..67a42d3c55a7 100644
--- a/clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ b/clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -369,16 +369,11 @@ bool JSONCompilationDatabase::parse(std::string 
&ErrorMessage) {
   }
   auto *ValueString = dyn_cast(Value);
   auto *SequenceString = dyn_cast(Value);
-  if (KeyValue == "arguments" && !SequenceString) {
-ErrorMessage = "Expected sequence as value.";
-return false;
-  } else if (KeyValue != "arguments" && !ValueString) {
-ErrorMessage = "Expected string as value.";
-return false;
-  }
-  if (KeyValue == "directory") {
-Directory = ValueString;
-  } else if (KeyValue == "arguments") {
+  if (KeyValue == "arguments") {
+if (!SequenceString) {
+  ErrorMessage = "Expected sequence as value.";
+  return false;
+}
 Command = std::vector();
 for (auto &Argument : *SequenceString) {
   auto *Scalar = dyn_cast(&Argument);
@@ -388,17 +383,25 @@ bool JSONCompilationDatabase::parse(std::string 
&ErrorMessage) {
   }
   Command->push_back(Scalar);
 }
-  } else if (KeyValue == "command") {
-if (!Command)
-  Command = std::vector(1, ValueString);
-  } else if (KeyValue == "file") {
-File = ValueString;
-  } else if (KeyValue == "output") {
-Output = ValueString;
   } else {
-ErrorMessage = ("Unknown key: \"" +
-KeyString->getRawValue() + "\"").str();
-return false;
+if (!ValueString) {
+  ErrorMessage = "Expected string as value.";
+  return false;
+}
+if (KeyValue == "directory") {
+  Directory = ValueString;
+} else if (KeyValue == "command") {
+  if (!Command)
+Command = std::vector(1, ValueString);
+} else if (KeyValue == "file") {
+  File = ValueString;
+} else if (KeyValue == "output") {
+  Output = ValueString;
+} else {
+  ErrorMessage =
+  ("Unknown key: \"" + KeyString->getRawValue() + "\"").str();
+  return false;
+}
   }
 }
 if (!File) {



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


[PATCH] D87972: [OldPM] Pass manager: run SROA after (simple) loop unrolling

2020-09-20 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

https://reviews.llvm.org/D68593 added late SROA to NPM so it would be good to 
enable it for LPM as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87972

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


[PATCH] D87972: [OldPM] Pass manager: run SROA after (simple) loop unrolling

2020-09-20 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

Surprising this causes only such a small perf regression. I guess it should be 
OK given that, but here probably are some pathological cases out there where 
this may cause some noticeable compile-time regressions.

IIUC the additional cases this catches come mainly from fully unrolled loops. 
If only we had a better way to conditionally run passes :) Then we would 
ideally only run SROA (and other additional simplification passes) late on 
functions that had loops fully unrolled. One lightweight way to do so would be 
to have loop unroll add an 'additional-simplification' attribute to functions 
that contain loops which it full unrolled and have SROA just run again late if 
the attribute is present. A similar approach may be helpful in other places too 
(e.g. the off-by-default `-extra-vectorizer-passes` option, 
https://github.com/llvm/llvm-project/blob/master/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp#L774)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87972

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


[PATCH] D75791: [clang-format] Added new option IndentExternBlock

2020-09-20 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

Any chance this changes could have caused this regression 
https://bugs.llvm.org/show_bug.cgi?id=47589 ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75791

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


[PATCH] D81272: [clang-tidy] New check `bugprone-redundant-branch-condition`

2020-09-20 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

Any chance this changes could have caused this regression 
https://bugs.llvm.org/show_bug.cgi?id=47589 ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81272

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


[PATCH] D87983: [Sema] Split special builtin type lookups into a separate function

2020-09-20 Thread Raul Tambre via Phabricator via cfe-commits
tambre created this revision.
tambre added reviewers: rsmith, rjmccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
tambre requested review of this revision.

In case further such cases appear in the future we've got a generic function to 
add them to.
Additionally changed the ObjC special case to check the language and the 
identifier builtin ID instead of the name.

Addresses the cleanup suggestion from D87917 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87983

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaLookup.cpp


Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -907,6 +907,24 @@
   return false;
 }
 
+/// Looks up the declaration of "struct objc_super" and
+/// saves it for later use in building builtin declaration of
+/// objc_msgSendSuper and objc_msgSendSuper_stret.
+static void LookupPredefedObjCSuperType(Sema &Sema, Scope *S) {
+  ASTContext &Context = Sema.Context;
+  LookupResult Result(Sema, &Context.Idents.get("objc_super"), 
SourceLocation(),
+  Sema::LookupTagName);
+  Sema.LookupName(Result, S);
+  if (Result.getResultKind() == LookupResult::Found)
+if (const TagDecl *TD = Result.getAsSingle())
+  Context.setObjCSuperType(Context.getTagDeclType(TD));
+}
+
+void Sema::LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID) {
+  if (getLangOpts().ObjC && ID == Builtin::BIobjc_msgSendSuper)
+LookupPredefedObjCSuperType(*this, S);
+}
+
 /// Determine whether we can declare a special member function within
 /// the class at this point.
 static bool CanDeclareSpecialMemberFunction(const CXXRecordDecl *Class) {
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2035,24 +2035,6 @@
   return S;
 }
 
-/// Looks up the declaration of "struct objc_super" and
-/// saves it for later use in building builtin declaration of
-/// objc_msgSendSuper and objc_msgSendSuper_stret. If no such
-/// pre-existing declaration exists no action takes place.
-static void LookupPredefedObjCSuperType(Sema &ThisSema, Scope *S,
-IdentifierInfo *II) {
-  if (!II->isStr("objc_msgSendSuper"))
-return;
-  ASTContext &Context = ThisSema.Context;
-
-  LookupResult Result(ThisSema, &Context.Idents.get("objc_super"),
-  SourceLocation(), Sema::LookupTagName);
-  ThisSema.LookupName(Result, S);
-  if (Result.getResultKind() == LookupResult::Found)
-if (const TagDecl *TD = Result.getAsSingle())
-  Context.setObjCSuperType(Context.getTagDeclType(TD));
-}
-
 static StringRef getHeaderName(Builtin::Context &BuiltinInfo, unsigned ID,
ASTContext::GetBuiltinTypeError Error) {
   switch (Error) {
@@ -2113,7 +2095,7 @@
 NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID,
  Scope *S, bool ForRedeclaration,
  SourceLocation Loc) {
-  LookupPredefedObjCSuperType(*this, S, II);
+  LookupNecessaryTypesForBuiltin(S, ID);
 
   ASTContext::GetBuiltinTypeError Error;
   QualType R = Context.GetBuiltinType(ID, Error);
@@ -9671,7 +9653,7 @@
 NewFD->addAttr(BuiltinAttr::CreateImplicit(Context, BuiltinID));
   } else {
 ASTContext::GetBuiltinTypeError Error;
-LookupPredefedObjCSuperType(*this, S, NewFD->getIdentifier());
+LookupNecessaryTypesForBuiltin(S, BuiltinID);
 QualType BuiltinType = Context.GetBuiltinType(BuiltinID, Error);
 
 if (!Error && !BuiltinType.isNull() &&
@@ -10880,7 +10862,7 @@
 // declaration against the expected type for the builtin.
 if (unsigned BuiltinID = NewFD->getBuiltinID()) {
   ASTContext::GetBuiltinTypeError Error;
-  LookupPredefedObjCSuperType(*this, S, NewFD->getIdentifier());
+  LookupNecessaryTypesForBuiltin(S, BuiltinID);
   QualType T = Context.GetBuiltinType(BuiltinID, Error);
   // If the type of the builtin differs only in its exception
   // specification, that's OK.
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -3813,6 +3813,7 @@
   RedeclarationKind Redecl
 = NotForRedeclaration);
   bool LookupBuiltin(LookupResult &R);
+  void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID);
   bool LookupName(LookupResult &R, Scope *S,
   bool AllowBuiltinCreation = false);
   bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,


Index: clang/lib/Sema/SemaLookup.cpp
=