[PATCH] D91337: [clangd] Add missing tests to rename feature

2020-11-13 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 305047.
kbobyrev marked 4 inline comments as done.
kbobyrev added a comment.

Address the comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91337

Files:
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -141,6 +141,12 @@
   ~[[F^oo]]();
   void f([[F^oo]] x);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
+
+template
+[[F^oo]]::~[[Fo^o]]() {}
   )cpp",
 
   // Template class constructor.
@@ -152,6 +158,9 @@
   template
   [[F^oo]](T t);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
   )cpp",
 
   // Class in template argument.
@@ -199,6 +208,30 @@
 }
   )cpp",
 
+  // Templated method instantiation.
+  R"cpp(
+template
+class Foo {
+public:
+  static T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo::[[f^oo]]();
+}
+  )cpp",
+  R"cpp(
+template
+class Foo {
+public:
+  T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo().[[f^oo]]();
+}
+  )cpp",
+
   // Template class (partial) specializations.
   R"cpp(
 template 
@@ -307,6 +340,19 @@
 }
   )cpp",
 
+  // Static class member.
+  R"cpp(
+struct Foo {
+  static Foo *[[Static^Member]];
+};
+
+Foo* Foo::[[Static^Member]] = nullptr;
+
+void foo() {
+  Foo* Pointer = Foo::[[Static^Member]];
+}
+  )cpp",
+
   // Reference in lambda parameters.
   R"cpp(
 template 
@@ -588,6 +634,100 @@
   ns::[[Old^Alias]] Bar;
 }
   )cpp",
+
+  // Templated class specialization.
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+
+template
+class [[Foo^]];
+  )cpp",
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+  )cpp",
+
+  // Function template specialization.
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]() {};
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]() {};
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template 
+void [[f^oo]](T t);
+
+template <>
+void [[f^oo]](int a);
+
+void test() {
+  [[f^oo]](1);
+}
+  )cpp",
+
+  // Variable template.
+  R"cpp(
+template 
+bool [[F^oo]] = true;
+
+// Explicit template specialization
+template <>
+bool [[F^oo]] = false;
+
+// Partial template specialization
+template 
+bool [[F^oo]] = false;
+
+void foo() {
+  // Ref to the explicit template specialization
+  [[F^oo]];
+  // Ref to the primary template.
+  [[F^oo]];
+}
+  )cpp",
+
+  // User defined conversion.
+  R"cpp(
+class [[F^oo]] {
+public:
+  [[F^oo]]() {}
+};
+
+class Baz {
+public:
+  operator [[F^oo]]() {
+return [[F^oo]]();
+  }
+};
+
+int main() {
+  Baz boo;
+  [[F^oo]] foo = static_cast<[[F^oo]]>(boo);
+}
+  )cpp",
   };
   llvm::StringRef NewName = "NewName";
   for (llvm::StringRef T : Tests) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91368: Frontend: Split out addVFSOverlays from createVFSFromCompilerInvocation, NFC

2020-11-13 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D91368

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


[PATCH] D91367: Serialization: Merge three diagnostics to simplify ASTReader::getInputFile, NFC

2020-11-13 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Getting rid of the duplication is definitely nice. I left one inline question 
about the terminology used.




Comment at: clang/include/clang/Basic/DiagnosticSerializationKinds.td:20
 "malformed block record in PCH file: '%0'">, DefaultFatal;
 def err_fe_pch_file_modified : Error<
+"file '%0' has been modified since the "

I'm a bit confused by the fact that a diagnostic with `pch_file` in its name 
might output `module file` or `AST file` as well.

This file already contains a couple diagnostics that use a similar `%select` 
and have `module` in their name (e.g. `err_module_file_out_of_date`). Would it 
make sense to unify the terminology here?


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

https://reviews.llvm.org/D91367

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


[PATCH] D91366: Serialization: Hoist the check for in-flight diagnostics in ASTReader::getInputFile, NFC

2020-11-13 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D91366

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


[PATCH] D91295: Frontend: Remove unused parameter from ASTUnit::LoadFromCompilerInvocationAction, NFC

2020-11-13 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

LGTM


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

https://reviews.llvm.org/D91295

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


[PATCH] D91258: [clangd] Sanity-check array sizes read from disk before allocating them.

2020-11-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

oops, this is actually a problem of the test. it is providing an invalid 
encoding :/ sent out https://reviews.llvm.org/D91405 to fix the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91258

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


[PATCH] D91405: [clangd] Assert on varint encoding

2020-11-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

5th byte of a varint can't be bigger than 0x0f, fix a test and add an
assertion.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91405

Files:
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/unittests/SerializationTests.cpp


Index: clang-tools-extra/clangd/unittests/SerializationTests.cpp
===
--- clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -366,9 +366,9 @@
   Pos += FileDigest.size();
 
   // Varints are little-endian base-128 numbers, where the top-bit of each byte
-  // indicates whether there are more. 8fff7f -> 0x.
+  // indicates whether there are more. 8fff0f -> 0x.
   std::string CorruptSrcs =
-  (Srcs->Data.take_front(Pos) + llvm::fromHex("8fff7f") +
+  (Srcs->Data.take_front(Pos) + llvm::fromHex("8fff0f") +
"some_random_garbage")
   .str();
   Srcs->Data = CorruptSrcs;
Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -87,6 +87,7 @@
 uint32_t Val = B & ~More;
 for (int Shift = 7; B & More && Shift < 32; Shift += 7) {
   B = consume8();
+  assert((B & ~More) < (1 << (32 - Shift)) && "Invalid varint encoding");
   Val |= (B & ~More) << Shift;
 }
 return Val;


Index: clang-tools-extra/clangd/unittests/SerializationTests.cpp
===
--- clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -366,9 +366,9 @@
   Pos += FileDigest.size();
 
   // Varints are little-endian base-128 numbers, where the top-bit of each byte
-  // indicates whether there are more. 8fff7f -> 0x.
+  // indicates whether there are more. 8fff0f -> 0x.
   std::string CorruptSrcs =
-  (Srcs->Data.take_front(Pos) + llvm::fromHex("8fff7f") +
+  (Srcs->Data.take_front(Pos) + llvm::fromHex("8fff0f") +
"some_random_garbage")
   .str();
   Srcs->Data = CorruptSrcs;
Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -87,6 +87,7 @@
 uint32_t Val = B & ~More;
 for (int Shift = 7; B & More && Shift < 32; Shift += 7) {
   B = consume8();
+  assert((B & ~More) < (1 << (32 - Shift)) && "Invalid varint encoding");
   Val |= (B & ~More) << Shift;
 }
 return Val;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89031: [SVE] Add support to vectorize_width loop pragma for scalable vectors

2020-11-13 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

In D89031#2391248 , @SjoerdMeijer 
wrote:

> In D89031#2391160 , @david-arm wrote:
>
>> Hi @SjoerdMeijer I think that given we now support scalable vectors we 
>> thought it made sense to be able to specify whether the user wants 'fixed' 
>> or 'scalable' vectorisation along with the vector width, although without 
>> specifying the additional property the default continues to remain 'fixed'. 
>> However, what you said about having a vectorize_scalable pragma is correct 
>> and we are intending to also add a pragma like this in a future patch.
>
> Okay, I haven't looked at the implementation to be honest, but am just trying 
> to understand the different use cases of this first.
> I just seem to be missing or not understanding why fixed/scalable is an 
> option to only vectorize_width, why not to vectorize(enable) or just a 
> separate one like vectorize_scalable? By making scalable/fixed and option to 
> vectorize_width, you can't toggle this for other pragmas like 
> interleave(enable) that enable vectorisation, which would be inconsistent? It 
> also seems to be more work to me to do this first for vectorize_width, and 
> then fix up other pragmas later. But I might be missing something (obivous) 
> here.

Hi @SjoerdMeijer, all valid and good questions. We think it makes sense to 
allow specifying explicitly what the meaning of '4' is when specifying the 
width. So that `vectorize_width(4, fixed)` means vectorizing with `<4 x eltty>` 
and `vectorize_width(4, scalable)` means vectorizing with ``. Like @david-arm said, we also plan to add something like 
`vectorize_style(fixed|scalable)`. This approach should be fully complementary 
to `vectorize_with` so that it would be possible to have:

  // Use scalable vectors, but leave it to the cost-model to choose the most 
efficient N in .
  // If the pragma is not specified, it defaults to vectorize_style(fixed).
  #pragma clang loop vectorize_style(scalable)
  
  // Use <4 x eltty>
  #pragma clang loop vectorize_width(4, fixed)
  
  // Use 
  #pragma clang loop vectorize_width(4, scalable)
  
  // If vectorize_style(scalable) is specified, then use , 
otherwise <4 x eltty>
  #pragma clang loop vectorize_width(4)   // uses <4 x 
eltty>
  #pragma clang loop vectorize_width(4) vectorize_style(scalable) // uses 

  
  // Conflicting options, clang should print diagnostic and error or ignore the 
hint.
  #pragma clang loop vectorize_width(4, fixed) vectorize_style(scalable)

I hope that gives a bit more context.


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

https://reviews.llvm.org/D89031

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


[PATCH] D91405: [clangd] Assert on varint encoding

2020-11-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 305055.
kadircet added a comment.

- Also fix the high byte


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91405

Files:
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/unittests/SerializationTests.cpp


Index: clang-tools-extra/clangd/unittests/SerializationTests.cpp
===
--- clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -366,9 +366,9 @@
   Pos += FileDigest.size();
 
   // Varints are little-endian base-128 numbers, where the top-bit of each byte
-  // indicates whether there are more. 8fff7f -> 0x.
+  // indicates whether there are more. 0f -> 0x.
   std::string CorruptSrcs =
-  (Srcs->Data.take_front(Pos) + llvm::fromHex("8fff7f") +
+  (Srcs->Data.take_front(Pos) + llvm::fromHex("0f") +
"some_random_garbage")
   .str();
   Srcs->Data = CorruptSrcs;
Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -87,6 +87,7 @@
 uint32_t Val = B & ~More;
 for (int Shift = 7; B & More && Shift < 32; Shift += 7) {
   B = consume8();
+  assert((B & ~More) < (1 << (32 - Shift)) && "Invalid varint encoding");
   Val |= (B & ~More) << Shift;
 }
 return Val;


Index: clang-tools-extra/clangd/unittests/SerializationTests.cpp
===
--- clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -366,9 +366,9 @@
   Pos += FileDigest.size();
 
   // Varints are little-endian base-128 numbers, where the top-bit of each byte
-  // indicates whether there are more. 8fff7f -> 0x.
+  // indicates whether there are more. 0f -> 0x.
   std::string CorruptSrcs =
-  (Srcs->Data.take_front(Pos) + llvm::fromHex("8fff7f") +
+  (Srcs->Data.take_front(Pos) + llvm::fromHex("0f") +
"some_random_garbage")
   .str();
   Srcs->Data = CorruptSrcs;
Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -87,6 +87,7 @@
 uint32_t Val = B & ~More;
 for (int Shift = 7; B & More && Shift < 32; Shift += 7) {
   B = consume8();
+  assert((B & ~More) < (1 << (32 - Shift)) && "Invalid varint encoding");
   Val |= (B & ~More) << Shift;
 }
 return Val;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2020-11-13 Thread Andrew Savonichev via Phabricator via cfe-commits
asavonic added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:4554
+
+  // Language rules define if it is legal to cast from one address space
+  // to another, and which address space we should use as a "common

sdmitriev wrote:
> bader wrote:
> > Anastasia wrote:
> > > What language rules?
> > I suppose it's a generic note and author didn't meant some particular 
> > language here. This change was contributed by @sdmitriev. 
> > @sdmitriev, could you clarify, please?
> This comment was originally added by @asavonic to 
> clang/lib/CodeGen/CGExprScalar.cpp (lines 2962-2965 in this patch), and later 
> I reused his code along with the comment in this file while fixing a very 
> similar issue. So, I guess it would be more correct to ask Andrew to clarify. 
> @asavonic, can you please comment on this?
> This comment was originally added by @asavonic to 
> clang/lib/CodeGen/CGExprScalar.cpp (lines 2962-2965 in this patch), and later 
> I reused his code along with the comment in this file while fixing a very 
> similar issue.

There is `if (Opts.SYCLIsDevice)` In CGExprScalar.cpp, so we handle SYCL 
language rules.
In SYCL, (almost) all pointers have default address space in AST, but in CG 
some pointers become private/local/global, and some are lowered as generic 
pointers. We need to add an implicit addrspacecast in CG to emit an expression 
that expects the same type for its operands.

For example:
const char *str = ... ;
const char *phi_str = i > 2 ? str : "hello world!";

In AST types of `str` and `"hello world"` are the same (`const char *`). In CG 
we emit `str` as `i8 addrspace(4)*` and `"hello world"` as `i8*`. At this point 
we have to decide what type `phi_str` should have, and addrspacecast the 
operands accordingly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89909

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


[PATCH] D90524: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-13 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

Ping. It would be nice to get this finally merged so that the testsuite noise 
finally goes down on the sparc64 Linux worker.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90524

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


[PATCH] D91348: [OpenCL] Warn about side effects for unevaluated vec_step arg

2020-11-13 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh updated this revision to Diff 305058.
svenvh added a comment.

Add test case for OpenCL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91348

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/coroutines.cpp
  clang/test/SemaOpenCL/vec_step.cl


Index: clang/test/SemaOpenCL/vec_step.cl
===
--- clang/test/SemaOpenCL/vec_step.cl
+++ clang/test/SemaOpenCL/vec_step.cl
@@ -29,4 +29,6 @@
   int res13 = vec_step(*incomplete1); // expected-error {{'vec_step' requires 
built-in scalar or vector type, '__private struct S' invalid}}
   int res14 = vec_step(int16*); // expected-error {{'vec_step' requires 
built-in scalar or vector type, '__private int16 *' invalid}}
   int res15 = vec_step(void(void)); // expected-error {{'vec_step' requires 
built-in scalar or vector type, 'void (void)' invalid}}
+
+  int res_no_effect = vec_step(auto3++); // expected-warning {{expression with 
side effects has no effect in an unevaluated context}}
 }
Index: clang/test/SemaCXX/coroutines.cpp
===
--- clang/test/SemaCXX/coroutines.cpp
+++ clang/test/SemaCXX/coroutines.cpp
@@ -328,6 +328,7 @@
 // expected-warning@-1 {{declaration does not declare 
anything}}
   sizeof(co_await a); // expected-error {{'co_await' cannot be used in an 
unevaluated context}}
   // expected-error@-1 {{invalid application of 'sizeof' 
to an incomplete type 'void'}}
+  // expected-warning@-2 {{expression with side effects 
has no effect in an unevaluated context}}
   typeid(co_await a); // expected-error {{'co_await' cannot be used in an 
unevaluated context}}
   // expected-warning@-1 {{expression with side effects 
has no effect in an unevaluated context}}
   // expected-warning@-2 {{expression result unused}}
@@ -335,6 +336,7 @@
 // expected-warning@-1 {{declaration does not declare 
anything}}
   sizeof(co_yield 2); // expected-error {{'co_yield' cannot be used in an 
unevaluated context}}
   // expected-error@-1 {{invalid application of 'sizeof' 
to an incomplete type 'void'}}
+  // expected-warning@-2 {{expression with side effects 
has no effect in an unevaluated context}}
   typeid(co_yield 3); // expected-error {{'co_yield' cannot be used in an 
unevaluated context}}
   // expected-warning@-1 {{expression with side effects 
has no effect in an unevaluated context}}
   // expected-warning@-2 {{expression result unused}}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -4027,7 +4027,7 @@
 
   bool IsUnevaluatedOperand =
   (ExprKind == UETT_SizeOf || ExprKind == UETT_AlignOf ||
-   ExprKind == UETT_PreferredAlignOf);
+   ExprKind == UETT_PreferredAlignOf || ExprKind == UETT_VecStep);
   if (IsUnevaluatedOperand) {
 ExprResult Result = CheckUnevaluatedOperand(E);
 if (Result.isInvalid())
@@ -4035,6 +4035,12 @@
 E = Result.get();
   }
 
+  // The operand for sizeof and alignof is in an unevaluated expression 
context,
+  // so side effects could result in unintended consequences.
+  if (IsUnevaluatedOperand && !inTemplateInstantiation() &&
+  E->HasSideEffects(Context, false))
+Diag(E->getExprLoc(), diag::warn_side_effects_unevaluated_context);
+
   if (ExprKind == UETT_VecStep)
 return CheckVecStepTraitOperandType(*this, ExprTy, E->getExprLoc(),
 E->getSourceRange());
@@ -4071,12 +4077,6 @@
 return true;
   }
 
-  // The operand for sizeof and alignof is in an unevaluated expression 
context,
-  // so side effects could result in unintended consequences.
-  if (IsUnevaluatedOperand && !inTemplateInstantiation() &&
-  E->HasSideEffects(Context, false))
-Diag(E->getExprLoc(), diag::warn_side_effects_unevaluated_context);
-
   if (CheckObjCTraitOperandConstraints(*this, ExprTy, E->getExprLoc(),
E->getSourceRange(), ExprKind))
 return true;


Index: clang/test/SemaOpenCL/vec_step.cl
===
--- clang/test/SemaOpenCL/vec_step.cl
+++ clang/test/SemaOpenCL/vec_step.cl
@@ -29,4 +29,6 @@
   int res13 = vec_step(*incomplete1); // expected-error {{'vec_step' requires built-in scalar or vector type, '__private struct S' invalid}}
   int res14 = vec_step(int16*); // expected-error {{'vec_step' requires built-in scalar or vector type, '__private int16 *' invalid}}
   int res15 = vec_step(void(void)); // expected-error {{'vec_step' requires built-in scalar or vector type, 'void (void)' invalid}}
+
+  int res_no_effect = vec_step(aut

[PATCH] D90524: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-13 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D90524#2388214 , @glaubitz wrote:

> I think it should be good for merging now. I addressed all remarks. I'm still 
> convinced that "workaround" is the proper term though.

Quite the contrary: the comment you cited

  // FIXME: This is a bit of a hack. We should really unify this code for
  // reasoning about oslibdir spellings with the lib dir spellings in the
  // GCCInstallationDetector, but that is a more significant refactoring.

pretty clearly is about how/where support for that layout is implemented in the 
`clang` Driver code, not about the layout itself.

Besides, you haven't explained why it's appropriate to no longer test support 
for the old (pre-Debian 9,I believe) directory layout.  However, as I said I 
don't feel qualified to review that part, so you'll need another reviewer for 
that, no matter if only testing the new layout or both old and new ones.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90524

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


[PATCH] D90524: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-13 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D90524#2393312 , @glaubitz wrote:

> Ping. It would be nice to get this finally merged so that the testsuite noise 
> finally goes down on the sparc64 Linux worker.

Please be a little more patient: one ping a week is considered appropriate, but 
after only two days is a bit over the top.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90524

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


[PATCH] D88905: [Clang] Allow "ext_vector_type" applied to Booleans

2020-11-13 Thread Simon Moll via Phabricator via cfe-commits
simoll added a comment.

Any comments for this one? Is this good to go?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88905

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


[PATCH] D90956: [clang][SVE] Activate macro `__ARM_FEATURE_SVE_VECTOR_OPERATORS`.

2020-11-13 Thread Renato Golin via Phabricator via cfe-commits
rengolin accepted this revision.
rengolin added a comment.

Hi @fpetrogalli, the document is so dense that it took me a while to check the 
macros and I was still wrong.

Either I'm losing my skill to read Arm documents or folks are getting worse at 
writing them.

Giving this is a change that only affects SVE targets, and I have no way of 
independently verify codegen, I'm trusting you and the rest of Arm to make sure 
it's the right semantics. :)

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90956

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


[PATCH] D90524: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-13 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

In D90524#2393319 , @ro wrote:

> In D90524#2388214 , @glaubitz wrote:
>
>> I think it should be good for merging now. I addressed all remarks. I'm 
>> still convinced that "workaround" is the proper term though.
>
> Quite the contrary: the comment you cited
>
>   // FIXME: This is a bit of a hack. We should really unify this code for
>   // reasoning about oslibdir spellings with the lib dir spellings in the
>   // GCCInstallationDetector, but that is a more significant refactoring.
>
> pretty clearly is about how/where support for that layout is implemented in 
> the `clang` Driver code, not about the layout itself.

I don't understand that argument. I call it "workaround", the source comment 
calls it "hack". It's clearly not to stay forever as it's an ugly
workaround, but until a proper fix comes around, I would like to add "sparc" 
here as well so the testsuite failures drop from over
400 to just below 70.

> Besides, you haven't explained why it's appropriate to no longer test support 
> for the old (pre-Debian 9,I believe) directory layout.  However, as I said I 
> don't feel qualified to review that part, so you'll need another reviewer for 
> that, no matter if only testing the new layout or both old and new ones.

Debian 8 doesn't even support sparc as the port was dropped in this release:

> https://cdimage.debian.org/cdimage/archive/8.0.0/

The last sparc release was 7.11.0 and that's Wheezy which is long out of 
support:

> https://cdimage.debian.org/cdimage/archive/7.11.0/

And, as I said, MultiArch was and is the same for all architectures, including 
sparc/sparc64. It does not make sense to test sparc here differently than the 
other
Debian architectures. There is no special sparc configuration in Debian and I 
think I can make that statement as Debian's primary maintainer for the sparc64
port.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90524

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


[PATCH] D90524: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-13 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

In D90524#2393320 , @ro wrote:

> In D90524#2393312 , @glaubitz wrote:
>
>> Ping. It would be nice to get this finally merged so that the testsuite 
>> noise finally goes down on the sparc64 Linux worker.
>
> Please be a little more patient: one ping a week is considered appropriate, 
> but after only two days is a bit over the top.

The problem is that LLVM is a very fast moving target and when waiting long for 
changes to be merged, one constantly runs
into the risk of having to rebase patches.

I would like to move forward with other changes and having unmerged changes 
open takes away attention.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90524

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


[PATCH] D91147: AArch64: classify Triple::aarch64_32 as AArch64

2020-11-13 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added inline comments.



Comment at: clang/lib/Driver/ToolChain.cpp:1066
   if (getTriple().getArch() == llvm::Triple::x86_64 ||
-  getTriple().isAArch64() || getTriple().isRISCV())
+  (getTriple().isAArch64() && getTriple().isArch64Bit()) ||
+  getTriple().isRISCV())

dexonsmith wrote:
> Is there a short-form we'd want for this?
> 
> Here are two ideas:
> ```
> // getTriple().isAArch64_64() and getTriple().isAArch64_32()
> bool Triple::isAArch64_64() { return isAArch64() && isArch64Bit(); }
> bool Triple::isAArch64_32() { return isAArch64() && isArch32Bit(); }
> 
> // getTriple().isAArch64(64) and getTriple().isAArch64(32)
> bool Triple::isAArch64(int Bits) {
>   assert(Bits == 32 || Bits == 64);
>   if (!isAArch64())
> return false;
>   return isArch64Bit() ? Bits == 64 : Bits == 32;
> }
> ```
> Or do you think it's better as-is?
Tricky one. The bare "64" and "32" are a bit non-descript, but having both 
`isAArch64` and `isArch64` in the same line seems just slightly worse to me so 
I'll update the patch.


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

https://reviews.llvm.org/D91147

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


[PATCH] D91147: AArch64: classify Triple::aarch64_32 as AArch64

2020-11-13 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover updated this revision to Diff 305064.

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

https://reviews.llvm.org/D91147

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/frame-pointer-elim.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/BinaryFormat/MachO.cpp


Index: llvm/lib/BinaryFormat/MachO.cpp
===
--- llvm/lib/BinaryFormat/MachO.cpp
+++ llvm/lib/BinaryFormat/MachO.cpp
@@ -55,7 +55,7 @@
 }
 
 static MachO::CPUSubTypeARM64 getARM64SubType(const Triple &T) {
-  assert(T.isAArch64() || T.getArch() == Triple::aarch64_32);
+  assert(T.isAArch64());
   if (T.isArch32Bit())
 return (MachO::CPUSubTypeARM64)MachO::CPU_SUBTYPE_ARM64_32_V8;
   if (T.getArchName() == "arm64e")
@@ -84,9 +84,7 @@
   if (T.isARM() || T.isThumb())
 return MachO::CPU_TYPE_ARM;
   if (T.isAArch64())
-return MachO::CPU_TYPE_ARM64;
-  if (T.getArch() == Triple::aarch64_32)
-return MachO::CPU_TYPE_ARM64_32;
+return T.isArch32Bit() ? MachO::CPU_TYPE_ARM64_32 : MachO::CPU_TYPE_ARM64;
   if (T.getArch() == Triple::ppc)
 return MachO::CPU_TYPE_POWERPC;
   if (T.getArch() == Triple::ppc64)
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -714,7 +714,17 @@
 
   /// Tests whether the target is AArch64 (little and big endian).
   bool isAArch64() const {
-return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be;
+return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be ||
+   getArch() == Triple::aarch64_32;
+  }
+
+  /// Tests whether the target is AArch64 and pointers are the size specified 
by
+  /// \p PointerWidth.
+  bool isAArch64(int PointerWidth) const {
+assert(PointerWidth == 64 || PointerWidth == 32);
+if (!isAArch64())
+  return false;
+return isArch64Bit() ? PointerWidth == 64 : PointerWidth == 32;
   }
 
   /// Tests whether the target is MIPS 32-bit (little and big endian).
Index: clang/test/Driver/frame-pointer-elim.c
===
--- clang/test/Driver/frame-pointer-elim.c
+++ clang/test/Driver/frame-pointer-elim.c
@@ -97,6 +97,8 @@
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 // RUN: %clang -### -target x86_64-scei-ps4 -S -O2 %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
+// RUN: %clang -### -target aarch64-apple-darwin -arch arm64_32 -S %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 
 // RUN: %clang -### -target powerpc64 -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-ALL %s
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -1063,9 +1063,9 @@
   getTriple().isAArch64())
 Res |= SanitizerKind::CFIICall;
   if (getTriple().getArch() == llvm::Triple::x86_64 ||
-  getTriple().isAArch64() || getTriple().isRISCV())
+  getTriple().isAArch64(64) || getTriple().isRISCV())
 Res |= SanitizerKind::ShadowCallStack;
-  if (getTriple().isAArch64())
+  if (getTriple().isAArch64(64))
 Res |= SanitizerKind::MemTag;
   return Res;
 }


Index: llvm/lib/BinaryFormat/MachO.cpp
===
--- llvm/lib/BinaryFormat/MachO.cpp
+++ llvm/lib/BinaryFormat/MachO.cpp
@@ -55,7 +55,7 @@
 }
 
 static MachO::CPUSubTypeARM64 getARM64SubType(const Triple &T) {
-  assert(T.isAArch64() || T.getArch() == Triple::aarch64_32);
+  assert(T.isAArch64());
   if (T.isArch32Bit())
 return (MachO::CPUSubTypeARM64)MachO::CPU_SUBTYPE_ARM64_32_V8;
   if (T.getArchName() == "arm64e")
@@ -84,9 +84,7 @@
   if (T.isARM() || T.isThumb())
 return MachO::CPU_TYPE_ARM;
   if (T.isAArch64())
-return MachO::CPU_TYPE_ARM64;
-  if (T.getArch() == Triple::aarch64_32)
-return MachO::CPU_TYPE_ARM64_32;
+return T.isArch32Bit() ? MachO::CPU_TYPE_ARM64_32 : MachO::CPU_TYPE_ARM64;
   if (T.getArch() == Triple::ppc)
 return MachO::CPU_TYPE_POWERPC;
   if (T.getArch() == Triple::ppc64)
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -714,7 +714,17 @@
 
   /// Tests whether the target is AArch64 (little and big endian).
   bool isAArch64() const {
-return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be;
+return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be ||
+   getArch() == Triple::aarch64_32;
+  }
+
+  /// Tests whether the target is AArch64 and pointers are the size specified by
+  /// \p PointerWidth.
+  bool isAArch64(int PointerWidth) const {
+assert(PointerWidth == 64 || PointerWidth == 32);
+if (!isAArch64())
+  return false;
+return isArch64Bit()

[PATCH] D91337: [clangd] Add missing tests to rename feature

2020-11-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:618
+
+  // Templated method instantiation.
+  R"cpp(

hokein wrote:
> nit: we have groups of templates on ~Line  215 already,  I'd suggest to move 
> these template-related cases to there.
this looks like still undone. 

I would move this section (from Line638-Line710) to Line307.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91337

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


[PATCH] D91258: [clangd] Sanity-check array sizes read from disk before allocating them.

2020-11-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D91258#2392646 , @eugenis wrote:

> Hi Sam,
>
> this patch is failing on the ubsan bot with:
>
>   [ RUN  ] SerializationTest.NoCrashOnBadArraySize
>   
> /b/sanitizer-x86_64-linux-fast/build/llvm-project/clang-tools-extra/clangd/index/Serialization.cpp:90:26:
>  runtime error: left shift of 127 by 28 places cannot be represented in type 
> 'int'
>   #0 0x392dd57 in clang::clangd::(anonymous 
> namespace)::Reader::consumeVar() 
> /b/sanitizer-x86_64-linux-fast/build/llvm-project/clang-tools-extra/clangd/index/Serialization.cpp:90:26

Thanks Evgenii! (It's really surprising to me this is using signed arithmetic!)

Is the sanitizer strictly correct here that this is UB? From my reading only C 
requires the result of signed shifts to be representable, not C++. 
https://eel.is/c++draft/expr.shift
So this should be well-defined with the same result as the unsigned arithmetic 
(assuming 2s complement, I guess).

(We'll fix this to use unsigned arithmetic in any case)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91258

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


[PATCH] D91337: [clangd] Add missing tests to rename feature

2020-11-13 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 305070.
kbobyrev added a comment.

Move the rest of templated cases to appropriate location.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91337

Files:
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -141,6 +141,12 @@
   ~[[F^oo]]();
   void f([[F^oo]] x);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
+
+template
+[[F^oo]]::~[[Fo^o]]() {}
   )cpp",
 
   // Template class constructor.
@@ -152,6 +158,9 @@
   template
   [[F^oo]](T t);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
   )cpp",
 
   // Class in template argument.
@@ -199,6 +208,30 @@
 }
   )cpp",
 
+  // Templated method instantiation.
+  R"cpp(
+template
+class Foo {
+public:
+  static T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo::[[f^oo]]();
+}
+  )cpp",
+  R"cpp(
+template
+class Foo {
+public:
+  T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo().[[f^oo]]();
+}
+  )cpp",
+
   // Template class (partial) specializations.
   R"cpp(
 template 
@@ -272,6 +305,80 @@
 }
   )cpp",
 
+  // Templated class specialization.
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+
+template
+class [[Foo^]];
+  )cpp",
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+  )cpp",
+
+  // Function template specialization.
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]() {};
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]() {};
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template 
+void [[f^oo]](T t);
+
+template <>
+void [[f^oo]](int a);
+
+void test() {
+  [[f^oo]](1);
+}
+  )cpp",
+
+  // Variable template.
+  R"cpp(
+template 
+bool [[F^oo]] = true;
+
+// Explicit template specialization
+template <>
+bool [[F^oo]] = false;
+
+// Partial template specialization
+template 
+bool [[F^oo]] = false;
+
+void foo() {
+  // Ref to the explicit template specialization
+  [[F^oo]];
+  // Ref to the primary template.
+  [[F^oo]];
+}
+  )cpp",
+
   // Complicated class type.
   R"cpp(
  // Forward declaration.
@@ -307,6 +414,19 @@
 }
   )cpp",
 
+  // Static class member.
+  R"cpp(
+struct Foo {
+  static Foo *[[Static^Member]];
+};
+
+Foo* Foo::[[Static^Member]] = nullptr;
+
+void foo() {
+  Foo* Pointer = Foo::[[Static^Member]];
+}
+  )cpp",
+
   // Reference in lambda parameters.
   R"cpp(
 template 
@@ -588,6 +708,26 @@
   ns::[[Old^Alias]] Bar;
 }
   )cpp",
+
+  // User defined conversion.
+  R"cpp(
+class [[F^oo]] {
+public:
+  [[F^oo]]() {}
+};
+
+class Baz {
+public:
+  operator [[F^oo]]() {
+return [[F^oo]]();
+  }
+};
+
+int main() {
+  Baz boo;
+  [[F^oo]] foo = static_cast<[[F^oo]]>(boo);
+}
+  )cpp",
   };
   llvm::StringRef NewName = "NewName";
   for (llvm::StringRef T : Tests) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90507: Adding DWARF64 clang flag

2020-11-13 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Hi @ayermolo, do you think this might be triggered by D82756 
? (my only upstream patch ATM)




Comment at: clang/test/Driver/debug-options.c:377
 // NO_DEBUG_UNUSED_TYPES: 
"-debug-info-kind={{limited|line-tables-only|standalone}}"
-// NO_DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=unused-types"
+// NO_DEBUG_U∏NUSED_TYPES-NOT: "-debug-info-kind=unused-types"
+//

Probably extra character.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90507

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


[clang-tools-extra] a115248 - [clangd] Add missing tests to rename feature

2020-11-13 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-11-13T12:27:40+01:00
New Revision: a1152482826c9a80977871aa46e131ac803c5f44

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

LOG: [clangd] Add missing tests to rename feature

This adds a couple of missed tests from existing clang-rename ones and
introduces several new ones (e.g. static class member). This patch is required
to ensure feature parity for migration off Clang-Rename API D71880.

Reviewed By: hokein

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index daf63d25ed7f4..876262a463a53 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -141,6 +141,12 @@ TEST(RenameTest, WithinFileRename) {
   ~[[F^oo]]();
   void f([[F^oo]] x);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
+
+template
+[[F^oo]]::~[[Fo^o]]() {}
   )cpp",
 
   // Template class constructor.
@@ -152,6 +158,9 @@ TEST(RenameTest, WithinFileRename) {
   template
   [[F^oo]](T t);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
   )cpp",
 
   // Class in template argument.
@@ -199,6 +208,30 @@ TEST(RenameTest, WithinFileRename) {
 }
   )cpp",
 
+  // Templated method instantiation.
+  R"cpp(
+template
+class Foo {
+public:
+  static T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo::[[f^oo]]();
+}
+  )cpp",
+  R"cpp(
+template
+class Foo {
+public:
+  T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo().[[f^oo]]();
+}
+  )cpp",
+
   // Template class (partial) specializations.
   R"cpp(
 template 
@@ -272,6 +305,80 @@ TEST(RenameTest, WithinFileRename) {
 }
   )cpp",
 
+  // Templated class specialization.
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+
+template
+class [[Foo^]];
+  )cpp",
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+  )cpp",
+
+  // Function template specialization.
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]() {};
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]() {};
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template 
+void [[f^oo]](T t);
+
+template <>
+void [[f^oo]](int a);
+
+void test() {
+  [[f^oo]](1);
+}
+  )cpp",
+
+  // Variable template.
+  R"cpp(
+template 
+bool [[F^oo]] = true;
+
+// Explicit template specialization
+template <>
+bool [[F^oo]] = false;
+
+// Partial template specialization
+template 
+bool [[F^oo]] = false;
+
+void foo() {
+  // Ref to the explicit template specialization
+  [[F^oo]];
+  // Ref to the primary template.
+  [[F^oo]];
+}
+  )cpp",
+
   // Complicated class type.
   R"cpp(
  // Forward declaration.
@@ -307,6 +414,19 @@ TEST(RenameTest, WithinFileRename) {
 }
   )cpp",
 
+  // Static class member.
+  R"cpp(
+struct Foo {
+  static Foo *[[Static^Member]];
+};
+
+Foo* Foo::[[Static^Member]] = nullptr;
+
+void foo() {
+  Foo* Pointer = Foo::[[Static^Member]];
+}
+  )cpp",
+
   // Reference in lambda parameters.
   R"cpp(
 template 
@@ -588,6 +708,26 @@ TEST(RenameTest, WithinFileRename) {
   ns::[[Old^Alias]] Bar;
 }
   )cpp",
+
+  // User defined conversion.
+  R"cpp(
+class [[F^oo]] {
+public:
+  [[F^oo]]() {}
+};
+
+class Baz {
+public:
+  operator [[F^oo]]() {
+return [[F^oo]]();
+  }
+};
+
+int main() {
+  Baz boo;
+  [[F^oo]] foo = static_cast<[[F^oo]]>(boo);
+}
+  )cpp",
   };
   llvm::StringRef NewName = "NewName";
   for (llvm::StringRef T : Tests) {



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


[PATCH] D91405: [clangd] Assert on varint encoding

2020-11-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/index/Serialization.cpp:90
   B = consume8();
+  assert((B & ~More) < (1 << (32 - Shift)) && "Invalid varint encoding");
   Val |= (B & ~More) << Shift;

I'm fine with an assert, but this still leaves us with the suspected UB in 
NDEBUG mode, which doesn't seem OK.
(As noted on D91258 I'm not sure this is actual UB under C++ rules)

The issue here is integral promotion rules say that uint_8 << anything uses 
*signed* arithmetic. And same for a bunch of the other operations.

I think the clearest thing to do is explicitly type B as uint32_t, so no 
expression it is in can ever be promoted to (signed) int.
(Unless int is bigger than 32 bits, in which case we've always got enough bits 
to shift into)



Comment at: clang-tools-extra/clangd/unittests/SerializationTests.cpp:371
   std::string CorruptSrcs =
-  (Srcs->Data.take_front(Pos) + llvm::fromHex("8fff7f") +
+  (Srcs->Data.take_front(Pos) + llvm::fromHex("0f") +
"some_random_garbage")

/shamecube

In my defense, I grew up on a 68k mac... little endian is weird


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91405

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


[PATCH] D91337: [clangd] Add missing tests to rename feature

2020-11-13 Thread Kirill Bobyrev 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 rGa1152482826c: [clangd] Add missing tests to rename feature 
(authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91337

Files:
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -141,6 +141,12 @@
   ~[[F^oo]]();
   void f([[F^oo]] x);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
+
+template
+[[F^oo]]::~[[Fo^o]]() {}
   )cpp",
 
   // Template class constructor.
@@ -152,6 +158,9 @@
   template
   [[F^oo]](T t);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
   )cpp",
 
   // Class in template argument.
@@ -199,6 +208,30 @@
 }
   )cpp",
 
+  // Templated method instantiation.
+  R"cpp(
+template
+class Foo {
+public:
+  static T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo::[[f^oo]]();
+}
+  )cpp",
+  R"cpp(
+template
+class Foo {
+public:
+  T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo().[[f^oo]]();
+}
+  )cpp",
+
   // Template class (partial) specializations.
   R"cpp(
 template 
@@ -272,6 +305,80 @@
 }
   )cpp",
 
+  // Templated class specialization.
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+
+template
+class [[Foo^]];
+  )cpp",
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+  )cpp",
+
+  // Function template specialization.
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]() {};
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]() {};
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template 
+void [[f^oo]](T t);
+
+template <>
+void [[f^oo]](int a);
+
+void test() {
+  [[f^oo]](1);
+}
+  )cpp",
+
+  // Variable template.
+  R"cpp(
+template 
+bool [[F^oo]] = true;
+
+// Explicit template specialization
+template <>
+bool [[F^oo]] = false;
+
+// Partial template specialization
+template 
+bool [[F^oo]] = false;
+
+void foo() {
+  // Ref to the explicit template specialization
+  [[F^oo]];
+  // Ref to the primary template.
+  [[F^oo]];
+}
+  )cpp",
+
   // Complicated class type.
   R"cpp(
  // Forward declaration.
@@ -307,6 +414,19 @@
 }
   )cpp",
 
+  // Static class member.
+  R"cpp(
+struct Foo {
+  static Foo *[[Static^Member]];
+};
+
+Foo* Foo::[[Static^Member]] = nullptr;
+
+void foo() {
+  Foo* Pointer = Foo::[[Static^Member]];
+}
+  )cpp",
+
   // Reference in lambda parameters.
   R"cpp(
 template 
@@ -588,6 +708,26 @@
   ns::[[Old^Alias]] Bar;
 }
   )cpp",
+
+  // User defined conversion.
+  R"cpp(
+class [[F^oo]] {
+public:
+  [[F^oo]]() {}
+};
+
+class Baz {
+public:
+  operator [[F^oo]]() {
+return [[F^oo]]();
+  }
+};
+
+int main() {
+  Baz boo;
+  [[F^oo]] foo = static_cast<[[F^oo]]>(boo);
+}
+  )cpp",
   };
   llvm::StringRef NewName = "NewName";
   for (llvm::StringRef T : Tests) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91330: [clangd] Ensure we test for compatibility of serialized index format

2020-11-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Very nice, thanks for doing this!




Comment at: 
clang-tools-extra/clangd/test/index-serialization/version-is-correct.test:1
+# If this test fails it means there has been a backward incompatilbe change to
+# serialization format. Please bump the version number in

I think this test is REQUIRES: zlib
(see windows failures)



Comment at: 
clang-tools-extra/clangd/test/index-serialization/version-is-correct.test:1
+# If this test fails it means there has been a backward incompatilbe change to
+# serialization format. Please bump the version number in

sammccall wrote:
> I think this test is REQUIRES: zlib
> (see windows failures)
nit: maybe say a bit more about what the test does? And separate what the test 
does vs what failure means vs what action to take a little.

This test tries to parse a checked-in binary index.
If it fails, there has been...
Please bump the version number...



Comment at: 
clang-tools-extra/clangd/test/index-serialization/version-is-correct.test:3
+# serialization format. Please bump the version number in
+# clang-tools-extra/clangd/index/Serialization.cpp and regenarate the 
sample.idx
+# with

nit: regenerate sample.idx



Comment at: 
clang-tools-extra/clangd/test/index-serialization/version-is-correct.test:5
+# with
+# clangd-indexer \
+# clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp > \

this isn't easy to copy/paste because of the comment markers.
This file isn't interpreted so there's no need for them, I think...

It could also be formatted so it's easier to recognize the command (surround by 
blank lines, indent by a couple of spaces?)



Comment at: 
clang-tools-extra/clangd/test/index-serialization/version-is-correct.test:10
+# indexing sample.cpp would yield non-trivial values for those.
+# RUN: dexp %/S/Inputs/sample.idx
+

`dexp ... -c="find B" | grep Bar`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91330

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


[PATCH] D91405: [clangd] Assert on varint encoding

2020-11-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 305094.
kadircet marked an inline comment as done.
kadircet added a comment.

- Increase width of `B` to prevent integer promotion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91405

Files:
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/unittests/SerializationTests.cpp


Index: clang-tools-extra/clangd/unittests/SerializationTests.cpp
===
--- clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -366,9 +366,9 @@
   Pos += FileDigest.size();
 
   // Varints are little-endian base-128 numbers, where the top-bit of each byte
-  // indicates whether there are more. 8fff7f -> 0x.
+  // indicates whether there are more. 0f -> 0x.
   std::string CorruptSrcs =
-  (Srcs->Data.take_front(Pos) + llvm::fromHex("8fff7f") +
+  (Srcs->Data.take_front(Pos) + llvm::fromHex("0f") +
"some_random_garbage")
   .str();
   Srcs->Data = CorruptSrcs;
Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -21,6 +21,7 @@
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
 #include 
 
 namespace clang {
@@ -81,12 +82,16 @@
 
   uint32_t consumeVar() {
 constexpr static uint8_t More = 1 << 7;
-uint8_t B = consume8();
+
+// Use a 32 bit unsigned here to prevent promotion to signed int (unless 
int
+// is wider than 32 bits).
+uint32_t B = consume8();
 if (LLVM_LIKELY(!(B & More)))
   return B;
 uint32_t Val = B & ~More;
 for (int Shift = 7; B & More && Shift < 32; Shift += 7) {
   B = consume8();
+  assert((B & ~More) < (1 << (32 - Shift)) && "Invalid varint encoding");
   Val |= (B & ~More) << Shift;
 }
 return Val;


Index: clang-tools-extra/clangd/unittests/SerializationTests.cpp
===
--- clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -366,9 +366,9 @@
   Pos += FileDigest.size();
 
   // Varints are little-endian base-128 numbers, where the top-bit of each byte
-  // indicates whether there are more. 8fff7f -> 0x.
+  // indicates whether there are more. 0f -> 0x.
   std::string CorruptSrcs =
-  (Srcs->Data.take_front(Pos) + llvm::fromHex("8fff7f") +
+  (Srcs->Data.take_front(Pos) + llvm::fromHex("0f") +
"some_random_garbage")
   .str();
   Srcs->Data = CorruptSrcs;
Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -21,6 +21,7 @@
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
 #include 
 
 namespace clang {
@@ -81,12 +82,16 @@
 
   uint32_t consumeVar() {
 constexpr static uint8_t More = 1 << 7;
-uint8_t B = consume8();
+
+// Use a 32 bit unsigned here to prevent promotion to signed int (unless int
+// is wider than 32 bits).
+uint32_t B = consume8();
 if (LLVM_LIKELY(!(B & More)))
   return B;
 uint32_t Val = B & ~More;
 for (int Shift = 7; B & More && Shift < 32; Shift += 7) {
   B = consume8();
+  assert((B & ~More) < (1 << (32 - Shift)) && "Invalid varint encoding");
   Val |= (B & ~More) << Shift;
 }
 return Val;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91405: [clangd] Assert on varint encoding

2020-11-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/index/Serialization.cpp:94
   B = consume8();
+  assert((B & ~More) < (1 << (32 - Shift)) && "Invalid varint encoding");
   Val |= (B & ~More) << Shift;

hmm, actually it's also invalid to have the More bit set on the last byte...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91405

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


[PATCH] D91330: [clangd] Ensure we test for compatibility of serialized index format

2020-11-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 305096.
kadircet added a comment.

- Update comments
- Query for Bar
- Only run with zlib


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91330

Files:
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
  clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
  clang-tools-extra/clangd/test/lit.cfg.py
  clang-tools-extra/clangd/test/lit.site.cfg.py.in


Index: clang-tools-extra/clangd/test/lit.site.cfg.py.in
===
--- clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -25,6 +25,7 @@
 config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.."
 config.clangd_build_xpc = @CLANGD_BUILD_XPC@
 config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@
+config.have_zlib = @LLVM_ENABLE_ZLIB@
 
 # Delegate logic to lit.cfg.py.
 lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py")
Index: clang-tools-extra/clangd/test/lit.cfg.py
===
--- clang-tools-extra/clangd/test/lit.cfg.py
+++ clang-tools-extra/clangd/test/lit.cfg.py
@@ -30,3 +30,6 @@
 
 if config.clangd_enable_remote:
   config.available_features.add('clangd-remote-index')
+
+if config.have_zlib:
+  config.available_features.add('zlib')
Index: clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
@@ -0,0 +1,16 @@
+# REQUIRES: zlib
+# This test tries to parse a checked-in binary index.
+# If this test fails it means there has been a backward incompatilbe change to
+# serialization format.
+# Please bump the version number in
+# clang-tools-extra/clangd/index/Serialization.cpp and regenarate sample.idx
+# with
+#
+#   clangd-indexer
+# clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp >
+# clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
+#
+# Also if you've introduced new slabs/chunks to serialized index, make sure
+# indexing sample.cpp would yield non-trivial values for those.
+# RUN: dexp %/S/Inputs/sample.idx -c="find B" | grep Bar
+
Index: clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
@@ -0,0 +1,4 @@
+#pragma once
+
+// Introduce a symbol.
+struct Foo {};
Index: clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
@@ -0,0 +1,5 @@
+// Include a file to ensure we have multiple sources.
+#include "sample.h"
+
+// This introduces a symbol, a reference and a relation.
+struct Bar : public Foo {};


Index: clang-tools-extra/clangd/test/lit.site.cfg.py.in
===
--- clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -25,6 +25,7 @@
 config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.."
 config.clangd_build_xpc = @CLANGD_BUILD_XPC@
 config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@
+config.have_zlib = @LLVM_ENABLE_ZLIB@
 
 # Delegate logic to lit.cfg.py.
 lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py")
Index: clang-tools-extra/clangd/test/lit.cfg.py
===
--- clang-tools-extra/clangd/test/lit.cfg.py
+++ clang-tools-extra/clangd/test/lit.cfg.py
@@ -30,3 +30,6 @@
 
 if config.clangd_enable_remote:
   config.available_features.add('clangd-remote-index')
+
+if config.have_zlib:
+  config.available_features.add('zlib')
Index: clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
@@ -0,0 +1,16 @@
+# REQUIRES: zlib
+# This test tries to parse a checked-in binary index.
+# If this test fails it means there has been a backward incompatilbe change to
+# serialization format.
+# Please bump the version number in
+# clang-tools-extra/clangd/index/Serialization.cpp and regenarate sample.idx
+# with
+#
+#   clangd-indexer
+# clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp >
+# clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
+#
+# Also if you've introduced new slabs/chunks to serialized index, make sure
+# indexing

[PATCH] D91330: [clangd] Ensure we test for compatibility of serialized index format

2020-11-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: 
clang-tools-extra/clangd/test/index-serialization/version-is-correct.test:15
+# indexing sample.cpp would yield non-trivial values for those.
+# RUN: dexp %/S/Inputs/sample.idx -c="find B" | grep Bar
+

as discussed offline, maybe `|| not grep -v -e RUN: -e REQUIRES: %S` ?



Comment at: 
clang-tools-extra/clangd/test/index-serialization/version-is-correct.test:5
+# with
+# clangd-indexer \
+# clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp > \

sammccall wrote:
> this isn't easy to copy/paste because of the comment markers.
> This file isn't interpreted so there's no need for them, I think...
> 
> It could also be formatted so it's easier to recognize the command (surround 
> by blank lines, indent by a couple of spaces?)
again, we don't need the comment markers (but do need the line-continuations) 
for copy-paste


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91330

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


[PATCH] D91330: [clangd] Ensure we test for compatibility of serialized index format

2020-11-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 305100.
kadircet added a comment.

- Drop comment markers
- Make failure print the doc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91330

Files:
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
  clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
  clang-tools-extra/clangd/test/lit.cfg.py
  clang-tools-extra/clangd/test/lit.site.cfg.py.in


Index: clang-tools-extra/clangd/test/lit.site.cfg.py.in
===
--- clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -25,6 +25,7 @@
 config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.."
 config.clangd_build_xpc = @CLANGD_BUILD_XPC@
 config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@
+config.have_zlib = @LLVM_ENABLE_ZLIB@
 
 # Delegate logic to lit.cfg.py.
 lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py")
Index: clang-tools-extra/clangd/test/lit.cfg.py
===
--- clang-tools-extra/clangd/test/lit.cfg.py
+++ clang-tools-extra/clangd/test/lit.cfg.py
@@ -30,3 +30,6 @@
 
 if config.clangd_enable_remote:
   config.available_features.add('clangd-remote-index')
+
+if config.have_zlib:
+  config.available_features.add('zlib')
Index: clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
@@ -0,0 +1,16 @@
+# REQUIRES: zlib
+This test tries to parse a checked-in binary index.
+If this test fails it means there has been a backward incompatilbe change to
+serialization format.
+Please bump the version number in
+clang-tools-extra/clangd/index/Serialization.cpp and regenarate sample.idx with
+
+  clangd-indexer \
+clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp > \
+clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
+
+Also if you've introduced new slabs/chunks to serialized index, make sure
+indexing sample.cpp would yield non-trivial values for those.
+# RUN: (dexp %/S/Inputs/sample.idx -c="find B" | grep Bar) \
+# RUN: || (grep -v '^#' %s && exit 1)
+
Index: clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
@@ -0,0 +1,4 @@
+#pragma once
+
+// Introduce a symbol.
+struct Foo {};
Index: clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
@@ -0,0 +1,5 @@
+// Include a file to ensure we have multiple sources.
+#include "sample.h"
+
+// This introduces a symbol, a reference and a relation.
+struct Bar : public Foo {};


Index: clang-tools-extra/clangd/test/lit.site.cfg.py.in
===
--- clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -25,6 +25,7 @@
 config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.."
 config.clangd_build_xpc = @CLANGD_BUILD_XPC@
 config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@
+config.have_zlib = @LLVM_ENABLE_ZLIB@
 
 # Delegate logic to lit.cfg.py.
 lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py")
Index: clang-tools-extra/clangd/test/lit.cfg.py
===
--- clang-tools-extra/clangd/test/lit.cfg.py
+++ clang-tools-extra/clangd/test/lit.cfg.py
@@ -30,3 +30,6 @@
 
 if config.clangd_enable_remote:
   config.available_features.add('clangd-remote-index')
+
+if config.have_zlib:
+  config.available_features.add('zlib')
Index: clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
@@ -0,0 +1,16 @@
+# REQUIRES: zlib
+This test tries to parse a checked-in binary index.
+If this test fails it means there has been a backward incompatilbe change to
+serialization format.
+Please bump the version number in
+clang-tools-extra/clangd/index/Serialization.cpp and regenarate sample.idx with
+
+  clangd-indexer \
+clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp > \
+clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
+
+Also if you've introduced new slabs/chunks to serialized index, make sure
+indexing s

[PATCH] D90524: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-13 Thread Rainer Orth via Phabricator via cfe-commits
ro resigned from this revision.
ro added a comment.

In D90524#2393353 , @glaubitz wrote:

> In D90524#2393319 , @ro wrote:
>
>> In D90524#2388214 , @glaubitz wrote:
>>
>>> I think it should be good for merging now. I addressed all remarks. I'm 
>>> still convinced that "workaround" is the proper term though.
>>
>> Quite the contrary: the comment you cited
>>
>>   // FIXME: This is a bit of a hack. We should really unify this code for
>>   // reasoning about oslibdir spellings with the lib dir spellings in the
>>   // GCCInstallationDetector, but that is a more significant refactoring.
>>
>> pretty clearly is about how/where support for that layout is implemented in 
>> the `clang` Driver code, not about the layout itself.
>
> I don't understand that argument. I call it "workaround", the source comment 
> calls it "hack". It's clearly not to stay forever as it's an ugly
> workaround, but until a proper fix comes around, I would like to add "sparc" 
> here as well so the testsuite failures drop from over
> 400 to just below 70.

I think we're talking past each other, but as I've said, i'm not able to review 
the rest of this patch, so I won't belabour the point.

>> Besides, you haven't explained why it's appropriate to no longer test 
>> support for the old (pre-Debian 9,I believe) directory layout.  However, as 
>> I said I don't feel qualified to review that part, so you'll need another 
>> reviewer for that, no matter if only testing the new layout or both old and 
>> new ones.
>
> Debian 8 doesn't even support sparc as the port was dropped in this release:
>
>> https://cdimage.debian.org/cdimage/archive/8.0.0/
>
> The last sparc release was 7.11.0 and that's Wheezy which is long out of 
> support:
>
>> https://cdimage.debian.org/cdimage/archive/7.11.0/
>
> And, as I said, MultiArch was and is the same for all architectures, 
> including sparc/sparc64. It does not make sense to test sparc here 
> differently than the other
> Debian architectures. There is no special sparc configuration in Debian and I 
> think I can make that statement as Debian's primary maintainer for the sparc64
> port.

I had an extremely hard time researching the history of directory layouts for 
my patch D85582 .  Do as you like, I'm out of 
this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90524

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


[PATCH] D91410: [llvm][clang][mlir] Add checks for the return values from Target::createXXX to prevent protential null deref

2020-11-13 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie created this revision.
OikawaKirie added reviewers: serge-sans-paille, ahmedcharles, niravd, echristo, 
maskray0, pcc, tejohnson, espindola, courbet, andreadb, epastor, enderby, 
lhames, whchung, ftynse.
OikawaKirie added projects: LLVM, clang, MLIR.
Herald added subscribers: llvm-commits, cfe-commits, rdzhabarov, tatianashp, 
msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, lucyrfox, 
mgester, arpith-jacob, csigg, antiagainst, shauheen, rriddle, mehdi_amini, 
rupprecht, steven_wu, gbedwell, hiraditya.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
OikawaKirie requested review of this revision.
Herald added subscribers: stephenneuendorffer, nicolasvasilache.
Herald added a reviewer: herhut.

All these potential null pointer dereferences are reported by my static 
analyzer for null smart pointer dereferences, which has a different 
implementation from `alpha.cplusplus.SmartPtr`.

The checked pointers in this patch are initialized by Target::createXXX 
functions. When the creator function pointer is not correctly set, a null 
pointer will be returned, or the creator function may originally return a null 
pointer.

Some of them may not make sense as they may be checked before entering the 
function, but I fixed them all in this patch. I submit this fix because 1) 
similar checks are found in some other places in the LLVM codebase for the same 
return value of the function; and, 2) some of the pointers are dereferenced 
before they are checked, which may definitely trigger a null pointer 
dereference if the return value is nullptr.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91410

Files:
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
  clang/tools/driver/cc1as_main.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
  llvm/lib/CodeGen/LLVMTargetMachine.cpp
  llvm/lib/CodeGen/ParallelCG.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/LTO/LTOModule.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
  llvm/tools/llvm-exegesis/lib/LlvmState.cpp
  llvm/tools/llvm-exegesis/llvm-exegesis.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-objdump/MachODump.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp
  mlir/lib/ExecutionEngine/ExecutionEngine.cpp

Index: mlir/lib/ExecutionEngine/ExecutionEngine.cpp
===
--- mlir/lib/ExecutionEngine/ExecutionEngine.cpp
+++ mlir/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -131,6 +131,10 @@
 
   std::unique_ptr machine(target->createTargetMachine(
   targetTriple, cpu, features.getString(), {}, {}));
+  if (!machine) {
+errs() << "Unable to create target machine\n";
+return true;
+  }
   llvmModule->setDataLayout(machine->createDataLayout());
   llvmModule->setTargetTriple(targetTriple);
   return false;
Index: mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp
===
--- mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp
+++ mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp
@@ -131,6 +131,10 @@
 }
 targetMachine.reset(target->createTargetMachine(triple.str(), targetChip,
 features, {}, {}));
+if (targetMachine == nullptr) {
+  emitError(loc, "connot initialize target machine");
+  return {};
+}
   }
 
   llvmModule.setDataLayout(targetMachine->createDataLayout());
Index: llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
===
--- llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
+++ llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
@@ -764,6 +764,8 @@
 ErrorAndExit("Unable to create disassembler!");
 
   std::unique_ptr MII(TheTarget->createMCInstrInfo());
+  if (!MII)
+ErrorAndExit("Unable to create target instruction info!");
 
   std::unique_ptr InstPrinter(
   TheTarget->createMCInstPrinter(Triple(TripleName), 0, *MAI, *MII, *MRI));
Index: llvm/tools/llvm-objdump/MachODump.cpp
===
--- llvm/tools/llvm-objdump/MachODump.cpp
+++ llvm/tools/llvm-objdump/MachODump.cpp
@@ -7200,10 +7200,32 @@
   else
 MachOMCPU = MCPU;
 
+#define CHECK_TARGET_INFO_CREATION(NAME)  \
+  do {\
+if (!NAME) {  \
+  WithColor::error(errs(), "llvm-objdump")\
+  << "couldn't initialize disassembler for target " << TripleName \
+  << '\n';\
+  return; 

[PATCH] D85582: [clang][Driver] Search lib32 on Linux/sparc64 with -m32

2020-11-13 Thread Rainer Orth via Phabricator via cfe-commits
ro abandoned this revision.
ro added a comment.
Herald added a subscriber: pengfei.

Superceded by D90524 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85582

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


[PATCH] D90524: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-13 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D90524#2393366 , @glaubitz wrote:

> In D90524#2393320 , @ro wrote:
>
>> In D90524#2393312 , @glaubitz wrote:
>>
>>> Ping. It would be nice to get this finally merged so that the testsuite 
>>> noise finally goes down on the sparc64 Linux worker.
>>
>> Please be a little more patient: one ping a week is considered appropriate, 
>> but after only two days is a bit over the top.
>
> The problem is that LLVM is a very fast moving target and when waiting long 
> for changes to be merged, one constantly runs
> into the risk of having to rebase patches.

True, but it's the same for everyone.  Constantly pinging at short intervals 
won't get you faster reviews, but just creates noise and annoys possible 
reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90524

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


[clang] d2d59d2 - Reland [clang][cli] Port ObjCMTAction to new option parsing system

2020-11-13 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2020-11-13T13:42:54+01:00
New Revision: d2d59d2be9852b620b982c7304de5d9eaca35404

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

LOG: Reland [clang][cli] Port ObjCMTAction to new option parsing system

Merge existing marhsalling info kinds and add some primitives to
express flag options that contribute to a bitfield.

Depends on D82574

Original patch by Daniel Grumberg.

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/Option/OptParser.td
llvm/unittests/Option/OptionMarshallingTest.cpp
llvm/unittests/Option/Opts.td
llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2d22151c6496..0b0def564cf3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -340,36 +340,53 @@ def ccc_objcmt_migrate : Separate<["-"], 
"ccc-objcmt-migrate">,
   InternalDriverOpt,
   HelpText<"Apply modifications and produces temporary files to migrate to "
"modern ObjC syntax">;
+
 def objcmt_migrate_literals : Flag<["-"], "objcmt-migrate-literals">, 
Flags<[CC1Option]>,
-  HelpText<"Enable migration to modern ObjC literals">;
+  HelpText<"Enable migration to modern ObjC literals">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_Literals">;
 def objcmt_migrate_subscripting : Flag<["-"], "objcmt-migrate-subscripting">, 
Flags<[CC1Option]>,
-  HelpText<"Enable migration to modern ObjC subscripting">;
+  HelpText<"Enable migration to modern ObjC subscripting">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_Subscripting">;
 def objcmt_migrate_property : Flag<["-"], "objcmt-migrate-property">, 
Flags<[CC1Option]>,
-  HelpText<"Enable migration to modern ObjC property">;
+  HelpText<"Enable migration to modern ObjC property">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_Property">;
 def objcmt_migrate_all : Flag<["-"], "objcmt-migrate-all">, Flags<[CC1Option]>,
-  HelpText<"Enable migration to modern ObjC">;
+  HelpText<"Enable migration to modern ObjC">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_MigrateDecls">;
 def objcmt_migrate_readonly_property : Flag<["-"], 
"objcmt-migrate-readonly-property">, Flags<[CC1Option]>,
-  HelpText<"Enable migration to modern ObjC readonly property">;
+  HelpText<"Enable migration to modern ObjC readonly property">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_ReadonlyProperty">;
 def objcmt_migrate_readwrite_property : Flag<["-"], 
"objcmt-migrate-readwrite-property">, Flags<[CC1Option]>,
-  HelpText<"Enable migration to modern ObjC readwrite property">;
+  HelpText<"Enable migration to modern ObjC readwrite property">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_ReadwriteProperty">;
 def objcmt_migrate_property_dot_syntax : Flag<["-"], 
"objcmt-migrate-property-dot-syntax">, Flags<[CC1Option]>,
-  HelpText<"Enable migration of setter/getter messages to property-dot 
syntax">;
+  HelpText<"Enable migration of setter/getter messages to property-dot 
syntax">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_PropertyDotSyntax">;
 def objcmt_migrate_annotation : Flag<["-"], "objcmt-migrate-annotation">, 
Flags<[CC1Option]>,
-  HelpText<"Enable migration to property and method annotations">;
+  HelpText<"Enable migration to property and method annotations">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_Annotation">;
 def objcmt_migrate_instancetype : Flag<["-"], "objcmt-migrate-instancetype">, 
Flags<[CC1Option]>,
-  HelpText<"Enable migration to infer instancetype for method result type">;
+  HelpText<"Enable migration to infer instancetype for method result type">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_Instancetype">;
 def objcmt_migrate_nsmacros : Flag<["-"], "objcmt-migrate-ns-macros">, 
Flags<[CC1Option]>,
-  HelpText<"Enable migration to NS_ENUM/NS_OPTIONS macros">;
+  HelpText<"Enable migration to NS_ENUM/NS_OPTIONS macros">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_NsMacros">;
 def objcmt_migrate_protocol_conformance : Flag<["-"], 
"objcmt-migrate-protocol-conformance">, Flags<[CC1Option]>,
-  HelpText<"Enable migration to add protocol conformance on classes">;
+  HelpText<"Enable migration to add protocol conformance on 

[PATCH] D90524: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-13 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

> ! In D90524#2393635 , @ro wrote:
>
> I had an extremely hard time researching the history of directory layouts for 
> my patch D85582 .  Do as you like, I'm out 
> of this.

Please feel free to reach out to the corresponding debian-$ARCH mailing list 
for such questions. Debian-specific layouts are not
necessarily obvious at first glance to people not very familiar with the 
distribution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90524

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


[PATCH] D82860: Port ObjCMTAction to new option parsing system

2020-11-13 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Thank you for the heads-up. It seems like Clang 5 didn't like the usage of 
`static constexpr` member via an instance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82860

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


[clang] 7ad6c84 - [clang] Fix an assertion crash in delayed access check.

2020-11-13 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-11-13T14:02:57+01:00
New Revision: 7ad6c8414ce2c229129c93281835eb9457cf0bfb

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

LOG: [clang] Fix an assertion crash in delayed access check.

`TD->getTemplatedDecl()` might not be a DeclContext variant, which can
trigger an assertion inside `isa<>`.

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

Added: 
clang/test/SemaCXX/cxx14-access.cpp

Modified: 
clang/lib/Sema/SemaAccess.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp
index bd15b81cbed0..be30445d143c 100644
--- a/clang/lib/Sema/SemaAccess.cpp
+++ b/clang/lib/Sema/SemaAccess.cpp
@@ -1476,7 +1476,8 @@ void Sema::HandleDelayedAccessCheck(DelayedDiagnostic 
&DD, Decl *D) {
   } else if (FunctionDecl *FN = dyn_cast(D)) {
 DC = FN;
   } else if (TemplateDecl *TD = dyn_cast(D)) {
-DC = cast(TD->getTemplatedDecl());
+if (isa(TD->getTemplatedDecl()))
+  DC = cast(TD->getTemplatedDecl());
   }
 
   EffectiveContext EC(DC);

diff  --git a/clang/test/SemaCXX/cxx14-access.cpp 
b/clang/test/SemaCXX/cxx14-access.cpp
new file mode 100644
index ..ea129b175696
--- /dev/null
+++ b/clang/test/SemaCXX/cxx14-access.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
+
+namespace NoCrashOnDelayedAccessCheck {
+class Foo {
+  class Private; // expected-note {{declared private here}}
+};
+
+struct Bar {};
+
+template 
+Foo::Private Bar::ABC; // expected-error {{no member named 'ABC' in 
'NoCrashOnDelayedAccessCheck::Bar'}} \
+  expected-error {{'Private' is a private member of}}
+}



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


[PATCH] D91380: [clang] Fix an assertion crash in delayed access check.

2020-11-13 Thread Haojian Wu 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 rG7ad6c8414ce2: [clang] Fix an assertion crash in delayed 
access check. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91380

Files:
  clang/lib/Sema/SemaAccess.cpp
  clang/test/SemaCXX/cxx14-access.cpp


Index: clang/test/SemaCXX/cxx14-access.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx14-access.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
+
+namespace NoCrashOnDelayedAccessCheck {
+class Foo {
+  class Private; // expected-note {{declared private here}}
+};
+
+struct Bar {};
+
+template 
+Foo::Private Bar::ABC; // expected-error {{no member named 'ABC' in 
'NoCrashOnDelayedAccessCheck::Bar'}} \
+  expected-error {{'Private' is a private member of}}
+}
Index: clang/lib/Sema/SemaAccess.cpp
===
--- clang/lib/Sema/SemaAccess.cpp
+++ clang/lib/Sema/SemaAccess.cpp
@@ -1476,7 +1476,8 @@
   } else if (FunctionDecl *FN = dyn_cast(D)) {
 DC = FN;
   } else if (TemplateDecl *TD = dyn_cast(D)) {
-DC = cast(TD->getTemplatedDecl());
+if (isa(TD->getTemplatedDecl()))
+  DC = cast(TD->getTemplatedDecl());
   }
 
   EffectiveContext EC(DC);


Index: clang/test/SemaCXX/cxx14-access.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx14-access.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
+
+namespace NoCrashOnDelayedAccessCheck {
+class Foo {
+  class Private; // expected-note {{declared private here}}
+};
+
+struct Bar {};
+
+template 
+Foo::Private Bar::ABC; // expected-error {{no member named 'ABC' in 'NoCrashOnDelayedAccessCheck::Bar'}} \
+  expected-error {{'Private' is a private member of}}
+}
Index: clang/lib/Sema/SemaAccess.cpp
===
--- clang/lib/Sema/SemaAccess.cpp
+++ clang/lib/Sema/SemaAccess.cpp
@@ -1476,7 +1476,8 @@
   } else if (FunctionDecl *FN = dyn_cast(D)) {
 DC = FN;
   } else if (TemplateDecl *TD = dyn_cast(D)) {
-DC = cast(TD->getTemplatedDecl());
+if (isa(TD->getTemplatedDecl()))
+  DC = cast(TD->getTemplatedDecl());
   }
 
   EffectiveContext EC(DC);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91330: [clangd] Ensure we test for compatibility of serialized index format

2020-11-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 305106.
kadircet added a comment.

- Drop subshell usage


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91330

Files:
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
  clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
  clang-tools-extra/clangd/test/lit.cfg.py
  clang-tools-extra/clangd/test/lit.site.cfg.py.in


Index: clang-tools-extra/clangd/test/lit.site.cfg.py.in
===
--- clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -25,6 +25,7 @@
 config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.."
 config.clangd_build_xpc = @CLANGD_BUILD_XPC@
 config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@
+config.have_zlib = @LLVM_ENABLE_ZLIB@
 
 # Delegate logic to lit.cfg.py.
 lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py")
Index: clang-tools-extra/clangd/test/lit.cfg.py
===
--- clang-tools-extra/clangd/test/lit.cfg.py
+++ clang-tools-extra/clangd/test/lit.cfg.py
@@ -30,3 +30,6 @@
 
 if config.clangd_enable_remote:
   config.available_features.add('clangd-remote-index')
+
+if config.have_zlib:
+  config.available_features.add('zlib')
Index: clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
@@ -0,0 +1,14 @@
+# REQUIRES: zlib
+This test tries to parse a checked-in binary index.
+If this test fails it means there has been a backward incompatilbe change to
+serialization format.
+Please bump the version number in
+clang-tools-extra/clangd/index/Serialization.cpp and regenarate sample.idx with
+
+  clangd-indexer \
+clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp > \
+clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
+
+Also if you've introduced new slabs/chunks to serialized index, make sure
+indexing sample.cpp would yield non-trivial values for those.
+# RUN: dexp %/S/Inputs/sample.idx -c="find B" | grep Bar || not grep -v '^#' %s
Index: clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
@@ -0,0 +1,4 @@
+#pragma once
+
+// Introduce a symbol.
+struct Foo {};
Index: clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
@@ -0,0 +1,5 @@
+// Include a file to ensure we have multiple sources.
+#include "sample.h"
+
+// This introduces a symbol, a reference and a relation.
+struct Bar : public Foo {};


Index: clang-tools-extra/clangd/test/lit.site.cfg.py.in
===
--- clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -25,6 +25,7 @@
 config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.."
 config.clangd_build_xpc = @CLANGD_BUILD_XPC@
 config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@
+config.have_zlib = @LLVM_ENABLE_ZLIB@
 
 # Delegate logic to lit.cfg.py.
 lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py")
Index: clang-tools-extra/clangd/test/lit.cfg.py
===
--- clang-tools-extra/clangd/test/lit.cfg.py
+++ clang-tools-extra/clangd/test/lit.cfg.py
@@ -30,3 +30,6 @@
 
 if config.clangd_enable_remote:
   config.available_features.add('clangd-remote-index')
+
+if config.have_zlib:
+  config.available_features.add('zlib')
Index: clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
@@ -0,0 +1,14 @@
+# REQUIRES: zlib
+This test tries to parse a checked-in binary index.
+If this test fails it means there has been a backward incompatilbe change to
+serialization format.
+Please bump the version number in
+clang-tools-extra/clangd/index/Serialization.cpp and regenarate sample.idx with
+
+  clangd-indexer \
+clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp > \
+clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
+
+Also if you've introduced new slabs/chunks to serialized index, make sure
+indexing sample.cpp would yield non-trivial values for those.

[PATCH] D91311: Add new 'preferred_name' attribute.

2020-11-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

The attribute parts LGTM, but I did have a question about the libc++ parts.




Comment at: clang/include/clang/Basic/Attr.td:2367
+def PreferredName : InheritableAttr {
+  let Spellings = [Clang<"preferred_name">];
+  let Subjects = SubjectList<[ClassTmpl]>;

rsmith wrote:
> aaron.ballman wrote:
> > This seems like one we should exempt from C code, WDYT? If you agree, you 
> > can change it to `Clang<"preferred_name", /*AllowInC*/ 0>`
> Done. For my information, what difference does this make? The `Subjects` list 
> already means that it can't ever be applied in C -- does this effectively 
> exclude it from `__has_c_attribute` (and maybe change the diagnostic on use), 
> or does it go deeper than that?
You got the important points -- it changes the feature testing macro behavior 
and impacts diagnostics, but otherwise, not a whole lot of functional 
difference.



Comment at: clang/include/clang/Basic/Attr.td:2369
+  let Subjects = SubjectList<[ClassTmpl]>;
+  let Args = [TypeArgument<"TypedefType">];
+  let Documentation = [PreferredNameDocs];

rsmith wrote:
> aaron.ballman wrote:
> > Would it make sense for this to be a variadic parameter of type arguments 
> > (with a constraint that at least one type be named)? This way you can 
> > write: `[[clang::preferred_name(string, wstring)]]` instead of 
> > `[[clang::preferred_name(string), clang::preferred_name(wstring)]]`
> I did think a little bit about that, and I don't mind going in that 
> direction. I have only very weak justifications for the current approach:
> 
> * I think we would want to allow the attribute to be repeated and accumulate 
> regardless (see the `` + `` example for `std::basic_string` 
> in libc++), and I would prefer to not have two different syntaxes for the 
> same thing.
> * The separate attributes give us some room for extensibility in the future, 
> by adding new optional arguments, though I don't have a great example for 
> such a possible extension.
> * Implementation simplicity: when instantiating a template with 
> `preferred_name(X)`, we either drop the attribute or retain it depending on 
> whether the name is `X`, and if there were multiple names, we'd need to do 
> something more sophisticated. (Also the trivial simplicity of only iterating 
> over one list of types, rather than a list of lists.)
> * I expect users of this attribute to be very rare (libc++, maybe a couple of 
> types in Abseil, maybe a handful of types in boost, probably not much else), 
> so optimizing for them may not be worth any added complexity, and I wouldn't 
> expect any significant difference in parse time / memory usage / etc from the 
> combined model versus the separate model.
> 
> On balance I weakly prefer the one-type-per-attribute model, but I'm happy to 
> let you make the call.
> On balance I weakly prefer the one-type-per-attribute model, but I'm happy to 
> let you make the call.

That all sounds like compelling rationale to me, so I'm fine with the current 
approach. The biggest benefit I can see to the other approach (aside from 
shorter code) is that it feels like it would be slightly faster to parse in 
these very commonly included header files, but that may wash out in the extra 
work to instantiate the template anyway.



Comment at: clang/include/clang/Basic/Attr.td:2372
+  let InheritEvenIfAlreadyPresent = 1;
+  let MeaningfulToClassTemplateDefinition = 1;
+  let TemplateDependent = 1;

rsmith wrote:
> Incidentally, this flag appears to be backwards? If set to `1`, we 
> instantiate the attribute with the declaration; if set to `0` we instantiate 
> only with the definition.
Huh, that does seem backwards. I'll investigate and maybe swap the polarity if 
it seems sensible, thanks for mentioning it!



Comment at: libcxx/include/iosfwd:188
 
+#ifdef _LIBCPP_PREFERRED_NAME
+template 

We always define `_LIBCPP_PREFERRED_NAME` so is this actually needed?



Comment at: libcxx/include/iosfwd:245
 
+#ifdef _LIBCPP_PREFERRED_NAME
+template 

Same question here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91311

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


[PATCH] D91405: [clangd] Assert on varint encoding

2020-11-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 305108.
kadircet added a comment.

- Only assert on the 5th byte, prior bytes can have any value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91405

Files:
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/unittests/SerializationTests.cpp


Index: clang-tools-extra/clangd/unittests/SerializationTests.cpp
===
--- clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -366,9 +366,9 @@
   Pos += FileDigest.size();
 
   // Varints are little-endian base-128 numbers, where the top-bit of each byte
-  // indicates whether there are more. 8fff7f -> 0x.
+  // indicates whether there are more. 0f -> 0x.
   std::string CorruptSrcs =
-  (Srcs->Data.take_front(Pos) + llvm::fromHex("8fff7f") +
+  (Srcs->Data.take_front(Pos) + llvm::fromHex("0f") +
"some_random_garbage")
   .str();
   Srcs->Data = CorruptSrcs;
Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -21,6 +21,7 @@
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
 #include 
 
 namespace clang {
@@ -81,12 +82,17 @@
 
   uint32_t consumeVar() {
 constexpr static uint8_t More = 1 << 7;
-uint8_t B = consume8();
+
+// Use a 32 bit unsigned here to prevent promotion to signed int (unless 
int
+// is wider than 32 bits).
+uint32_t B = consume8();
 if (LLVM_LIKELY(!(B & More)))
   return B;
 uint32_t Val = B & ~More;
 for (int Shift = 7; B & More && Shift < 32; Shift += 7) {
   B = consume8();
+  // 5th byte of a varint can only have lowest 4 bits set.
+  assert((Shift != 28 || B == (B & 0x0f)) && "Invalid varint encoding");
   Val |= (B & ~More) << Shift;
 }
 return Val;


Index: clang-tools-extra/clangd/unittests/SerializationTests.cpp
===
--- clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -366,9 +366,9 @@
   Pos += FileDigest.size();
 
   // Varints are little-endian base-128 numbers, where the top-bit of each byte
-  // indicates whether there are more. 8fff7f -> 0x.
+  // indicates whether there are more. 0f -> 0x.
   std::string CorruptSrcs =
-  (Srcs->Data.take_front(Pos) + llvm::fromHex("8fff7f") +
+  (Srcs->Data.take_front(Pos) + llvm::fromHex("0f") +
"some_random_garbage")
   .str();
   Srcs->Data = CorruptSrcs;
Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -21,6 +21,7 @@
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
 #include 
 
 namespace clang {
@@ -81,12 +82,17 @@
 
   uint32_t consumeVar() {
 constexpr static uint8_t More = 1 << 7;
-uint8_t B = consume8();
+
+// Use a 32 bit unsigned here to prevent promotion to signed int (unless int
+// is wider than 32 bits).
+uint32_t B = consume8();
 if (LLVM_LIKELY(!(B & More)))
   return B;
 uint32_t Val = B & ~More;
 for (int Shift = 7; B & More && Shift < 32; Shift += 7) {
   B = consume8();
+  // 5th byte of a varint can only have lowest 4 bits set.
+  assert((Shift != 28 || B == (B & 0x0f)) && "Invalid varint encoding");
   Val |= (B & ~More) << Shift;
 }
 return Val;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91417: [IRGen] Add !annotation metadata for auto-init stores.

2020-11-13 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
fhahn added reviewers: thegameg, paquette, jdoerfert, rjmccall.
Herald added subscribers: cfe-commits, dexonsmith, jfb, hiraditya.
Herald added projects: clang, LLVM.
fhahn requested review of this revision.

This patch updates Clang's IRGen to add !annotation nodes with an
"auto-init" annotation to all stores for auto-initialization.

As discussed in 'RFC: Combining Annotation Metadata and Remarks'
(http://lists.llvm.org/pipermail/llvm-dev/2020-November/146393.html)
this allows using optimization remarks to track down where auto-init
code was inserted (and not removed by optimizations).

There are a few cases in the tests where !annotation gets dropped by
optimizations. Those optimizations will be updated in subsequent
patches.

This patch is based on a patch by Francis Visoiu Mistrih.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91417

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/test/CodeGenCXX/auto-var-init.cpp
  clang/test/CodeGenCXX/trivial-auto-var-init-attribute.cpp
  clang/test/CodeGenCXX/trivial-auto-var-init.cpp
  llvm/include/llvm/IR/Instruction.h
  llvm/lib/IR/Metadata.cpp

Index: llvm/lib/IR/Metadata.cpp
===
--- llvm/lib/IR/Metadata.cpp
+++ llvm/lib/IR/Metadata.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "llvm/IR/Metadata.h"
 #include "LLVMContextImpl.h"
 #include "MetadataImpl.h"
 #include "SymbolTableListTraitsImpl.h"
@@ -38,7 +39,7 @@
 #include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/Instruction.h"
 #include "llvm/IR/LLVMContext.h"
-#include "llvm/IR/Metadata.h"
+#include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/TrackingMDRef.h"
 #include "llvm/IR/Type.h"
@@ -1305,6 +1306,27 @@
   Value::setMetadata(KindID, Node);
 }
 
+void Instruction::addAnnotationMetadata(StringRef Name) {
+  MDBuilder MDB(getContext());
+
+  auto *Existing = getMetadata(LLVMContext::MD_annotation);
+  SmallVector Names;
+  bool AppendName = true;
+  if (Existing) {
+auto *Tuple = cast(Existing);
+for (auto &N : Tuple->operands()) {
+  if (cast(N.get())->getString() == Name)
+AppendName = false;
+  Names.push_back(N.get());
+}
+  }
+  if (AppendName)
+Names.push_back(MDB.createString(Name));
+
+  MDNode *MD = MDTuple::get(getContext(), Names);
+  setMetadata(LLVMContext::MD_annotation, MD);
+}
+
 void Instruction::setAAMetadata(const AAMDNodes &N) {
   setMetadata(LLVMContext::MD_tbaa, N.TBAA);
   setMetadata(LLVMContext::MD_tbaa_struct, N.TBAAStruct);
Index: llvm/include/llvm/IR/Instruction.h
===
--- llvm/include/llvm/IR/Instruction.h
+++ llvm/include/llvm/IR/Instruction.h
@@ -340,6 +340,11 @@
   }
   /// @}
 
+  /// Adds an !annotation metadata node with \p Annotation to this instruction.
+  /// If this instruction already has !annotation metadata, append \p Annotation
+  /// to the existing node.
+  void addAnnotationMetadata(StringRef Annotation);
+
   /// Sets the metadata on this instruction from the AAMDNodes structure.
   void setAAMetadata(const AAMDNodes &N);
 
Index: clang/test/CodeGenCXX/trivial-auto-var-init.cpp
===
--- clang/test/CodeGenCXX/trivial-auto-var-init.cpp
+++ clang/test/CodeGenCXX/trivial-auto-var-init.cpp
@@ -12,9 +12,9 @@
 
 // UNINIT-LABEL:  test_selfinit(
 // ZERO-LABEL:test_selfinit(
-// ZERO: store i32 0, i32* %self, align 4
+// ZERO: store i32 0, i32* %self, align 4, !annotation [[AUTO_INIT:!.+]]
 // PATTERN-LABEL: test_selfinit(
-// PATTERN: store i32 -1431655766, i32* %self, align 4
+// PATTERN: store i32 -1431655766, i32* %self, align 4, !annotation [[AUTO_INIT:!.+]]
 void test_selfinit() {
   int self = self + 1;
   used(self);
@@ -22,9 +22,9 @@
 
 // UNINIT-LABEL:  test_block(
 // ZERO-LABEL:test_block(
-// ZERO: store i32 0, i32* %block
+// ZERO: store i32 0, i32* %block, align 4, !annotation [[AUTO_INIT:!.+]]
 // PATTERN-LABEL: test_block(
-// PATTERN: store i32 -1431655766, i32* %block
+// PATTERN: store i32 -1431655766, i32* %block, align 4, !annotation [[AUTO_INIT:!.+]]
 void test_block() {
   __block int block;
   used(block);
@@ -38,12 +38,12 @@
 // ZERO-LABEL:test_block_self_init(
 // ZERO:  %block = alloca <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i8* }>, align 8
 // ZERO:  %captured1 = getelementptr inbounds %struct.__block_byref_captured, %struct.__block_byref_captured* %captured, i32 0, i32 4
-// ZERO-NEXT: store %struct.XYZ* null, %struct.XYZ** %captured1, align 8
+// ZERO-NEXT: store %struct.XYZ* null, %struct.XYZ** %captured1, align 8, !annotation [[AUTO_INIT:!.+]]
 // ZERO:  %call = call %struct.XYZ* @create(
 // PATTERN-LABEL: test_block_self_init(
 // PATTERN:   %block = alloca <{ i8*, i32, i32,

[PATCH] D90524: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-13 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D90524#2393651 , @glaubitz wrote:

> 



> Please feel free to reach out to the corresponding debian-$ARCH mailing list 
> for such questions. Debian-specific layouts are not
> necessarily obvious at first glance to people not very familiar with the 
> distribution.

I could have.  However, my only interest in Linux/SPARC was to have a 
comparison point for my Solaris/SPARC work to determine which test failures 
occur on all SPARC targets and which ones are Solaris-specific.  I simply don't 
have to time to dig deeper into Linux issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90524

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


[PATCH] D90524: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-13 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

In D90524#2393746 , @ro wrote:

> In D90524#2393651 , @glaubitz wrote:
>
>> 
>
>
>
>> Please feel free to reach out to the corresponding debian-$ARCH mailing list 
>> for such questions. Debian-specific layouts are not
>> necessarily obvious at first glance to people not very familiar with the 
>> distribution.
>
> I could have.  However, my only interest in Linux/SPARC was to have a 
> comparison point for my Solaris/SPARC work to determine which test failures 
> occur on all SPARC targets and which ones are Solaris-specific.  I simply 
> don't have to time to dig deeper into Linux issues.

No worries. I'm glad someone is taking care of the Solaris parts and appreciate 
fixes from other parties.

Please don't see my comments as dismissive in any way, they aren't meant that 
way. I appreciate the feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90524

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


[PATCH] D90524: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-13 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D90524#2393747 , @glaubitz wrote:

> 



> No worries. I'm glad someone is taking care of the Solaris parts and 
> appreciate fixes from other parties.

My pleasure: hopefully our work will also be for the benefit of the other 
party.  I certainly do have some patches in the queue that will fix bugs also 
occuring on Linux/SPARC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90524

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


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2020-11-13 Thread Alexey Bader via Phabricator via cfe-commits
bader added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:4554
+
+  // Language rules define if it is legal to cast from one address space
+  // to another, and which address space we should use as a "common

asavonic wrote:
> sdmitriev wrote:
> > bader wrote:
> > > Anastasia wrote:
> > > > What language rules?
> > > I suppose it's a generic note and author didn't meant some particular 
> > > language here. This change was contributed by @sdmitriev. 
> > > @sdmitriev, could you clarify, please?
> > This comment was originally added by @asavonic to 
> > clang/lib/CodeGen/CGExprScalar.cpp (lines 2962-2965 in this patch), and 
> > later I reused his code along with the comment in this file while fixing a 
> > very similar issue. So, I guess it would be more correct to ask Andrew to 
> > clarify. @asavonic, can you please comment on this?
> > This comment was originally added by @asavonic to 
> > clang/lib/CodeGen/CGExprScalar.cpp (lines 2962-2965 in this patch), and 
> > later I reused his code along with the comment in this file while fixing a 
> > very similar issue.
> 
> There is `if (Opts.SYCLIsDevice)` In CGExprScalar.cpp, so we handle SYCL 
> language rules.
> In SYCL, (almost) all pointers have default address space in AST, but in CG 
> some pointers become private/local/global, and some are lowered as generic 
> pointers. We need to add an implicit addrspacecast in CG to emit an 
> expression that expects the same type for its operands.
> 
> For example:
> const char *str = ... ;
> const char *phi_str = i > 2 ? str : "hello world!";
> 
> In AST types of `str` and `"hello world"` are the same (`const char *`). In 
> CG we emit `str` as `i8 addrspace(4)*` and `"hello world"` as `i8*`. At this 
> point we have to decide what type `phi_str` should have, and addrspacecast 
> the operands accordingly.
Is it possible to avoid fixing address space mismatch at this point by 
adjusting AST as suggested by John in this comment: 
https://reviews.llvm.org/D89909#inline-837495?

I wonder if it can be done w/o impacting C++ template metaprogramming as noted 
in this thread: 
http://clang-developers.42468.n3.nabble.com/RFC-Re-use-OpenCL-address-space-attributes-for-SYCL-td4068754.html.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89909

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


[PATCH] D91047: Add a call super attribute plugin example

2020-11-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/ClangPlugins.rst:117
+Defining CallSuperAttr
+===
+

psionic12 wrote:
> aaron.ballman wrote:
> > aaron.ballman wrote:
> > > The number of underlines here looks off -- can you verify it's correct?
> > This still appears to be incorrect and will cause build errors for the 
> > documentation.
> Do you mean that there's a command to build the documentation and currently 
> my patch will cause a failure on it?
> 
> I thought this ClangPlugins.rst is only an documentation with markdown, but 
> seems that it's not what I thought?
> 
> Currently I will make sure there's no build error on the plugin itself and 
> the regression test case, and make sure the
> regression test will pass. Seems that's not enough, right?
> Do you mean that there's a command to build the documentation and currently 
> my patch will cause a failure on it?

Yes, we have a bot that builds docs: http://lab.llvm.org:8011/#/builders/92

> I thought this ClangPlugins.rst is only an documentation with markdown, but 
> seems that it's not what I thought?

It is a documentation file with markdown, but the markdown bots will complain 
if a markdown file cannot be built (they treat markdown warnings as errors).

> Currently I will make sure there's no build error on the plugin itself and 
> the regression test case, and make sure the regression test will pass. Seems 
> that's not enough, right?

Most of the time that's enough because the markdown usage is pretty trivial and 
can be inspected by sight for obvious issues (so people don't typically have to 
set up their build environments to generate documentation and test it with 
every patch).

In this case, the issue is with the underlines under the title. The number of 
underlines needs to match the number of characters in the title, but in this 
case there are 20 `=` characters but 23 title characters.



Comment at: clang/examples/CallSuperAttribute/CallSuperAttrInfo.cpp:9-10
+//
+// clang plugin, checks every overridden virtual function whether called
+// this function or not.
+//

How about: `This Clang plugin checks that overrides of the marked virtual 
function directly call the marked function.`



Comment at: clang/examples/CallSuperAttribute/CallSuperAttrInfo.cpp:80
+
+  // Now find if supper is used in `MethodDecl`.
+  MethodUsageVisitor Visitor(OverriddenMarkedMethods);

supper is used -> the superclass method is called



Comment at: clang/examples/CallSuperAttribute/CallSuperAttrInfo.cpp:84
+  // After traversing, all methods left in `OverriddenMarkedMethods`
+  // are not get called, warning about these.
+  for (const auto &LeftOverriddens : OverriddenMarkedMethods) {

are not get called, warning -> are not called, warn



Comment at: clang/examples/CallSuperAttribute/CallSuperAttrInfo.cpp:152
+  S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
+  << Attr << "methods";
+  return false;

Instead of `methods`, how about `virtual functions`? Then the logic can be: `if 
(!TheMethod || !TheMethod->isVirtual())` and you can remove the diagnostic 
below.



Comment at: clang/examples/CallSuperAttribute/CallSuperAttrInfo.cpp:166-168
+// No need to add an attr object (usually an annotation attr is added)
+// save the address of the Decl in sets, it maybe faster than compare to
+// strings.

attr is added) save the address of the Decl in sets -> .attr is added). Save 
the address of the Decl in a set



Comment at: clang/test/Frontend/plugin-call-super.cpp:1-2
+// RUN: %clang -fplugin=%llvmshlibdir/CallSuperAttr%pluginext -emit-llvm -S %s 
-o - 2>&1 | FileCheck %s --check-prefix=CALLSUPER
+// RUN: not %clang -fplugin=%llvmshlibdir/CallSuperAttr%pluginext -emit-llvm 
-DBAD_CALLSUPER -S %s -o - 2>&1 | FileCheck %s --check-prefix=BADCALLSUPER
+// REQUIRES: plugins, examples

The way we would typically test something like this is to pass `-fsyntax-only` 
and `-verify` to verify the diagnostics rather than using FileCheck, because 
the plugin doesn't have any impact on code generation (just diagnostics). This 
makes the test faster to check (and is a bit easier than using FileCheck).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91047

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


[PATCH] D91035: [NFC, Refactor] Convert FunctionDefinitionKind from DeclSpech.h to a scoped enum

2020-11-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Sema/DeclSpec.h:1762
 };
+using FDK = FunctionDefinitionKind;
 

rsmith wrote:
> I don't think it's OK to have an initialism like this in the `clang` 
> namespace scope -- generally-speaking, the larger the scope of a name, the 
> longer and more descriptive the name needs to be. Is spelling out the full 
> name of the enumeration everywhere it appears unacceptably verbose?
That will change uses like this:
```
D.setFunctionDefinitionKind(FDK::Definition);
```
into
```
D.setFunctionDefinitionKind(FunctionDefinitionKind::Definition);
```
which repeats the enumeration name twice (once for the function and once for 
the enumerator) and is rather unfortunate. I'm not certain it's more 
unfortunate than putting an initialism into the `clang` namespace though.



Comment at: clang/include/clang/Sema/DeclSpec.h:1837
   /// Actually a FunctionDefinitionKind.
-  unsigned FunctionDefinition : 2;
+  FunctionDefinitionKind FunctionDefinition : 2;
 

rsmith wrote:
> aaron.ballman wrote:
> > faisalv wrote:
> > > aaron.ballman wrote:
> > > > faisalv wrote:
> > > > > aaron.ballman wrote:
> > > > > > I think we need to keep this as `unsigned` because some compilers 
> > > > > > struggle with bit-fields of enumeration types (even when the 
> > > > > > enumeration underlying type is fixed): https://godbolt.org/z/P8x8Kz
> > > > > As Barry had reminded me - this warning was deemed a bug: 
> > > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51242.  Are you sure we 
> > > > > should still tailor our code to appease it? Is there a config file we 
> > > > > can use to #define an ENUM_UNSIGNED_BITFIELD(x) or some such - that 
> > > > > does the right thing for most compilers - (and are we even 
> > > > > comfortable from a style-guide perpective, with such a 
> > > > > conditional-define strategy?
> > > > > 
> > > > > Your thoughts?
> > > > > 
> > > > > Thanks!
> > > > The warning in GCC was a bug, but the fact that GCC issues the warning 
> > > > means `-Werror` builds will not be able to handle it. GCC 9.2 is really 
> > > > recent, so we can't just bump the supported version of GCC to 9.3 to 
> > > > avoid the issue. We could use macros to work around it for GCC, but 
> > > > IIRC, MSVC also had some hiccups over the years with using an 
> > > > enumeration as a bit-field member (I seem to recall it not wanting to 
> > > > pack the bits with surrounding fields, but I could be remembering 
> > > > incorrectly). I'm not certain whether macros are worth the effort, but 
> > > > my personal inclination is to just stick with `unsigned` unless there's 
> > > > a really big win from coming up with something more complex.
> > > Well - the biggest downside of making it unsigned (vs leaving it as an 
> > > enum) is that each assignment or initialization now requires a 
> > > static_cast.  
> > > 
> > > What would you folks suggest:
> > > 1) do not modernize such enums into scoped enums
> > > 2) scope these enums - sticking to unsigned bit-fields - and add 
> > > static_casts
> > > 3) teach the bots to ignore that gcc warning? (is this even an option)
> > > 
> > > Thank you!
> > For #2, do you have an idea of how often we'd need to insert the 
> > static_casts for this particular enum? I don't think we assign to this 
> > field all that often in a place where we only have an integer rather than 
> > an enumeration value, so my preference is for #2 on a case-by-case basis 
> > (for instance, we could add a helper function to set unsigned bit-fields to 
> > an enum value -- we already have one here with 
> > `setFunctionDefinitionKind()`).
> We should be very wary of having bit-fields of enumeration type anyway, 
> because the MS ABI layout rule for bit-fields doesn't pack adjacent 
> bit-fields together if they don't have the same storage type. (That's why we 
> use `unsigned : 1` bit-fields for flags most of the time -- so they'll pack 
> with adjacent `unsigned : 2` bitfields under the MS ABI.)
Thank you for the reminder -- that was the MSVC oddity I was mentioning but 
couldn't recall the details of!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91035

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


[PATCH] D90750: [clangd] Introduce ProjectAwareIndex

2020-11-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D90750#2378987 , @kadircet wrote:

> The index has the following query semantics:

Rehashing offline conversation:

- These heuristics mostly amount to guessing which high-level operation is 
being performed. It's a non-obvious place to put this logic, and it's hard to 
fix without fallout when the guess is wrong.
- These guesses will get stale. e.g. this queries all indexes for relations, 
but one index for lookup. We'd like to use both for Hover soon.

Our conclusion was we could query one index by default, and allow callers to 
override this using a context variable.
The arguments for a context variable vs attributes on request:

- it naturally applies to batches of requests
- it's a less invasive change
- it "hides" the option from other indexes

I'm not that sure about this implementation choice, but it also probably 
doesn't matter much.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90750

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


[PATCH] D91055: [clang-tidy] Introduce misc No Integer To Pointer Cast check

2020-11-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added subscribers: jeroen.dobbelaere, jdoerfert, hfinkel.
aaron.ballman added a comment.

In D91055#2382356 , @lebedev.ri wrote:

> CC'ing @rsmith regarding the suggestion/question of also having a clang 
> diagnostic for this.

I'm not Richard, but I have some thoughts just the same. :-) The C committee is 
currently exploring questions of pointer provenance that may have impact in 
this area. You can see the proposed text for a TS on pointer provenance here: 
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2577.pdf The paper goes into a 
lot of detail about various provenance choices and how those choices impact 
existing code, implementations, optimization opportunities, etc. and my concern 
with adding a provenance check to the Clang frontend at this time is that LLVM 
may want to implement changes from that TS which may cause unfortunate code 
churn for users who enable the warning in Clang. I think keeping this check in 
clang-tidy gives us good utility for catching bugs today, but also gives us a 
safer place to react to changes in the C standard. At some point, I expect the 
question of how to track provenance to settle down within the committee and our 
implementation, and that would be a good time to consider lifting the analysis 
into Clang. CCing @nlopes @hfinkel @jeroen.dobbelaere and @jdoerfert to raise 
awareness on the provenance TS in case it wasn't yet on their radar.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91055

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


[PATCH] D91311: Add new 'preferred_name' attribute.

2020-11-13 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: libcxx/include/regex:2520
+_LIBCPP_PREFERRED_NAME(wregex)
+basic_regex
 {

Why does this attribute go on the class template? Shouldn't it be an attribute 
on the typedef, so that you don't have to repeat yourself? I mean, I'd much 
rather see

template class BasicFoo { };
using [[preferred]] Foo = BasicFoo;
using [[preferred]] WFoo = BasicFoo;

than

template class BasicFoo;
using Foo = BasicFoo;
using WFoo = BasicFoo;
template class [[preferred(Foo, WFoo)]] BasicFoo { };

The latter repeats every identifier one extra time, compared to the former.

And then, in fact, couldn't you go one step further and say that typedefs in 
the same scope as the class template itself should //always// implicitly have 
this attribute? Even if the attribute doesn't appear in the source code, we 
still want to print `basic_regex` as `regex`, right? It shouldn't cost 
any additional work for the compiler to figure that out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91311

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


[PATCH] D90282: [clang-tidy] Add IgnoreShortNames config to identifier naming checks

2020-11-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D90282#2393019 , @smhc wrote:

> In D90282#2391360 , @aaron.ballman 
> wrote:
>
>> In D90282#2391005 , @njames93 wrote:
>>
>>> Should this be a NamingStyle option instead.
>>> `{key: readability-identifier-naming.ParameterShortSizeThreshold, value: 2}`
>>> WDYT?
>>
>> I think that makes a lot of sense -- I can imagine wanting to enforce 
>> different identifier lengths depending on whether we're spelling a type name 
>> vs a local variable name, etc.
>
> I considered this but thought the configuration and documentation would be 
> quite cumbersome. We could provide a global setting (as already done) and 
> allow refining it further by type if needed? For what it's worth I only need 
> it for local variables, I imagine that would be the main use case.
>
> Or should we simply add this threshold to every type of name, similar to how 
> suffix, prefix and case style have been done?

I think length of names matters differently in different contexts. I think 
three-letter identifiers as a class name should probably be a rarity, but may 
be more reasonable as a local variable. I think one-letter local variables are 
generally a bad thing, except for loop induction variables. That sort of thing. 
(And we may someday want to add more specific naming categories like "loop 
induction variable".) So I think adding the threshold to all the different name 
kinds is a more flexible approach.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90282

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


[PATCH] D91421: Fix temporary file name on Windows

2020-11-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
yaxunl requested review of this revision.

Bound arch may contain ':', which is invalid in Windows file names.

This patch fixes that.


https://reviews.llvm.org/D91421

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/hip-windows-filename.hip


Index: clang/test/Driver/hip-windows-filename.hip
===
--- /dev/null
+++ clang/test/Driver/hip-windows-filename.hip
@@ -0,0 +1,10 @@
+// REQUIRES: system-windows, clang-driver, amdgpu-registered-target
+
+// RUN: %clang -### -target x86_64-pc-windows-msvc \
+// RUN:   -x hip \
+// RUN:   --offload-arch=gfx908:xnack+ \
+// RUN:   -nogpuinc -nogpulib -save-temps \
+// RUN:   %s 2>&1 | FileCheck %s
+
+// CHECK: "-o" "hip-windows-filename-hip-amdgcn-amd-amdhsa-gfx908%xnack+.cui"
+// CHECK-NOT: "-o" 
"hip-windows-filename-hip-amdgcn-amd-amdhsa-gfx908:xnack+.cui"
\ No newline at end of file
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4635,9 +4635,16 @@
 
 const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
const char *BaseInput,
-   StringRef BoundArch, bool AtTopLevel,
+   StringRef OrigBoundArch, bool 
AtTopLevel,
bool MultipleArchs,
StringRef OffloadingPrefix) const {
+  std::string BoundArch = OrigBoundArch.str();
+#if defined(_WIN32)
+  // BoundArch may contains ':', which is invalid in file names on Windows,
+  // therefore replace it with '%'.
+  std::replace(BoundArch.begin(), BoundArch.end(), ':', '%');
+#endif
+
   llvm::PrettyStackTraceString CrashInfo("Computing output path");
   // Output to a user requested destination?
   if (AtTopLevel && !isa(JA) && !isa(JA)) {


Index: clang/test/Driver/hip-windows-filename.hip
===
--- /dev/null
+++ clang/test/Driver/hip-windows-filename.hip
@@ -0,0 +1,10 @@
+// REQUIRES: system-windows, clang-driver, amdgpu-registered-target
+
+// RUN: %clang -### -target x86_64-pc-windows-msvc \
+// RUN:   -x hip \
+// RUN:   --offload-arch=gfx908:xnack+ \
+// RUN:   -nogpuinc -nogpulib -save-temps \
+// RUN:   %s 2>&1 | FileCheck %s
+
+// CHECK: "-o" "hip-windows-filename-hip-amdgcn-amd-amdhsa-gfx908%xnack+.cui"
+// CHECK-NOT: "-o" "hip-windows-filename-hip-amdgcn-amd-amdhsa-gfx908:xnack+.cui"
\ No newline at end of file
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4635,9 +4635,16 @@
 
 const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
const char *BaseInput,
-   StringRef BoundArch, bool AtTopLevel,
+   StringRef OrigBoundArch, bool AtTopLevel,
bool MultipleArchs,
StringRef OffloadingPrefix) const {
+  std::string BoundArch = OrigBoundArch.str();
+#if defined(_WIN32)
+  // BoundArch may contains ':', which is invalid in file names on Windows,
+  // therefore replace it with '%'.
+  std::replace(BoundArch.begin(), BoundArch.end(), ':', '%');
+#endif
+
   llvm::PrettyStackTraceString CrashInfo("Computing output path");
   // Output to a user requested destination?
   if (AtTopLevel && !isa(JA) && !isa(JA)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91421: Fix temporary file name on Windows

2020-11-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 305127.
yaxunl added a comment.

add end of line to test


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

https://reviews.llvm.org/D91421

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/hip-windows-filename.hip


Index: clang/test/Driver/hip-windows-filename.hip
===
--- /dev/null
+++ clang/test/Driver/hip-windows-filename.hip
@@ -0,0 +1,10 @@
+// REQUIRES: system-windows, clang-driver, amdgpu-registered-target
+
+// RUN: %clang -### -target x86_64-pc-windows-msvc \
+// RUN:   -x hip \
+// RUN:   --offload-arch=gfx908:xnack+ \
+// RUN:   -nogpuinc -nogpulib -save-temps \
+// RUN:   %s 2>&1 | FileCheck %s
+
+// CHECK: "-o" "hip-windows-filename-hip-amdgcn-amd-amdhsa-gfx908%xnack+.cui"
+// CHECK-NOT: "-o" 
"hip-windows-filename-hip-amdgcn-amd-amdhsa-gfx908:xnack+.cui"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4635,9 +4635,16 @@
 
 const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
const char *BaseInput,
-   StringRef BoundArch, bool AtTopLevel,
+   StringRef OrigBoundArch, bool 
AtTopLevel,
bool MultipleArchs,
StringRef OffloadingPrefix) const {
+  std::string BoundArch = OrigBoundArch.str();
+#if defined(_WIN32)
+  // BoundArch may contains ':', which is invalid in file names on Windows,
+  // therefore replace it with '%'.
+  std::replace(BoundArch.begin(), BoundArch.end(), ':', '%');
+#endif
+
   llvm::PrettyStackTraceString CrashInfo("Computing output path");
   // Output to a user requested destination?
   if (AtTopLevel && !isa(JA) && !isa(JA)) {


Index: clang/test/Driver/hip-windows-filename.hip
===
--- /dev/null
+++ clang/test/Driver/hip-windows-filename.hip
@@ -0,0 +1,10 @@
+// REQUIRES: system-windows, clang-driver, amdgpu-registered-target
+
+// RUN: %clang -### -target x86_64-pc-windows-msvc \
+// RUN:   -x hip \
+// RUN:   --offload-arch=gfx908:xnack+ \
+// RUN:   -nogpuinc -nogpulib -save-temps \
+// RUN:   %s 2>&1 | FileCheck %s
+
+// CHECK: "-o" "hip-windows-filename-hip-amdgcn-amd-amdhsa-gfx908%xnack+.cui"
+// CHECK-NOT: "-o" "hip-windows-filename-hip-amdgcn-amd-amdhsa-gfx908:xnack+.cui"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4635,9 +4635,16 @@
 
 const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
const char *BaseInput,
-   StringRef BoundArch, bool AtTopLevel,
+   StringRef OrigBoundArch, bool AtTopLevel,
bool MultipleArchs,
StringRef OffloadingPrefix) const {
+  std::string BoundArch = OrigBoundArch.str();
+#if defined(_WIN32)
+  // BoundArch may contains ':', which is invalid in file names on Windows,
+  // therefore replace it with '%'.
+  std::replace(BoundArch.begin(), BoundArch.end(), ':', '%');
+#endif
+
   llvm::PrettyStackTraceString CrashInfo("Computing output path");
   // Output to a user requested destination?
   if (AtTopLevel && !isa(JA) && !isa(JA)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90750: [clangd] Introduce ProjectAwareIndex

2020-11-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

This looks really sensible to me! Nice you managed to reuse Memoize, there's 
very little ugly caching/locking left.




Comment at: clang-tools-extra/clangd/index/ProjectAware.cpp:81
+return IndexForProject.get(
+External.Location, [Server = External.Location,
+MP = llvm::StringRef(External.MountPoint), this] {

I think the cache key needs a bit more consideration.

It's unlikely that a filename will collide with a host/port, but they are 
currently sitting in the same namespace.

More worryingly, the mountpoint is used in the lambda body but not in the cache 
key - are we sure this is safe?

The clearest way to enforce this is to make index creation use the cache key 
only, and not other data from the config. Then you have to include what you're 
going to use.



Comment at: clang-tools-extra/clangd/index/ProjectAware.cpp:81
+return IndexForProject.get(
+External.Location, [Server = External.Location,
+MP = llvm::StringRef(External.MountPoint), this] {

sammccall wrote:
> I think the cache key needs a bit more consideration.
> 
> It's unlikely that a filename will collide with a host/port, but they are 
> currently sitting in the same namespace.
> 
> More worryingly, the mountpoint is used in the lambda body but not in the 
> cache key - are we sure this is safe?
> 
> The clearest way to enforce this is to make index creation use the cache key 
> only, and not other data from the config. Then you have to include what 
> you're going to use.
as discussed offline, allowing the config -> cache key and cache key -> index 
operations to be injectable is the key to testing I think



Comment at: clang-tools-extra/clangd/index/ProjectAware.cpp:100
+  });
+  addIndex(std::move(NewIndex));
+  return PlaceHolder;

from memoize:

> Concurrent calls for the same key may run the
> computation multiple times, but each call will return the same result.

so this side-effect may run multiple times too, resulting in multiple index 
copies getting leaked. This seems like it may be bad in the case of file 
indexes.

Why can't the memoize map own the indexes?
This would still result in loading the index multiple times and throwing things 
away, hmm. Not sure how best to resolve this.



Comment at: clang-tools-extra/clangd/index/ProjectAware.cpp:119
+  SymbolIndex *Result = nullptr;
+  auto PushIndex = [this, &Result](SymbolIndex *Idx) {
+if (!Result) {

consider moving this to `unique_ptr 
MergedIndex::create(ArrayRef>)` or so?

Not sure if this is something we'd want to use from ClangdMain...



Comment at: clang-tools-extra/clangd/index/ProjectAware.cpp:128
+  std::lock_guard Lock(Mu);
+  for (const auto &Idx : IndexStorage) {
+if (Idx.get() == Primary)

with the helper described above, the Primary ordering could be maybe better 
expressed as std::stable_partition



Comment at: clang-tools-extra/clangd/index/ProjectAware.h:30
+
+class ProjectAwareIndex : public SymbolIndex {
+public:

Is there a reason this class needs to be public?
I think we can expose factories returning SymbolIndex only


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90750

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


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2020-11-13 Thread Andrew Savonichev via Phabricator via cfe-commits
asavonic added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:4554
+
+  // Language rules define if it is legal to cast from one address space
+  // to another, and which address space we should use as a "common

bader wrote:
> asavonic wrote:
> > sdmitriev wrote:
> > > bader wrote:
> > > > Anastasia wrote:
> > > > > What language rules?
> > > > I suppose it's a generic note and author didn't meant some particular 
> > > > language here. This change was contributed by @sdmitriev. 
> > > > @sdmitriev, could you clarify, please?
> > > This comment was originally added by @asavonic to 
> > > clang/lib/CodeGen/CGExprScalar.cpp (lines 2962-2965 in this patch), and 
> > > later I reused his code along with the comment in this file while fixing 
> > > a very similar issue. So, I guess it would be more correct to ask Andrew 
> > > to clarify. @asavonic, can you please comment on this?
> > > This comment was originally added by @asavonic to 
> > > clang/lib/CodeGen/CGExprScalar.cpp (lines 2962-2965 in this patch), and 
> > > later I reused his code along with the comment in this file while fixing 
> > > a very similar issue.
> > 
> > There is `if (Opts.SYCLIsDevice)` In CGExprScalar.cpp, so we handle SYCL 
> > language rules.
> > In SYCL, (almost) all pointers have default address space in AST, but in CG 
> > some pointers become private/local/global, and some are lowered as generic 
> > pointers. We need to add an implicit addrspacecast in CG to emit an 
> > expression that expects the same type for its operands.
> > 
> > For example:
> > const char *str = ... ;
> > const char *phi_str = i > 2 ? str : "hello world!";
> > 
> > In AST types of `str` and `"hello world"` are the same (`const char *`). In 
> > CG we emit `str` as `i8 addrspace(4)*` and `"hello world"` as `i8*`. At 
> > this point we have to decide what type `phi_str` should have, and 
> > addrspacecast the operands accordingly.
> Is it possible to avoid fixing address space mismatch at this point by 
> adjusting AST as suggested by John in this comment: 
> https://reviews.llvm.org/D89909#inline-837495?
> 
> I wonder if it can be done w/o impacting C++ template metaprogramming as 
> noted in this thread: 
> http://clang-developers.42468.n3.nabble.com/RFC-Re-use-OpenCL-address-space-attributes-for-SYCL-td4068754.html.
> Is it possible to avoid fixing address space mismatch at this point by 
> adjusting AST

Some address space mismatches are present in CG already, see 
CodeGenModule::getStringLiteralAddressSpace and 
CodeGenModule::GetGlobalVarAddressSpace. This should be moved to AST (or 
replaced) as well, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89909

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


[PATCH] D89684: [AIX] Add mabi=vec-extabi options to enable the AIX extended and default vector ABIs.

2020-11-13 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 305136.
ZarkoCA retitled this revision from "[AIX] Add mvecnvol and mnovecnvol options 
to enable the AIX extended and default vector ABIs. " to "[AIX] Add 
mabi=vec-extabi options to enable the AIX extended and default vector ABIs. ".
ZarkoCA edited the summary of this revision.
ZarkoCA added a comment.

Addressed comments:


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89684

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/altivec.c
  clang/test/Preprocessor/aix-vec_extabi.c
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/aix-AppendingLinkage.ll
  llvm/test/CodeGen/PowerPC/aix-default-vec-abi.ll
  llvm/test/CodeGen/PowerPC/aix-func-align.ll
  llvm/test/CodeGen/PowerPC/aix-func-dsc-gen.ll
  llvm/test/CodeGen/PowerPC/aix-internal.ll
  llvm/test/CodeGen/PowerPC/aix-lower-block-address.ll
  llvm/test/CodeGen/PowerPC/aix-lower-constant-pool-index.ll
  llvm/test/CodeGen/PowerPC/aix-lower-jump-table.ll
  llvm/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll
  llvm/test/CodeGen/PowerPC/aix-return55.ll
  llvm/test/CodeGen/PowerPC/aix-space.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-data-sections.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-reloc-large.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-textdisassembly.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-toc.ll
  llvm/test/CodeGen/PowerPC/aix32-crsave.mir
  llvm/test/CodeGen/PowerPC/lower-globaladdr32-aix-asm.ll
  llvm/test/CodeGen/PowerPC/lower-globaladdr64-aix-asm.ll
  llvm/test/CodeGen/PowerPC/ppc32-i64-to-float-conv.ll
  llvm/test/CodeGen/PowerPC/ppc64-crsave.mir

Index: llvm/test/CodeGen/PowerPC/ppc64-crsave.mir
===
--- llvm/test/CodeGen/PowerPC/ppc64-crsave.mir
+++ llvm/test/CodeGen/PowerPC/ppc64-crsave.mir
@@ -7,7 +7,7 @@
 # RUN: FileCheck %s --check-prefixes=CHECK,SAVEALL
 
 
-# RUN: llc -mtriple powerpc64-unknown-aix-xcoff -x mir -mcpu=pwr4 \
+# RUN: llc -mtriple powerpc64-unknown-aix-xcoff -x mir -mcpu=pwr4 -mattr=-altivec \
 # RUN: -run-pass=prologepilog --verify-machineinstrs < %s | \
 # RUN: FileCheck %s --check-prefixes=CHECK,SAVEALL
 
Index: llvm/test/CodeGen/PowerPC/ppc32-i64-to-float-conv.ll
===
--- llvm/test/CodeGen/PowerPC/ppc32-i64-to-float-conv.ll
+++ llvm/test/CodeGen/PowerPC/ppc32-i64-to-float-conv.ll
@@ -1,4 +1,4 @@
-; RUN: llc -verify-machineinstrs < %s -mcpu=pwr4 \
+; RUN: llc -verify-machineinstrs < %s -mcpu=pwr4 -mattr=-altivec \
 ; RUN: -mtriple=powerpc-ibm-aix-xcoff 2>&1 | FileCheck %s
 
 ; RUN: llc -verify-machineinstrs < %s -mcpu=pwr4 \
Index: llvm/test/CodeGen/PowerPC/lower-globaladdr64-aix-asm.ll
===
--- llvm/test/CodeGen/PowerPC/lower-globaladdr64-aix-asm.ll
+++ llvm/test/CodeGen/PowerPC/lower-globaladdr64-aix-asm.ll
@@ -1,7 +1,7 @@
-; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff \
+; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mattr=-altivec -mtriple powerpc64-ibm-aix-xcoff \
 ; RUN: -code-model=small < %s | FileCheck %s --check-prefix=SMALL
 
-; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff \
+; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mattr=-altivec -mtriple powerpc64-ibm-aix-xcoff \
 ; RUN: -code-model=large < %s | FileCheck %s --check-prefix=LARGE
 
 @a = common global i32 0
Index: llvm/test/CodeGen/PowerPC/lower-globaladdr32-aix-asm.ll
===
--- llvm/test/CodeGen/PowerPC/lower-globaladdr32-aix-asm.ll
+++ llvm/test/CodeGen/PowerPC/lower-globaladdr32-aix-asm.ll
@@ -1,7 +1,7 @@
-; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff \
+; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mattr=-altivec -mtriple powerpc-ibm-aix-xcoff \
 ; RUN: -code-model=small < %s | FileCheck %s --check-prefix=SMALL
 
-; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff \
+; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mattr=-altivec -mtriple powerpc-ibm-aix-xcoff \
 ; RUN: -code-model=large < %s | FileCheck %s --check-prefix=LARGE
 
 @a = common global i32 0
Index: llvm/test/CodeGen/PowerPC/aix32-crsave.mir

[PATCH] D91428: Add support for multiple program address spaces

2020-11-13 Thread Paulo Matos via Phabricator via cfe-commits
pmatos created this revision.
pmatos added a reviewer: tlively.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, jdoerfert, 
hiraditya, dschuff.
Herald added projects: clang, LLVM.
pmatos requested review of this revision.
Herald added a subscriber: aheejin.

Allows for multiple program address spaces to be defined through
multiple Px-Py... in the data layout.
If none is specified, the default program address space is 0.

Unless data layout is modified with multiple Px, this patch shouldn't
have any effect on current code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91428

Files:
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/IR/DataLayout.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLParser.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DataLayout.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/test/Assembler/function-address_spaces.ll

Index: llvm/test/Assembler/function-address_spaces.ll
===
--- /dev/null
+++ llvm/test/Assembler/function-address_spaces.ll
@@ -0,0 +1,30 @@
+; RUN: llvm-as < %s | llvm-dis | FileCheck  %s
+
+; specifying explicitly P:0 (although it's the default)
+; P:1 specifies an extra address space for code where funcrefs live
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1-P0-P1"
+
+; square and double_square are in addrspace(0)
+define i32 @square(i32 %0) {
+; CHECK: define i32 @square(i32 %0) addrspace(0) {
+   %2 = mul nsw i32 %0, %0
+   ret i32 %2
+}
+
+define i32 @double_square(i32 %0) {
+; CHECK: define i32 @double_square(i32 %0) addrspace(0) {
+   %2 = shl i32 %0, 1
+   %3 = mul i32 %2, %0
+   ret i32 %3
+}
+
+; funcref is a pointer to a function in addrspace(1)
+; called in call_funcref
+%func = type void ()
+%funcref = type %func addrspace(1)*
+
+define void @call_funcref(%funcref %ref) {
+; CHECK: define void @call_funcref(void () addrspace(1)* %ref) addrspace(0) {
+   call void %ref()
+   ret void
+}
Index: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
===
--- llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -1220,12 +1220,12 @@
   Function *JT;
   if (isa(Slot.TypeID)) {
 JT = Function::Create(FT, Function::ExternalLinkage,
-  M.getDataLayout().getProgramAddressSpace(),
+  M.getDataLayout().getDefaultProgramAddressSpace(),
   getGlobalName(Slot, {}, "branch_funnel"), &M);
 JT->setVisibility(GlobalValue::HiddenVisibility);
   } else {
 JT = Function::Create(FT, Function::InternalLinkage,
-  M.getDataLayout().getProgramAddressSpace(),
+  M.getDataLayout().getDefaultProgramAddressSpace(),
   "branch_funnel", &M);
   }
   JT->addAttribute(1, Attribute::Nest);
Index: llvm/lib/Transforms/IPO/LowerTypeTests.cpp
===
--- llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -1276,12 +1276,12 @@
 void LowerTypeTestsModule::moveInitializerToModuleConstructor(
 GlobalVariable *GV) {
   if (WeakInitializerFn == nullptr) {
-WeakInitializerFn = Function::Create(
-FunctionType::get(Type::getVoidTy(M.getContext()),
-  /* IsVarArg */ false),
-GlobalValue::InternalLinkage,
-M.getDataLayout().getProgramAddressSpace(),
-"__cfi_global_var_init", &M);
+WeakInitializerFn =
+Function::Create(FunctionType::get(Type::getVoidTy(M.getContext()),
+   /* IsVarArg */ false),
+ GlobalValue::InternalLinkage,
+ M.getDataLayout().getDefaultProgramAddressSpace(),
+ "__cfi_global_var_init", &M);
 BasicBlock *BB =
 BasicBlock::Create(M.getContext(), "entry", WeakInitializerFn);
 ReturnInst::Create(M.getContext(), BB);
@@ -1517,12 +1517,11 @@
   for (unsigned I = 0; I != Functions.size(); ++I)
 GlobalLayout[Functions[I]] = I * EntrySize;
 
-  Function *JumpTableFn =
-  Function::Create(FunctionType::get(Type::getVoidTy(M.getContext()),
- /* IsVarArg */ false),
-   GlobalValue::PrivateLinkage,
-   M.getDataLayout().getProgramAddressSpace(),
-   ".cfi.jumptable", &M);
+  Function *JumpTableFn = Function::Create(
+  F

[PATCH] D91429: [OpenCL] Stop opencl-c-base.h leaking extension enabling

2020-11-13 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added reviewers: Anastasia, mantognini.
Herald added a subscriber: yaxunl.
Herald added a project: clang.
svenvh requested review of this revision.

opencl-c.h disables all extensions at its end, but opencl-c-base.h
does not, and that causes any inclusion of only opencl-c-base.h to
leave some extensions (such as cl_khr_fp16) enabled.  This affects the
`-fdeclare-opencl-builtins` option for example.

This violates the OpenCL Extension Specification which specifies that
"The initial state of the compiler is as if the directive #pragma
OPENCL EXTENSION all : disable was issued".

Fix by disabling all extensions at the end of opencl-c-base.h and
enable extensions inside opencl.h which relied on opencl-c-base.h
enabling the cl_khr_fp16/64 extensions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91429

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Headers/opencl-c.h
  clang/test/SemaOpenCL/half.cl


Index: clang/test/SemaOpenCL/half.cl
===
--- clang/test/SemaOpenCL/half.cl
+++ clang/test/SemaOpenCL/half.cl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value 
-triple spir-unknown-unknown
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value 
-triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header
 
-#pragma OPENCL EXTENSION cl_khr_fp16 : disable
 constant float f = 1.0h; // expected-error{{half precision constant requires 
cl_khr_fp16}}
 
 half half_disabled(half *p, // expected-error{{declaring function return value 
of type 'half' is not allowed}}
Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -4633,6 +4633,7 @@
 // Conversions with double data type parameters or return value.
 
 #ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
 char __ovld __cnfn convert_char(double);
 char __ovld __cnfn convert_char_rte(double);
 char __ovld __cnfn convert_char_rtn(double);
@@ -5455,6 +5456,7 @@
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
 // Convert half types to non-double types.
 uchar __ovld __cnfn convert_uchar(half);
 uchar __ovld __cnfn convert_uchar_rte(half);
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -568,4 +568,7 @@
 #pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : end
 #endif // cl_intel_device_side_avc_motion_estimation
 
+// Disable any extensions we may have enabled previously.
+#pragma OPENCL EXTENSION all : disable
+
 #endif //_OPENCL_BASE_H_


Index: clang/test/SemaOpenCL/half.cl
===
--- clang/test/SemaOpenCL/half.cl
+++ clang/test/SemaOpenCL/half.cl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value -triple spir-unknown-unknown
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value -triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header
 
-#pragma OPENCL EXTENSION cl_khr_fp16 : disable
 constant float f = 1.0h; // expected-error{{half precision constant requires cl_khr_fp16}}
 
 half half_disabled(half *p, // expected-error{{declaring function return value of type 'half' is not allowed}}
Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -4633,6 +4633,7 @@
 // Conversions with double data type parameters or return value.
 
 #ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
 char __ovld __cnfn convert_char(double);
 char __ovld __cnfn convert_char_rte(double);
 char __ovld __cnfn convert_char_rtn(double);
@@ -5455,6 +5456,7 @@
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
 // Convert half types to non-double types.
 uchar __ovld __cnfn convert_uchar(half);
 uchar __ovld __cnfn convert_uchar_rte(half);
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -568,4 +568,7 @@
 #pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : end
 #endif // cl_intel_device_side_avc_motion_estimation
 
+// Disable any extensions we may have enabled previously.
+#pragma OPENCL EXTENSION all : disable
+
 #endif //_OPENCL_BASE_H_
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91428: Add support for multiple program address spaces

2020-11-13 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added a comment.

This is WIP - there a still a few test failures but I am happy to start getting 
comments on this.

This is in preparation for implementation of reference types for the 
WebAssembly backend that requires functions to be able to live in multiple 
address spaces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91428

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


[PATCH] D89684: [AIX] Add mabi=vec-extabi options to enable the AIX extended and default vector ABIs.

2020-11-13 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA marked 8 inline comments as done.
ZarkoCA added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:532
   Options.EmitCallSiteInfo = CodeGenOpts.EmitCallSiteInfo;
+  Options.AIXExtendedAltivecABI = CodeGenOpts.AIXExtendedAltivecABI;
   Options.ValueTrackingVariableLocations =

Xiangling_L wrote:
> The ABI specifies `When the option to use nonvolatile vector registers is 
> enalbed. the compilation environment must also predefine __EXTABI__`. I 
> didn't see this. Should we also cover this in this patch?
Thanks, that was an oversight. 



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4571
   }
 
+  if (Arg *A =

Xiangling_L wrote:
> On clang, when we do: 
> `clang -target powerpc-ibm-aix-xcoff -maltivec -S -emit-llvm 
> test_faltivec.c`,  clang driver passes `-target-cpu pwr4` as default arch to 
> frontend without issuing any error.
> 
> However, with XL, we have: 
> `"-qaltivec" is not compatible with "-qarch=pwr4". "-qnoaltivec" is being 
> set.`  The same error will be issued if `pwr5` is used as well. 
> 
> So I suppose for AIX in clang, when user use `-maltivec` without specifying 
> arch level, we can do:
> 1)  by default pass `-target-cpu pwr6` to frontend 
> or  2) issue error for "-qarch=pwr4"+ enable altivec
> or 3) issue error for `-qacrh = pwr4` + diable altivec like XL does?
> 
> Also we should emit error when user use `-maltivec` with -mcpu=pwr5.
I think what XL does is probably the correct thing but in clang/llvm it looks 
like the hasAltivec setting is determined by the cpu level and the compiler 
simply ignores it when it's not supported by the cpu.  

For now, I'd like to follow the existing logic as all the other PPC targets and 
then I can follow up with a patch that emits an error when selecting altivec 
when the cpu doesn't support it.   



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4579
+
+bool haveMaltivec = false;
+

Xiangling_L wrote:
> I would suggest `s/haveMaltivec/HasAltivec` to be consistent with other 
> places where if altivec enabled is tested.
I reworked this so that I hopefully remove any confusion. 



Comment at: llvm/lib/CodeGen/CommandFlags.cpp:489
 Options.FloatABIType = getFloatABIForCalls();
+  Options.AIXExtendedAltivecABI = getAIXExtendedAltivecABI();
   Options.NoZerosInBSS = getDontPlaceZerosInBSS();

Xiangling_L wrote:
> Should we also check `-vecnvol` option is used for AIX only somewhere?
Is there a way to check whether an llc option is target specific?



Comment at: llvm/test/CodeGen/PowerPC/aix-AppendingLinkage.ll:4
 
-; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff < 
\
+; RUN: llc -verify-machineinstrs -mcpu=pwr4 -vecnvol -mtriple 
powerpc64-ibm-aix-xcoff < \
 ; RUN: %s | FileCheck %s

Xiangling_L wrote:
> May I ask why would we want to add -vecnvol for those testcases? As I 
> noticed, they don't need altivec feature enabled.
It is odd but those test cases hit the error 
`llvm/lib/Target/PowerPC/PPCISelLowering.cpp:6908` when that wasn't enabled.  
However, adding `mattr=-altivec` also suppresses it. It seems like specifying 
`mcpu=pwr4` doesn't not completely remove all altivec opts? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89684

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


[PATCH] D90892: [AIX][FE] Support constructor/destructor attribute

2020-11-13 Thread Sean Fertile via Phabricator via cfe-commits
sfertile added inline comments.



Comment at: clang/test/CodeGen/aix-constructor-attribute.cpp:8
 
-int foo() __attribute__((constructor(180)));
+// CHECK: @llvm.global_ctors = appending global [3 x { i32, void ()*, i8* }] 
[{ i32, void ()*, i8* } { i32 65535, void ()* bitcast (i32 ()* @foo3 to void 
()*), i8* null }, { i32, void ()*, i8* } { i32 180, void ()* bitcast (i32 ()* 
@foo2 to void ()*), i8* null }, { i32, void ()*, i8* } { i32 180, void ()* 
bitcast (i32 ()* @foo to void ()*), i8* null }]
 

Did you mean for this test to be a C or C++ test? If it is meant to be C++ it 
needs to mangle the function names, but considering the director it is in and 
the fact we have the same test in CodeGenCXX directory I expect this was meant 
to be C in which case it needs a `.c` extension and lose the `-x c++` in the 
run steps.



Comment at: clang/test/CodeGen/aix-destructor-attribute.cpp:1
-// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm < %s \
-// RUN: 2>&1 | \
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -emit-llvm \
+// RUN: -fno-use-cxa-atexit < %s | \

Similarly if this is meant to be a C test, give the file a .c extension.



Comment at: clang/test/CodeGen/aix-sinit-register-global-dtors-with-atexit.cpp:1
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -emit-llvm \
+// RUN: -fno-use-cxa-atexit -fregister-global-dtors-with-atexit < %s | \

I really think this test should be included in aix-destructor-attribute.c to 
highlight the codeine differences with and without the option.



Comment at: clang/test/CodeGenCXX/aix-destructor-attribute.cpp:1
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm \
+// RUN: -fno-use-cxa-atexit < %s | \

Can I ask why this is added as a new file? Its the same test as 
`aix-sinit-register-global-dtors-with-atexit.cpp` but without using 
`-fregister-global-dtors-with-atexit`. I suggest combining the 2.


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

https://reviews.llvm.org/D90892

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


[clang-tools-extra] 6e7dd1e - [clangd] Assert on varint encoding

2020-11-13 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-11-13T17:01:07+01:00
New Revision: 6e7dd1e3e1170080b76b5dcc5716bdd974343233

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

LOG: [clangd] Assert on varint encoding

5th byte of a varint can't be bigger than 0x0f, fix a test and add an
assertion.

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

Added: 


Modified: 
clang-tools-extra/clangd/index/Serialization.cpp
clang-tools-extra/clangd/unittests/SerializationTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/Serialization.cpp 
b/clang-tools-extra/clangd/index/Serialization.cpp
index 0b82224fa715..8b0ae3925a2f 100644
--- a/clang-tools-extra/clangd/index/Serialization.cpp
+++ b/clang-tools-extra/clangd/index/Serialization.cpp
@@ -21,6 +21,7 @@
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
 #include 
 
 namespace clang {
@@ -81,12 +82,17 @@ class Reader {
 
   uint32_t consumeVar() {
 constexpr static uint8_t More = 1 << 7;
-uint8_t B = consume8();
+
+// Use a 32 bit unsigned here to prevent promotion to signed int (unless 
int
+// is wider than 32 bits).
+uint32_t B = consume8();
 if (LLVM_LIKELY(!(B & More)))
   return B;
 uint32_t Val = B & ~More;
 for (int Shift = 7; B & More && Shift < 32; Shift += 7) {
   B = consume8();
+  // 5th byte of a varint can only have lowest 4 bits set.
+  assert((Shift != 28 || B == (B & 0x0f)) && "Invalid varint encoding");
   Val |= (B & ~More) << Shift;
 }
 return Val;

diff  --git a/clang-tools-extra/clangd/unittests/SerializationTests.cpp 
b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
index 94db6c9127a8..ca7d3ba7e3e1 100644
--- a/clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -366,9 +366,9 @@ TEST(SerializationTest, NoCrashOnBadArraySize) {
   Pos += FileDigest.size();
 
   // Varints are little-endian base-128 numbers, where the top-bit of each byte
-  // indicates whether there are more. 8fff7f -> 0x.
+  // indicates whether there are more. 0f -> 0x.
   std::string CorruptSrcs =
-  (Srcs->Data.take_front(Pos) + llvm::fromHex("8fff7f") +
+  (Srcs->Data.take_front(Pos) + llvm::fromHex("0f") +
"some_random_garbage")
   .str();
   Srcs->Data = CorruptSrcs;



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


[PATCH] D91429: [OpenCL] Stop opencl-c-base.h leaking extension enabling

2020-11-13 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91429

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


[PATCH] D88676: [PPC][AIX] Add vector callee saved registers for AIX extended vector ABI

2020-11-13 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 305150.
ZarkoCA added a comment.

Rebased and addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88676

Files:
  llvm/lib/Target/PowerPC/PPCCallingConv.td
  llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
  llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
  llvm/test/CodeGen/PowerPC/aix-csr-vector.ll

Index: llvm/test/CodeGen/PowerPC/aix-csr-vector.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-csr-vector.ll
@@ -0,0 +1,308 @@
+; RUN: llc -mtriple=powerpc-unknown-aix-xcoff -vec-extabi -verify-machineinstrs -mcpu=pwr7 \
+; RUN: -mattr=+altivec -stop-after=prologepilog < %s | \
+; RUN:   FileCheck --check-prefix=MIR32 %s
+
+; RUN: llc -mtriple=powerpc-unknown-aix-xcoff -vec-extabi -verify-machineinstrs \
+; RUN: -mcpu=pwr7 -mattr=+altivec < %s | \
+; RUN:   FileCheck --check-prefix=ASM32 %s
+
+; RUN: llc -mtriple=powerpc64-unknown-aix-xcoff -vec-extabi -verify-machineinstrs \
+; RUN: -mcpu=pwr7 -mattr=+altivec -stop-after=prologepilog < %s | \
+; RUN:   FileCheck --check-prefix=MIR64 %s
+
+; RUN: llc -mtriple=powerpc64-unknown-aix-xcoff -vec-extabi -verify-machineinstrs \
+; RUN: -mcpu=pwr7 -mattr=+altivec < %s | \
+; RUN:   FileCheck --check-prefix=ASM64 %s
+
+
+define dso_local void @vec_regs() {
+entry:
+  call void asm sideeffect "", "~{v13},~{v20},~{v26},~{v31}"()
+  ret void
+}
+
+; MIR32: name:vec_regs
+
+; MIR32-LABEL:   fixedStack:
+; MIR32-NEXT:- { id: 0, type: spill-slot, offset: -16, size: 16, alignment: 16, stack-id: default,
+; MIR32-NEXT:callee-saved-register: '$v31', callee-saved-restored: true, debug-info-variable: '',
+; MIR32-NEXT:debug-info-expression: '', debug-info-location: '' }
+; MIR32-NEXT:- { id: 1, type: spill-slot, offset: -96, size: 16, alignment: 16, stack-id: default,
+; MIR32-NEXT:callee-saved-register: '$v26', callee-saved-restored: true, debug-info-variable: '',
+; MIR32-NEXT:debug-info-expression: '', debug-info-location: '' }
+; MIR32-NEXT:- { id: 2, type: spill-slot, offset: -192, size: 16, alignment: 16, stack-id: default,
+; MIR32-NEXT:callee-saved-register: '$v20', callee-saved-restored: true, debug-info-variable: '',
+; MIR32-NEXT:debug-info-expression: '', debug-info-location: '' }
+; MIR32-NEXT:stack:
+
+; MIR32: liveins: $v20, $v26, $v31
+
+; MIR32-DAG: STXVD2X killed $v20, $r1, killed $r{{[0-9]+}} :: (store 16 into %fixed-stack.2)
+; MIR32-DAG: STXVD2X killed $v26, $r1, killed $r{{[0-9]+}} :: (store 16 into %fixed-stack.1)
+; MIR32-DAG: STXVD2X killed $v31, $r1, killed $r{{[0-9]+}} :: (store 16 into %fixed-stack.0)
+
+; MIR32: INLINEASM
+
+; MIR32-DAG: $v20 = LXVD2X $r1, killed $r{{[0-9]+}} :: (load 16 from %fixed-stack.2)
+; MIR32-DAG: $v26 = LXVD2X $r1, killed $r{{[0-9]+}} :: (load 16 from %fixed-stack.1)
+; MIR32-DAG: $v31 = LXVD2X $r1, killed $r{{[0-9]+}} :: (load 16 from %fixed-stack.0)
+; MIR32: BLR implicit $lr, implicit $rm
+
+; MIR64: name:vec_regs
+
+; MIR64-LABEL:   fixedStack:
+; MIR64-NEXT:- { id: 0, type: spill-slot, offset: -16, size: 16, alignment: 16, stack-id: default,
+; MIR64-NEXT:callee-saved-register: '$v31', callee-saved-restored: true, debug-info-variable: '',
+; MIR64-NEXT:debug-info-expression: '', debug-info-location: '' }
+; MIR64-NEXT:- { id: 1, type: spill-slot, offset: -96, size: 16, alignment: 16, stack-id: default,
+; MIR64-NEXT:callee-saved-register: '$v26', callee-saved-restored: true, debug-info-variable: '',
+; MIR64-NEXT:debug-info-expression: '', debug-info-location: '' }
+; MIR64-NEXT:- { id: 2, type: spill-slot, offset: -192, size: 16, alignment: 16, stack-id: default,
+; MIR64-NEXT:callee-saved-register: '$v20', callee-saved-restored: true, debug-info-variable: '',
+; MIR64-NEXT:debug-info-expression: '', debug-info-location: '' }
+; MIR64-NEXT:stack:
+
+; MIR64: liveins: $v20, $v26, $v31
+
+; MIR64-DAG: STXVD2X killed $v20, $x1, killed $x{{[0-9]+}} :: (store 16 into %fixed-stack.2)
+; MIR64-DAG: STXVD2X killed $v26, $x1, killed $x{{[0-9]+}} :: (store 16 into %fixed-stack.1)
+; MIR64-DAG: STXVD2X killed $v31, $x1, killed $x{{[0-9]+}} :: (store 16 into %fixed-stack.0)
+
+; MIR64: INLINEASM
+
+; MIR64-DAG: $v20 = LXVD2X $x1, killed $x{{[0-9]+}} :: (load 16 from %fixed-stack.2)
+; MIR64-DAG: $v26 = LXVD2X $x1, killed $x{{[0-9]+}} :: (load 16 from %fixed-stack.1)
+; MIR64-DAG: $v31 = LXVD2X $x1, killed $x{{[0-9]+}} :: (load 16 from %fixed-stack.0)
+; MIR64: BLR8 implicit $lr8, implicit $rm
+
+
+; ASM32-LABEL:   .vec_regs:
+
+; ASM32: li {{[0-9]+}}, -192
+; ASM32-DAG: stxvd2x 52, 1, {{[0-9]+}}   # 16-byte Folded Spill
+; ASM32-DA

[PATCH] D91405: [clangd] Assert on varint encoding

2020-11-13 Thread Kadir Cetinkaya 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 rG6e7dd1e3e117: [clangd] Assert on varint encoding (authored 
by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91405

Files:
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/unittests/SerializationTests.cpp


Index: clang-tools-extra/clangd/unittests/SerializationTests.cpp
===
--- clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -366,9 +366,9 @@
   Pos += FileDigest.size();
 
   // Varints are little-endian base-128 numbers, where the top-bit of each byte
-  // indicates whether there are more. 8fff7f -> 0x.
+  // indicates whether there are more. 0f -> 0x.
   std::string CorruptSrcs =
-  (Srcs->Data.take_front(Pos) + llvm::fromHex("8fff7f") +
+  (Srcs->Data.take_front(Pos) + llvm::fromHex("0f") +
"some_random_garbage")
   .str();
   Srcs->Data = CorruptSrcs;
Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -21,6 +21,7 @@
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
 #include 
 
 namespace clang {
@@ -81,12 +82,17 @@
 
   uint32_t consumeVar() {
 constexpr static uint8_t More = 1 << 7;
-uint8_t B = consume8();
+
+// Use a 32 bit unsigned here to prevent promotion to signed int (unless 
int
+// is wider than 32 bits).
+uint32_t B = consume8();
 if (LLVM_LIKELY(!(B & More)))
   return B;
 uint32_t Val = B & ~More;
 for (int Shift = 7; B & More && Shift < 32; Shift += 7) {
   B = consume8();
+  // 5th byte of a varint can only have lowest 4 bits set.
+  assert((Shift != 28 || B == (B & 0x0f)) && "Invalid varint encoding");
   Val |= (B & ~More) << Shift;
 }
 return Val;


Index: clang-tools-extra/clangd/unittests/SerializationTests.cpp
===
--- clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -366,9 +366,9 @@
   Pos += FileDigest.size();
 
   // Varints are little-endian base-128 numbers, where the top-bit of each byte
-  // indicates whether there are more. 8fff7f -> 0x.
+  // indicates whether there are more. 0f -> 0x.
   std::string CorruptSrcs =
-  (Srcs->Data.take_front(Pos) + llvm::fromHex("8fff7f") +
+  (Srcs->Data.take_front(Pos) + llvm::fromHex("0f") +
"some_random_garbage")
   .str();
   Srcs->Data = CorruptSrcs;
Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -21,6 +21,7 @@
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
 #include 
 
 namespace clang {
@@ -81,12 +82,17 @@
 
   uint32_t consumeVar() {
 constexpr static uint8_t More = 1 << 7;
-uint8_t B = consume8();
+
+// Use a 32 bit unsigned here to prevent promotion to signed int (unless int
+// is wider than 32 bits).
+uint32_t B = consume8();
 if (LLVM_LIKELY(!(B & More)))
   return B;
 uint32_t Val = B & ~More;
 for (int Shift = 7; B & More && Shift < 32; Shift += 7) {
   B = consume8();
+  // 5th byte of a varint can only have lowest 4 bits set.
+  assert((Shift != 28 || B == (B & 0x0f)) && "Invalid varint encoding");
   Val |= (B & ~More) << Shift;
 }
 return Val;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88676: [PPC][AIX] Add vector callee saved registers for AIX extended vector ABI

2020-11-13 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA marked an inline comment as done.
ZarkoCA added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:184
   if (TM.isPPC64()) {
-if (Subtarget.hasAltivec())
+if (Subtarget.hasAltivec()) {
+  if (Subtarget.isAIXABI() && !TM.getAIXExtendedAltivecABI())

sfertile wrote:
> I suggest doing the error checking once before  getting into the 
> 32-bit/64-bit blocks.
Thanks, good suggestion, I moved it up right at the beginning of the function. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88676

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


[PATCH] D13673: Add initial support for the MUSL C library.

2020-11-13 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.
Herald added subscribers: krytarowski, mgorny.

@vkalintiris @jroelofs Is it possible to detect Musl through some macro? I'd 
like to get rid of the CMake option -- this isn't the sort of property that we 
want to set explicitly at configure time, it's the sort of property we want to 
sniff out in the library instead.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D13673

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


[clang-tools-extra] 8741a76 - [clangd] Ensure we test for compatibility of serialized index format

2020-11-13 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-11-13T17:06:23+01:00
New Revision: 8741a76f5dd11ba65fadfd3182da4d365ac15352

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

LOG: [clangd] Ensure we test for compatibility of serialized index format

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

Added: 
clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
clang-tools-extra/clangd/test/index-serialization/version-is-correct.test

Modified: 
clang-tools-extra/clangd/test/lit.cfg.py
clang-tools-extra/clangd/test/lit.site.cfg.py.in

Removed: 




diff  --git 
a/clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp 
b/clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
new file mode 100644
index ..7fe4e80f0477
--- /dev/null
+++ b/clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
@@ -0,0 +1,5 @@
+// Include a file to ensure we have multiple sources.
+#include "sample.h"
+
+// This introduces a symbol, a reference and a relation.
+struct Bar : public Foo {};

diff  --git a/clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h 
b/clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
new file mode 100644
index ..7cf73b9c43ab
--- /dev/null
+++ b/clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
@@ -0,0 +1,4 @@
+#pragma once
+
+// Introduce a symbol.
+struct Foo {};

diff  --git 
a/clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx 
b/clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
new file mode 100644
index ..5ecb294f3191
Binary files /dev/null and 
b/clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx 
diff er

diff  --git 
a/clang-tools-extra/clangd/test/index-serialization/version-is-correct.test 
b/clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
new file mode 100644
index ..b4227d204ae2
--- /dev/null
+++ b/clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
@@ -0,0 +1,14 @@
+# REQUIRES: zlib
+This test tries to parse a checked-in binary index.
+If this test fails it means there has been a backward incompatilbe change to
+serialization format.
+Please bump the version number in
+clang-tools-extra/clangd/index/Serialization.cpp and regenarate sample.idx with
+
+  clangd-indexer \
+clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp > \
+clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
+
+Also if you've introduced new slabs/chunks to serialized index, make sure
+indexing sample.cpp would yield non-trivial values for those.
+# RUN: dexp %/S/Inputs/sample.idx -c="find B" | grep Bar || not grep -v '^#' %s

diff  --git a/clang-tools-extra/clangd/test/lit.cfg.py 
b/clang-tools-extra/clangd/test/lit.cfg.py
index a8a38a7fafd3..2680eb441df9 100644
--- a/clang-tools-extra/clangd/test/lit.cfg.py
+++ b/clang-tools-extra/clangd/test/lit.cfg.py
@@ -30,3 +30,6 @@ def calculate_arch_features(arch_string):
 
 if config.clangd_enable_remote:
   config.available_features.add('clangd-remote-index')
+
+if config.have_zlib:
+  config.available_features.add('zlib')

diff  --git a/clang-tools-extra/clangd/test/lit.site.cfg.py.in 
b/clang-tools-extra/clangd/test/lit.site.cfg.py.in
index 750e5c500f6f..efcc770095b3 100644
--- a/clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ b/clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -25,6 +25,7 @@ config.clangd_source_dir = "@CMAKE_CURRENT_SOURCE_DIR@/.."
 config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.."
 config.clangd_build_xpc = @CLANGD_BUILD_XPC@
 config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@
+config.have_zlib = @LLVM_ENABLE_ZLIB@
 
 # Delegate logic to lit.cfg.py.
 lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py")



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


[PATCH] D91330: [clangd] Ensure we test for compatibility of serialized index format

2020-11-13 Thread Kadir Cetinkaya 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 rG8741a76f5dd1: [clangd] Ensure we test for compatibility of 
serialized index format (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91330

Files:
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
  clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
  clang-tools-extra/clangd/test/lit.cfg.py
  clang-tools-extra/clangd/test/lit.site.cfg.py.in


Index: clang-tools-extra/clangd/test/lit.site.cfg.py.in
===
--- clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -25,6 +25,7 @@
 config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.."
 config.clangd_build_xpc = @CLANGD_BUILD_XPC@
 config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@
+config.have_zlib = @LLVM_ENABLE_ZLIB@
 
 # Delegate logic to lit.cfg.py.
 lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py")
Index: clang-tools-extra/clangd/test/lit.cfg.py
===
--- clang-tools-extra/clangd/test/lit.cfg.py
+++ clang-tools-extra/clangd/test/lit.cfg.py
@@ -30,3 +30,6 @@
 
 if config.clangd_enable_remote:
   config.available_features.add('clangd-remote-index')
+
+if config.have_zlib:
+  config.available_features.add('zlib')
Index: clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
@@ -0,0 +1,14 @@
+# REQUIRES: zlib
+This test tries to parse a checked-in binary index.
+If this test fails it means there has been a backward incompatilbe change to
+serialization format.
+Please bump the version number in
+clang-tools-extra/clangd/index/Serialization.cpp and regenarate sample.idx with
+
+  clangd-indexer \
+clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp > \
+clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
+
+Also if you've introduced new slabs/chunks to serialized index, make sure
+indexing sample.cpp would yield non-trivial values for those.
+# RUN: dexp %/S/Inputs/sample.idx -c="find B" | grep Bar || not grep -v '^#' %s
Index: clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
@@ -0,0 +1,4 @@
+#pragma once
+
+// Introduce a symbol.
+struct Foo {};
Index: clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
@@ -0,0 +1,5 @@
+// Include a file to ensure we have multiple sources.
+#include "sample.h"
+
+// This introduces a symbol, a reference and a relation.
+struct Bar : public Foo {};


Index: clang-tools-extra/clangd/test/lit.site.cfg.py.in
===
--- clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -25,6 +25,7 @@
 config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.."
 config.clangd_build_xpc = @CLANGD_BUILD_XPC@
 config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@
+config.have_zlib = @LLVM_ENABLE_ZLIB@
 
 # Delegate logic to lit.cfg.py.
 lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py")
Index: clang-tools-extra/clangd/test/lit.cfg.py
===
--- clang-tools-extra/clangd/test/lit.cfg.py
+++ clang-tools-extra/clangd/test/lit.cfg.py
@@ -30,3 +30,6 @@
 
 if config.clangd_enable_remote:
   config.available_features.add('clangd-remote-index')
+
+if config.have_zlib:
+  config.available_features.add('zlib')
Index: clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
@@ -0,0 +1,14 @@
+# REQUIRES: zlib
+This test tries to parse a checked-in binary index.
+If this test fails it means there has been a backward incompatilbe change to
+serialization format.
+Please bump the version number in
+clang-tools-extra/clangd/index/Serialization.cpp and regenarate sample.idx with
+
+  clangd-indexer \
+clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp > \
+clang-tools-extra/clangd/test/index-serializatio

[PATCH] D91429: [OpenCL] Stop opencl-c-base.h leaking extension enabling

2020-11-13 Thread Marco Antognini via Phabricator via cfe-commits
mantognini added a comment.

LGMT as it reduces the divergence in compilation flows. I let @Anastasia, or 
someone else more familiar with the codebase, give the final approval though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91429

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


[PATCH] D91121: [InferAddrSpace] Teach to handle assumed address space.

2020-11-13 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 305154.
hliao added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Add a note in the AMDGPU usage document on the assumption made here.
- Revise the test in clang.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91121

Files:
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
  llvm/docs/AMDGPUUsage.rst
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
  llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
  llvm/test/CodeGen/AMDGPU/GlobalISel/divergent-control-flow.ll
  llvm/test/Transforms/InferAddressSpaces/AMDGPU/assumed-addrspace.ll

Index: llvm/test/Transforms/InferAddressSpaces/AMDGPU/assumed-addrspace.ll
===
--- /dev/null
+++ llvm/test/Transforms/InferAddressSpaces/AMDGPU/assumed-addrspace.ll
@@ -0,0 +1,12 @@
+; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -infer-address-spaces -o - %s | FileCheck %s
+
+@c0 = addrspace(4) global float* undef
+
+; CHECK-LABEL: @generic_ptr_from_constant
+; CHECK: addrspacecast float* %p to float addrspace(1)*
+; CHECK-NEXT: load float, float addrspace(1)*
+define float @generic_ptr_from_constant() {
+  %p = load float*, float* addrspace(4)* @c0
+  %v = load float, float* %p
+  ret float %v
+}
Index: llvm/test/CodeGen/AMDGPU/GlobalISel/divergent-control-flow.ll
===
--- llvm/test/CodeGen/AMDGPU/GlobalISel/divergent-control-flow.ll
+++ llvm/test/CodeGen/AMDGPU/GlobalISel/divergent-control-flow.ll
@@ -138,7 +138,7 @@
 ; CHECK-NEXT:s_cselect_b32 s4, 1, 0
 ; CHECK-NEXT:s_and_b32 s4, s4, 1
 ; CHECK-NEXT:s_cmp_lg_u32 s4, 0
-; CHECK-NEXT:s_cbranch_scc1 BB4_6
+; CHECK-NEXT:s_cbranch_scc1 BB4_4
 ; CHECK-NEXT:  ; %bb.1: ; %bb2
 ; CHECK-NEXT:s_getpc_b64 s[6:7]
 ; CHECK-NEXT:s_add_u32 s6, s6, const.ptr@gotpcrel32@lo+4
@@ -150,23 +150,23 @@
 ; CHECK-NEXT:s_waitcnt lgkmcnt(0)
 ; CHECK-NEXT:v_mov_b32_e32 v0, s6
 ; CHECK-NEXT:v_mov_b32_e32 v1, s7
-; CHECK-NEXT:flat_load_dword v0, v[0:1]
-; CHECK-NEXT:s_waitcnt vmcnt(0) lgkmcnt(0)
-; CHECK-NEXT:v_cmp_ngt_f32_e32 vcc, 1.0, v0
-; CHECK-NEXT:s_and_saveexec_b64 s[6:7], vcc
+; CHECK-NEXT:global_load_dword v0, v[0:1], off
+; CHECK-NEXT:s_waitcnt vmcnt(0)
+; CHECK-NEXT:v_cmp_gt_f32_e32 vcc, 1.0, v0
+; CHECK-NEXT:s_cbranch_vccnz BB4_3
 ; CHECK-NEXT:  ; %bb.2: ; %bb7
 ; CHECK-NEXT:s_mov_b32 s4, 0
-; CHECK-NEXT:  ; %bb.3: ; %bb8
-; CHECK-NEXT:s_or_b64 exec, exec, s[6:7]
-; CHECK-NEXT:v_cmp_eq_u32_e64 s[6:7], s4, 0
-; CHECK-NEXT:s_and_saveexec_b64 s[4:5], s[6:7]
-; CHECK-NEXT:s_cbranch_execz BB4_5
-; CHECK-NEXT:  ; %bb.4: ; %bb11
+; CHECK-NEXT:  BB4_3: ; %bb8
+; CHECK-NEXT:s_cmp_lg_u32 s4, 0
+; CHECK-NEXT:s_cselect_b32 s4, 1, 0
+; CHECK-NEXT:s_and_b32 s4, s4, 1
+; CHECK-NEXT:s_cmp_lg_u32 s4, 0
+; CHECK-NEXT:s_cbranch_scc0 BB4_5
+; CHECK-NEXT:  BB4_4: ; %bb12
+; CHECK-NEXT:s_setpc_b64 s[30:31]
+; CHECK-NEXT:  BB4_5: ; %bb11
 ; CHECK-NEXT:v_mov_b32_e32 v0, 4.0
 ; CHECK-NEXT:buffer_store_dword v0, v0, s[0:3], 0 offen
-; CHECK-NEXT:  BB4_5: ; %Flow
-; CHECK-NEXT:s_or_b64 exec, exec, s[4:5]
-; CHECK-NEXT:  BB4_6: ; %bb12
 ; CHECK-NEXT:s_waitcnt vmcnt(0)
 ; CHECK-NEXT:s_setpc_b64 s[30:31]
 bb:
Index: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
===
--- llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
+++ llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
@@ -286,6 +286,8 @@
   case Instruction::IntToPtr:
 return isNoopPtrIntCastPair(Op, DL, TTI);
   default:
+if (TTI->getAssumedAddrSpace(&V))
+  return true;
 return false;
   }
 }
@@ -478,9 +480,12 @@
 }
 // Otherwise, adds its operands to the stack and explores them.
 PostorderStack.back().setInt(true);
-for (Value *PtrOperand : getPointerOperands(*TopVal, *DL, TTI)) {
-  appendsFlatAddressExpressionToPostorderStack(PtrOperand, PostorderStack,
-   Visited);
+// Skip values with an assumed address space.
+if (!TTI->getAssumedAddrSpace(TopVal)) {
+  for (Value *PtrOperand : getPointerOperands(*TopVal, *DL, TTI)) {
+appendsFlatAddressExpressionToPostorderStack(PtrOperand, PostorderStack,
+ Visited);
+  }
 }
   }
   return Postorder;
@@ -555,6 +560,16 @@
 return nullptr;
   }
 
+  if (auto AS = TTI->getAssumedAddrSpace(I)) {
+// For the assumed address space, insert an `addrspa

[PATCH] D91121: [InferAddrSpace] Teach to handle assumed address space.

2020-11-13 Thread Michael Liao via Phabricator via cfe-commits
hliao added inline comments.



Comment at: llvm/include/llvm/CodeGen/BasicTTIImpl.h:227
 
+  Optional getAssumedAddrSpace(const Value *V) const {
+return getTLI()->getTargetMachine().getAssumedAddrSpace(V);

hliao wrote:
> arsenm wrote:
> > We already have a -1 as an invalid addrspace, so optional isn't necessary
> OK. Do we need to document that in the IR langref? That invalid address space 
> ID is not documented anywhere.
Shall we assume this before that reserved invalid address space ID is 
well-received and documented in LLVM IR ref? I will make either change in this 
change accordingly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91121

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


[PATCH] D90507: Adding DWARF64 clang flag

2020-11-13 Thread Wenlei He via Phabricator via cfe-commits
wenlei added a comment.

This change covers non-LTO cases. For LTO, I think we would need to pass it 
from driver to LTO. Something like this: tools::addLTOOptions -> lld -> 
lto::Config (Config->TargetOptions->MCTargetOptions) ->LTO Backend.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90507

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


[PATCH] D91367: Serialization: Merge three diagnostics to simplify ASTReader::getInputFile, NFC

2020-11-13 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSerializationKinds.td:20
 "malformed block record in PCH file: '%0'">, DefaultFatal;
 def err_fe_pch_file_modified : Error<
+"file '%0' has been modified since the "

jansvoboda11 wrote:
> I'm a bit confused by the fact that a diagnostic with `pch_file` in its name 
> might output `module file` or `AST file` as well.
> 
> This file already contains a couple diagnostics that use a similar `%select` 
> and have `module` in their name (e.g. `err_module_file_out_of_date`). Would 
> it make sense to unify the terminology here?
Yeah, I wasn't sure what to do about that. `module` is also wrong. I ended up 
choosing `pch` just since the diagnostic was in a group of `pch` diagnostics.

IMO, the best name for all of these is `ast` since that's the most generic 
term. I could rename the others to `ast` in a prep commit and then update this 
patch to use `ast` as well. WDYT?


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

https://reviews.llvm.org/D91367

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


[PATCH] D91361: [AIX][driver] Include crti[_64].o and -bcdtors also for C language link invocations by default

2020-11-13 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 305160.
Xiangling_L added a comment.

Remove the `if` condition and tweak the comments;


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

https://reviews.llvm.org/D91361

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -16,7 +16,7 @@
 // CHECK-LD32: "-b32"
 // CHECK-LD32: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
-// CHECK-LD32-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-NOT: "-lc++"
 // CHECK-LD32: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
@@ -38,7 +38,7 @@
 // CHECK-LD64: "-b64"
 // CHECK-LD64: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
-// CHECK-LD64-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
+// CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-NOT: "-lc++"
 // CHECK-LD64: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
@@ -61,7 +61,7 @@
 // CHECK-LD32-PTHREAD: "-b32"
 // CHECK-LD32-PTHREAD: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
-// CHECK-LD32-PTHREAD-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-PTHREAD: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PTHREAD-NOT: "-lc++"
 // CHECK-LD32-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
@@ -85,7 +85,7 @@
 // CHECK-LD64-PTHREAD: "-b64"
 // CHECK-LD64-PTHREAD: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
-// CHECK-LD64-PTHREAD-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
+// CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64-PTHREAD: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-PTHREAD-NOT: "-lc++"
 // CHECK-LD64-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
@@ -109,7 +109,7 @@
 // CHECK-LD32-PROF: "-b32"
 // CHECK-LD32-PROF: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-PROF: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
-// CHECK-LD32-PROF-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32-PROF: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PROF-NOT: "-lc++"
 // CHECK-LD32-PROF: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
@@ -132,7 +132,7 @@
 // CHECK-LD64-GPROF: "-b64"
 // CHECK-LD64-GPROF: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-GPROF: "[[SYSROOT]]/usr/lib{{/|}}gcrt0_64.o"
-// CHECK-LD64-GPROF-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
+// CHECK-LD64-GPROF: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64-GPROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-GPROF-NOT: "-lc++"
 // CHECK-LD64-GPROF: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
@@ -155,7 +155,7 @@
 // CHECK-LD32-STATIC: "-b32"
 // CHECK-LD32-STATIC: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-STATIC: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
-// CHECK-LD32-STATIC-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32-STATIC: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-STATIC: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-STATIC-NOT: "-lc++"
 // CHECK-LD32-STATIC: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
@@ -178,7 +178,7 @@
 // CHECK-LD32-LIBP: "-b32"
 // CHECK-LD32-LIBP: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-LIBP: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
-// CHECK-LD32-LIBP-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32-LIBP: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-LIBP: "-L[[SYSROOT]]/powerpc-ibm-aix7.1.0.0"
 // CHECK-LD32-LIBP: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-LIBP-NOT: "-lc++"
@@ -228,7 +228,7 @@
 // CHECK-LD64-NO-DEFAULT-LIBS: "-b64"
 // CHECK-LD64-NO-DEFAULT-LIBS: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-NO-DEFAULT-LIBS: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
-// CHECK-LD64-NO-DEFAULT-LIBS-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
+// CHECK-LD64-NO-DEFAULT-LIBS: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64-NO-DEFAULT-LIBS: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc++"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
@@ 

[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2020-11-13 Thread Alexey Bader via Phabricator via cfe-commits
bader updated this revision to Diff 305165.
bader added a comment.

Remove support for `sycl_constant` address space attribute.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89909

Files:
  clang/include/clang/Basic/AddressSpaces.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/TCE.h
  clang/lib/Basic/Targets/X86.h
  clang/test/SemaTemplate/address_space-dependent.cpp

Index: clang/test/SemaTemplate/address_space-dependent.cpp
===
--- clang/test/SemaTemplate/address_space-dependent.cpp
+++ clang/test/SemaTemplate/address_space-dependent.cpp
@@ -43,7 +43,7 @@
 
 template 
 void tooBig() {
-  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388589)}}
+  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388590)}}
 }
 
 template 
Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -37,7 +37,6 @@
 0,   // cuda_shared
 0,   // sycl_global
 0,   // sycl_local
-0,   // sycl_constant
 0,   // sycl_private
 270, // ptr32_sptr
 271, // ptr32_uptr
Index: clang/lib/Basic/Targets/TCE.h
===
--- clang/lib/Basic/Targets/TCE.h
+++ clang/lib/Basic/Targets/TCE.h
@@ -44,7 +44,6 @@
 0, // cuda_shared
 3, // sycl_global
 4, // sycl_local
-5, // sycl_constant
 0, // sycl_private
 0, // ptr32_sptr
 0, // ptr32_uptr
Index: clang/lib/Basic/Targets/SPIR.h
===
--- clang/lib/Basic/Targets/SPIR.h
+++ clang/lib/Basic/Targets/SPIR.h
@@ -35,7 +35,6 @@
 0, // cuda_shared
 1, // sycl_global
 3, // sycl_local
-2, // sycl_constant
 0, // sycl_private
 0, // ptr32_sptr
 0, // ptr32_uptr
@@ -56,7 +55,6 @@
 0, // cuda_shared
 1, // sycl_global
 3, // sycl_local
-2, // sycl_constant
 0, // sycl_private
 0, // ptr32_sptr
 0, // ptr32_uptr
Index: clang/lib/Basic/Targets/NVPTX.h
===
--- clang/lib/Basic/Targets/NVPTX.h
+++ clang/lib/Basic/Targets/NVPTX.h
@@ -37,7 +37,6 @@
 3, // cuda_shared
 1, // sycl_global
 3, // sycl_local
-4, // sycl_constant
 0, // sycl_private
 0, // ptr32_sptr
 0, // ptr32_uptr
Index: clang/lib/Basic/Targets/AMDGPU.cpp
===
--- clang/lib/Basic/Targets/AMDGPU.cpp
+++ clang/lib/Basic/Targets/AMDGPU.cpp
@@ -53,7 +53,6 @@
 Local,// cuda_shared
 Global,   // sycl_global
 Local,// sycl_local
-Constant, // sycl_constant
 Private,  // sycl_private
 Generic,  // ptr32_sptr
 Generic,  // ptr32_uptr
@@ -74,7 +73,6 @@
 Local,// cuda_shared
 Global,   // sycl_global
 Local,// sycl_local
-Constant, // sycl_constant
 Private,  // sycl_private
 Generic,  // ptr32_sptr
 Generic,  // ptr32_uptr
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -2082,7 +2082,6 @@
   case LangAS::sycl_private:
 return "__private";
   case LangAS::opencl_constant:
-  case LangAS::sycl_constant:
 return "__constant";
   case LangAS::opencl_generic:
 return "__generic";
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -932,7 +932,6 @@
 9,  // cuda_shared
 1,  // sycl_global
 3,  // sycl_local
-2,  // sycl_constant
 0,  // sycl_private
 10, // ptr32_sptr
 11, // ptr32_uptr
Index: clang/include/clang/Sema/ParsedAttr.h
===
--- clang/include/clang/Sema/ParsedAttr.h
+++ clang/include/clang/Sema/ParsedAttr.h
@@ -626,8 +626,6 @@
   /// representation in LangAS, otherwise returns default address space.
   LangAS asSYCLLangAS() const {
 switch (getKind()) {
-case ParsedAttr::AT_OpenCLConstantAddressSpace:
-  return LangAS::sycl_constant;
 case ParsedAttr::AT_OpenCLGlobalAddressSpace:
   return LangAS::sycl_global;
 case ParsedAttr::AT_OpenCLLocalAddressSpace:
Index: clang/include/clang/Basic/AddressSpaces.h
===
--- clang/include/clang/Basic/AddressSpaces.h
+++ clang

[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2020-11-13 Thread Alexey Bader via Phabricator via cfe-commits
bader updated this revision to Diff 305167.
bader added a comment.

Upload full patch after removing `sycl_constant` address space attribute 
support.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89909

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/AddressSpaces.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/TCE.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGenSYCL/address-space-cond-op.cpp
  clang/test/CodeGenSYCL/address-space-of-returns.cpp
  clang/test/CodeGenSYCL/address-space-parameter-conversions.cpp
  clang/test/CodeGenSYCL/address-spaces.cpp
  clang/test/SemaSYCL/address-space-parameter-conversions.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp

Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -244,6 +244,8 @@
   case Musl: return "musl";
   case MuslEABI: return "musleabi";
   case MuslEABIHF: return "musleabihf";
+  case SYCLDevice:
+return "sycldevice";
   case Simulator: return "simulator";
   }
 
@@ -529,26 +531,27 @@
 
 static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
   return StringSwitch(EnvironmentName)
-.StartsWith("eabihf", Triple::EABIHF)
-.StartsWith("eabi", Triple::EABI)
-.StartsWith("gnuabin32", Triple::GNUABIN32)
-.StartsWith("gnuabi64", Triple::GNUABI64)
-.StartsWith("gnueabihf", Triple::GNUEABIHF)
-.StartsWith("gnueabi", Triple::GNUEABI)
-.StartsWith("gnux32", Triple::GNUX32)
-.StartsWith("code16", Triple::CODE16)
-.StartsWith("gnu", Triple::GNU)
-.StartsWith("android", Triple::Android)
-.StartsWith("musleabihf", Triple::MuslEABIHF)
-.StartsWith("musleabi", Triple::MuslEABI)
-.StartsWith("musl", Triple::Musl)
-.StartsWith("msvc", Triple::MSVC)
-.StartsWith("itanium", Triple::Itanium)
-.StartsWith("cygnus", Triple::Cygnus)
-.StartsWith("coreclr", Triple::CoreCLR)
-.StartsWith("simulator", Triple::Simulator)
-.StartsWith("macabi", Triple::MacABI)
-.Default(Triple::UnknownEnvironment);
+  .StartsWith("eabihf", Triple::EABIHF)
+  .StartsWith("eabi", Triple::EABI)
+  .StartsWith("gnuabin32", Triple::GNUABIN32)
+  .StartsWith("gnuabi64", Triple::GNUABI64)
+  .StartsWith("gnueabihf", Triple::GNUEABIHF)
+  .StartsWith("gnueabi", Triple::GNUEABI)
+  .StartsWith("gnux32", Triple::GNUX32)
+  .StartsWith("code16", Triple::CODE16)
+  .StartsWith("gnu", Triple::GNU)
+  .StartsWith("android", Triple::Android)
+  .StartsWith("musleabihf", Triple::MuslEABIHF)
+  .StartsWith("musleabi", Triple::MuslEABI)
+  .StartsWith("musl", Triple::Musl)
+  .StartsWith("msvc", Triple::MSVC)
+  .StartsWith("itanium", Triple::Itanium)
+  .StartsWith("cygnus", Triple::Cygnus)
+  .StartsWith("coreclr", Triple::CoreCLR)
+  .StartsWith("sycldevice", Triple::SYCLDevice)
+  .StartsWith("simulator", Triple::Simulator)
+  .StartsWith("macabi", Triple::MacABI)
+  .Default(Triple::UnknownEnvironment);
 }
 
 static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) {
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -217,8 +217,9 @@
 Itanium,
 Cygnus,
 CoreCLR,
+SYCLDevice,
 Simulator, // Simulator variants of other systems, e.g., Apple's iOS
-MacABI, // Mac Catalyst variant of Apple's iOS deployment target.
+MacABI,// Mac Catalyst variant of Apple's iOS deployment target.
 LastEnvironmentType = MacABI
   };
   enum ObjectFormatType {
@@ -492,6 +493,10 @@
isMacCatalystEnvironment()));
   }
 
+  bool isSYCLDeviceEnvironment() const {
+return getEnvironment() == Triple::SYCLDevice;
+  }
+
   bool isOSNetBSD() const {
 return getOS() == Triple::NetBSD;
   }
Index: clang/test/SemaTemplate/address_space-dependent.cpp
===
--- clang/test/SemaTemplate/address_space-dependent.cpp
+++ clang/test/SemaTemplate/address_space-dependent.cpp
@@ -43,7 +43,7 @@
 
 template 
 void tooBig() {
-  __attribute__((address_spa

[PATCH] D13673: Add initial support for the MUSL C library.

2020-11-13 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In D13673#2394064 , @ldionne wrote:

> @vkalintiris @jroelofs Is it possible to detect Musl through some macro? I'd 
> like to get rid of the CMake option -- this isn't the sort of property that 
> we want to set explicitly at configure time, it's the sort of property we 
> want to sniff out in the library instead.

I wish there was. Last I remember talking about it, Rich Felker was really 
against having one. I doubt this has changed.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D13673

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


[clang] 46ca880 - clang: Don't assert on no_unique_address fields in @encode()

2020-11-13 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-11-13T11:39:10-05:00
New Revision: 46ca880fcae24693d381ca05c16c704675545433

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

LOG: clang: Don't assert on no_unique_address fields in @encode()

Just skip (non-bitfield) zero-sized fields, like we do with empty bases.

The class->struct conversion in the test is because -std=c++20 else deletes 
some default methods
due to non-accessible base dtors otherwise.

As a side-effect of writing the test, I discovered that D76801 did an ABI 
breaking change of sorts
for Objective-C's @encode. But it's been in for a while, so I'm not sure if we 
want to row back on
that or now.

Fixes PR48048.

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

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
clang/test/CodeGenObjCXX/encode.mm

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 68d6a2435c23..d63f299f021f 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -7677,7 +7677,9 @@ void 
ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
   }
 
   unsigned i = 0;
-  for (auto *Field : RDecl->fields()) {
+  for (FieldDecl *Field : RDecl->fields()) {
+if (!Field->isZeroLengthBitField(*this) && Field->isZeroSize(*this))
+  continue;
 uint64_t offs = layout.getFieldOffset(i);
 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
   std::make_pair(offs, Field));

diff  --git a/clang/test/CodeGenObjCXX/encode.mm 
b/clang/test/CodeGenObjCXX/encode.mm
index 7bc64dafb476..61d0791a637c 100644
--- a/clang/test/CodeGenObjCXX/encode.mm
+++ b/clang/test/CodeGenObjCXX/encode.mm
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=gnu++98 %s -triple=x86_64-apple-darwin10 -emit-llvm -o 
- | FileCheck %s
+// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++98 %s 
-triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes 
CHECK,CHECKCXX98 %s
+// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++20 %s 
-triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes 
CHECK,CHECKCXX20 %s
 
 // CHECK: v17@0:8{vector=}16
 // CHECK: {vector=}
@@ -87,7 +88,9 @@ @implementation RedBalloonHGXFormWrapper
 
   typedef vector< float,  fixed<4> > vector4f;
 
-  // CHECK: @_ZN11rdar93574002ggE = constant [49 x i8] c"{vector >=[4f]}\00"
+  // FIXME: This 
diff erence is due to D76801. It was probably an unintentional change. Maybe we 
want to undo it?
+  // CHECKCXX98: @_ZN11rdar93574002ggE = constant [49 x i8] c"{vector >=[4f]}\00"
+  // CHECKCXX20: @_ZN11rdar93574002ggE = constant [48 x i8] c"{vector>=[4f]}\00"
   extern const char gg[] = @encode(vector4f);
 }
 
@@ -170,21 +173,21 @@ @implementation RedBalloonHGXFormWrapper
 
 
 // PR10990
-class CefBase {
+struct CefBase {
   virtual ~CefBase() {}
 };
-class CefBrowser : public virtual CefBase {};
-class CefBrowserImpl : public CefBrowser {};
+struct CefBrowser : public virtual CefBase {};
+struct CefBrowserImpl : public CefBrowser {};
 // CHECK: @g6 = constant [21 x i8] c"{CefBrowserImpl=^^?}\00"
 extern const char g6[] = @encode(CefBrowserImpl);
 
 // PR10990_2
-class CefBase2 {
+struct CefBase2 {
   virtual ~CefBase2() {}
   int i;
 };
-class CefBrowser2 : public virtual CefBase2 {};
-class CefBrowserImpl2 : public CefBrowser2 {};
+struct CefBrowser2 : public virtual CefBase2 {};
+struct CefBrowserImpl2 : public CefBrowser2 {};
 // CHECK: @g7 = constant [26 x i8] c"{CefBrowserImpl2=^^?^^?i}\00"
 extern const char g7[] = @encode(CefBrowserImpl2);
 
@@ -245,3 +248,15 @@ @implementation N
   // CHECK: @{{.*}} = private unnamed_addr constant [13 x i8] 
c"{N={S=@}}\00"
   return @encode(N);
 }
+
+#if __cplusplus >= 202002L
+namespace PR48048 {
+  struct F {};
+  struct I {
+int m;
+[[no_unique_address]] F n;
+  };
+  // CHECKCXX20: @_ZN7PR480481xE = constant [6 x i8] c"{I=i}\00"
+  extern const char x[] = @encode(I);
+}
+#endif



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


[PATCH] D90622: clang: Don't assert on no_unique_address fields in @encode()

2020-11-13 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG46ca880fcae2: clang: Don't assert on no_unique_address 
fields in @encode() (authored by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90622

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/CodeGenObjCXX/encode.mm


Index: clang/test/CodeGenObjCXX/encode.mm
===
--- clang/test/CodeGenObjCXX/encode.mm
+++ clang/test/CodeGenObjCXX/encode.mm
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=gnu++98 %s -triple=x86_64-apple-darwin10 -emit-llvm -o 
- | FileCheck %s
+// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++98 %s 
-triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes 
CHECK,CHECKCXX98 %s
+// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++20 %s 
-triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes 
CHECK,CHECKCXX20 %s
 
 // CHECK: v17@0:8{vector=}16
 // CHECK: {vector=}
@@ -87,7 +88,9 @@
 
   typedef vector< float,  fixed<4> > vector4f;
 
-  // CHECK: @_ZN11rdar93574002ggE = constant [49 x i8] c"{vector >=[4f]}\00"
+  // FIXME: This difference is due to D76801. It was probably an unintentional 
change. Maybe we want to undo it?
+  // CHECKCXX98: @_ZN11rdar93574002ggE = constant [49 x i8] c"{vector >=[4f]}\00"
+  // CHECKCXX20: @_ZN11rdar93574002ggE = constant [48 x i8] c"{vector>=[4f]}\00"
   extern const char gg[] = @encode(vector4f);
 }
 
@@ -170,21 +173,21 @@
 
 
 // PR10990
-class CefBase {
+struct CefBase {
   virtual ~CefBase() {}
 };
-class CefBrowser : public virtual CefBase {};
-class CefBrowserImpl : public CefBrowser {};
+struct CefBrowser : public virtual CefBase {};
+struct CefBrowserImpl : public CefBrowser {};
 // CHECK: @g6 = constant [21 x i8] c"{CefBrowserImpl=^^?}\00"
 extern const char g6[] = @encode(CefBrowserImpl);
 
 // PR10990_2
-class CefBase2 {
+struct CefBase2 {
   virtual ~CefBase2() {}
   int i;
 };
-class CefBrowser2 : public virtual CefBase2 {};
-class CefBrowserImpl2 : public CefBrowser2 {};
+struct CefBrowser2 : public virtual CefBase2 {};
+struct CefBrowserImpl2 : public CefBrowser2 {};
 // CHECK: @g7 = constant [26 x i8] c"{CefBrowserImpl2=^^?^^?i}\00"
 extern const char g7[] = @encode(CefBrowserImpl2);
 
@@ -245,3 +248,15 @@
   // CHECK: @{{.*}} = private unnamed_addr constant [13 x i8] 
c"{N={S=@}}\00"
   return @encode(N);
 }
+
+#if __cplusplus >= 202002L
+namespace PR48048 {
+  struct F {};
+  struct I {
+int m;
+[[no_unique_address]] F n;
+  };
+  // CHECKCXX20: @_ZN7PR480481xE = constant [6 x i8] c"{I=i}\00"
+  extern const char x[] = @encode(I);
+}
+#endif
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -7677,7 +7677,9 @@
   }
 
   unsigned i = 0;
-  for (auto *Field : RDecl->fields()) {
+  for (FieldDecl *Field : RDecl->fields()) {
+if (!Field->isZeroLengthBitField(*this) && Field->isZeroSize(*this))
+  continue;
 uint64_t offs = layout.getFieldOffset(i);
 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
   std::make_pair(offs, Field));


Index: clang/test/CodeGenObjCXX/encode.mm
===
--- clang/test/CodeGenObjCXX/encode.mm
+++ clang/test/CodeGenObjCXX/encode.mm
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=gnu++98 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++98 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX98 %s
+// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++20 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX20 %s
 
 // CHECK: v17@0:8{vector=}16
 // CHECK: {vector=}
@@ -87,7 +88,9 @@
 
   typedef vector< float,  fixed<4> > vector4f;
 
-  // CHECK: @_ZN11rdar93574002ggE = constant [49 x i8] c"{vector >=[4f]}\00"
+  // FIXME: This difference is due to D76801. It was probably an unintentional change. Maybe we want to undo it?
+  // CHECKCXX98: @_ZN11rdar93574002ggE = constant [49 x i8] c"{vector >=[4f]}\00"
+  // CHECKCXX20: @_ZN11rdar93574002ggE = constant [48 x i8] c"{vector>=[4f]}\00"
   extern const char gg[] = @encode(vector4f);
 }
 
@@ -170,21 +173,21 @@
 
 
 // PR10990
-class CefBase {
+struct CefBase {
   virtual ~CefBase() {}
 };
-class CefBrowser : public virtual CefBase {};
-class CefBrowserImpl : public CefBrowser {};
+struct CefBrowser : public virtual CefBase {};
+struct CefBrowserImpl : public CefBrowser {};
 // CHECK: @g6 = constant [21 x i8] c"{CefBrowserImpl=^^?}\00"
 extern const char g6[] = @encode(CefBrowserImpl);
 
 // PR10990_2
-class CefBase2 {
+struct CefBase2 {
   virtual ~CefBase2() {}
   int i;
 };
-class CefBrowser2 : 

[PATCH] D91373: [OpenMP5.0] Support more kinds of lvalues in map clauses

2020-11-13 Thread Jacob Weightman via Phabricator via cfe-commits
jacobdweightman added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:17141
+   Visit(ACO->getTrueExpr()->IgnoreParenImpCasts()) ||
+   Visit(ACO->getFalseExpr()->IgnoreParenImpCasts());
+  }

It looks like this short-circuits and the false expression doesn't get visited 
if the true expression is "well-formed." We probably want to emit diagnostics 
and fail if either expression is bad (i.e. visit true expression && visit false 
expression), but that results in an incorrect component list.

I suspect this may indicate a deeper issue, since I'm not sure what the 
components should actually be. It seems like in general it should be a 
tree-like structure rather than a list-like structure, but that seems like it 
may require significant changes. Any thoughts on this or suggestions for 
improvement?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91373

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


[PATCH] D13673: Add initial support for the MUSL C library.

2020-11-13 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

More context: https://www.openwall.com/lists/musl/2013/03/29/13


Repository:
  rL LLVM

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

https://reviews.llvm.org/D13673

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


[PATCH] D91361: [AIX][driver] Include crti[_64].o and -bcdtors also for C language link invocations by default

2020-11-13 Thread David Tenty via Phabricator via cfe-commits
daltenty accepted this revision.
daltenty added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


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

https://reviews.llvm.org/D91361

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


[PATCH] D91436: Serialization: Rename three AST diagnostics, NFC

2020-11-13 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added a reviewer: jansvoboda11.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.

All three diagnostics have a select between "PCH", "module", and "AST"
in the text. The most generic of these is "AST", so rename them from
`err_module_...` to `err_ast_...`.


https://reviews.llvm.org/D91436

Files:
  clang/include/clang/Basic/DiagnosticSerializationKinds.td
  clang/lib/Serialization/ASTReader.cpp


Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -4505,9 +4505,9 @@
   return Missing;
 
 // Otherwise, return an error.
-Diag(diag::err_module_file_not_found) << moduleKindForDiagnostic(Type)
-  << FileName << !ErrorStr.empty()
-  << ErrorStr;
+Diag(diag::err_ast_file_not_found)
+<< moduleKindForDiagnostic(Type) << FileName << !ErrorStr.empty()
+<< ErrorStr;
 return Failure;
 
   case ModuleManager::OutOfDate:
@@ -4517,9 +4517,9 @@
   return OutOfDate;
 
 // Otherwise, return an error.
-Diag(diag::err_module_file_out_of_date) << moduleKindForDiagnostic(Type)
-<< FileName << !ErrorStr.empty()
-<< ErrorStr;
+Diag(diag::err_ast_file_out_of_date)
+<< moduleKindForDiagnostic(Type) << FileName << !ErrorStr.empty()
+<< ErrorStr;
 return Failure;
   }
 
@@ -4540,7 +4540,7 @@
 
   // Sniff for the signature.
   if (llvm::Error Err = doesntStartWithASTFileMagic(Stream)) {
-Diag(diag::err_module_file_invalid)
+Diag(diag::err_ast_file_invalid)
 << moduleKindForDiagnostic(Type) << FileName << std::move(Err);
 return Failure;
   }
Index: clang/include/clang/Basic/DiagnosticSerializationKinds.td
===
--- clang/include/clang/Basic/DiagnosticSerializationKinds.td
+++ clang/include/clang/Basic/DiagnosticSerializationKinds.td
@@ -63,12 +63,12 @@
 
 def err_module_file_conflict : Error<
   "module '%0' is defined in both '%1' and '%2'">, DefaultFatal;
-def err_module_file_not_found : Error<
+def err_ast_file_not_found : Error<
   "%select{PCH|module|AST}0 file '%1' not found%select{|: %3}2">, DefaultFatal;
-def err_module_file_out_of_date : Error<
+def err_ast_file_out_of_date : Error<
   "%select{PCH|module|AST}0 file '%1' is out of date and "
   "needs to be rebuilt%select{|: %3}2">, DefaultFatal;
-def err_module_file_invalid : Error<
+def err_ast_file_invalid : Error<
   "file '%1' is not a valid precompiled %select{PCH|module|AST}0 file">, 
DefaultFatal;
 def note_module_file_imported_by : Note<
   "imported by %select{|module '%2' in }1'%0'">;


Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -4505,9 +4505,9 @@
   return Missing;
 
 // Otherwise, return an error.
-Diag(diag::err_module_file_not_found) << moduleKindForDiagnostic(Type)
-  << FileName << !ErrorStr.empty()
-  << ErrorStr;
+Diag(diag::err_ast_file_not_found)
+<< moduleKindForDiagnostic(Type) << FileName << !ErrorStr.empty()
+<< ErrorStr;
 return Failure;
 
   case ModuleManager::OutOfDate:
@@ -4517,9 +4517,9 @@
   return OutOfDate;
 
 // Otherwise, return an error.
-Diag(diag::err_module_file_out_of_date) << moduleKindForDiagnostic(Type)
-<< FileName << !ErrorStr.empty()
-<< ErrorStr;
+Diag(diag::err_ast_file_out_of_date)
+<< moduleKindForDiagnostic(Type) << FileName << !ErrorStr.empty()
+<< ErrorStr;
 return Failure;
   }
 
@@ -4540,7 +4540,7 @@
 
   // Sniff for the signature.
   if (llvm::Error Err = doesntStartWithASTFileMagic(Stream)) {
-Diag(diag::err_module_file_invalid)
+Diag(diag::err_ast_file_invalid)
 << moduleKindForDiagnostic(Type) << FileName << std::move(Err);
 return Failure;
   }
Index: clang/include/clang/Basic/DiagnosticSerializationKinds.td
===
--- clang/include/clang/Basic/DiagnosticSerializationKinds.td
+++ clang/include/clang/Basic/DiagnosticSerializationKinds.td
@@ -63,12 +63,12 @@
 
 def err_module_file_conflict : Error<
   "module '%0' is defined in both '%1' and '%2'">, DefaultFatal;
-def err_module_file_not_found : Error<
+def err_ast_file_not_found : Error<
   "%select{PCH|module|AST}0 file '%1' not found%select{|: %3}2">, DefaultFatal;
-def err_module_file_out_of_date : Error<
+def err_ast_file_out_of_date : Error<
   "%select

[PATCH] D91438: [AArch64] Define __ARM_FEATURE_{CRC32,ATOMICS}

2020-11-13 Thread Andre Vieira via Phabricator via cfe-commits
avieira created this revision.
Herald added subscribers: cfe-commits, danielkiss, jfb, kristof.beyls.
Herald added a project: clang.
avieira requested review of this revision.

Hi all,

This patch implements the definition of __ARM_FEATURE_ATOMICS and fixes the 
missing definition of __ARM_FEATURE_CRC32 for Armv8.1-A.

Kind regards,
Andre


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91438

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/test/Preprocessor/aarch64-target-features.c


Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -56,6 +56,8 @@
 // RUN: %clang -target arm64-none-linux-gnu -mcrc -x c -E -dM %s -o - | 
FileCheck --check-prefix=CHECK-CRC32 %s
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+crc -x c -E -dM 
%s -o - | FileCheck --check-prefix=CHECK-CRC32 %s
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+crc -x c -E -dM %s 
-o - | FileCheck --check-prefix=CHECK-CRC32 %s
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s 
-o - | FileCheck --check-prefix=CHECK-CRC32 %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o 
- | FileCheck --check-prefix=CHECK-CRC32 %s
 // CHECK-CRC32: __ARM_FEATURE_CRC32 1
 
 // RUN: %clang -target aarch64-none-linux-gnu -fno-math-errno 
-fno-signed-zeros\
@@ -396,3 +398,9 @@
 // CHECK-BFLOAT: __ARM_FEATURE_BF16 1
 // CHECK-BFLOAT: __ARM_FEATURE_BF16_VECTOR_ARITHMETIC 1
 
+// == Check Largse System Extensions (LSE)
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+lse -x c -E -dM 
%s -o - | FileCheck --check-prefix=CHECK-LSE %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+lse -x c -E -dM %s 
-o - | FileCheck --check-prefix=CHECK-LSE %s
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s 
-o - | FileCheck --check-prefix=CHECK-LSE %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o 
- | FileCheck --check-prefix=CHECK-LSE %s
+// CHECK-LSE: __ARM_FEATURE_ATOMICS 1
Index: clang/lib/Basic/Targets/AArch64.h
===
--- clang/lib/Basic/Targets/AArch64.h
+++ clang/lib/Basic/Targets/AArch64.h
@@ -42,6 +42,7 @@
   bool HasSVE2SHA3;
   bool HasSVE2SM4;
   bool HasSVE2BitPerm;
+  bool HasLSE;
 
   llvm::AArch64::ArchKind ArchKind;
 
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -155,8 +155,9 @@
 
 void AArch64TargetInfo::getTargetDefinesARMV81A(const LangOptions &Opts,
 MacroBuilder &Builder) const {
-  // FIXME: Armv8.1 makes __ARM_FEATURE_CRC32 mandatory. Handle it here.
   Builder.defineMacro("__ARM_FEATURE_QRDMX", "1");
+  Builder.defineMacro("__ARM_FEATURE_ATOMICS", "1");
+  Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
 }
 
 void AArch64TargetInfo::getTargetDefinesARMV82A(const LangOptions &Opts,
@@ -176,8 +177,6 @@
 void AArch64TargetInfo::getTargetDefinesARMV84A(const LangOptions &Opts,
 MacroBuilder &Builder) const {
   // Also include the Armv8.3 defines
-  // FIXME: Armv8.4 makes __ARM_FEATURE_ATOMICS, defined in GCC, mandatory.
-  // Add and handle it here.
   getTargetDefinesARMV83A(Opts, Builder);
 }
 
@@ -304,6 +303,9 @@
   if (HasMatMul)
 Builder.defineMacro("__ARM_FEATURE_MATMUL_INT8", "1");
 
+  if (HasLSE)
+Builder.defineMacro("__ARM_FEATURE_ATOMICS", "1");
+
   if (HasBFloat16) {
 Builder.defineMacro("__ARM_FEATURE_BF16", "1");
 Builder.defineMacro("__ARM_FEATURE_BF16_VECTOR_ARITHMETIC", "1");
@@ -396,6 +398,7 @@
   HasSVE2SHA3 = false;
   HasSVE2SM4 = false;
   HasSVE2BitPerm = false;
+  HasLSE = false;
 
   ArchKind = llvm::AArch64::ArchKind::ARMV8A;
 
@@ -467,6 +470,8 @@
   HasMatMul = true;
 if (Feature == "+bf16")
   HasBFloat16 = true;
+if (Feature == "+lse")
+  HasLSE = true;
   }
 
   setDataLayout();


Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -56,6 +56,8 @@
 // RUN: %clang -target arm64-none-linux-gnu -mcrc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+crc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+crc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o -

[PATCH] D91367: Serialization: Merge three diagnostics to simplify ASTReader::getInputFile, NFC

2020-11-13 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith updated this revision to Diff 305184.
dexonsmith added a comment.

Rename to use `ast_` to match https://reviews.llvm.org/D91436.


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

https://reviews.llvm.org/D91367

Files:
  clang/include/clang/Basic/DiagnosticSerializationKinds.td
  clang/lib/Serialization/ASTReader.cpp


Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -2397,17 +2397,9 @@
 
   // The top-level PCH is stale.
   StringRef TopLevelPCHName(ImportStack.back()->FileName);
-  unsigned DiagnosticKind =
-  moduleKindForDiagnostic(ImportStack.back()->Kind);
-  if (DiagnosticKind == 0)
-Diag(diag::err_fe_pch_file_modified)
-<< Filename << TopLevelPCHName << FileChange;
-  else if (DiagnosticKind == 1)
-Diag(diag::err_fe_module_file_modified)
-<< Filename << TopLevelPCHName << FileChange;
-  else
-Diag(diag::err_fe_ast_file_modified)
-<< Filename << TopLevelPCHName << FileChange;
+  Diag(diag::err_fe_ast_file_modified)
+  << Filename << moduleKindForDiagnostic(ImportStack.back()->Kind)
+  << TopLevelPCHName << FileChange;
 
   // Print the import stack.
   if (ImportStack.size() > 1) {
Index: clang/include/clang/Basic/DiagnosticSerializationKinds.td
===
--- clang/include/clang/Basic/DiagnosticSerializationKinds.td
+++ clang/include/clang/Basic/DiagnosticSerializationKinds.td
@@ -17,17 +17,10 @@
 "malformed or corrupted AST file: '%0'">, DefaultFatal;
 def err_fe_pch_malformed_block : Error<
 "malformed block record in PCH file: '%0'">, DefaultFatal;
-def err_fe_pch_file_modified : Error<
-"file '%0' has been modified since the precompiled header '%1' was built"
-": %select{size|mtime|content}2 changed">,
-DefaultFatal;
-def err_fe_module_file_modified : Error<
-"file '%0' has been modified since the module file '%1' was built"
-": %select{size|mtime|content}2 changed">,
-DefaultFatal;
 def err_fe_ast_file_modified : Error<
-"file '%0' has been modified since the AST file '%1' was built"
-": %select{size|mtime|content}2 changed">,
+"file '%0' has been modified since the "
+"%select{precompiled header|module file|AST file}1 '%2' was built"
+": %select{size|mtime|content}3 changed">,
 DefaultFatal;
 def err_fe_pch_file_overridden : Error<
 "file '%0' from the precompiled header has been overridden">;


Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -2397,17 +2397,9 @@
 
   // The top-level PCH is stale.
   StringRef TopLevelPCHName(ImportStack.back()->FileName);
-  unsigned DiagnosticKind =
-  moduleKindForDiagnostic(ImportStack.back()->Kind);
-  if (DiagnosticKind == 0)
-Diag(diag::err_fe_pch_file_modified)
-<< Filename << TopLevelPCHName << FileChange;
-  else if (DiagnosticKind == 1)
-Diag(diag::err_fe_module_file_modified)
-<< Filename << TopLevelPCHName << FileChange;
-  else
-Diag(diag::err_fe_ast_file_modified)
-<< Filename << TopLevelPCHName << FileChange;
+  Diag(diag::err_fe_ast_file_modified)
+  << Filename << moduleKindForDiagnostic(ImportStack.back()->Kind)
+  << TopLevelPCHName << FileChange;
 
   // Print the import stack.
   if (ImportStack.size() > 1) {
Index: clang/include/clang/Basic/DiagnosticSerializationKinds.td
===
--- clang/include/clang/Basic/DiagnosticSerializationKinds.td
+++ clang/include/clang/Basic/DiagnosticSerializationKinds.td
@@ -17,17 +17,10 @@
 "malformed or corrupted AST file: '%0'">, DefaultFatal;
 def err_fe_pch_malformed_block : Error<
 "malformed block record in PCH file: '%0'">, DefaultFatal;
-def err_fe_pch_file_modified : Error<
-"file '%0' has been modified since the precompiled header '%1' was built"
-": %select{size|mtime|content}2 changed">,
-DefaultFatal;
-def err_fe_module_file_modified : Error<
-"file '%0' has been modified since the module file '%1' was built"
-": %select{size|mtime|content}2 changed">,
-DefaultFatal;
 def err_fe_ast_file_modified : Error<
-"file '%0' has been modified since the AST file '%1' was built"
-": %select{size|mtime|content}2 changed">,
+"file '%0' has been modified since the "
+"%select{precompiled header|module file|AST file}1 '%2' was built"
+": %select{size|mtime|content}3 changed">,
 DefaultFatal;
 def err_fe_pch_file_overridden : Error<
 "file '%0' from the precompiled header has been overridden">;
__

[clang-tools-extra] 8dc2aa0 - [clangd] Canonicalize LLVM_ENABLE_ZLIB

2020-11-13 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-11-13T18:20:37+01:00
New Revision: 8dc2aa0e412171dad5cdc1aa60a92ddcd3800202

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

LOG: [clangd] Canonicalize LLVM_ENABLE_ZLIB

It is used in our lit test's configuration now.

Added: 


Modified: 
clang-tools-extra/clangd/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index 03756c208acd..2b324674c81f 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -14,8 +14,11 @@ if (NOT DEFINED CLANGD_BUILD_XPC)
   unset(CLANGD_BUILD_XPC_DEFAULT)
 endif ()
 
-llvm_canonicalize_cmake_booleans(CLANGD_BUILD_XPC)
-llvm_canonicalize_cmake_booleans(CLANGD_ENABLE_REMOTE)
+llvm_canonicalize_cmake_booleans(
+  CLANGD_BUILD_XPC
+  CLANGD_ENABLE_REMOTE
+  LLVM_ENABLE_ZLIB
+)
 
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/Features.inc.in



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


[PATCH] D90188: Add support for attribute 'using_if_exists'

2020-11-13 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 305193.
erik.pilkington marked 2 inline comments as done.
erik.pilkington added a comment.
Herald added a subscriber: jdoerfert.

Add support for C++11-style attributes on using-declarations.


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

https://reviews.llvm.org/D90188

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DeclNodes.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/Parser/cxx0x-attributes.cpp
  clang/test/SemaCXX/attr-deprecated.cpp
  clang/test/SemaCXX/using-if-exists-attr.cpp
  clang/test/SemaCXX/using-if-exists.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -6414,6 +6414,7 @@
   case Decl::Concept:
   case Decl::LifetimeExtendedTemporary:
   case Decl::RequiresExprBody:
+  case Decl::UnresolvedUsingIfExists:
 return C;
 
   // Declaration kinds that don't make any sense here, but are
Index: clang/test/SemaCXX/using-if-exists.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/using-if-exists.cpp
@@ -0,0 +1,193 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only %s -verify
+
+#define UIE [[clang::using_if_exists]]
+
+namespace test_basic {
+namespace NS {}
+
+using NS::x UIE; // expected-note{{using declaration annotated with 'using_if_exists' here}}
+x usex(); // expected-error{{reference to unresolved using declaration}}
+
+using NotNS::x UIE; // expected-error{{use of undeclared identifier 'NotNS'}}
+} // test_basic
+
+namespace test_redecl {
+namespace NS {}
+
+using NS::x UIE;
+using NS::x UIE;
+
+namespace NS1 {}
+namespace NS2 {}
+namespace NS3 {
+int A(); // expected-note{{target of using declaration}}
+struct B {}; // expected-note{{target of using declaration}}
+int C(); // expected-note{{conflicting declaration}}
+struct D {}; // expected-note{{conflicting declaration}}
+}
+
+using NS1::A UIE;
+using NS2::A UIE; // expected-note{{using declaration annotated with 'using_if_exists' here}} expected-note{{conflicting declaration}}
+using NS3::A UIE; // expected-error{{target of using declaration conflicts with declaration already in scope}}
+int i = A(); // expected-error{{reference to unresolved using declaration}}
+
+using NS1::B UIE;
+using NS2::B UIE; // expected-note{{conflicting declaration}} expected-note{{using declaration annotated with 'using_if_exists' here}}
+using NS3::B UIE; // expected-error{{target of using declaration conflicts with declaration already in scope}}
+B myB; // expected-error{{reference to unresolved using declaration}}
+
+using NS3::C UIE;
+using NS2::C UIE; // expected-error{{target of using declaration conflicts with declaration already in scope}} expected-note{{target of using declaration}}
+int j = C();
+
+using NS3::D UIE;
+using NS2::D UIE; // expected-error{{target of using declaration conflicts with declaration already in scope}} expected-note{{target of using declaration}}
+D myD;
+} // test_redecl
+
+namespace test_dependent {
+template 
+struct S : B {
+  using B::mf UIE; // expected-note 3 {{using declaration annotated with 'using_if_exists' here}}
+  using typename B::mt UIE; // expected-note{{using declaration annotated with 'using_if_exists' here}}
+};
+
+struct BaseEmpty {
+};
+struct BaseNonEmpty {
+  void mf();
+  typedef int mt;
+};
+
+void f() {
+  S empty;
+  S nonempty;
+  empty.mf(); // expected-error {{reference to unresolved using declaration}}
+  nonempty.mf();
+  (&empty)->mf(); // expected-error {{reference to unresolved using declaration}}
+  (&nonempty)->mf();
+
+  S::mt y; // expected-error {{reference to unresolved using declaration}}
+  S::mt z;
+
+  S::mf(); // expected-error {{reference to unresolved using declaration}}
+}
+
+template 
+struct Implicit : B {
+  using B::mf UIE; // expected-note {{using declaration annotated with 'using_if_exists' here}}
+  using typename B::mt UIE; // expected-note 2 {{using declaration annotated with 'using_if_exists' here}}
+
+  void use() {
+mf(); // expected-error {{referenc

[PATCH] D90173: [PowerPC] Exploit splat instruction xxsplti32dx in Power10

2020-11-13 Thread Victor Huang via Phabricator via cfe-commits
NeHuang added a comment.

Please clang-format the patch to pass pre-merge checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90173

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


[PATCH] D90871: [Sema] Fold VLAs to constant arrays in a few more contexts

2020-11-13 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a reviewer: efriedma.
erik.pilkington added a comment.

Ping!


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

https://reviews.llvm.org/D90871

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


[PATCH] D91330: [clangd] Ensure we test for compatibility of serialized index format

2020-11-13 Thread dmajor via Phabricator via cfe-commits
dmajor added a comment.

This broke the bots: http://lab.llvm.org:8011/#/builders/109/builds/2682

File 
"/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/clangd/test/lit.site.cfg.py",
 line 35
  config.have_zlib =
^
  SyntaxError: invalid syntax


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91330

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


[PATCH] D91330: [clangd] Ensure we test for compatibility of serialized index format

2020-11-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

should be fixed with 
https://github.com/llvm/llvm-project/commit/8dc2aa0e412171dad5cdc1aa60a92ddcd3800202.
 please let me know if it doesn't work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91330

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


[PATCH] D91279: [PowerPC] DForm instructions should be preferred when using zero register

2020-11-13 Thread Victor Huang via Phabricator via cfe-commits
NeHuang added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCPreEmitPeephole.cpp:417
+
+  // should prefer D-form if LXVX / STXVX uses a ZERO or ZERO8
+  if (MI.getOpcode() == PPC::LXVX || MI.getOpcode() == PPC::STXVX) {

amyk wrote:
> Please capitalize and end with a period for the comments. 
> Is it possible to elaborate a bit more on the comments? In terms of why we 
> were prefer the D-Forms, and why we should not apply the transformation if 
> its a frame index. 
nit: add a period at the end of comment and do the same for other comments. 



Comment at: llvm/lib/Target/PowerPC/PPCPreEmitPeephole.cpp:424
+ MI.getOperand(1).getReg() == PPC::ZERO8)) {
+  MI.setDesc(TII->get(MI.getOpcode() == PPC::STXVX ? PPC::STXV : 
PPC::LXV));
+

run `clang-format` to pass pre-merge checks 



Comment at: llvm/test/CodeGen/PowerPC/VSX-XForm-Scalars.ll:2
 ; RUN: llc < %s -mcpu=pwr8 -mtriple=powerpc64le-unknown-unknown \
-; RUN:   -ppc-vsr-nums-as-vr -ppc-asm-full-reg-names -verify-machineinstrs \
+; RUN:   -ppc-vsr-nums-as-vr -ppc-asm-full-reg-names -verify-machineinstrs \ 
 ; RUN:   | FileCheck %s --check-prefix=CHECK-P8

amyk wrote:
> I think this is an unrelated change. 
+1 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91279

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


[PATCH] D91330: [clangd] Ensure we test for compatibility of serialized index format

2020-11-13 Thread dmajor via Phabricator via cfe-commits
dmajor added a comment.

In D91330#2394415 , @kadircet wrote:

> Looks like it is already green at 
> http://lab.llvm.org:8011/#/builders/109/builds/2693

Yep, I'm seeing the same, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91330

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


[PATCH] D91330: [clangd] Ensure we test for compatibility of serialized index format

2020-11-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Looks like it is already green at 
http://lab.llvm.org:8011/#/builders/109/builds/2693


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91330

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


  1   2   >