[PATCH] D101813: [Driver] Move -print-runtime-dir and -print-resource-dir tests

2021-05-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/print-resource-dir.c:1
+// Test if the -print-resource-dir option is accepted without error.
+// Allow unspecified output because the value of CLANG_RESOURCE_DIR is unknown.

This isn't very useful. You can specify `-resource-dir` and check the output.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101813

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


[PATCH] D101702: [clang-format] Add more support for C# 8 nullables

2021-05-04 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

LGTM. That's great. Thanks for working on this and for the cleanup.




Comment at: clang/lib/Format/FormatTokenLexer.cpp:102
+
+// FIXME: Investigate what token type gives the correct operator priority.
+if (tryMergeTokens(FatArrow, TT_JsFatArrow))

Could you explain in what case the operator precedence may be wrong here?



Comment at: clang/lib/Format/TokenAnnotator.cpp:3195
+// No space before null forgiving '!'.
+if (Right.is(TT_JsNonNullAssertion))
+  return false;

exv wrote:
> curdeius wrote:
> > Should it be renamed to include C#?
> Now that you've mentioned it, I do see that JS also defines an almost 
> duplicate set of null-related operators, including null-propagating, 
> null-coalescing and null-coalescing assignment operators, and clang-format 
> handles them with a different code path than C# 😅. They do have slightly 
> different names, but the way they should be parsed and interpreted is the 
> same, and I think it makes sense to use the same logic and token definitions 
> for both of these languages. This resulted in a lot of special-handling for 
> C# tokens that wasn't necessary being removed too.
> 
> However, renaming them would introduce a lot of noise, so I think I would 
> prefer to do that in a separate commit.
Fair enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101702

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


[PATCH] D100917: [NewPM] Only invalidate modified functions' analyses in CGSCC passes

2021-05-04 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

An unfortunate side-effect of this change is that NewPM uses even more memory. 
tramp3d-v4 is up 20% in max-rss 
(https://llvm-compile-time-tracker.com/compare.php?from=4ef1f90e4d564b872e3598ccef45adb740eb0f0d&to=d14d84af2f5ebb8ae2188ce6884a29a586dc0a40&stat=max-rss)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100917

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


[PATCH] D101766: [TableGen] [Clang] Clean up Options.td and add asserts

2021-05-04 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.

Nice, thank you, Paul!




Comment at: clang/include/clang/Driver/Options.td:1089
+  LangOpts<"DoubleSquareBracketAttributes">,
+  Default,
   PosFlag, NegFlag,

Were you planning to refactor this too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101766

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


[PATCH] D101743: [clangd] Fix hover crash on broken code

2021-05-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 342671.
kadircet added a comment.

- s/x/undefined


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101743

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2438,6 +2438,20 @@
   }
 }
 
+TEST(Hover, NoCrash) {
+  Annotations T(R"cpp(
+/* error-ok */
+template T foo(T);
+
+// Setter variable heuristic might fail if the callexpr is broken.
+struct X { int Y; void [[^setY]](float) { Y = foo(undefined); } };)cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  for (const auto &P : T.points())
+getHover(AST, P, format::getLLVMStyle(), nullptr);
+}
+
 TEST(Hover, DocsFromMostSpecial) {
   Annotations T(R"cpp(
   // doc1
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -505,7 +505,7 @@
   if (auto *CE = llvm::dyn_cast(RHS->IgnoreCasts())) {
 if (CE->getNumArgs() != 1)
   return llvm::None;
-auto *ND = llvm::dyn_cast(CE->getCalleeDecl());
+auto *ND = llvm::dyn_cast_or_null(CE->getCalleeDecl());
 if (!ND || !ND->getIdentifier() || ND->getName() != "move" ||
 !ND->isInStdNamespace())
   return llvm::None;


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2438,6 +2438,20 @@
   }
 }
 
+TEST(Hover, NoCrash) {
+  Annotations T(R"cpp(
+/* error-ok */
+template T foo(T);
+
+// Setter variable heuristic might fail if the callexpr is broken.
+struct X { int Y; void [[^setY]](float) { Y = foo(undefined); } };)cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  for (const auto &P : T.points())
+getHover(AST, P, format::getLLVMStyle(), nullptr);
+}
+
 TEST(Hover, DocsFromMostSpecial) {
   Annotations T(R"cpp(
   // doc1
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -505,7 +505,7 @@
   if (auto *CE = llvm::dyn_cast(RHS->IgnoreCasts())) {
 if (CE->getNumArgs() != 1)
   return llvm::None;
-auto *ND = llvm::dyn_cast(CE->getCalleeDecl());
+auto *ND = llvm::dyn_cast_or_null(CE->getCalleeDecl());
 if (!ND || !ND->getIdentifier() || ND->getName() != "move" ||
 !ND->isInStdNamespace())
   return llvm::None;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101743: [clangd] Fix hover crash on broken code

2021-05-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:2447
+// Setter variable heuristic might fail if the callexpr is broken.
+struct X { int Y; void [[^setY]](float) { Y = foo(x); } };)cpp");
+

hokein wrote:
> IIUC, x refers to an undefined variable right? might be renamed it to 
> `undefine`.
> 
> Instead of creating a new test, maybe add this no-crash test to `TEST(Hover, 
> NoHover) {`, looks like a good fit there.
> IIUC, x refers to an undefined variable right? might be renamed it to 
> undefine.

Done.

> Instead of creating a new test, maybe add this no-crash test to TEST(Hover, 
> NoHover) {, looks like a good fit there.

This produces a hover though. I think we should collect all the cases about 
crash-ness here, independent of whether they produce a hover or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101743

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


[clang] b83b232 - Introduce -Wreserved-identifier

2021-05-04 Thread via cfe-commits

Author: serge-sans-paille
Date: 2021-05-04T11:19:01+02:00
New Revision: b83b23275b745287bf9d3d72a93b593119f53f75

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

LOG: Introduce -Wreserved-identifier

Warn when a declaration uses an identifier that doesn't obey the reserved
identifier rule from C and/or C++.

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

Added: 
clang/test/Sema/reserved-identifier.c
clang/test/Sema/reserved-identifier.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/Decl.h
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/IdentifierTable.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/Decl.cpp
clang/lib/Basic/IdentifierTable.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/Preprocessor/macro-reserved.c
clang/test/Preprocessor/macro-reserved.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 36ceb1bc7cfb5..bb8a28ed236ba 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -67,7 +67,8 @@ Non-comprehensive list of changes in this release
 New Compiler Flags
 --
 
-- ...
+- ``-Wreserved-identifier`` emits warning when user code uses reserved
+  identifiers.
 
 Deprecated Compiler Flags
 -

diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 66dda5c9761ae..020df62755706 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -356,6 +356,10 @@ class NamedDecl : public Decl {
   /// a C++ class.
   bool isCXXInstanceMember() const;
 
+  /// Determine if the declaration obeys the reserved identifier rules of the
+  /// given language.
+  ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const;
+
   /// Determine what kind of linkage this entity has.
   ///
   /// This is not the linkage as defined by the standard or the codegen notion

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 3a7f18b60398b..f6a4fbb1e04c8 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -638,7 +638,8 @@ def : DiagGroup<"sequence-point", [Unsequenced]>;
 // Preprocessor warnings.
 def AmbiguousMacro : DiagGroup<"ambiguous-macro">;
 def KeywordAsMacro : DiagGroup<"keyword-macro">;
-def ReservedIdAsMacro : DiagGroup<"reserved-id-macro">;
+def ReservedIdAsMacro : DiagGroup<"reserved-macro-identifier">;
+def ReservedIdAsMacroAlias : DiagGroup<"reserved-id-macro", 
[ReservedIdAsMacro]>;
 
 // Just silence warnings about -Wstrict-aliasing for now.
 def : DiagGroup<"strict-aliasing=0">;
@@ -801,6 +802,9 @@ def LargeByValueCopy : DiagGroup<"large-by-value-copy">;
 def DuplicateArgDecl : DiagGroup<"duplicate-method-arg">;
 def SignedEnumBitfield : DiagGroup<"signed-enum-bitfield">;
 
+def ReservedIdentifier : DiagGroup<"reserved-identifier",
+[ReservedIdAsMacro]>;
+
 // Unreachable code warning groups.
 //
 //  The goal is make -Wunreachable-code on by default, in -Wall, or at

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 639565feb5766..c3ada2ccebab4 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -379,6 +379,15 @@ def warn_unused_lambda_capture: Warning<"lambda capture %0 
is not "
   "%select{used|required to be captured for this use}1">,
   InGroup, DefaultIgnore;
 
+def warn_reserved_extern_symbol: Warning<
+  "identifier %0 is reserved because %select{"
+  "|" // ReservedIdentifierStatus::NotReserved
+  "it starts with '_' at global scope|"
+  "it starts with '__'|"
+  "it starts with '_' followed by a capital letter|"
+  "it contains '__'}1">,
+  InGroup, DefaultIgnore;
+
 def warn_parameter_size: Warning<
   "%0 is a large (%1 bytes) pass-by-value argument; "
   "pass it by reference instead ?">, InGroup;

diff  --git a/clang/include/clang/Basic/IdentifierTable.h 
b/clang/include/clang/Basic/IdentifierTable.h
index 204a0f0cc0a5d..e074a7d3254cf 100644
--- a/clang/include/clang/Basic/IdentifierTable.h
+++ b/clang/include/clang/Basic/IdentifierTable.h
@@ -40,6 +40,14 @@ class LangOptions;
 class MultiKeywordSelector;
 class SourceLocation;
 
+enum class ReservedIdentifierStatus {
+  NotReserved = 0,
+  StartsWithUnderscoreAtGlobalScope,
+  StartsWithDoubleUnderscore,
+  StartsWithUnderscoreFollowedByCapitalLetter,
+  ContainsDou

[PATCH] D93095: Introduce -Wreserved-identifier

2021-05-04 Thread serge 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 rGb83b23275b74: Introduce -Wreserved-identifier (authored by 
serge-sans-paille).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D93095?vs=341853&id=342681#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93095

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/Basic/IdentifierTable.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/Preprocessor/macro-reserved.c
  clang/test/Preprocessor/macro-reserved.cpp
  clang/test/Sema/reserved-identifier.c
  clang/test/Sema/reserved-identifier.cpp

Index: clang/test/Sema/reserved-identifier.cpp
===
--- /dev/null
+++ clang/test/Sema/reserved-identifier.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify -Wreserved-identifier %s
+
+int foo__bar() { return 0; }// expected-warning {{identifier 'foo__bar' is reserved because it contains '__'}}
+static int _bar() { return 0; } // expected-warning {{identifier '_bar' is reserved because it starts with '_' at global scope}}
+static int _Bar() { return 0; } // expected-warning {{identifier '_Bar' is reserved because it starts with '_' followed by a capital letter}}
+int _barbouille() { return 0; } // expected-warning {{identifier '_barbouille' is reserved because it starts with '_' at global scope}}
+
+void foo(unsigned int _Reserved) { // expected-warning {{identifier '_Reserved' is reserved because it starts with '_' followed by a capital letter}}
+  unsigned int __1 =   // expected-warning {{identifier '__1' is reserved because it starts with '__'}}
+  _Reserved;   // no-warning
+}
+
+// This one is explicitly skipped by -Wreserved-identifier
+void *_; // no-warning
+
+template  constexpr bool __toucan = true; // expected-warning {{identifier '__toucan' is reserved because it starts with '__'}}
+
+template 
+concept _Barbotine = __toucan; // expected-warning {{identifier '_Barbotine' is reserved because it starts with '_' followed by a capital letter}}
+
+template  // expected-warning {{'__' is reserved because it starts with '__'}}
+struct BarbeNoire {};
+
+template  // no-warning
+struct BarbeJaune {};
+
+template  // expected-warning {{'__' is reserved because it starts with '__'}}
+void BarbeRousse() {}
+
+namespace _Barbidur { // expected-warning {{identifier '_Barbidur' is reserved because it starts with '_' followed by a capital letter}}
+
+struct __barbidou {}; // expected-warning {{identifier '__barbidou' is reserved because it starts with '__'}}
+struct _barbidou {};  // no-warning
+
+int __barbouille; // expected-warning {{identifier '__barbouille' is reserved because it starts with '__'}}
+int _barbouille;  // no-warning
+
+int __babar() { return 0; } // expected-warning {{identifier '__babar' is reserved because it starts with '__'}}
+int _babar() { return 0; }  // no-warning
+
+} // namespace _Barbidur
+
+class __barbapapa { // expected-warning {{identifier '__barbapapa' is reserved because it starts with '__'}}
+  void _barbabelle() {} // no-warning
+  int _Barbalala;   // expected-warning {{identifier '_Barbalala' is reserved because it starts with '_' followed by a capital letter}}
+};
+
+enum class __menu { // expected-warning {{identifier '__menu' is reserved because it starts with '__'}}
+  __some,   // expected-warning {{identifier '__some' is reserved because it starts with '__'}}
+  _Other,   // expected-warning {{identifier '_Other' is reserved because it starts with '_' followed by a capital letter}}
+  _other// no-warning
+};
+
+enum _Menu { // expected-warning {{identifier '_Menu' is reserved because it starts with '_' followed by a capital letter}}
+  _OtheR_,   // expected-warning {{identifier '_OtheR_' is reserved because it starts with '_' followed by a capital letter}}
+  _other_// expected-warning {{identifier '_other_' is reserved because it starts with '_' at global scope}}
+};
+
+enum {
+  __some, // expected-warning {{identifier '__some' is reserved because it starts with '__'}}
+  _Other, // expected-warning {{identifier '_Other' is reserved because it starts with '_' followed by a capital letter}}
+  _other  // expected-warning {{identifier '_other' is reserved because it starts with '_' at global scope}}
+};
+
+static union {
+  int _barbeFleurie; // no-warning
+}

[PATCH] D100778: [clang-format] Prevent extraneous space insertion in bitshift operators

2021-05-04 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

@penagos, I'll submit this for you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100778

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


[clang-tools-extra] f800ac8 - [clangd] Fix hover crash on broken code

2021-05-04 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-05-04T11:42:31+02:00
New Revision: f800ac8309417b78c084f2eabfd54d43a66b64a2

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

LOG: [clangd] Fix hover crash on broken code

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

Added: 


Modified: 
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index f9de910835581..c58dab22f8a3e 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -505,7 +505,7 @@ llvm::Optional setterVariableName(const 
CXXMethodDecl *CMD) {
   if (auto *CE = llvm::dyn_cast(RHS->IgnoreCasts())) {
 if (CE->getNumArgs() != 1)
   return llvm::None;
-auto *ND = llvm::dyn_cast(CE->getCalleeDecl());
+auto *ND = llvm::dyn_cast_or_null(CE->getCalleeDecl());
 if (!ND || !ND->getIdentifier() || ND->getName() != "move" ||
 !ND->isInStdNamespace())
   return llvm::None;

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 6624290ec41c5..c2645b99926c3 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2438,6 +2438,20 @@ TEST(Hover, DocsFromAST) {
   }
 }
 
+TEST(Hover, NoCrash) {
+  Annotations T(R"cpp(
+/* error-ok */
+template T foo(T);
+
+// Setter variable heuristic might fail if the callexpr is broken.
+struct X { int Y; void [[^setY]](float) { Y = foo(undefined); } };)cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  for (const auto &P : T.points())
+getHover(AST, P, format::getLLVMStyle(), nullptr);
+}
+
 TEST(Hover, DocsFromMostSpecial) {
   Annotations T(R"cpp(
   // doc1



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


[PATCH] D101743: [clangd] Fix hover crash on broken code

2021-05-04 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 rGf800ac830941: [clangd] Fix hover crash on broken code 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101743

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2438,6 +2438,20 @@
   }
 }
 
+TEST(Hover, NoCrash) {
+  Annotations T(R"cpp(
+/* error-ok */
+template T foo(T);
+
+// Setter variable heuristic might fail if the callexpr is broken.
+struct X { int Y; void [[^setY]](float) { Y = foo(undefined); } };)cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  for (const auto &P : T.points())
+getHover(AST, P, format::getLLVMStyle(), nullptr);
+}
+
 TEST(Hover, DocsFromMostSpecial) {
   Annotations T(R"cpp(
   // doc1
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -505,7 +505,7 @@
   if (auto *CE = llvm::dyn_cast(RHS->IgnoreCasts())) {
 if (CE->getNumArgs() != 1)
   return llvm::None;
-auto *ND = llvm::dyn_cast(CE->getCalleeDecl());
+auto *ND = llvm::dyn_cast_or_null(CE->getCalleeDecl());
 if (!ND || !ND->getIdentifier() || ND->getName() != "move" ||
 !ND->isInStdNamespace())
   return llvm::None;


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2438,6 +2438,20 @@
   }
 }
 
+TEST(Hover, NoCrash) {
+  Annotations T(R"cpp(
+/* error-ok */
+template T foo(T);
+
+// Setter variable heuristic might fail if the callexpr is broken.
+struct X { int Y; void [[^setY]](float) { Y = foo(undefined); } };)cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  for (const auto &P : T.points())
+getHover(AST, P, format::getLLVMStyle(), nullptr);
+}
+
 TEST(Hover, DocsFromMostSpecial) {
   Annotations T(R"cpp(
   // doc1
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -505,7 +505,7 @@
   if (auto *CE = llvm::dyn_cast(RHS->IgnoreCasts())) {
 if (CE->getNumArgs() != 1)
   return llvm::None;
-auto *ND = llvm::dyn_cast(CE->getCalleeDecl());
+auto *ND = llvm::dyn_cast_or_null(CE->getCalleeDecl());
 if (!ND || !ND->getIdentifier() || ND->getName() != "move" ||
 !ND->isInStdNamespace())
   return llvm::None;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101516: Introduce clangd-server-monitor tool

2021-05-04 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 342688.
kbobyrev marked 2 inline comments as done.
kbobyrev added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101516

Files:
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/monitor/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
  clang-tools-extra/clangd/test/CMakeLists.txt
  clang-tools-extra/clangd/test/remote-index/pipeline.test
  clang-tools-extra/clangd/test/remote-index/pipeline_helper.py

Index: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
===
--- clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
+++ clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
@@ -15,9 +15,10 @@
 import sys
 import time
 import threading
+import json
 
 
-def kill_server_after_delay(server_process):
+def kill_process_after_delay(server_process):
   time.sleep(10)
   if server_process.poll() is None:
 server_process.kill()
@@ -30,6 +31,7 @@
   parser.add_argument('--index-file', required=True)
   parser.add_argument('--server-arg', action='append', default=[])
   parser.add_argument('--server-log', nargs='?', type=argparse.FileType('wb'), default=os.devnull)
+  parser.add_argument('--with-monitor', action='store_true')
 
   args = parser.parse_args()
 
@@ -48,7 +50,7 @@
   # This will kill index_server_process if it hangs without printing init
   # message.
   shutdown_thread = threading.Thread(
-  target=kill_server_after_delay, args=(index_server_process,))
+  target=kill_process_after_delay, args=(index_server_process,))
   shutdown_thread.daemon = True
   shutdown_thread.start()
 
@@ -67,6 +69,14 @@
 print('Server initialization failed. Shutting down.', file=sys.stderr)
 sys.exit(1)
 
+  if args.with_monitor:
+print('Running clangd-index-server-monitor...', file=sys.stderr)
+index_server_monitor_process = subprocess.Popen([
+'clangd-index-server-monitor', server_address,
+], stderr=subprocess.PIPE)
+
+index_server_monitor_process.wait()
+
   in_file = open(args.input_file_name)
 
   print('Staring clangd...', file=sys.stderr)
@@ -84,6 +94,11 @@
 args.server_log.write(line)
 args.server_log.flush()
 
+  if args.with_monitor:
+for line in index_server_monitor_process.stderr:
+args.server_log.write(line)
+args.server_log.flush()
+
 
 if __name__ == '__main__':
   main()
Index: clang-tools-extra/clangd/test/remote-index/pipeline.test
===
--- clang-tools-extra/clangd/test/remote-index/pipeline.test
+++ clang-tools-extra/clangd/test/remote-index/pipeline.test
@@ -1,8 +1,13 @@
 # RUN: rm -rf %t
 # RUN: clangd-indexer %S/Inputs/Source.cpp > %t.idx
-# RUN: %python %S/pipeline_helper.py --input-file-name=%s --project-root=%S --index-file=%t.idx | FileCheck %s
+# RUN: %python %S/pipeline_helper.py --with-monitor --input-file-name=%s --project-root=%S --index-file=%t.idx | FileCheck %s
 # REQUIRES: clangd-remote-index
 
+#  CHECK:  "uptime_seconds": "{{.*}}",
+# CHECK-NEXT:  "index_age_seconds": "{{.*}}",
+# CHECK-NEXT:  "index_commit_hash": "{{.*}}",
+# CHECK-NEXT:  "index_link": "{{.*}}"
+
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 #  CHECK:  "id": 0,
 # CHECK-NEXT:  "jsonrpc": "2.0",
Index: clang-tools-extra/clangd/test/CMakeLists.txt
===
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ clang-tools-extra/clangd/test/CMakeLists.txt
@@ -22,7 +22,7 @@
 endif()
 
 if(CLANGD_ENABLE_REMOTE)
-  list(APPEND CLANGD_TEST_DEPS clangd-index-server)
+  list(APPEND CLANGD_TEST_DEPS clangd-index-server clangd-index-server-monitor)
 endif()
 
 foreach(dep FileCheck count not llvm-config)
Index: clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
@@ -0,0 +1,76 @@
+//===--- Monitor.cpp - Request server monitoring information through CLI --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MonitoringService.grpc.pb.h"
+#include "MonitoringService.pb.h"
+
+#include "support/Logger.h"
+#include "clang/Basic/Version.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/Signals.h"
+
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace re

[PATCH] D101516: Introduce clangd-server-monitor tool

2021-05-04 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 342689.
kbobyrev added a comment.

Remove (now) unused Python JSON import.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101516

Files:
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/monitor/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
  clang-tools-extra/clangd/test/CMakeLists.txt
  clang-tools-extra/clangd/test/remote-index/pipeline.test
  clang-tools-extra/clangd/test/remote-index/pipeline_helper.py

Index: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
===
--- clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
+++ clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
@@ -17,7 +17,7 @@
 import threading
 
 
-def kill_server_after_delay(server_process):
+def kill_process_after_delay(server_process):
   time.sleep(10)
   if server_process.poll() is None:
 server_process.kill()
@@ -30,6 +30,7 @@
   parser.add_argument('--index-file', required=True)
   parser.add_argument('--server-arg', action='append', default=[])
   parser.add_argument('--server-log', nargs='?', type=argparse.FileType('wb'), default=os.devnull)
+  parser.add_argument('--with-monitor', action='store_true')
 
   args = parser.parse_args()
 
@@ -48,7 +49,7 @@
   # This will kill index_server_process if it hangs without printing init
   # message.
   shutdown_thread = threading.Thread(
-  target=kill_server_after_delay, args=(index_server_process,))
+  target=kill_process_after_delay, args=(index_server_process,))
   shutdown_thread.daemon = True
   shutdown_thread.start()
 
@@ -67,6 +68,14 @@
 print('Server initialization failed. Shutting down.', file=sys.stderr)
 sys.exit(1)
 
+  if args.with_monitor:
+print('Running clangd-index-server-monitor...', file=sys.stderr)
+index_server_monitor_process = subprocess.Popen([
+'clangd-index-server-monitor', server_address,
+], stderr=subprocess.PIPE)
+
+index_server_monitor_process.wait()
+
   in_file = open(args.input_file_name)
 
   print('Staring clangd...', file=sys.stderr)
@@ -84,6 +93,11 @@
 args.server_log.write(line)
 args.server_log.flush()
 
+  if args.with_monitor:
+for line in index_server_monitor_process.stderr:
+args.server_log.write(line)
+args.server_log.flush()
+
 
 if __name__ == '__main__':
   main()
Index: clang-tools-extra/clangd/test/remote-index/pipeline.test
===
--- clang-tools-extra/clangd/test/remote-index/pipeline.test
+++ clang-tools-extra/clangd/test/remote-index/pipeline.test
@@ -1,8 +1,13 @@
 # RUN: rm -rf %t
 # RUN: clangd-indexer %S/Inputs/Source.cpp > %t.idx
-# RUN: %python %S/pipeline_helper.py --input-file-name=%s --project-root=%S --index-file=%t.idx | FileCheck %s
+# RUN: %python %S/pipeline_helper.py --with-monitor --input-file-name=%s --project-root=%S --index-file=%t.idx | FileCheck %s
 # REQUIRES: clangd-remote-index
 
+#  CHECK:  "uptime_seconds": "{{.*}}",
+# CHECK-NEXT:  "index_age_seconds": "{{.*}}",
+# CHECK-NEXT:  "index_commit_hash": "{{.*}}",
+# CHECK-NEXT:  "index_link": "{{.*}}"
+
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 #  CHECK:  "id": 0,
 # CHECK-NEXT:  "jsonrpc": "2.0",
Index: clang-tools-extra/clangd/test/CMakeLists.txt
===
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ clang-tools-extra/clangd/test/CMakeLists.txt
@@ -22,7 +22,7 @@
 endif()
 
 if(CLANGD_ENABLE_REMOTE)
-  list(APPEND CLANGD_TEST_DEPS clangd-index-server)
+  list(APPEND CLANGD_TEST_DEPS clangd-index-server clangd-index-server-monitor)
 endif()
 
 foreach(dep FileCheck count not llvm-config)
Index: clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
@@ -0,0 +1,76 @@
+//===--- Monitor.cpp - Request server monitoring information through CLI --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MonitoringService.grpc.pb.h"
+#include "MonitoringService.pb.h"
+
+#include "support/Logger.h"
+#include "clang/Basic/Version.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/Signals.h"
+
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace remote {
+namespace {
+
+static constexpr char Overview[] = R"(
+Thi

[clang] 8fa56f7 - [clang-format] Prevent extraneous space insertion in bitshift operators

2021-05-04 Thread Krasimir Georgiev via cfe-commits

Author: Luis Penagos
Date: 2021-05-04T12:28:49+02:00
New Revision: 8fa56f7ededcbe28cbbb810b5d261b72ab0d8035

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

LOG: [clang-format] Prevent extraneous space insertion in bitshift operators

This serves to augment the improvements made in 
https://reviews.llvm.org/D86581. It prevents clang-format from interpreting 
bitshift operators as template arguments in certain circumstances. This is an 
attempt at fixing https://bugs.llvm.org/show_bug.cgi?id=49868

Reviewed By: MyDeveloperDay, krasimir

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 719bb3fdd0665..54b73d6e75bb6 100755
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -116,10 +116,17 @@ class AnnotatingParser {
 while (CurrentToken) {
   if (CurrentToken->is(tok::greater)) {
 // Try to do a better job at looking for ">>" within the condition of
-// a statement.
+// a statement. Conservatively insert spaces between consecutive ">"
+// tokens to prevent splitting right bitshift operators and potentially
+// altering program semantics. This check is overly conservative and
+// will prevent spaces from being inserted in select nested template
+// parameter cases, but should not alter program semantics.
 if (CurrentToken->Next && CurrentToken->Next->is(tok::greater) &&
 Left->ParentBracket != tok::less &&
-isKeywordWithCondition(*Line.First))
+(isKeywordWithCondition(*Line.First) ||
+ CurrentToken->getStartOfNonWhitespace() ==
+ 
CurrentToken->Next->getStartOfNonWhitespace().getLocWithOffset(
+ -1)))
   return false;
 Left->MatchingParen = CurrentToken;
 CurrentToken->MatchingParen = Left;

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 38b4c654f817a..1ba43e3eaf198 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -8007,6 +8007,8 @@ TEST_F(FormatTest, UnderstandsTemplateParameters) {
   verifyFormat("a = 1;", Style);
   verifyFormat("a >>= 1;", Style);
 
+  verifyFormat("test < a | b >> c;");
+  verifyFormat("test> c;");
   verifyFormat("test >> a >> b;");
   verifyFormat("test << a >> b;");
 



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


[PATCH] D100778: [clang-format] Prevent extraneous space insertion in bitshift operators

2021-05-04 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8fa56f7ededc: [clang-format] Prevent extraneous space 
insertion in bitshift operators (authored by penagos, committed by krasimir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100778

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8007,6 +8007,8 @@
   verifyFormat("a = 1;", Style);
   verifyFormat("a >>= 1;", Style);
 
+  verifyFormat("test < a | b >> c;");
+  verifyFormat("test> c;");
   verifyFormat("test >> a >> b;");
   verifyFormat("test << a >> b;");
 
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -116,10 +116,17 @@
 while (CurrentToken) {
   if (CurrentToken->is(tok::greater)) {
 // Try to do a better job at looking for ">>" within the condition of
-// a statement.
+// a statement. Conservatively insert spaces between consecutive ">"
+// tokens to prevent splitting right bitshift operators and potentially
+// altering program semantics. This check is overly conservative and
+// will prevent spaces from being inserted in select nested template
+// parameter cases, but should not alter program semantics.
 if (CurrentToken->Next && CurrentToken->Next->is(tok::greater) &&
 Left->ParentBracket != tok::less &&
-isKeywordWithCondition(*Line.First))
+(isKeywordWithCondition(*Line.First) ||
+ CurrentToken->getStartOfNonWhitespace() ==
+ 
CurrentToken->Next->getStartOfNonWhitespace().getLocWithOffset(
+ -1)))
   return false;
 Left->MatchingParen = CurrentToken;
 CurrentToken->MatchingParen = Left;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8007,6 +8007,8 @@
   verifyFormat("a = 1;", Style);
   verifyFormat("a >>= 1;", Style);
 
+  verifyFormat("test < a | b >> c;");
+  verifyFormat("test> c;");
   verifyFormat("test >> a >> b;");
   verifyFormat("test << a >> b;");
 
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -116,10 +116,17 @@
 while (CurrentToken) {
   if (CurrentToken->is(tok::greater)) {
 // Try to do a better job at looking for ">>" within the condition of
-// a statement.
+// a statement. Conservatively insert spaces between consecutive ">"
+// tokens to prevent splitting right bitshift operators and potentially
+// altering program semantics. This check is overly conservative and
+// will prevent spaces from being inserted in select nested template
+// parameter cases, but should not alter program semantics.
 if (CurrentToken->Next && CurrentToken->Next->is(tok::greater) &&
 Left->ParentBracket != tok::less &&
-isKeywordWithCondition(*Line.First))
+(isKeywordWithCondition(*Line.First) ||
+ CurrentToken->getStartOfNonWhitespace() ==
+ CurrentToken->Next->getStartOfNonWhitespace().getLocWithOffset(
+ -1)))
   return false;
 Left->MatchingParen = CurrentToken;
 CurrentToken->MatchingParen = Left;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101516: Introduce clangd-server-monitor tool

2021-05-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, let's ship it!




Comment at: clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp:15
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/Signals.h"

nit: this is probably not needed now as we dropped formatv



Comment at: clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp:72
+Response.DebugString(), JsonStatus.error_code(),
+JsonStatus.error_message());
+return -1;

nit: i am not sure if this really compiles (was testing it for status-updater 
patch on gcp). as this is a stringpiece, so you might wanna call 
ToString/as_string on it.



Comment at: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py:33
   parser.add_argument('--server-log', nargs='?', type=argparse.FileType('wb'), 
default=os.devnull)
+  parser.add_argument('--with-monitor', action='store_true')
 

nit: as discussed offline this is only to save some runtime on tests that don't 
care about it. I'd probably drop this and add later if we feel the need, but up 
to you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101516

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


[PATCH] D101516: Introduce clangd-server-monitor tool

2021-05-04 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 342692.
kbobyrev marked 3 inline comments as done.
kbobyrev added a comment.

Resolve post-LGTM comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101516

Files:
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/monitor/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
  clang-tools-extra/clangd/test/CMakeLists.txt
  clang-tools-extra/clangd/test/remote-index/pipeline.test
  clang-tools-extra/clangd/test/remote-index/pipeline_helper.py

Index: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
===
--- clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
+++ clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
@@ -17,7 +17,7 @@
 import threading
 
 
-def kill_server_after_delay(server_process):
+def kill_process_after_delay(server_process):
   time.sleep(10)
   if server_process.poll() is None:
 server_process.kill()
@@ -48,7 +48,7 @@
   # This will kill index_server_process if it hangs without printing init
   # message.
   shutdown_thread = threading.Thread(
-  target=kill_server_after_delay, args=(index_server_process,))
+  target=kill_process_after_delay, args=(index_server_process,))
   shutdown_thread.daemon = True
   shutdown_thread.start()
 
@@ -67,6 +67,13 @@
 print('Server initialization failed. Shutting down.', file=sys.stderr)
 sys.exit(1)
 
+  print('Running clangd-index-server-monitor...', file=sys.stderr)
+  index_server_monitor_process = subprocess.Popen([
+  'clangd-index-server-monitor', server_address,
+  ], stderr=subprocess.PIPE)
+
+  index_server_monitor_process.wait()
+
   in_file = open(args.input_file_name)
 
   print('Staring clangd...', file=sys.stderr)
@@ -84,6 +91,10 @@
 args.server_log.write(line)
 args.server_log.flush()
 
+  for line in index_server_monitor_process.stderr:
+args.server_log.write(line)
+args.server_log.flush()
+
 
 if __name__ == '__main__':
   main()
Index: clang-tools-extra/clangd/test/remote-index/pipeline.test
===
--- clang-tools-extra/clangd/test/remote-index/pipeline.test
+++ clang-tools-extra/clangd/test/remote-index/pipeline.test
@@ -1,8 +1,13 @@
 # RUN: rm -rf %t
 # RUN: clangd-indexer %S/Inputs/Source.cpp > %t.idx
-# RUN: %python %S/pipeline_helper.py --input-file-name=%s --project-root=%S --index-file=%t.idx | FileCheck %s
+# RUN: %python %S/pipeline_helper.py --with-monitor --input-file-name=%s --project-root=%S --index-file=%t.idx | FileCheck %s
 # REQUIRES: clangd-remote-index
 
+#  CHECK:  "uptime_seconds": "{{.*}}",
+# CHECK-NEXT:  "index_age_seconds": "{{.*}}",
+# CHECK-NEXT:  "index_commit_hash": "{{.*}}",
+# CHECK-NEXT:  "index_link": "{{.*}}"
+
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 #  CHECK:  "id": 0,
 # CHECK-NEXT:  "jsonrpc": "2.0",
Index: clang-tools-extra/clangd/test/CMakeLists.txt
===
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ clang-tools-extra/clangd/test/CMakeLists.txt
@@ -22,7 +22,7 @@
 endif()
 
 if(CLANGD_ENABLE_REMOTE)
-  list(APPEND CLANGD_TEST_DEPS clangd-index-server)
+  list(APPEND CLANGD_TEST_DEPS clangd-index-server clangd-index-server-monitor)
 endif()
 
 foreach(dep FileCheck count not llvm-config)
Index: clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
@@ -0,0 +1,75 @@
+//===--- Monitor.cpp - Request server monitoring information through CLI --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MonitoringService.grpc.pb.h"
+#include "MonitoringService.pb.h"
+
+#include "support/Logger.h"
+#include "clang/Basic/Version.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Signals.h"
+
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace remote {
+namespace {
+
+static constexpr char Overview[] = R"(
+This tool requests monitoring information (uptime, index freshness) from the
+server and prints it to stdout.
+)";
+
+llvm::cl::opt
+ServerAddress("server-address", llvm::cl::Positional,
+  llvm::cl::desc("Address of the invoked server."),
+  llvm::cl::Required);
+
+} // namespace
+} // namespace remote
+} // namespace clangd
+} // namespace clang
+
+int main(int argc, char *argv[]

[PATCH] D101516: Introduce clangd-server-monitor tool

2021-05-04 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 342693.
kbobyrev added a comment.

Remove leftover --with-monitor from the lit test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101516

Files:
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/monitor/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
  clang-tools-extra/clangd/test/CMakeLists.txt
  clang-tools-extra/clangd/test/remote-index/pipeline.test
  clang-tools-extra/clangd/test/remote-index/pipeline_helper.py

Index: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
===
--- clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
+++ clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
@@ -17,7 +17,7 @@
 import threading
 
 
-def kill_server_after_delay(server_process):
+def kill_process_after_delay(server_process):
   time.sleep(10)
   if server_process.poll() is None:
 server_process.kill()
@@ -48,7 +48,7 @@
   # This will kill index_server_process if it hangs without printing init
   # message.
   shutdown_thread = threading.Thread(
-  target=kill_server_after_delay, args=(index_server_process,))
+  target=kill_process_after_delay, args=(index_server_process,))
   shutdown_thread.daemon = True
   shutdown_thread.start()
 
@@ -67,6 +67,13 @@
 print('Server initialization failed. Shutting down.', file=sys.stderr)
 sys.exit(1)
 
+  print('Running clangd-index-server-monitor...', file=sys.stderr)
+  index_server_monitor_process = subprocess.Popen([
+  'clangd-index-server-monitor', server_address,
+  ], stderr=subprocess.PIPE)
+
+  index_server_monitor_process.wait()
+
   in_file = open(args.input_file_name)
 
   print('Staring clangd...', file=sys.stderr)
@@ -84,6 +91,10 @@
 args.server_log.write(line)
 args.server_log.flush()
 
+  for line in index_server_monitor_process.stderr:
+args.server_log.write(line)
+args.server_log.flush()
+
 
 if __name__ == '__main__':
   main()
Index: clang-tools-extra/clangd/test/remote-index/pipeline.test
===
--- clang-tools-extra/clangd/test/remote-index/pipeline.test
+++ clang-tools-extra/clangd/test/remote-index/pipeline.test
@@ -3,6 +3,11 @@
 # RUN: %python %S/pipeline_helper.py --input-file-name=%s --project-root=%S --index-file=%t.idx | FileCheck %s
 # REQUIRES: clangd-remote-index
 
+#  CHECK:  "uptime_seconds": "{{.*}}",
+# CHECK-NEXT:  "index_age_seconds": "{{.*}}",
+# CHECK-NEXT:  "index_commit_hash": "{{.*}}",
+# CHECK-NEXT:  "index_link": "{{.*}}"
+
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 #  CHECK:  "id": 0,
 # CHECK-NEXT:  "jsonrpc": "2.0",
Index: clang-tools-extra/clangd/test/CMakeLists.txt
===
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ clang-tools-extra/clangd/test/CMakeLists.txt
@@ -22,7 +22,7 @@
 endif()
 
 if(CLANGD_ENABLE_REMOTE)
-  list(APPEND CLANGD_TEST_DEPS clangd-index-server)
+  list(APPEND CLANGD_TEST_DEPS clangd-index-server clangd-index-server-monitor)
 endif()
 
 foreach(dep FileCheck count not llvm-config)
Index: clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
@@ -0,0 +1,75 @@
+//===--- Monitor.cpp - Request server monitoring information through CLI --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MonitoringService.grpc.pb.h"
+#include "MonitoringService.pb.h"
+
+#include "support/Logger.h"
+#include "clang/Basic/Version.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Signals.h"
+
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace remote {
+namespace {
+
+static constexpr char Overview[] = R"(
+This tool requests monitoring information (uptime, index freshness) from the
+server and prints it to stdout.
+)";
+
+llvm::cl::opt
+ServerAddress("server-address", llvm::cl::Positional,
+  llvm::cl::desc("Address of the invoked server."),
+  llvm::cl::Required);
+
+} // namespace
+} // namespace remote
+} // namespace clangd
+} // namespace clang
+
+int main(int argc, char *argv[]) {
+  using namespace clang::clangd::remote;
+  llvm::cl::ParseCommandLineOptions(argc, argv, Overview);
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+
+  const auto Channel =
+  grpc::CreateChannel(ServerA

[clang-tools-extra] 34593ae - Introduce clangd-server-monitor tool

2021-05-04 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2021-05-04T12:48:21+02:00
New Revision: 34593ae9982ad267639893ed4ce41242f9493056

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

LOG: Introduce clangd-server-monitor tool

Reviewed By: kadircet

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

Added: 
clang-tools-extra/clangd/index/remote/monitor/CMakeLists.txt
clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp

Modified: 
clang-tools-extra/clangd/index/remote/CMakeLists.txt
clang-tools-extra/clangd/test/CMakeLists.txt
clang-tools-extra/clangd/test/remote-index/pipeline.test
clang-tools-extra/clangd/test/remote-index/pipeline_helper.py

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/CMakeLists.txt 
b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
index 2aa6e9b6cfa9d..beae5be405e08 100644
--- a/clang-tools-extra/clangd/index/remote/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
@@ -38,6 +38,7 @@ if (CLANGD_ENABLE_REMOTE)
 
   add_subdirectory(marshalling)
   add_subdirectory(server)
+  add_subdirectory(monitor)
 else()
   # Provides a no-op implementation of clangdRemoteIndex.
   add_subdirectory(unimplemented)

diff  --git a/clang-tools-extra/clangd/index/remote/monitor/CMakeLists.txt 
b/clang-tools-extra/clangd/index/remote/monitor/CMakeLists.txt
new file mode 100644
index 0..602cb3e134dd6
--- /dev/null
+++ b/clang-tools-extra/clangd/index/remote/monitor/CMakeLists.txt
@@ -0,0 +1,18 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+add_clang_executable(clangd-index-server-monitor
+  Monitor.cpp
+
+  DEPENDS
+  RemoteIndexServiceProto
+  )
+
+target_link_libraries(clangd-index-server-monitor
+  PRIVATE
+  clangBasic
+  clangdSupport
+
+  MonitoringServiceProto
+  RemoteIndexServiceProto
+  )

diff  --git a/clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp 
b/clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
new file mode 100644
index 0..96451f7764675
--- /dev/null
+++ b/clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
@@ -0,0 +1,75 @@
+//===--- Monitor.cpp - Request server monitoring information through CLI 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MonitoringService.grpc.pb.h"
+#include "MonitoringService.pb.h"
+
+#include "support/Logger.h"
+#include "clang/Basic/Version.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Signals.h"
+
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace remote {
+namespace {
+
+static constexpr char Overview[] = R"(
+This tool requests monitoring information (uptime, index freshness) from the
+server and prints it to stdout.
+)";
+
+llvm::cl::opt
+ServerAddress("server-address", llvm::cl::Positional,
+  llvm::cl::desc("Address of the invoked server."),
+  llvm::cl::Required);
+
+} // namespace
+} // namespace remote
+} // namespace clangd
+} // namespace clang
+
+int main(int argc, char *argv[]) {
+  using namespace clang::clangd::remote;
+  llvm::cl::ParseCommandLineOptions(argc, argv, Overview);
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+
+  const auto Channel =
+  grpc::CreateChannel(ServerAddress, grpc::InsecureChannelCredentials());
+  const auto Stub = clang::clangd::remote::v1::Monitor::NewStub(Channel);
+  grpc::ClientContext Context;
+  Context.set_deadline(std::chrono::system_clock::now() +
+   std::chrono::seconds(10));
+  Context.AddMetadata("version", clang::getClangToolFullVersion("clangd"));
+  const clang::clangd::remote::v1::MonitoringInfoRequest Request;
+  clang::clangd::remote::v1::MonitoringInfoReply Response;
+  const auto Status = Stub->MonitoringInfo(&Context, Request, &Response);
+  if (!Status.ok()) {
+clang::clangd::elog("Can not request monitoring information ({0}): {1}\n",
+Status.error_code(), Status.error_message());
+return -1;
+  }
+  std::string Output;
+  google::protobuf::util::JsonPrintOptions Options;
+  Options.add_whitespace = true;
+  Options.always_print_primitive_fields = true;
+  Options.preserve_proto_field_names = true;
+  const auto JsonStatus =
+  google::protobuf::util::MessageToJsonString(Response, &Output, Options);
+  if (!JsonStatus.ok()) {
+clang::clangd::elog("Can not convert response ({0}) to JSON ({1}): {2}\n",
+Response.DebugString(), JsonStatus.error_code(),
+JsonStatus.error_message().as_string());
+retu

[PATCH] D101516: Introduce clangd-server-monitor tool

2021-05-04 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 rG34593ae9982a: Introduce clangd-server-monitor tool (authored 
by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101516

Files:
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/monitor/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
  clang-tools-extra/clangd/test/CMakeLists.txt
  clang-tools-extra/clangd/test/remote-index/pipeline.test
  clang-tools-extra/clangd/test/remote-index/pipeline_helper.py

Index: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
===
--- clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
+++ clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
@@ -17,7 +17,7 @@
 import threading
 
 
-def kill_server_after_delay(server_process):
+def kill_process_after_delay(server_process):
   time.sleep(10)
   if server_process.poll() is None:
 server_process.kill()
@@ -48,7 +48,7 @@
   # This will kill index_server_process if it hangs without printing init
   # message.
   shutdown_thread = threading.Thread(
-  target=kill_server_after_delay, args=(index_server_process,))
+  target=kill_process_after_delay, args=(index_server_process,))
   shutdown_thread.daemon = True
   shutdown_thread.start()
 
@@ -67,6 +67,13 @@
 print('Server initialization failed. Shutting down.', file=sys.stderr)
 sys.exit(1)
 
+  print('Running clangd-index-server-monitor...', file=sys.stderr)
+  index_server_monitor_process = subprocess.Popen([
+  'clangd-index-server-monitor', server_address,
+  ], stderr=subprocess.PIPE)
+
+  index_server_monitor_process.wait()
+
   in_file = open(args.input_file_name)
 
   print('Staring clangd...', file=sys.stderr)
@@ -84,6 +91,10 @@
 args.server_log.write(line)
 args.server_log.flush()
 
+  for line in index_server_monitor_process.stderr:
+args.server_log.write(line)
+args.server_log.flush()
+
 
 if __name__ == '__main__':
   main()
Index: clang-tools-extra/clangd/test/remote-index/pipeline.test
===
--- clang-tools-extra/clangd/test/remote-index/pipeline.test
+++ clang-tools-extra/clangd/test/remote-index/pipeline.test
@@ -3,6 +3,11 @@
 # RUN: %python %S/pipeline_helper.py --input-file-name=%s --project-root=%S --index-file=%t.idx | FileCheck %s
 # REQUIRES: clangd-remote-index
 
+#  CHECK:  "uptime_seconds": "{{.*}}",
+# CHECK-NEXT:  "index_age_seconds": "{{.*}}",
+# CHECK-NEXT:  "index_commit_hash": "{{.*}}",
+# CHECK-NEXT:  "index_link": "{{.*}}"
+
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 #  CHECK:  "id": 0,
 # CHECK-NEXT:  "jsonrpc": "2.0",
Index: clang-tools-extra/clangd/test/CMakeLists.txt
===
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ clang-tools-extra/clangd/test/CMakeLists.txt
@@ -22,7 +22,7 @@
 endif()
 
 if(CLANGD_ENABLE_REMOTE)
-  list(APPEND CLANGD_TEST_DEPS clangd-index-server)
+  list(APPEND CLANGD_TEST_DEPS clangd-index-server clangd-index-server-monitor)
 endif()
 
 foreach(dep FileCheck count not llvm-config)
Index: clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
@@ -0,0 +1,75 @@
+//===--- Monitor.cpp - Request server monitoring information through CLI --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MonitoringService.grpc.pb.h"
+#include "MonitoringService.pb.h"
+
+#include "support/Logger.h"
+#include "clang/Basic/Version.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Signals.h"
+
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace remote {
+namespace {
+
+static constexpr char Overview[] = R"(
+This tool requests monitoring information (uptime, index freshness) from the
+server and prints it to stdout.
+)";
+
+llvm::cl::opt
+ServerAddress("server-address", llvm::cl::Positional,
+  llvm::cl::desc("Address of the invoked server."),
+  llvm::cl::Required);
+
+} // namespace
+} // namespace remote
+} // namespace clangd
+} // namespace clang
+
+int main(int argc, char *argv[]) {
+  using namespace clang::clangd::remote;
+  llvm::cl::ParseCommandLineOptions(argc, argv, Overview);
+  llvm::sys:

[clang-tools-extra] c2e9baf - [clang-tidy] Fix cppcoreguidelines-pro-type-vararg false positives with __builtin_ms_va_list

2021-05-04 Thread Georgy Komarov via cfe-commits

Author: Georgy Komarov
Date: 2021-05-04T13:49:20+03:00
New Revision: c2e9baf2e8dafe92f57fe4171d4b6a5f50d5999e

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

LOG: [clang-tidy] Fix cppcoreguidelines-pro-type-vararg false positives with 
__builtin_ms_va_list

This commit fixes cppcoreguidelines-pro-type-vararg false positives on
'char *' variables.

The incorrect warnings generated by clang-tidy can be illustrated with
the following minimal example:

```
goid foo(char* in) {
  char *tmp = in;
}
```

The problem is that __builtin_ms_va_list desugared as 'char *', which
leads to false positives.

Fixes bugzilla issue 48042.

Reviewed By: aaron.ballman

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp

Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
index ec0e87ae22c05..b26cd59fd672a 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
@@ -10,6 +10,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/TargetInfo.h"
 
 using namespace clang::ast_matchers;
 
@@ -60,8 +61,45 @@ namespace {
 AST_MATCHER(QualType, isVAList) {
   ASTContext &Context = Finder->getASTContext();
   QualType Desugar = Node.getDesugaredType(Context);
-  return Context.getBuiltinVaListType().getDesugaredType(Context) == Desugar ||
- Context.getBuiltinMSVaListType().getDesugaredType(Context) == Desugar;
+  QualType NodeTy = Node.getUnqualifiedType();
+
+  auto CheckVaList = [](QualType NodeTy, QualType Expected,
+const ASTContext &Context) {
+if (NodeTy == Expected)
+  return true;
+QualType Desugar = NodeTy;
+QualType Ty;
+do {
+  Ty = Desugar;
+  Desugar = Ty.getSingleStepDesugaredType(Context);
+  if (Desugar == Expected)
+return true;
+} while (Desugar != Ty);
+return false;
+  };
+
+  // The internal implementation of __builtin_va_list depends on the target
+  // type. Some targets implements va_list as 'char *' or 'void *'.
+  // In these cases we need to remove all typedefs one by one to check this.
+  using BuiltinVaListKind = TargetInfo::BuiltinVaListKind;
+  BuiltinVaListKind VaListKind = 
Context.getTargetInfo().getBuiltinVaListKind();
+  if (VaListKind == BuiltinVaListKind::CharPtrBuiltinVaList ||
+  VaListKind == BuiltinVaListKind::VoidPtrBuiltinVaList) {
+if (CheckVaList(NodeTy, Context.getBuiltinVaListType(), Context))
+  return true;
+  } else if (Desugar ==
+ Context.getBuiltinVaListType().getDesugaredType(Context)) {
+return true;
+  }
+
+  // We also need to check the implementation of __builtin_ms_va_list in the
+  // same way, because it may 
diff er from the va_list implementation.
+  if (Desugar == Context.getBuiltinMSVaListType().getDesugaredType(Context) &&
+  CheckVaList(NodeTy, Context.getBuiltinMSVaListType(), Context)) {
+return true;
+  }
+
+  return false;
 }
 
 AST_MATCHER_P(AdjustedType, hasOriginalType,

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
new file mode 100644
index 0..9cb82497a3aec
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
@@ -0,0 +1,26 @@
+// Purpose:
+// Ensure that the 'cppcoreguidelines-pro-type-vararg' check works with the
+// built-in va_list on Windows systems.
+
+// REQUIRES: system-windows
+
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-vararg %t
+
+void test_ms_va_list(int a, ...) {
+  __builtin_ms_va_list ap;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type 
va_list; use variadic templates instead
+  __builtin_ms_va_start(ap, a);
+  int b = __builtin_va_arg(ap, int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not use va_arg to define 
c-style vararg functions; use variadic templates instead
+  __builtin_ms_va_end(ap);
+}
+
+void test_typedefs(int a, ...) {
+  typedef __builtin_ms_va_list my_va_list1;
+  my_va_list1 ap1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type 
va_list; use variadic templates instead
+
+  using my_va_list2 = __builtin_ms_va_list;
+  my_va

[PATCH] D101259: [clang-tidy] Fix cppcoreguidelines-pro-type-vararg false positives with __builtin_ms_va_list

2021-05-04 Thread Georgy Komarov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc2e9baf2e8da: [clang-tidy] Fix 
cppcoreguidelines-pro-type-vararg false positives with… (authored by jubnzv).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101259

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
@@ -58,3 +58,11 @@
   (void)__builtin_isinf_sign(0.f);
   (void)__builtin_prefetch(nullptr);
 }
+
+// Some implementations of __builtin_va_list and __builtin_ms_va_list desugared
+// as 'char *' or 'void *'. This test checks whether we are handling this case
+// correctly and not generating false positives.
+void no_false_positive_desugar_va_list(char *in) {
+  char *tmp1 = in;
+  void *tmp2 = in;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
@@ -0,0 +1,26 @@
+// Purpose:
+// Ensure that the 'cppcoreguidelines-pro-type-vararg' check works with the
+// built-in va_list on Windows systems.
+
+// REQUIRES: system-windows
+
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-vararg %t
+
+void test_ms_va_list(int a, ...) {
+  __builtin_ms_va_list ap;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type va_list; use variadic templates instead
+  __builtin_ms_va_start(ap, a);
+  int b = __builtin_va_arg(ap, int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not use va_arg to define c-style vararg functions; use variadic templates instead
+  __builtin_ms_va_end(ap);
+}
+
+void test_typedefs(int a, ...) {
+  typedef __builtin_ms_va_list my_va_list1;
+  my_va_list1 ap1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type va_list; use variadic templates instead
+
+  using my_va_list2 = __builtin_ms_va_list;
+  my_va_list2 ap2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type va_list; use variadic templates instead
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
@@ -10,6 +10,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/TargetInfo.h"
 
 using namespace clang::ast_matchers;
 
@@ -60,8 +61,45 @@
 AST_MATCHER(QualType, isVAList) {
   ASTContext &Context = Finder->getASTContext();
   QualType Desugar = Node.getDesugaredType(Context);
-  return Context.getBuiltinVaListType().getDesugaredType(Context) == Desugar ||
- Context.getBuiltinMSVaListType().getDesugaredType(Context) == Desugar;
+  QualType NodeTy = Node.getUnqualifiedType();
+
+  auto CheckVaList = [](QualType NodeTy, QualType Expected,
+const ASTContext &Context) {
+if (NodeTy == Expected)
+  return true;
+QualType Desugar = NodeTy;
+QualType Ty;
+do {
+  Ty = Desugar;
+  Desugar = Ty.getSingleStepDesugaredType(Context);
+  if (Desugar == Expected)
+return true;
+} while (Desugar != Ty);
+return false;
+  };
+
+  // The internal implementation of __builtin_va_list depends on the target
+  // type. Some targets implements va_list as 'char *' or 'void *'.
+  // In these cases we need to remove all typedefs one by one to check this.
+  using BuiltinVaListKind = TargetInfo::BuiltinVaListKind;
+  BuiltinVaListKind VaListKind = Context.getTargetInfo().getBuiltinVaListKind();
+  if (VaListKind == BuiltinVaListKind::CharPtrBuiltinVaList ||
+  VaListKind == BuiltinVaListKind::VoidPtrBuiltinVaList) {
+if (CheckVaList(NodeTy, Context.getBuiltinVaListType(), Context))
+  return true;
+  } else if (Desugar ==
+ Context.getBuiltinVaListType().getDesugaredType(Context)) {
+return true;
+  }
+
+  // We also need to check the implementation of __builtin_ms_va_list in the
+  // same way, because it may differ from the va_list implementation.
+  if (Desugar == Context.getBuiltinMSVaListType().getDesugaredType(Context) &&
+  CheckVaList(NodeTy, Context.getBuiltinMSVaListType(), Context)) {
+return true;
+  }

[PATCH] D101140: [WebAssembly][CodeGen] IR support for WebAssembly local variables

2021-05-04 Thread Andy Wingo via Phabricator via cfe-commits
wingo updated this revision to Diff 342698.
wingo added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix clang datalayout expectations


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101140

Files:
  clang/lib/Basic/Targets/WebAssembly.h
  clang/test/CodeGen/target-data.c
  llvm/include/llvm/CodeGen/MIRYamlMapping.h
  llvm/include/llvm/CodeGen/TargetFrameLowering.h
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/ir-locals.ll

Index: llvm/test/CodeGen/WebAssembly/ir-locals.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/ir-locals.ll
@@ -0,0 +1,76 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false | FileCheck %s
+
+%i32_cell = type i32 addrspace(1)*
+%i64_cell = type i64 addrspace(1)*
+%f32_cell = type float addrspace(1)*
+%f64_cell = type double addrspace(1)*
+
+define i32 @ir_local_i32(i32 %arg) {
+ ; CHECK-LABEL: ir_local_i32:
+ ; CHECK-NEXT: .functype ir_local_i32 (i32) -> (i32)
+ %retval = alloca i32, addrspace(1)
+ ; CHECK-NEXT: .local i32
+ store i32 %arg, %i32_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ %reloaded = load i32, %i32_cell %retval
+ ; The DAG combiner infers that %reloaded is the same as %arg and
+ ; ultimately causes "local.get 0" to be emitted instead of
+ ; "local.get 1".
+ ; CHECK-NEXT: local.get 0
+ ret i32 %reloaded
+ ; CHECK-NEXT: end_function
+}
+
+define i64 @ir_local_i64(i64 %arg) {
+ ; CHECK-LABEL: ir_local_i64:
+ ; CHECK-NEXT: .functype ir_local_i64 (i64) -> (i64)
+ %retval = alloca i64, addrspace(1)
+ ; CHECK-NEXT: .local i64
+ store i64 %arg, %i64_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ %reloaded = load i64, %i64_cell %retval
+ ; See note in ir_local_i32.
+ ; CHECK-NEXT: local.get 0
+ ret i64 %reloaded
+ ; CHECK-NEXT: end_function
+}
+
+define float @ir_local_f32(float %arg) {
+ ; CHECK-LABEL: ir_local_f32:
+ ; CHECK-NEXT: .functype ir_local_f32 (f32) -> (f32)
+ %retval = alloca float, addrspace(1)
+ ; CHECK-NEXT: .local f32
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ store float %arg, %f32_cell %retval
+ ; See note in ir_local_i32.
+ ; CHECK-NEXT: local.get 0
+ %reloaded = load float, %f32_cell %retval
+ ; CHECK-NEXT: end_function
+ ret float %reloaded
+}
+
+define double @ir_local_f64(double %arg) {
+ ; CHECK-LABEL: ir_local_f64:
+ ; CHECK-NEXT: .functype ir_local_f64 (f64) -> (f64)
+ %retval = alloca double, addrspace(1)
+ ; CHECK-NEXT: .local f64
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ store double %arg, %f64_cell %retval
+ ; CHECK-NEXT: local.get 0
+ %reloaded = load double, %f64_cell %retval
+ ; CHECK-NEXT: end_function
+ ret double %reloaded
+}
+
+define void @ir_unreferenced_local() {
+ ; CHECK-LABEL: ir_unreferenced_local:
+ ; CHECK-NEXT: .functype ir_unreferenced_local () -> ()
+ %unused = alloca i32, addrspace(1)
+ ; CHECK-NEXT: .local i32
+ ret void
+ ; CHECK-NEXT: end_function
+}
Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -120,8 +120,8 @@
 Optional CM, CodeGenOpt::Level OL, bool JIT)
 : LLVMTargetMachine(T,
 TT.isArch64Bit()
-? "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1"
-: "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1",
+? "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1-A0:u"
+: "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1-A0:u",
 TT, CPU, FS, Options, getEffectiveRelocModel(RM, TT),
 getEffectiveCodeModel(CM, CodeModel::Large), OL),
   TLOF(new WebAssemblyTargetObjectFile()) {
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
@@ -72,6 +72,8 @@
 SDCallSeqEnd<[SDTCisVT<0, iPTR>, SDTCisVT<1, iPTR>]>;
 def SDT_WebAssemblyBrTable: SDTypePro

[PATCH] D100934: [clang][modules] Build inferred modules

2021-05-04 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D100934#2733857 , @dexonsmith 
wrote:

> Given that there are four different things being done in this commit, it 
> sounds naively like it should be four separate commits. If the logic is too 
> intertwined to land each of the four pieces separately (certainly possible), 
> can you quickly explain why, to motivate landing them together? (Or maybe 
> there's an NFC refactoring that could be separated as a prep, to make the 
> functional changes more isolated / easy to reason about?)

I think that landing everything together provides more context for people going 
through git log in the future.

If you really think splitting this up would be better, how about this?

1. Fix `AsWritten` for umbrella headers/directories.
2. Add tests to `clang/test/Modules`.
3. Add tests to `clang/test/ClangScanDeps`, make the necessary changes to 
`Tooling/DependencyScanning`, add response file Python script.




Comment at: clang/test/ClangScanDeps/modules-inferred-explicit-build.m:10-12
+// RUN: %S/module-deps-to-rsp.py %t.db --module-name=Inferred > %t.inferred.rsp
+// RUN: %S/module-deps-to-rsp.py %t.db --module-name=System > %t.system.rsp
+// RUN: %S/module-deps-to-rsp.py %t.db --tu-index=0 > %t.tu.rsp

dexonsmith wrote:
> I took me a while to figure out that `.rsp` and `-to-rsp` means "response 
> file". Can we just use `response` (or even `response-file`?) in both cases, 
> or is `.rsp` a well-known extension I'm just not aware of?
> 
> I'm also not sure we want to use this in a test (see my next comment). If 
> it's a useful utility regardless perhaps it could have a home in clang/utils.
The Clang driver already has an option `--rsp-quoting={posix,windows}`, so I 
think the shortcut is somewhat known. I can rename the script to 
`module-deps-to-response-file`, if you think that's clearer. It could be useful 
in general, co moving this  to `clang/utils` sounds fine.



Comment at: clang/test/ClangScanDeps/modules-inferred-explicit-build.m:13-17
+// RUN: %clang @%t.inferred.rsp -pedantic -Werror
+// RUN: %clang @%t.system.rsp -pedantic -Werror
+// RUN: %clang -x objective-c -fsyntax-only %t.dir/modules_cdb_input.cpp \
+// RUN:   -F%S/Inputs/frameworks -fmodules -fimplicit-module-maps \
+// RUN:   -pedantic -Werror @%t.tu.rsp

dexonsmith wrote:
> I feel like the clang invocations that build/use modules should be in 
> `clang/test/Modules`. Two independent things:
> - Can clang build inferred modules explicitly? (tested in clang/test/Modules)
> - Can clang-scan-deps generate deps for inferred modules? (tested in 
> clang/test/ClangScanDeps)
I agree that we should test explicit build of inferred modules in 
`clang/test/Modules` (without `clang-scan-deps`). I'll look into it.

I'm not sure I'd be happy with only checking the dependencies produced by 
`clang-scan-deps` here. Testing that the generated command-line actually works 
is as important IMO, and it will be even more so when we start optimizing the 
command line (stripping out unused header search paths, definitions etc.).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100934

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


[PATCH] D101766: [TableGen] [Clang] Clean up Options.td and add asserts

2021-05-04 Thread Paul C. Anagnostopoulos via Phabricator via cfe-commits
Paul-C-Anagnostopoulos added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1089
+  LangOpts<"DoubleSquareBracketAttributes">,
+  Default,
   PosFlag, NegFlag,

jansvoboda11 wrote:
> Were you planning to refactor this too?
You can't use the paste operator (#) there because c2x is a defvar. Defvars and 
undefined identifiers are taken literally by paste, due to its frequent use in 
forming record and class names.

This behavior is noted in the Programmer's Reference, but I think I will add a 
more prominent note. I wonder if we should change the behavior so defvars are 
treated normally.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101766

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


[PATCH] D101766: [TableGen] [Clang] Clean up Options.td and add asserts

2021-05-04 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1089
+  LangOpts<"DoubleSquareBracketAttributes">,
+  Default,
   PosFlag, NegFlag,

Paul-C-Anagnostopoulos wrote:
> jansvoboda11 wrote:
> > Were you planning to refactor this too?
> You can't use the paste operator (#) there because c2x is a defvar. Defvars 
> and undefined identifiers are taken literally by paste, due to its frequent 
> use in forming record and class names.
> 
> This behavior is noted in the Programmer's Reference, but I think I will add 
> a more prominent note. I wonder if we should change the behavior so defvars 
> are treated normally.
I see. In that case, can you please undo the whitespace change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101766

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


[PATCH] D101630: [HIP] Fix device-only compilation

2021-05-04 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/include/clang/Driver/Options.td:977
   NegFlag>;
+defm hip_bundle_device_output : BoolFOption<"hip-bundle-device-output", 
EmptyKPM, DefaultTrue,
+  PosFlag,

The TableGen marshalling infrastructure (`BoolFOption` et. al.) is only 
intended for flags that map to the `-cc1` frontend and its `CompilerInvocation` 
class. (`EmptyKPM` that disables this mapping shouldn't even exist anymore.)

Since these flags only work on the driver level, use something like this 
instead:

```
def fhip_bundle_device_output : Flag<["-"], "fhip-bundle-device-output">, 
Group;
def fno_hip_bundle_device_output : Flag<["-"], "fno-hip-bundle-device-output">, 
Group, HelpText<"Do not bundle output files of HIP device 
compilation">;
```


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

https://reviews.llvm.org/D101630

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


[PATCH] D101776: Work around an unfortunate macro in the Windows SDK

2021-05-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

> Once accepted I'll need someone to commit the change on my behalf.

Thanks for mentioning this up front! What email address and name would you like 
to have used for attribution on the commit?




Comment at: clang/include/clang/Analysis/CFG.h:1392-1393
 
-  template 
-  void VisitBlockStmts(CALLBACK& O) const {
+  template 
+  void VisitBlockStmts(CALLBACKFN& O) const {
 for (const_iterator I = begin(), E = end(); I != E; ++I)

Good catch on fixing this! I think a better fix would be to change the name 
`CALLBACK` to `Callback` to more closely match our usual naming conventions 
(https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly).
 Keeping it in all caps makes the identifier look like a macro when it isn't 
one. You might as well address the clang-format issue while you're touching the 
code, as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101776

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-05-04 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

I believe everything I pointed out so far has been resolved. I still have one 
more nit about the unit test though (just to not make it fail on some Windows 
setups).

FWIW, given that this is in quite the raw state at the moment, I wonder if we 
should actually keep it out of the list of installed binaries until it reaches 
some kind of MVP state. Once this landed this otherwise gets shipped as part of 
the next clang release and shows up in people's shells.




Comment at: clang/unittests/Interpreter/InterpreterTest.cpp:86
+
+  EXPECT_DEATH((void)Interp->Parse("int var1 = 42;"), "");
+}

You still need a `#ifdef GTEST_HAS_DEATH_TEST` around this (death tests aren't 
supported on some specific setups)


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

https://reviews.llvm.org/D96033

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-05-04 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

(Obviously this should still wait on Richard & John as I think they still have 
unaddressed objections)


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

https://reviews.llvm.org/D96033

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


[clang] d0e3a15 - [clang][cli] NFC: Remove confusing `EmptyKPM` variable

2021-05-04 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-05-04T14:27:57+02:00
New Revision: d0e3a15e36830d0fe6049eb0543f0af5a2e1ad12

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

LOG: [clang][cli] NFC: Remove confusing `EmptyKPM` variable

Added: 


Modified: 
clang/include/clang/Driver/Options.td
llvm/include/llvm/Option/OptParser.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 56e8b76def50..2825fba16ef0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -971,9 +971,9 @@ def fgpu_inline_threshold_EQ : Joined<["-"], 
"fgpu-inline-threshold=">,
 def gpu_instrument_lib_EQ : Joined<["--"], "gpu-instrument-lib=">,
   HelpText<"Instrument device library for HIP, which is a LLVM bitcode 
containing "
   "__cyg_profile_func_enter and __cyg_profile_func_exit">;
-defm gpu_sanitize : BoolFOption<"gpu-sanitize", EmptyKPM, DefaultFalse,
-  PosFlag,
-  NegFlag>;
+def fgpu_sanitize : Flag<["-"], "fgpu-sanitize">, Group,
+  HelpText<"Enable sanitizer for AMDGPU target">;
+def fno_gpu_sanitize : Flag<["-"], "fno-gpu-sanitize">, Group;
 def cuid_EQ : Joined<["-"], "cuid=">, Flags<[CC1Option]>,
   HelpText<"An ID for compilation unit, which should be the same for the same "
"compilation unit but 
diff erent for 
diff erent compilation units. "

diff  --git a/llvm/include/llvm/Option/OptParser.td 
b/llvm/include/llvm/Option/OptParser.td
index 45f092af7166..ad0c1eb7406a 100644
--- a/llvm/include/llvm/Option/OptParser.td
+++ b/llvm/include/llvm/Option/OptParser.td
@@ -152,8 +152,6 @@ class KeyPathAndMacro;
-
 class ImpliedByAnyOf key_paths, code value = "true"> {
   code ImpliedCheck = !foldl("false", key_paths, accumulator, key_path,
  !strconcat(accumulator, " || ", key_path));



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


[PATCH] D101766: [TableGen] [Clang] Clean up Options.td and add asserts

2021-05-04 Thread Paul C. Anagnostopoulos via Phabricator via cfe-commits
Paul-C-Anagnostopoulos added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1089
+  LangOpts<"DoubleSquareBracketAttributes">,
+  Default,
   PosFlag, NegFlag,

jansvoboda11 wrote:
> Paul-C-Anagnostopoulos wrote:
> > jansvoboda11 wrote:
> > > Were you planning to refactor this too?
> > You can't use the paste operator (#) there because c2x is a defvar. Defvars 
> > and undefined identifiers are taken literally by paste, due to its frequent 
> > use in forming record and class names.
> > 
> > This behavior is noted in the Programmer's Reference, but I think I will 
> > add a more prominent note. I wonder if we should change the behavior so 
> > defvars are treated normally.
> I see. In that case, can you please undo the whitespace change?
Sure, but don't we try to avoid over-long lines in .td files, too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101766

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


[PATCH] D95425: Implementation of global.get/set for reftypes in LLVM IR

2021-05-04 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 342708.
pmatos added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix patch submitted to phab...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95425

Files:
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/lib/Basic/Targets/WebAssembly.h
  clang/test/CodeGen/target-data.c
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/include/llvm/Support/MachineValueType.h
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/MachineOperand.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/externref-globalget.ll
  llvm/test/CodeGen/WebAssembly/externref-globalset.ll
  llvm/test/CodeGen/WebAssembly/externref-inttoptr.ll
  llvm/test/CodeGen/WebAssembly/externref-ptrtoint.ll
  llvm/test/CodeGen/WebAssembly/externref-undef.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-load.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
  llvm/test/CodeGen/WebAssembly/funcref-call.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
  llvm/test/CodeGen/WebAssembly/global-get.ll
  llvm/test/CodeGen/WebAssembly/global-set.ll

Index: llvm/test/CodeGen/WebAssembly/global-set.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/global-set.ll
@@ -0,0 +1,57 @@
+; RUN: llc --mtriple=wasm32-unknown-unknown -asm-verbose=false < %s | FileCheck %s
+
+@i32_global = local_unnamed_addr addrspace(1) global i32 undef
+@i64_global = local_unnamed_addr addrspace(1) global i64 undef
+@f32_global = local_unnamed_addr addrspace(1) global float undef
+@f64_global = local_unnamed_addr addrspace(1) global double undef
+
+define void @set_i32_global(i32 %v) {
+; CHECK-LABEL: set_i32_global:
+; CHECK-NEXT: functype   set_i32_global (i32) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set i32_global
+; CHECK-NEXT: end_function
+  store i32 %v, i32 addrspace(1)* @i32_global
+  ret void
+}
+
+define void @set_i64_global(i64 %v) {
+; CHECK-LABEL: set_i64_global:
+; CHECK-NEXT: functype   set_i64_global (i64) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set i64_global
+; CHECK-NEXT: end_function
+  store i64 %v, i64 addrspace(1)* @i64_global
+  ret void
+}
+
+define void @set_f32_global(float %v) {
+; CHECK-LABEL: set_f32_global:
+; CHECK-NEXT: functype   set_f32_global (f32) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set f32_global
+; CHECK-NEXT: end_function
+  store float %v, float addrspace(1)* @f32_global
+  ret void
+}
+
+define void @set_f64_global(double %v) {
+; CHECK-LABEL: set_f64_global:
+; CHECK-NEXT: functype   set_f64_global (f64) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set f64_global
+; CHECK-NEXT: end_function
+  store double %v, double addrspace(1)* @f64_global
+  ret void
+}
+
+;; LLVM doesn't yet declare proper WebAssembly globals for these values,
+;; instead placing them in linear memory.  To fix in a followup.
+; FIXME-CHECK: .globl i32_global
+; FIXME-CHECK: .globaltype i32_global, i32
+; FIXME-CHECK: .globl i64_global
+; FIXME-CHECK: .globaltype i64_global, i64
+; FIXME-CHECK: .globl f32_global
+; FIXME-CHECK: .globaltype f32_global, f32
+; FIXME-CHECK: .globl f64_global
+; FIXME-CHECK: .globaltype f64_global, f64
Index: llvm/test/CodeGen/WebAssembly/global-get.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/global-get.ll
@@ -0,0 +1,54 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false | FileCheck %s
+
+@i32_global = local_unnamed_addr addrspace(1) global i32 undef
+@i64_global = local_unnamed_addr addrspace(1) global i64 undef
+@f32_global = local_unnamed_addr addrspace(1) global float undef
+@f64_global = local_unnamed_addr addrspace(1) global double undef
+
+define i32 @return_i32_global() {
+; CHECK-LABEL: return_i32_global:
+; CHECK-NEXT: functype   return_i32_global () -> (i32)
+; CHECK-NEXT: global.get i32_global
+; CHECK-NEXT: end_function
+  %v = load i32, i32 addrspa

[PATCH] D95425: Implementation of global.get/set for reftypes in LLVM IR

2021-05-04 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 342712.
pmatos added a comment.

Fix patch set... again!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95425

Files:
  clang/lib/Basic/Targets/WebAssembly.cpp
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/include/llvm/Support/MachineValueType.h
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/MachineOperand.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/externref-globalget.ll
  llvm/test/CodeGen/WebAssembly/externref-globalset.ll
  llvm/test/CodeGen/WebAssembly/externref-inttoptr.ll
  llvm/test/CodeGen/WebAssembly/externref-ptrtoint.ll
  llvm/test/CodeGen/WebAssembly/externref-undef.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-load.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
  llvm/test/CodeGen/WebAssembly/funcref-call.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalset.ll

Index: llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
@@ -0,0 +1,20 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define void @set_funcref_global(%funcref %g) {
+  ;; this generates a global.set of @funcref_global
+  store %funcref %g, %funcref addrspace(1)* @funcref_global
+  ret void
+}
+
+; CHECK-LABEL: set_funcref_global:
+; CHECK-NEXT: functype   set_funcref_global (funcref) -> ()
+; CHECK-NEXT: local.get  0
+; CHECK-NEXT: global.set funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
@@ -0,0 +1,19 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define %funcref @return_funcref_global() {
+  ;; this generates a global.get of @funcref_global
+  %ref = load %funcref, %funcref addrspace(1)* @funcref_global
+  ret %funcref %ref
+}
+
+; CHECK-LABEL: return_funcref_global:
+; CHECK-NEXT: .functype   return_funcref_global () -> (funcref)
+; CHECK-NEXT: global.get funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-call.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-call.ll
@@ -0,0 +1,23 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type void ()
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+define void @call_funcref(%funcref %ref) {
+  call addrspace(20) void %ref() 
+  ret void
+}
+
+; CHECK-LABEL: call_funcref:
+; CHECK-NEXT: functype   call_funcref (funcref) -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: call_indirect __funcref_call_table, () -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: ref.null func
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: end_function
+
+; CHECK: .tabletype __funcref_call_table, funcref
Index: llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
@@ -0,0 +1,11 @@
+; RUN: not llc --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types < %s 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
+
+%extern = type opaque
+%externref = type %extern addrspace(10)*
+
+define void @store_extern(%

[clang] 0089583 - [clang][cli][docs] Clarify marshalling infrastructure documentation

2021-05-04 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-05-04T15:16:32+02:00
New Revision: 00895831ab23f4de2713a6ad529ba48773d067c1

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

LOG: [clang][cli][docs] Clarify marshalling infrastructure documentation

Added: 


Modified: 
clang/docs/InternalsManual.rst
clang/include/clang/Driver/Options.td
llvm/include/llvm/Option/OptParser.td

Removed: 




diff  --git a/clang/docs/InternalsManual.rst b/clang/docs/InternalsManual.rst
index c1e45569a816..b5f3e4166d38 100644
--- a/clang/docs/InternalsManual.rst
+++ b/clang/docs/InternalsManual.rst
@@ -576,11 +576,11 @@ Compiler Invocation
 ---
 
 One of the classes provided by the Frontend library is ``CompilerInvocation``,
-which holds information that describe current invocation of the Clang frontend.
-The information typically comes from the command line constructed by the Clang
-driver or from clients performing custom initialization. The data structure is
-split into logical units used by 
diff erent parts of the compiler, for example
-``PreprocessorOptions``, ``LanguageOptions`` or ``CodeGenOptions``.
+which holds information that describe current invocation of the Clang ``-cc1``
+frontend. The information typically comes from the command line constructed by
+the Clang driver or from clients performing custom initialization. The data
+structure is split into logical units used by 
diff erent parts of the compiler,
+for example ``PreprocessorOptions``, ``LanguageOptions`` or ``CodeGenOptions``.
 
 Command Line Interface
 --
@@ -758,12 +758,16 @@ desired.
 Option Marshalling Infrastructure
 -
 
-The option marshalling infrastructure automates the parsing of command line
-arguments into ``CompilerInvocation`` and their generation from
-``CompilerInvocation``. The system replaces lots of repetitive C++ code with
-simple, declarative tablegen annotations and it's being used for the majority 
of
-the ``-cc1`` command line interface. This section provides an overview of the
-system.
+The option marshalling infrastructure automates the parsing of the Clang
+``-cc1`` frontend command line arguments into ``CompilerInvocation`` and their
+generation from ``CompilerInvocation``. The system replaces lots of repetitive
+C++ code with simple, declarative tablegen annotations and it's being used for
+the majority of the ``-cc1`` command line interface. This section provides an
+overview of the system.
+
+**Note:** The marshalling infrastructure is not intended for driver-only
+options. Only options of the ``-cc1`` frontend need to be marshalled to/from
+``CompilerInvocation`` instance.
 
 To read and modify contents of ``CompilerInvocation``, the marshalling system
 uses key paths, which are declared in two steps. First, a tablegen definition
@@ -856,6 +860,10 @@ generated ``Options.inc``? This is specified by the 
``Marshalling`` utilities
 described below. All of them take a key path argument and possibly other
 information required for parsing or generating the command line argument.
 
+**Note:** The marshalling infrastructure is not intended for driver-only
+options. Only options of the ``-cc1`` frontend need to be marshalled to/from
+``CompilerInvocation`` instance.
+
 **Positive Flag**
 
 The key path defaults to ``false`` and is set to ``true`` when the flag is

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2825fba16ef0..e76cfc3ea21f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -394,6 +394,8 @@ class MarshalledFlagRec.
+/// Used for -cc1 frontend options. Driver-only options do not map to
+/// CompilerInvocation.
 multiclass BoolFOption> {
@@ -425,6 +429,8 @@ multiclass BoolFOption.
+// Used for -cc1 frontend options. Driver-only options do not map to
+// CompilerInvocation.
 multiclass BoolGOption> {

diff  --git a/llvm/include/llvm/Option/OptParser.td 
b/llvm/include/llvm/Option/OptParser.td
index ad0c1eb7406a..96014b505d0f 100644
--- a/llvm/include/llvm/Option/OptParser.td
+++ b/llvm/include/llvm/Option/OptParser.td
@@ -144,56 +144,68 @@ class MetaVarName { string MetaVarName = 
name; }
 class Values { string Values = value; }
 class ValuesCode { code ValuesCode = valuecode; }
 
-// Helpers for defining marshalling information.
+// Helpers for defining marshalling information (typically used in Clang's -cc1
+// frontend).
 
+// The key path to the mapped field and the macro prefix for the resulting
+// definition database.
 class KeyPathAndMacro {
   code KeyPath = !strconcat(key_path_prefix, key_path_base);
   code MacroPrefix = macro_prefix;
 }
 
+// Mixin that implies the specified value for the current option when any of 
the
+// giv

[PATCH] D101790: [clang-tidy] Aliasing: Add support for passing the variable into a function by reference.

2021-05-04 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D101790#2734937 , @NoQ wrote:

> +Adam, the original author of bugprone-redundant-branch-condition. Adam, do 
> you have any thoughts regarding the tests regressed by this patch? Are they 
> something we should absolutely keep warning on?

Actually, this checker did not give any false positives whever I tested it on 
several open-source projects. I can agree with the one where the function 
starts another thread which changes its parameter, but the rest, where the 
local variable is mutated after or in the branch I cannot see any reason to 
disappear. Can you tell me an example where these are false positives? Why do 
these warnings disappear?


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

https://reviews.llvm.org/D101790

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


[PATCH] D101640: [clang][patch] Add support for option -fextend-arguments={32,64}: widen integer arguments to int64 in unprototyped function calls

2021-05-04 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Nice, that looks better. I think we can optimize it a tad by introducing an 
enum with two cases and store that in `LangOptions` instead of a 32-bit number.




Comment at: clang/include/clang/Basic/LangOptions.def:417
 
+COMPATIBLE_VALUE_LANGOPT(ExtendIntArgs, 32, 32, 
+   "Controls how scalar integer arguments are extended in 
calls"

Since we're accepting only two values (either `32` or `64`), we can define an 
enum for those values and reduce size of this member from 32 bits to just 1.



Comment at: clang/include/clang/Driver/Options.td:1435
+  Values<"32,64">,
+  MarshallingInfoInt>;
 def fbracket_depth_EQ : Joined<["-"], "fbracket-depth=">, Group, 
Flags<[CoreOption]>;

The `MarshallingInfoEnum` multiclass can be used instead ([[ 
https://clang.llvm.org/docs/InternalsManual.html#option-marshalling-annotations 
| docs ]]).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101640

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


[clang] 64911ee - [OpenCL] Allow pipe as a valid identifier prior to OpenCL 2.0.

2021-05-04 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2021-05-04T14:30:42+01:00
New Revision: 64911eec75bb0c54e40665a2c3f744f046c66a59

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

LOG: [OpenCL] Allow pipe as a valid identifier prior to OpenCL 2.0.

Pipe has not been a reserved keyword in the earlier OpenCL
standards. However we failed to allow its use as an identifier
in the original commit. This issues is fixed now and testing
is improved accordingly.

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

Added: 


Modified: 
clang/lib/Parse/ParseDecl.cpp
clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl

Removed: 




diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index eb567f528a1cd..b56f3934fcedf 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -3930,6 +3930,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
 // OpenCL 2.0 and later define this keyword. OpenCL 1.2 and earlier
 // should support the "pipe" word as identifier.
 Tok.getIdentifierInfo()->revertTokenIDToIdentifier();
+Tok.setKind(tok::identifier);
 goto DoneWithDeclSpec;
   }
   isInvalid = DS.SetTypePipe(true, Loc, PrevSpec, DiagID, Policy);

diff  --git a/clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl 
b/clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
index 441a24cf85227..557c191f64076 100644
--- a/clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
+++ b/clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
@@ -1,3 +1,9 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
 
-void foo(read_only pipe int p); // expected-error {{expected parameter 
declarator}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+void foo(read_only pipe int p);
+// expected-warning@-1 {{type specifier missing, defaults to 'int'}}
+// expected-error@-2 {{access qualifier can only be used for pipe and image 
type}}
+// expected-error@-3 {{expected ')'}} expected-note@-3 {{to match this '('}}
+
+// 'pipe' should be accepted as an identifier.
+typedef int pipe;



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


[PATCH] D101052: [OpenCL] Allow pipe as a valid identifier prior to OpenCL 2.0

2021-05-04 Thread Anastasia Stulova 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 rG64911eec75bb: [OpenCL] Allow pipe as a valid identifier 
prior to OpenCL 2.0. (authored by Anastasia).
Herald added a subscriber: ldrumm.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101052

Files:
  clang/lib/Parse/ParseDecl.cpp
  clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl


Index: clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
@@ -1,3 +1,9 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
 
-void foo(read_only pipe int p); // expected-error {{expected parameter 
declarator}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+void foo(read_only pipe int p);
+// expected-warning@-1 {{type specifier missing, defaults to 'int'}}
+// expected-error@-2 {{access qualifier can only be used for pipe and image 
type}}
+// expected-error@-3 {{expected ')'}} expected-note@-3 {{to match this '('}}
+
+// 'pipe' should be accepted as an identifier.
+typedef int pipe;
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -3930,6 +3930,7 @@
 // OpenCL 2.0 and later define this keyword. OpenCL 1.2 and earlier
 // should support the "pipe" word as identifier.
 Tok.getIdentifierInfo()->revertTokenIDToIdentifier();
+Tok.setKind(tok::identifier);
 goto DoneWithDeclSpec;
   }
   isInvalid = DS.SetTypePipe(true, Loc, PrevSpec, DiagID, Policy);


Index: clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
@@ -1,3 +1,9 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
 
-void foo(read_only pipe int p); // expected-error {{expected parameter declarator}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+void foo(read_only pipe int p);
+// expected-warning@-1 {{type specifier missing, defaults to 'int'}}
+// expected-error@-2 {{access qualifier can only be used for pipe and image type}}
+// expected-error@-3 {{expected ')'}} expected-note@-3 {{to match this '('}}
+
+// 'pipe' should be accepted as an identifier.
+typedef int pipe;
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -3930,6 +3930,7 @@
 // OpenCL 2.0 and later define this keyword. OpenCL 1.2 and earlier
 // should support the "pipe" word as identifier.
 Tok.getIdentifierInfo()->revertTokenIDToIdentifier();
+Tok.setKind(tok::identifier);
 goto DoneWithDeclSpec;
   }
   isInvalid = DS.SetTypePipe(true, Loc, PrevSpec, DiagID, Policy);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101776: Work around an unfortunate macro in the Windows SDK

2021-05-04 Thread Zachary Henkel via Phabricator via cfe-commits
zahen updated this revision to Diff 342715.
zahen added a comment.

Updated the macro based on Aaron's suggestion.  clang-formatted the function.


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

https://reviews.llvm.org/D101776

Files:
  clang/include/clang/Analysis/CFG.h


Index: clang/include/clang/Analysis/CFG.h
===
--- clang/include/clang/Analysis/CFG.h
+++ clang/include/clang/Analysis/CFG.h
@@ -1389,13 +1389,12 @@
   // Member templates useful for various batch operations over CFGs.
   
//======//
 
-  template 
-  void VisitBlockStmts(CALLBACK& O) const {
+  template  void VisitBlockStmts(Callback &O) const {
 for (const_iterator I = begin(), E = end(); I != E; ++I)
   for (CFGBlock::const_iterator BI = (*I)->begin(), BE = (*I)->end();
BI != BE; ++BI) {
 if (Optional stmt = BI->getAs())
-  O(const_cast(stmt->getStmt()));
+  O(const_cast(stmt->getStmt()));
   }
   }
 


Index: clang/include/clang/Analysis/CFG.h
===
--- clang/include/clang/Analysis/CFG.h
+++ clang/include/clang/Analysis/CFG.h
@@ -1389,13 +1389,12 @@
   // Member templates useful for various batch operations over CFGs.
   //======//
 
-  template 
-  void VisitBlockStmts(CALLBACK& O) const {
+  template  void VisitBlockStmts(Callback &O) const {
 for (const_iterator I = begin(), E = end(); I != E; ++I)
   for (CFGBlock::const_iterator BI = (*I)->begin(), BE = (*I)->end();
BI != BE; ++BI) {
 if (Optional stmt = BI->getAs())
-  O(const_cast(stmt->getStmt()));
+  O(const_cast(stmt->getStmt()));
   }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101776: Work around an unfortunate macro in the Windows SDK

2021-05-04 Thread Zachary Henkel via Phabricator via cfe-commits
zahen added a comment.

In D101776#2736003 , @aaron.ballman 
wrote:

>> Once accepted I'll need someone to commit the change on my behalf.
>
> Thanks for mentioning this up front! What email address and name would you 
> like to have used for attribution on the commit?

Zachary Henkel, za...@microsoft.com (GitHub username ZacharyHenkel)


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

https://reviews.llvm.org/D101776

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


[PATCH] D95425: Implementation of global.get/set for reftypes in LLVM IR

2021-05-04 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 342718.
pmatos added a comment.

Fix broken merge of table ins reordering commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95425

Files:
  clang/lib/Basic/Targets/WebAssembly.cpp
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/include/llvm/Support/MachineValueType.h
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/MachineOperand.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/externref-globalget.ll
  llvm/test/CodeGen/WebAssembly/externref-globalset.ll
  llvm/test/CodeGen/WebAssembly/externref-inttoptr.ll
  llvm/test/CodeGen/WebAssembly/externref-ptrtoint.ll
  llvm/test/CodeGen/WebAssembly/externref-undef.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-load.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
  llvm/test/CodeGen/WebAssembly/funcref-call.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalset.ll

Index: llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
@@ -0,0 +1,20 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define void @set_funcref_global(%funcref %g) {
+  ;; this generates a global.set of @funcref_global
+  store %funcref %g, %funcref addrspace(1)* @funcref_global
+  ret void
+}
+
+; CHECK-LABEL: set_funcref_global:
+; CHECK-NEXT: functype   set_funcref_global (funcref) -> ()
+; CHECK-NEXT: local.get  0
+; CHECK-NEXT: global.set funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
@@ -0,0 +1,19 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define %funcref @return_funcref_global() {
+  ;; this generates a global.get of @funcref_global
+  %ref = load %funcref, %funcref addrspace(1)* @funcref_global
+  ret %funcref %ref
+}
+
+; CHECK-LABEL: return_funcref_global:
+; CHECK-NEXT: .functype   return_funcref_global () -> (funcref)
+; CHECK-NEXT: global.get funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-call.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-call.ll
@@ -0,0 +1,23 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type void ()
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+define void @call_funcref(%funcref %ref) {
+  call addrspace(20) void %ref() 
+  ret void
+}
+
+; CHECK-LABEL: call_funcref:
+; CHECK-NEXT: functype   call_funcref (funcref) -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: call_indirect __funcref_call_table, () -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: ref.null func
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: end_function
+
+; CHECK: .tabletype __funcref_call_table, funcref
Index: llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
@@ -0,0 +1,11 @@
+; RUN: not llc --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types < %s 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
+
+%extern = type opaque
+%externref = type %extern addrspace(10)*
+
+def

[PATCH] D101608: [WebAssembly] Support for WebAssembly globals in LLVM IR

2021-05-04 Thread Andy Wingo via Phabricator via cfe-commits
wingo updated this revision to Diff 342719.
wingo added a comment.

Rebase on main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101608

Files:
  clang/lib/Basic/Targets/WebAssembly.h
  clang/test/CodeGen/target-data.c
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/global-get.ll
  llvm/test/CodeGen/WebAssembly/global-set.ll

Index: llvm/test/CodeGen/WebAssembly/global-set.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/global-set.ll
@@ -0,0 +1,57 @@
+; RUN: llc --mtriple=wasm32-unknown-unknown -asm-verbose=false < %s | FileCheck %s
+
+@i32_global = local_unnamed_addr addrspace(1) global i32 undef
+@i64_global = local_unnamed_addr addrspace(1) global i64 undef
+@f32_global = local_unnamed_addr addrspace(1) global float undef
+@f64_global = local_unnamed_addr addrspace(1) global double undef
+
+define void @set_i32_global(i32 %v) {
+; CHECK-LABEL: set_i32_global:
+; CHECK-NEXT: functype   set_i32_global (i32) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set i32_global
+; CHECK-NEXT: end_function
+  store i32 %v, i32 addrspace(1)* @i32_global
+  ret void
+}
+
+define void @set_i64_global(i64 %v) {
+; CHECK-LABEL: set_i64_global:
+; CHECK-NEXT: functype   set_i64_global (i64) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set i64_global
+; CHECK-NEXT: end_function
+  store i64 %v, i64 addrspace(1)* @i64_global
+  ret void
+}
+
+define void @set_f32_global(float %v) {
+; CHECK-LABEL: set_f32_global:
+; CHECK-NEXT: functype   set_f32_global (f32) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set f32_global
+; CHECK-NEXT: end_function
+  store float %v, float addrspace(1)* @f32_global
+  ret void
+}
+
+define void @set_f64_global(double %v) {
+; CHECK-LABEL: set_f64_global:
+; CHECK-NEXT: functype   set_f64_global (f64) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set f64_global
+; CHECK-NEXT: end_function
+  store double %v, double addrspace(1)* @f64_global
+  ret void
+}
+
+;; LLVM doesn't yet declare proper WebAssembly globals for these values,
+;; instead placing them in linear memory.  To fix in a followup.
+; FIXME-CHECK: .globl i32_global
+; FIXME-CHECK: .globaltype i32_global, i32
+; FIXME-CHECK: .globl i64_global
+; FIXME-CHECK: .globaltype i64_global, i64
+; FIXME-CHECK: .globl f32_global
+; FIXME-CHECK: .globaltype f32_global, f32
+; FIXME-CHECK: .globl f64_global
+; FIXME-CHECK: .globaltype f64_global, f64
Index: llvm/test/CodeGen/WebAssembly/global-get.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/global-get.ll
@@ -0,0 +1,54 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false | FileCheck %s
+
+@i32_global = local_unnamed_addr addrspace(1) global i32 undef
+@i64_global = local_unnamed_addr addrspace(1) global i64 undef
+@f32_global = local_unnamed_addr addrspace(1) global float undef
+@f64_global = local_unnamed_addr addrspace(1) global double undef
+
+define i32 @return_i32_global() {
+; CHECK-LABEL: return_i32_global:
+; CHECK-NEXT: functype   return_i32_global () -> (i32)
+; CHECK-NEXT: global.get i32_global
+; CHECK-NEXT: end_function
+  %v = load i32, i32 addrspace(1)* @i32_global
+  ret i32 %v
+}
+
+define i64 @return_i64_global() {
+; CHECK-LABEL: return_i64_global:
+; CHECK-NEXT: functype   return_i64_global () -> (i64)
+; CHECK-NEXT: global.get i64_global
+; CHECK-NEXT: end_function
+  %v = load i64, i64 addrspace(1)* @i64_global
+  ret i64 %v
+}
+
+define float @return_f32_global() {
+; CHECK-LABEL: return_f32_global:
+; CHECK-NEXT: functype   return_f32_global () -> (f32)
+; CHECK-NEXT: global.get f32_global
+; CHECK-NEXT: end_function
+  %v = load float, float addrspace(1)* @f32_global
+  ret float %v
+}
+
+define double @return_f64_global() {
+; CHECK-LABEL: return_f64_global:
+; CHECK-NEXT: functype   return_f64_global () -> (f64)
+; CHECK-NEXT: global.get f64_global
+; CHECK-NEXT: end_function
+  %v = load double, double addrspace(1)* @f64_global
+  ret double %v
+}
+
+
+;; LLVM doesn't yet declare proper WebAssembly globals for these values,
+;; instead placing them in linear memory.  To fix in a followup.
+; FIXME-CHECK: .globl i32_global
+; FIXME-CHECK: .globaltype i32_global, i32
+; FIXME-CHECK: .globl i64_global
+; FIXME-CHECK: .globaltype i64_global, i64
+; FIXME-CHECK: .globl f32_global
+; FIXME-CHECK: .globaltype f32_global, f32
+; FIXME-CHECK: .globl f64_global
+; FIXME-CHECK: .globaltype f64_global, f64
Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp

[PATCH] D101832: [clang] accept -fsanitize-ignorelist= in addition to -fsanitize-blacklist=

2021-05-04 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: clang/include/clang/Driver/Options.td:1524
+  Alias,
+  HelpText<"Deprecated, use -fsanitize-coverage-ignorelist= instead">;
 def fsanitize_memory_track_origins_EQ : Joined<["-"], 
"fsanitize-memory-track-origins=">,

Should the aliases above also have "Deprecated' in their help texts?


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

https://reviews.llvm.org/D101832

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


[PATCH] D101832: [clang] accept -fsanitize-ignorelist= in addition to -fsanitize-blacklist=

2021-05-04 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Thanks!


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

https://reviews.llvm.org/D101832

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


[clang] db210bc - [Matrix] Implement C-style explicit type conversions in CXX for matrix types

2021-05-04 Thread Florian Hahn via cfe-commits

Author: Saurabh Jha
Date: 2021-05-04T15:27:57+01:00
New Revision: db210bc69bb50979fb843b68fcb71a9c905e971b

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

LOG: [Matrix] Implement C-style explicit type conversions in CXX for matrix 
types

This patch implements C-style explicit type conversions in CXX for matrix 
types. It is part of fixing https://bugs.llvm.org/show_bug.cgi?id=47141

Reviewed By: fhahn

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

Added: 
clang/test/CodeGenCXX/matrix-casts.cpp

Modified: 
clang/lib/Sema/SemaCast.cpp
clang/test/SemaCXX/matrix-casts.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index d347975e1341b..8a9ee1a309941 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -2648,6 +2648,13 @@ void CastOperation::CheckCXXCStyleCast(bool 
FunctionalStyle,
   return;
   }
 
+  if (DestType->getAs() ||
+  SrcExpr.get()->getType()->getAs()) {
+if (Self.CheckMatrixCast(OpRange, DestType, SrcExpr.get()->getType(), 
Kind))
+  SrcExpr = ExprError();
+return;
+  }
+
   // AltiVec vector initialization with a single literal.
   if (const VectorType *vecTy = DestType->getAs())
 if (vecTy->getVectorKind() == VectorType::AltiVecVector

diff  --git a/clang/test/CodeGenCXX/matrix-casts.cpp 
b/clang/test/CodeGenCXX/matrix-casts.cpp
new file mode 100644
index 0..26fd77fd26f60
--- /dev/null
+++ b/clang/test/CodeGenCXX/matrix-casts.cpp
@@ -0,0 +1,175 @@
+// RUN: %clang_cc1 -std=c++11 -fenable-matrix -triple x86_64-apple-darwin %s 
-emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
+template 
+using matrix_4_4 = X __attribute__((matrix_type(4, 4)));
+
+template 
+using matrix_5_5 = Y __attribute__((matrix_type(5, 5)));
+
+// CHECK-LABEL: define{{.*}} void @_Z19CastCharMatrixToIntv
+void CastCharMatrixToInt() {
+  // CHECK: [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
+  // CHECK-NEXT: [[CONV:%.*]] = sext <25 x i8> [[C]] to <25 x i32>
+  // CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i32]* {{.*}} to <25 x i32>*
+  // CHECK-NEXT: store <25 x i32> [[CONV]], <25 x i32>* [[CONV1]], align 4
+
+  matrix_5_5 c;
+  matrix_5_5 i;
+  i = (matrix_5_5)c;
+}
+
+// CHECK-LABEL: define{{.*}} void @_Z27CastCharMatrixToUnsignedIntv
+void CastCharMatrixToUnsignedInt() {
+  // CHECK:   [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
+  // CHECK-NEXT:  [[CONV:%.*]] = sext <25 x i8> [[C]] to <25 x i32>
+  // CHECK-NEXT:  [[CONV1:%.*]] = bitcast [25 x i32]* {{.*}} to <25 x i32>*
+  // CHECK-NEXT:  store <25 x i32> [[CONV]], <25 x i32>* [[CONV1]], align 4
+  // CHECK-NEXT:  ret void
+
+  matrix_5_5 c;
+  matrix_5_5 u;
+  u = (matrix_5_5)c;
+}
+
+// CHECK-LABEL: define{{.*}} void @_Z32CastUnsignedLongIntMatrixToShortv
+void CastUnsignedLongIntMatrixToShort() {
+  // CHECK:  [[U:%.*]] = load <25 x i64>, <25 x i64>* {{.*}}, align 8
+  // CHECK-NEXT: [[CONV:%.*]] = trunc <25 x i64> {{.*}} to <25 x i16>
+  // CHECK-NEXT: [[CONV1:%.*]] = bitcast [25 x i16]* {{.*}} to <25 x i16>*
+  // CHECK-NEXT: store <25 x i16> [[CONV]], <25 x i16>* [[CONV1]], align 2
+  // CHECK-NEXT: ret void
+
+  matrix_5_5 u;
+  matrix_5_5 s;
+  s = (matrix_5_5)u;
+}
+
+// CHECK-LABEL: define{{.*}} void @_Z20CastIntMatrixToShortv()
+void CastIntMatrixToShort() {
+  // CHECK:   [[I:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:  [[CONV:%.*]] = trunc <25 x i32> [[I]] to <25 x i16>
+  // CHECK-NEXT:  [[CONV1:%.*]] = bitcast [25 x i16]* {{.*}} to <25 x i16>*
+  // CHECK-NEXT:  store <25 x i16> [[CONV]], <25 x i16>* [[CONV1]], align 2
+  // CHECK-NEXT:  ret void
+
+  matrix_5_5 i;
+  matrix_5_5 s;
+  s = (matrix_5_5)i;
+}
+
+// CHECK-LABEL: define{{.*}} void @_Z20CastIntMatrixToFloatv()
+void CastIntMatrixToFloat() {
+  // CHECK:   [[I:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:  [[CONV]] = sitofp <25 x i32> {{.*}} to <25 x float>
+  // CHECK-NEXT:  [[CONV1]] = bitcast [25 x float]* {{.*}} to <25 x float>*
+  // CHECK-NEXT:  store <25 x float> [[CONV]], <25 x float>* [[CONV1]], align 4
+  // CHECK-NEXT:  ret void
+
+  matrix_5_5 i;
+  matrix_5_5 f;
+  f = (matrix_5_5)i;
+}
+
+// CHECK-LABEL: define{{.*}} void @_Z28CastUnsignedIntMatrixToFloatv()
+void CastUnsignedIntMatrixToFloat() {
+  // CHECK:   [[U:%.*]] = load <25 x i16>, <25 x i16>* {{.*}}, align 2
+  // CHECK-NEXT:  [[CONV:%.*]] = uitofp <25 x i16> [[U]] to <25 x float>
+  // CHECK-NEXT:  [[CONV1:%.*]] = bitcast [25 x float]* {{.*}} to <25 x float>*
+  // CHECK-NEXT:  store <25 x float> [[CONV]], <25 x float>* {{.*}}, align 4
+  // CHECK-NEXT:  ret void
+
+  matrix_5_5 u;
+  matrix_5_5 f;
+  f = (matrix_5_5)u;
+}
+
+// CHECK-LABEL: define{{.*}} void @_Z21CastDoubleMatrixT

[PATCH] D101696: [Matrix] Implement C-style explicit type conversions in CXX for matrix types

2021-05-04 Thread Florian Hahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdb210bc69bb5: [Matrix] Implement C-style explicit type 
conversions in CXX for matrix types (authored by SaurabhJha, committed by 
fhahn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101696

Files:
  clang/lib/Sema/SemaCast.cpp
  clang/test/CodeGenCXX/matrix-casts.cpp
  clang/test/SemaCXX/matrix-casts.cpp

Index: clang/test/SemaCXX/matrix-casts.cpp
===
--- clang/test/SemaCXX/matrix-casts.cpp
+++ clang/test/SemaCXX/matrix-casts.cpp
@@ -14,7 +14,6 @@
 typedef int vec __attribute__((vector_size(4)));
 
 void f1() {
-  // TODO: Update this test once the support of C-style casts for C++ is implemented.
   matrix_4_4 m1;
   matrix_4_4 m2;
   matrix_4_4 m3;
@@ -23,45 +22,46 @@
   vec v;
   test_struct *s;
 
-  (matrix_4_4)m1;   // expected-error {{C-style cast from 'matrix_4_4' (aka 'char __attribute__((matrix_type(4, \
-4)))') to 'matrix_4_4' (aka 'int __attribute__((matrix_type(4, 4)))') is not allowed}}
-  (matrix_4_4)m2; // expected-error {{C-style cast from 'matrix_4_4' (aka 'int __attribute__((matrix_type(4, \
-4)))') to 'matrix_4_4' (aka 'short __attribute__((matrix_type(4, 4)))') is not allowed}}
-  (matrix_5_5)m3;   // expected-error {{C-style cast from 'matrix_4_4' (aka 'short __attribute__((matrix_type(4, \
-4)))') to 'matrix_5_5' (aka 'int __attribute__((matrix_type(5, 5)))') is not allowed}}
+  m2 = (matrix_4_4)m1;
+  m2 = m1; // expected-error {{assigning to 'matrix_4_4' from incompatible type 'matrix_4_4'}}
+  m3 = (matrix_4_4)m2;
+  (matrix_5_5)m3; // expected-error {{conversion between matrix types 'matrix_5_5' (aka 'int __attribute__\
+((matrix_type(5, 5)))') and 'matrix_4_4' (aka 'short __attribute__((matrix_type(4, 4)))') of different size is not\
+ allowed}}
 
-  (int)m3;// expected-error {{C-style cast from 'matrix_4_4' (aka 'short __attribute__((matrix_type(4, \
-4)))') to 'int'}}
-  (matrix_4_4)i; // expected-error {{C-style cast from 'int' to 'matrix_4_4' (aka 'int __attribute__((\
-matrix_type(4, 4)))') is not allowed}}
+  (int)m3;// expected-error {{conversion between matrix type 'matrix_4_4' (aka 'short __attribute__\
+((matrix_type(4, 4)))') and incompatible type 'int' is not allowed}}
+  (matrix_4_4)i; // expected-error {{conversion between matrix type 'matrix_4_4' (aka 'int __attribute__\
+((matrix_type(4, 4)))') and incompatible type 'int' is not allowed}}
 
-  (vec) m2;// expected-error {{C-style cast from 'matrix_4_4' (aka 'int __attribute__((matrix_type(4, 4)))') \
-to 'vec' (vector of 1 'int' value) is not allowed}}
-  (matrix_4_4)v; // expected-error {{C-style cast from 'vec' (vector of 1 'int' value) to 'matrix_4_4' \
-(aka 'char __attribute__((matrix_type(4, 4)))') is not allowed}}
+  (vec) m2;// expected-error {{conversion between matrix type 'matrix_4_4' (aka 'int __attribute__\
+((matrix_type(4, 4)))') and incompatible type 'vec' (vector of 1 'int' value) is not allowed}}
+  (matrix_4_4)v; // expected-error {{conversion between matrix type 'matrix_4_4' (aka 'char __attribute__\
+((matrix_type(4, 4)))') and incompatible type 'vec' (vector of 1 'int' value) is not allowed}}
 
-  (test_struct *)m1;// expected-error {{cannot cast from type 'matrix_4_4' (aka 'char __attribute__\
-((matrix_type(4, 4)))') to pointer type 'test_struct *}}'
-  (matrix_5_5)s; // expected-error {{C-style cast from 'test_struct *' to 'matrix_5_5' (aka 'float __attribute__\
-((matrix_type(5, 5)))') is not allowed}}'
+  (test_struct *)m1;// expected-error {{conversion between matrix type 'matrix_4_4' (aka 'char __attribute__\
+((matrix_type(4, 4)))') and incompatible type 'test_struct *' is not allowed}}'
+  (matrix_5_5)s; // expected-error {{conversion between matrix type 'matrix_5_5' (aka 'float __attribute__\
+((matrix_type(5, 5)))') and incompatible type 'test_struct *' is not allowed}}'
 }
 
 void f2() {
-  // TODO: Update this test once the support of C-style casts for C++ is implemented.
   matrix_4_4 m1;
-  matrix_5_5 m2;
-  matrix_5_5 m3;
-  matrix_4_4 m4;
+  matrix_4_4 m2;
+  matrix_5_5 m3;
+  matrix_5_5 m4;
+  matrix_4_4 m5;
+  matrix_5_5 m6;
   float f;
 
-  (matrix_4_4)m1;   // expected-error {{C-style cast from 'matrix_4_4' (aka 'float __attribute__\
-((matrix_type(4, 4)))') to 'matrix_4_4' (aka 'double __attribute__((matrix_type(4, 4)))') is not allowed}}
-  (matrix_5_5)m2;// expected-error {{C-style cast from 'matrix_5_5' (aka 'double __attribute__\
-((matrix_type(5, 5)))') to 'matrix_5_5' (aka 'float __attribute__((matrix_type(5, 5)))') is not allowed}}
-  (matrix_5_5)m3; // expected-error {{C-style cast from 'matrix_5_5' (aka 'int __attribute__\
-((matrix_type(5, 5)))') to 'matrix_5_5' (aka 'unsigned int __attribute__((matrix_type(5, 5)))') \
-is not allowed}}
-  (matrix_4_4)m

[PATCH] D95425: Implementation of global.get/set for reftypes in LLVM IR

2021-05-04 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 342729.
pmatos added a comment.

Removed extraneous changes to previous patches


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95425

Files:
  clang/lib/Basic/Targets/WebAssembly.cpp
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/include/llvm/Support/MachineValueType.h
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/MachineOperand.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/externref-globalget.ll
  llvm/test/CodeGen/WebAssembly/externref-globalset.ll
  llvm/test/CodeGen/WebAssembly/externref-inttoptr.ll
  llvm/test/CodeGen/WebAssembly/externref-ptrtoint.ll
  llvm/test/CodeGen/WebAssembly/externref-undef.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-load.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
  llvm/test/CodeGen/WebAssembly/funcref-call.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalset.ll

Index: llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
@@ -0,0 +1,20 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define void @set_funcref_global(%funcref %g) {
+  ;; this generates a global.set of @funcref_global
+  store %funcref %g, %funcref addrspace(1)* @funcref_global
+  ret void
+}
+
+; CHECK-LABEL: set_funcref_global:
+; CHECK-NEXT: functype   set_funcref_global (funcref) -> ()
+; CHECK-NEXT: local.get  0
+; CHECK-NEXT: global.set funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
@@ -0,0 +1,19 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define %funcref @return_funcref_global() {
+  ;; this generates a global.get of @funcref_global
+  %ref = load %funcref, %funcref addrspace(1)* @funcref_global
+  ret %funcref %ref
+}
+
+; CHECK-LABEL: return_funcref_global:
+; CHECK-NEXT: .functype   return_funcref_global () -> (funcref)
+; CHECK-NEXT: global.get funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-call.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-call.ll
@@ -0,0 +1,23 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type void ()
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+define void @call_funcref(%funcref %ref) {
+  call addrspace(20) void %ref() 
+  ret void
+}
+
+; CHECK-LABEL: call_funcref:
+; CHECK-NEXT: functype   call_funcref (funcref) -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: call_indirect __funcref_call_table, () -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: ref.null func
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: end_function
+
+; CHECK: .tabletype __funcref_call_table, funcref
Index: llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
@@ -0,0 +1,11 @@
+; RUN: not llc --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types < %s 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
+
+%extern = type opaque
+%externref = type %extern addrspace(10)*
+
+defi

[PATCH] D100482: [PowerPC] Provide MMA builtins for compatibility

2021-05-04 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir updated this revision to Diff 342732.
saghir added a comment.

Addressed review comments to add _mma_ version of the built-ins as
aliases to the existing _vsx_ versions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100482

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-pair-mma.c

Index: clang/test/CodeGen/builtins-ppc-pair-mma.c
===
--- clang/test/CodeGen/builtins-ppc-pair-mma.c
+++ clang/test/CodeGen/builtins-ppc-pair-mma.c
@@ -5,7 +5,7 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = tail call <512 x i1> @llvm.ppc.mma.assemble.acc(<16 x i8> [[VC:%.*]], <16 x i8> [[VC]], <16 x i8> [[VC]], <16 x i8> [[VC]])
 // CHECK-NEXT:[[TMP1:%.*]] = bitcast i8* [[RESP:%.*]] to <512 x i1>*
-// CHECK-NEXT:store <512 x i1> [[TMP0]], <512 x i1>* [[TMP1]], align 64, !tbaa !2
+// CHECK-NEXT:store <512 x i1> [[TMP0]], <512 x i1>* [[TMP1]], align 64, !tbaa [[TBAA2:![0-9]+]]
 // CHECK-NEXT:ret void
 //
 void test1(unsigned char *vqp, unsigned char *vpp, vector unsigned char vc, unsigned char *resp) {
@@ -46,7 +46,7 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = tail call <256 x i1> @llvm.ppc.vsx.assemble.pair(<16 x i8> [[VC:%.*]], <16 x i8> [[VC]])
 // CHECK-NEXT:[[TMP1:%.*]] = bitcast i8* [[RESP:%.*]] to <256 x i1>*
-// CHECK-NEXT:store <256 x i1> [[TMP0]], <256 x i1>* [[TMP1]], align 32, !tbaa !6
+// CHECK-NEXT:store <256 x i1> [[TMP0]], <256 x i1>* [[TMP1]], align 32, !tbaa [[TBAA6:![0-9]+]]
 // CHECK-NEXT:ret void
 //
 void test3(unsigned char *vqp, unsigned char *vpp, vector unsigned char vc, unsigned char *resp) {
@@ -78,10 +78,10 @@
 // CHECK-LABEL: @test5(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast i8* [[VQP:%.*]] to <512 x i1>*
-// CHECK-NEXT:[[TMP1:%.*]] = load <512 x i1>, <512 x i1>* [[TMP0]], align 64, !tbaa !2
+// CHECK-NEXT:[[TMP1:%.*]] = load <512 x i1>, <512 x i1>* [[TMP0]], align 64, !tbaa [[TBAA2]]
 // CHECK-NEXT:[[TMP2:%.*]] = tail call <512 x i1> @llvm.ppc.mma.xxmtacc(<512 x i1> [[TMP1]])
 // CHECK-NEXT:[[TMP3:%.*]] = bitcast i8* [[RESP:%.*]] to <512 x i1>*
-// CHECK-NEXT:store <512 x i1> [[TMP2]], <512 x i1>* [[TMP3]], align 64, !tbaa !2
+// CHECK-NEXT:store <512 x i1> [[TMP2]], <512 x i1>* [[TMP3]], align 64, !tbaa [[TBAA2]]
 // CHECK-NEXT:ret void
 //
 void test5(unsigned char *vqp, unsigned char *vpp, vector unsigned char vc, unsigned char *resp) {
@@ -94,10 +94,10 @@
 // CHECK-LABEL: @test6(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast i8* [[VQP:%.*]] to <512 x i1>*
-// CHECK-NEXT:[[TMP1:%.*]] = load <512 x i1>, <512 x i1>* [[TMP0]], align 64, !tbaa !2
+// CHECK-NEXT:[[TMP1:%.*]] = load <512 x i1>, <512 x i1>* [[TMP0]], align 64, !tbaa [[TBAA2]]
 // CHECK-NEXT:[[TMP2:%.*]] = tail call <512 x i1> @llvm.ppc.mma.xxmfacc(<512 x i1> [[TMP1]])
 // CHECK-NEXT:[[TMP3:%.*]] = bitcast i8* [[RESP:%.*]] to <512 x i1>*
-// CHECK-NEXT:store <512 x i1> [[TMP2]], <512 x i1>* [[TMP3]], align 64, !tbaa !2
+// CHECK-NEXT:store <512 x i1> [[TMP2]], <512 x i1>* [[TMP3]], align 64, !tbaa [[TBAA2]]
 // CHECK-NEXT:ret void
 //
 void test6(unsigned char *vqp, unsigned char *vpp, vector unsigned char vc, unsigned char *resp) {
@@ -111,7 +111,7 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = tail call <512 x i1> @llvm.ppc.mma.xxsetaccz()
 // CHECK-NEXT:[[TMP1:%.*]] = bitcast i8* [[RESP:%.*]] to <512 x i1>*
-// CHECK-NEXT:store <512 x i1> [[TMP0]], <512 x i1>* [[TMP1]], align 64, !tbaa !2
+// CHECK-NEXT:store <512 x i1> [[TMP0]], <512 x i1>* [[TMP1]], align 64, !tbaa [[TBAA2]]
 // CHECK-NEXT:ret void
 //
 void test7(unsigned char *vqp, unsigned char *vpp, vector unsigned char vc, unsigned char *resp) {
@@ -125,7 +125,7 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = tail call <512 x i1> @llvm.ppc.mma.xvi4ger8(<16 x i8> [[VC:%.*]], <16 x i8> [[VC]])
 // CHECK-NEXT:[[TMP1:%.*]] = bitcast i8* [[RESP:%.*]] to <512 x i1>*
-// CHECK-NEXT:store <512 x i1> [[TMP0]], <512 x i1>* [[TMP1]], align 64, !tbaa !2
+// CHECK-NEXT:store <512 x i1> [[TMP0]], <512 x i1>* [[TMP1]], align 64, !tbaa [[TBAA2]]
 // CHECK-NEXT:ret void
 //
 void test8(unsigned char *vqp, unsigned char *vpp, vector unsigned char vc, unsigned char *resp) {
@@ -139,7 +139,7 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = tail call <512 x i1> @llvm.ppc.mma.xvi8ger4(<16 x i8> [[VC:%.*]], <16 x i8> [[VC]])
 // CHECK-NEXT:[[TMP1:%.*]] = bitcast i8* [[RESP:%.*]] to <512 x i1>*
-// CHECK-NEXT:store <512 x i1> [[TMP0]], <512 x i1>* [[TMP1]], align 64, !tbaa !2
+// CHECK-NEXT:store <512 x i1> [[TMP0]], <512 x i1>* [[TMP1]], align 64, !tbaa [[TBAA2]]
 // CHECK-NEXT:ret void
 //
 voi

[PATCH] D95425: Implementation of global.get/set for reftypes in LLVM IR

2021-05-04 Thread Andy Wingo via Phabricator via cfe-commits
wingo added inline comments.



Comment at: clang/lib/Basic/Targets/WebAssembly.h:150
   : WebAssemblyTargetInfo(T, Opts) {
-resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128");
+resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128-ni:1");
   }

This change is already in D101608; rebase?



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:4083
   EVT PtrVT = Ptr.getValueType();
+  EVT EltVT = PtrVT.getScalarType();
 

It turns out that all the changes here to `visitLoad` and `visitStore` are no 
longer needed.  The issue was that before we made `getPointerMemTy` virtual, it 
was hard-coded to return an integer of whatever the pointer bit size was.  But 
for externref and funcref values, where we're using pointers in non-default 
address spaces to represent opaque values, that's not what we want: an 
externref "in memory" isn't an i32.  Having made `getPointerMemTy` virtual and 
returning externref / funcref for those values, now we avoid the zero-extension 
paths, and even the ISD::ADD node doesn't cause us problems.



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:4257
+// Skip ZExt or Trunc if a ValueVT is zero sized
+if (!ValueVTs[i].isZeroSized() && MemVTs[i] != ValueVTs[i])
   Val = DAG.getPtrExtOrTrunc(Val, dl, MemVTs[i]);

Can revert this too, as mentioned above.



Comment at: llvm/lib/CodeGen/TargetLoweringBase.cpp:1684
   Type *Ty = VT.getTypeForEVT(Context);
-  if (Alignment >= DL.getABITypeAlign(Ty)) {
+  if (!VT.isZeroSized() && Alignment >= DL.getABITypeAlign(Ty)) {
 // Assume that an access that meets the ABI-specified alignment is fast.

This one I would think that we want to return true, that the access is "fast", 
for access to zero-sized types.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:2347
+  return false;
+}

I just checked and it would seem that the `getPointerMemTy` change means that 
this override no longer appears to be needed.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td:15
 multiclass TABLE {
+  let mayLoad = 1 in
   defm TABLE_GET_#rt : I<(outs rt:$res), (ins table32_op:$table),

I think you may need `hasSideEffects = 0` for these annotations to have an 
effect.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td:19
  [],
  "table.get\t$res, $table",
  "table.get\t$table",

Not something for this patch, but this is certainly bogus: surely we mean 
`table.get\t$table, $i` and we have an i32 index argument?



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td:59
+  (TABLE_SET_EXTERNREF i32:$table, i32:$idx, externref:$r)>,
+  Requires<[HasReferenceTypes]>;
+

Consider changing to use the approach used for `GLOBAL_GET` from the parent 
commit, and folding these into the multiclass so that we don't have to repeat 
the code for externref and funcref.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95425

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


[PATCH] D101785: [clangd][ObjC] Highlight Objc Ivar refs

2021-05-04 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 342734.
dgoldman added a comment.

Fix test broken on non-macOS


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101785

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -687,6 +687,19 @@
 @implementation $Class[[Foo]]($Namespace_decl[[Bar]])
 @end
   )cpp",
+  R"cpp(
+// ObjC: Properties and Ivars.
+@interface $Class_decl[[Foo]]
+@property(nonatomic, assign) int $Field_decl[[someProperty]];
+@end
+@implementation $Class_decl[[Foo]]
+@synthesize someProperty = $Field_decl[[_someProperty]];
+- (int)$Method_decl[[doSomething]] {
+  self.$Field[[someProperty]] = self.$Field[[someProperty]] + 1;
+  self->$Field[[_someProperty]] = $Field[[_someProperty]] + 1;
+}
+@end
+  )cpp",
   // Member imported from dependent base
   R"cpp(
 template  struct $Class_decl[[Base]] {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -780,6 +780,13 @@
   explicitReferenceTargets(DynTypedNode::create(*E), {}, Resolver)});
 }
 
+void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *OIRE) {
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  OIRE->getLocation(),
+  /*IsDecl=*/false,
+  {OIRE->getDecl()}});
+}
+
 void VisitObjCMessageExpr(const ObjCMessageExpr *E) {
   // The name may have several tokens, we can only report the first.
   Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -687,6 +687,19 @@
 @implementation $Class[[Foo]]($Namespace_decl[[Bar]])
 @end
   )cpp",
+  R"cpp(
+// ObjC: Properties and Ivars.
+@interface $Class_decl[[Foo]]
+@property(nonatomic, assign) int $Field_decl[[someProperty]];
+@end
+@implementation $Class_decl[[Foo]]
+@synthesize someProperty = $Field_decl[[_someProperty]];
+- (int)$Method_decl[[doSomething]] {
+  self.$Field[[someProperty]] = self.$Field[[someProperty]] + 1;
+  self->$Field[[_someProperty]] = $Field[[_someProperty]] + 1;
+}
+@end
+  )cpp",
   // Member imported from dependent base
   R"cpp(
 template  struct $Class_decl[[Base]] {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -780,6 +780,13 @@
   explicitReferenceTargets(DynTypedNode::create(*E), {}, Resolver)});
 }
 
+void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *OIRE) {
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  OIRE->getLocation(),
+  /*IsDecl=*/false,
+  {OIRE->getDecl()}});
+}
+
 void VisitObjCMessageExpr(const ObjCMessageExpr *E) {
   // The name may have several tokens, we can only report the first.
   Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d882750 - [analyzer] Fix a crash for dereferencing an empty llvm::Optional variable in SMTConstraintManager.h.

2021-05-04 Thread Balazs Benics via cfe-commits

Author: Ella Ma
Date: 2021-05-04T16:50:21+02:00
New Revision: d882750f1105b20d892545e7ebd96f82166dcb53

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

LOG: [analyzer] Fix a crash for dereferencing an empty llvm::Optional variable 
in SMTConstraintManager.h.

The first crash reported in the bug report 44338.

Condition `!isSat.hasValue() || isNotSat.getValue()` here should be
`!isNotSat.hasValue() || isNotSat.getValue()`.
`getValue()` here crashed when we used the static analyzer to analyze
postgresql-12.0.

Patch By: OikawaKirie

Reviewed By: steakhal, martong

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

Added: 
clang/test/Analysis/z3/D83660.c
clang/test/Analysis/z3/Inputs/MockZ3_solver_check.c

Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
index 07fc73a670f35..e4878d4e01564 100644
--- 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
+++ 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
@@ -146,7 +146,7 @@ class SMTConstraintManager : public 
clang::ento::SimpleConstraintManager {
   Solver->addConstraint(NotExp);
 
   Optional isNotSat = Solver->check();
-  if (!isSat.hasValue() || isNotSat.getValue())
+  if (!isNotSat.hasValue() || isNotSat.getValue())
 return nullptr;
 
   // This is the only solution, store it

diff  --git a/clang/test/Analysis/z3/D83660.c b/clang/test/Analysis/z3/D83660.c
new file mode 100644
index 0..fd46a51e3
--- /dev/null
+++ b/clang/test/Analysis/z3/D83660.c
@@ -0,0 +1,23 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: %host_cxx -shared -fPIC %S/Inputs/MockZ3_solver_check.c -o 
%t/MockZ3_solver_check.so
+//
+// RUN: LD_PRELOAD="%t/MockZ3_solver_check.so" 
  \
+// RUN: %clang_cc1 -analyze -analyzer-constraints=z3 -setup-static-analyzer
  \
+// RUN:   -analyzer-checker=core,debug.ExprInspection %s -verify 2>&1 | 
FileCheck %s
+//
+// REQUIRES: z3, asserts, shell, system-linux
+//
+// Works only with the z3 constraint manager.
+// expected-no-diagnostics
+
+// CHECK:  Z3_solver_check returns the real value: TRUE
+// CHECK-NEXT: Z3_solver_check returns the real value: TRUE
+// CHECK-NEXT: Z3_solver_check returns the real value: TRUE
+// CHECK-NEXT: Z3_solver_check returns the real value: TRUE
+// CHECK-NEXT: Z3_solver_check returns a mocked value: UNDEF
+
+void D83660(int b) {
+  if (b) {
+  }
+  (void)b; // no-crash
+}

diff  --git a/clang/test/Analysis/z3/Inputs/MockZ3_solver_check.c 
b/clang/test/Analysis/z3/Inputs/MockZ3_solver_check.c
new file mode 100644
index 0..9c63a64ada220
--- /dev/null
+++ b/clang/test/Analysis/z3/Inputs/MockZ3_solver_check.c
@@ -0,0 +1,28 @@
+#include 
+#include 
+
+#include 
+
+// Mock implementation: return UNDEF for the 5th invocation, otherwise it just
+// returns the result of the real invocation.
+Z3_lbool Z3_API Z3_solver_check(Z3_context c, Z3_solver s) {
+  static Z3_lbool (*OriginalFN)(Z3_context, Z3_solver);
+  if (!OriginalFN) {
+OriginalFN = (Z3_lbool(*)(Z3_context, Z3_solver))dlsym(RTLD_NEXT,
+   "Z3_solver_check");
+  }
+
+  // Invoke the actual solver.
+  Z3_lbool Result = OriginalFN(c, s);
+
+  // Mock the 5th invocation to return UNDEF.
+  static unsigned int Counter = 0;
+  if (++Counter == 5) {
+fprintf(stderr, "Z3_solver_check returns a mocked value: UNDEF\n");
+return Z3_L_UNDEF;
+  }
+  fprintf(stderr, "Z3_solver_check returns the real value: %s\n",
+  (Result == Z3_L_UNDEF ? "UNDEF"
+: ((Result == Z3_L_TRUE ? "TRUE" : "FALSE";
+  return Result;
+}



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


[PATCH] D83660: [analyzer] Fix a crash for dereferencing an empty llvm::Optional variable in SMTConstraintManager.h.

2021-05-04 Thread Balázs Benics via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd882750f1105: [analyzer] Fix a crash for dereferencing an 
empty llvm::Optional variable in… (authored by OikawaKirie, committed by 
steakhal).

Changed prior to commit:
  https://reviews.llvm.org/D83660?vs=333708&id=342738#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83660

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
  clang/test/Analysis/z3/D83660.c
  clang/test/Analysis/z3/Inputs/MockZ3_solver_check.c


Index: clang/test/Analysis/z3/Inputs/MockZ3_solver_check.c
===
--- /dev/null
+++ clang/test/Analysis/z3/Inputs/MockZ3_solver_check.c
@@ -0,0 +1,28 @@
+#include 
+#include 
+
+#include 
+
+// Mock implementation: return UNDEF for the 5th invocation, otherwise it just
+// returns the result of the real invocation.
+Z3_lbool Z3_API Z3_solver_check(Z3_context c, Z3_solver s) {
+  static Z3_lbool (*OriginalFN)(Z3_context, Z3_solver);
+  if (!OriginalFN) {
+OriginalFN = (Z3_lbool(*)(Z3_context, Z3_solver))dlsym(RTLD_NEXT,
+   "Z3_solver_check");
+  }
+
+  // Invoke the actual solver.
+  Z3_lbool Result = OriginalFN(c, s);
+
+  // Mock the 5th invocation to return UNDEF.
+  static unsigned int Counter = 0;
+  if (++Counter == 5) {
+fprintf(stderr, "Z3_solver_check returns a mocked value: UNDEF\n");
+return Z3_L_UNDEF;
+  }
+  fprintf(stderr, "Z3_solver_check returns the real value: %s\n",
+  (Result == Z3_L_UNDEF ? "UNDEF"
+: ((Result == Z3_L_TRUE ? "TRUE" : "FALSE";
+  return Result;
+}
Index: clang/test/Analysis/z3/D83660.c
===
--- /dev/null
+++ clang/test/Analysis/z3/D83660.c
@@ -0,0 +1,23 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: %host_cxx -shared -fPIC %S/Inputs/MockZ3_solver_check.c -o 
%t/MockZ3_solver_check.so
+//
+// RUN: LD_PRELOAD="%t/MockZ3_solver_check.so" 
  \
+// RUN: %clang_cc1 -analyze -analyzer-constraints=z3 -setup-static-analyzer
  \
+// RUN:   -analyzer-checker=core,debug.ExprInspection %s -verify 2>&1 | 
FileCheck %s
+//
+// REQUIRES: z3, asserts, shell, system-linux
+//
+// Works only with the z3 constraint manager.
+// expected-no-diagnostics
+
+// CHECK:  Z3_solver_check returns the real value: TRUE
+// CHECK-NEXT: Z3_solver_check returns the real value: TRUE
+// CHECK-NEXT: Z3_solver_check returns the real value: TRUE
+// CHECK-NEXT: Z3_solver_check returns the real value: TRUE
+// CHECK-NEXT: Z3_solver_check returns a mocked value: UNDEF
+
+void D83660(int b) {
+  if (b) {
+  }
+  (void)b; // no-crash
+}
Index: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
@@ -146,7 +146,7 @@
   Solver->addConstraint(NotExp);
 
   Optional isNotSat = Solver->check();
-  if (!isSat.hasValue() || isNotSat.getValue())
+  if (!isNotSat.hasValue() || isNotSat.getValue())
 return nullptr;
 
   // This is the only solution, store it


Index: clang/test/Analysis/z3/Inputs/MockZ3_solver_check.c
===
--- /dev/null
+++ clang/test/Analysis/z3/Inputs/MockZ3_solver_check.c
@@ -0,0 +1,28 @@
+#include 
+#include 
+
+#include 
+
+// Mock implementation: return UNDEF for the 5th invocation, otherwise it just
+// returns the result of the real invocation.
+Z3_lbool Z3_API Z3_solver_check(Z3_context c, Z3_solver s) {
+  static Z3_lbool (*OriginalFN)(Z3_context, Z3_solver);
+  if (!OriginalFN) {
+OriginalFN = (Z3_lbool(*)(Z3_context, Z3_solver))dlsym(RTLD_NEXT,
+   "Z3_solver_check");
+  }
+
+  // Invoke the actual solver.
+  Z3_lbool Result = OriginalFN(c, s);
+
+  // Mock the 5th invocation to return UNDEF.
+  static unsigned int Counter = 0;
+  if (++Counter == 5) {
+fprintf(stderr, "Z3_solver_check returns a mocked value: UNDEF\n");
+return Z3_L_UNDEF;
+  }
+  fprintf(stderr, "Z3_solver_check returns the real value: %s\n",
+  (Result == Z3_L_UNDEF ? "UNDEF"
+: ((Result == Z3_L_TRUE ? "TRUE" : "FALSE";
+  return Result;
+}
Index: clang/test/Analysis/z3/D83660.c
===
--- /dev/null
+++ clang/test/Analysis/z3/D83660.c
@@ -0,0 +1,23 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: %host_cxx -shared -fPIC %S/Inputs/MockZ3_solver_check.c -o %t/MockZ3_solver_check.so
+//
+// RUN: LD_PRELOAD="%t/MockZ3_solver_

[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-05-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/CodeGen/CGDecl.cpp:2618
+void CodeGenModule::EmitOMPAllocateDecl(const OMPAllocateDecl *D) {
+  for (Expr *E : const_cast(D)->varlists()) {
+auto *DE = cast(E);

ABataev wrote:
> jdoerfert wrote:
> > ABataev wrote:
> > > jdoerfert wrote:
> > > > ABataev wrote:
> > > > > jdoerfert wrote:
> > > > > > ABataev wrote:
> > > > > > > Why need to remove constantness here?
> > > > > > The problem is that the declaration, which might have been already 
> > > > > > generated in IR or not, had no address space attached before. Now 
> > > > > > we want to do that after the fact, potentially *way later*. To 
> > > > > > reuse the general codegen mechanism I modify the VarDecl 
> > > > > > (temporarily) by attaching the new address space and calling 
> > > > > > codegen again. If you have a better idea, I'm happy to change this.
> > > > > Why not just create it manually rather than rely on 
> > > > > `GetOrCreateLLVMGlobal`?
> > > > I'm not sure I follow. Creating a global is complicated, need to make 
> > > > sure all the linkage, visibility, address space stuff is set up, 
> > > > mangling, etc. Why would we duplicate all that code and risk messing 
> > > > things up now or in the future?
> > > And what about just setting the address-space on the LLVM type directly?
> > It's part of the type, we can't change it after the fact (at least that is 
> > not an existing API). 
> What about `Value::mutateType`?
I'll give it a shot, though the comment makes me nervous:

```
/// Mutate the type of this Value to be of the specified type.  


   
///
/// Note that this is an extremely dangerous operation which can create
/// completely invalid IR very easily.  It is strongly recommended that you
/// recreate IR objects with the right types instead of mutating them in
/// place.
```




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

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


[PATCH] D101776: Work around an unfortunate macro in the Windows SDK

2021-05-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


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

https://reviews.llvm.org/D101776

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


[clang] 54bff15 - Rename a template parameter that conflicted with a common macro; NFC

2021-05-04 Thread Aaron Ballman via cfe-commits

Author: Zachary Henkel
Date: 2021-05-04T11:19:54-04:00
New Revision: 54bff1522fc863329894d875d54c2fe4cd1b4f3f

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

LOG: Rename a template parameter that conflicted with a common macro; NFC

The CALLBACK macro is used extensively in the Windows SDK.

Added: 


Modified: 
clang/include/clang/Analysis/CFG.h

Removed: 




diff  --git a/clang/include/clang/Analysis/CFG.h 
b/clang/include/clang/Analysis/CFG.h
index a0f8c6d21a674..9e32eb8e066a9 100644
--- a/clang/include/clang/Analysis/CFG.h
+++ b/clang/include/clang/Analysis/CFG.h
@@ -1389,13 +1389,12 @@ class CFG {
   // Member templates useful for various batch operations over CFGs.
   
//======//
 
-  template 
-  void VisitBlockStmts(CALLBACK& O) const {
+  template  void VisitBlockStmts(Callback &O) const {
 for (const_iterator I = begin(), E = end(); I != E; ++I)
   for (CFGBlock::const_iterator BI = (*I)->begin(), BE = (*I)->end();
BI != BE; ++BI) {
 if (Optional stmt = BI->getAs())
-  O(const_cast(stmt->getStmt()));
+  O(const_cast(stmt->getStmt()));
   }
   }
 



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


[PATCH] D101776: Work around an unfortunate macro in the Windows SDK

2021-05-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thank you for the fix! I've committed on your behalf in 
54bff1522fc863329894d875d54c2fe4cd1b4f3f 



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

https://reviews.llvm.org/D101776

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


[PATCH] D101640: [clang][patch] Add support for option -fextend-arguments={32,64}: widen integer arguments to int64 in unprototyped function calls

2021-05-04 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 342750.
mibintc added a comment.

Responded to suggestions from @jansvoboda11


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101640

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/extend-arg-64.c
  clang/test/Driver/fextend-args.c

Index: clang/test/Driver/fextend-args.c
===
--- /dev/null
+++ clang/test/Driver/fextend-args.c
@@ -0,0 +1,17 @@
+// Options for intel arch
+// RUN: %clang -### -target x86_64-apple-darwin -fextend-arguments=32 %s 2>&1 \
+// RUN: | FileCheck --implicit-check-not "-fextend-arguments=32"  %s
+// RUN: %clang -### -target x86_64-apple-darwin -fextend-arguments=64 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-64 %s
+
+// Unsupported target
+// RUN: not %clang -target aarch64-unknown-windows-msvc -fextend-arguments=32 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=UNSUPPORTED-TARGET %s
+
+// Invalid option value
+// RUN: not %clang -target x86_64-apple-darwin -fextend-arguments=0 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=INVALID-VALUE %s
+
+// CHECK-64: "-cc1" {{.*}}"-fextend-arguments=64"
+// UNSUPPORTED-TARGET: error: unsupported option
+// INVALID-VALUE: error: invalid argument '0' to -fextend-arguments
Index: clang/test/CodeGen/extend-arg-64.c
===
--- /dev/null
+++ clang/test/CodeGen/extend-arg-64.c
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fextend-arguments=64  \
+// RUN:%s -emit-llvm -o - | FileCheck %s -check-prefix=CHECKEXT
+
+// When the option isn't selected, no effect
+// RUN: %clang_cc1 -triple x86_64-apple-darwin  \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+// The option isn't supported on x86, no effect
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fextend-arguments=64 \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+// The option isn't supported on ppc, no effect
+// RUN: %clang_cc1 -triple ppc64le -fextend-arguments=64 \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+int vararg(int, ...);
+
+unsigned int u32;
+int s32;
+unsigned short u16;
+short s16;
+unsigned char u8;
+signed char s8;
+
+int test() {
+  // CHECK: define{{.*}} i32 @test{{.*}}
+
+  // CHECKEXT:  [[TAG_u32:%.*]] = load i32, i32* @u32{{.*}}
+  // CHECKEXT: [[CONV_u32:%.*]] = zext i32 [[TAG_u32]] to i64
+
+  // CHECKEXT:  [[TAG_s32:%.*]] = load i32, i32* @s32
+  // CHECKEXT: [[CONV_s32:%.*]] = sext i32 [[TAG_s32]] to i64
+
+  // CHECKEXT:  [[TAG_u16:%.*]] = load i16, i16* @u16
+  // CHECKEXT: [[CONV_u16:%.*]] = zext i16 [[TAG_u16]] to i64
+
+  // CHECKEXT:  [[TAG_s16:%.*]] = load i16, i16* @s16
+  // CHECKEXT: [[CONV_s16:%.*]] = sext i16 [[TAG_s16]] to i64
+
+  // CHECKEXT:  [[TAG_u8:%.*]] = load i8, i8* @u8
+  // CHECKEXT: [[CONV_u8:%.*]] = zext i8 [[TAG_u8]] to i64
+
+  // CHECKEXT:  [[TAG_s8:%.*]] = load i8, i8* @s8
+  // CHECKEXT: [[CONV_s8:%.*]] = sext i8 [[TAG_s8]] to i64
+  // CHECKEXT: call{{.*}} @vararg(i32 %0, i64 [[CONV_u32]], i64 [[CONV_s32]], i64 [[CONV_u16]], i64 [[CONV_s16]], i64 [[CONV_u8]], i64 [[CONV_s8]]
+
+  int sum = 0;
+  sum = vararg(sum, u32, s32, u16, s16, u8, s8);
+  return sum;
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -821,6 +821,17 @@
   E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
 }
   }
+  if (BTy &&
+  getLangOpts().getExtendIntArgs() ==
+  LangOptions::ExtendArgsKind::ExtendTo64 &&
+  Context.getTargetInfo().supportsExtendIntArgs() && Ty->isIntegerType()) {
+E = (Ty->isUnsignedIntegerType())
+? ImpCastExprToType(E, Context.UnsignedLongLongTy, CK_IntegralCast)
+  .get()
+: ImpCastExprToType(E, Context.LongLongTy, CK_IntegralCast).get();
+assert(8 == Context.getTypeSizeInChars(Context.LongLongTy).getQuantity() &&
+   "Unexpected typesize for LongLongTy");
+  }
 
   // C++ performs lvalue-to-rvalue conversion as a default argument
   // promotion, even on class types, but note:
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4908,6 +4908,20 @@
 
   RenderFloatingPointOptions(TC, D, OFastEnabled, Args, CmdArgs, JA);
 
+  if (Arg *A = Args.getL

[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-05-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 342764.
jdoerfert added a comment.

Use mutateType, add test for static variable in function with allocate directive


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

Files:
  clang/include/clang/Basic/Attr.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/lib/AST/AttrImpl.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/allocate_codegen.cpp
  clang/test/OpenMP/declare_target_codegen.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/declare_target_device_only_compilation.cpp
  clang/test/OpenMP/declare_target_messages.cpp
  clang/test/OpenMP/declare_target_only_one_side_compilation.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
  clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -922,6 +922,13 @@
 VersionedClause
   ];
 }
+def OMP_BeginDeclareTarget : Directive<"begin declare target"> {
+  let allowedClauses = [
+VersionedClause,
+VersionedClause,
+VersionedClause,
+  ];
+}
 def OMP_DeclareTarget : Directive<"declare target"> {
   let allowedClauses = [
 VersionedClause,
Index: clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
===
--- clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
+++ clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
@@ -6,8 +6,8 @@
 
 // CHECK-DAG: @_Z3barv
 // CHECK-DAG: @_Z3bazv
-// CHECK-DAG: @"_Z53bar$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"
-// CHECK-DAG: @"_Z53baz$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"
+// CHECK-DAG: define{{.*}}@"_Z53bar$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"
+// CHECK-DAG: define{{.*}}@"_Z53baz$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"
 // CHECK-DAG: call i32 @"_Z53bar$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"()
 // CHECK-DAG: call i32 @"_Z53baz$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"()
 
Index: clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
===
--- clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
+++ clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
@@ -34,21 +34,16 @@
 #pragma omp declare target (bar)
 int caz() { return 0; }
 
-// DEVICE-DAG: define{{ hidden | }}i32 [[FOO:@.*foo.*]]()
 // DEVICE-DAG: define{{ hidden | }}i32 [[BAR:@.*bar.*]]()
-// DEVICE-DAG: define{{ hidden | }}i32 [[BAZ:@.*baz.*]]()
-// DEVICE-DAG: define{{ hidden | }}i32 [[DOO:@.*doo.*]]()
-// DEVICE-DAG: define{{ hidden | }}i32 [[CAR:@.*car.*]]()
-// DEVICE-DAG: define{{ hidden | }}i32 [[CAZ:@.*caz.*]]()
 
 static int c = foo() + bar() + baz();
 #pragma omp declare target (c)
-// HOST-DAG: @[[C_CTOR:__omp_offloading__.+_c_l44_ctor]] = private constant i8 0
-// DEVICE-DAG: define internal void [[C_CTOR:@__omp_offloading__.+_c_l44_ctor]]()
-// DEVICE-DAG: call i32 [[FOO]]()
-// DEVICE-DAG: call i32 [[BAR]]()
-// DEVICE-DAG: call i32 [[BAZ]]()
-// DEVICE-DAG: ret void
+// HOST-DAG: @[[C_CTOR:__omp_offloading__.+_c_l39_ctor]] = private constant i8 0
+
+// DEVICE-DAG: define internal void [[C_CTOR:@__omp_offloading__.+_c_l39_ctor]]()
+// DEVICE-DAG: define{{ hidden | }}i32 [[FOO:@.*foo.*]]()
+// DEVICE-DAG: define{{ hidden | }}i32 [[BAZ:@.*baz.*]]()
+// DEVICE-DAG: define{{ hidden | }}i32 [[DOO:@.*doo.*]]()
 
 struct S {
   int a;
@@ -60,17 +55,14 @@
 #pragma omp declare target
 S cd = doo() + car() + caz() + baz();
 #pragma omp end declare target
-// HOST-DAG: @[[CD_CTOR:__omp_offloading__.+_cd_l61_ctor]] = private constant i8 0
-// DEVICE-DAG: define internal void [[CD_CTOR:@__omp_offloading__.+_cd_l61_ctor]]()
-// DEVICE-DAG: call i32 [[DOO]]()
-// DEVICE-DAG: call i32 [[CAR]]()
-// DEVICE-DAG: call i32 [[CAZ]]()
-// DEVICE-DAG: ret void
-
-// HOST-DAG: @[[CD_DTOR:__omp_offloading__.+_cd_l61_dtor]] = private constant i8 0
-// DEVICE-DAG: define internal void [[CD_DTOR:@__omp_offloading__.+_cd_l61_dtor]]()
-// DEVICE-DAG: call void
-// DEVICE-DAG: ret void
+// HOST-DAG: @[[CD_CTOR:__omp_offloading__.+_cd_l56_ctor]] = private constant i8 0
+// DEVICE-DAG: define internal void [[CD_CTOR:@__omp_offloading__.+_cd_l56_ctor]]()
+
+// DEVICE-DAG: define{{ hidden | }}i32 [[CAR:@.*c

[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-05-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 342765.
jdoerfert marked 4 inline comments as done.
jdoerfert added a comment.

Remove const cast, clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

Files:
  clang/include/clang/Basic/Attr.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/lib/AST/AttrImpl.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/allocate_codegen.cpp
  clang/test/OpenMP/declare_target_codegen.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/declare_target_device_only_compilation.cpp
  clang/test/OpenMP/declare_target_messages.cpp
  clang/test/OpenMP/declare_target_only_one_side_compilation.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
  clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -922,6 +922,13 @@
 VersionedClause
   ];
 }
+def OMP_BeginDeclareTarget : Directive<"begin declare target"> {
+  let allowedClauses = [
+VersionedClause,
+VersionedClause,
+VersionedClause,
+  ];
+}
 def OMP_DeclareTarget : Directive<"declare target"> {
   let allowedClauses = [
 VersionedClause,
Index: clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
===
--- clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
+++ clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
@@ -6,8 +6,8 @@
 
 // CHECK-DAG: @_Z3barv
 // CHECK-DAG: @_Z3bazv
-// CHECK-DAG: @"_Z53bar$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"
-// CHECK-DAG: @"_Z53baz$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"
+// CHECK-DAG: define{{.*}}@"_Z53bar$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"
+// CHECK-DAG: define{{.*}}@"_Z53baz$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"
 // CHECK-DAG: call i32 @"_Z53bar$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"()
 // CHECK-DAG: call i32 @"_Z53baz$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"()
 
Index: clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
===
--- clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
+++ clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
@@ -34,21 +34,16 @@
 #pragma omp declare target (bar)
 int caz() { return 0; }
 
-// DEVICE-DAG: define{{ hidden | }}i32 [[FOO:@.*foo.*]]()
 // DEVICE-DAG: define{{ hidden | }}i32 [[BAR:@.*bar.*]]()
-// DEVICE-DAG: define{{ hidden | }}i32 [[BAZ:@.*baz.*]]()
-// DEVICE-DAG: define{{ hidden | }}i32 [[DOO:@.*doo.*]]()
-// DEVICE-DAG: define{{ hidden | }}i32 [[CAR:@.*car.*]]()
-// DEVICE-DAG: define{{ hidden | }}i32 [[CAZ:@.*caz.*]]()
 
 static int c = foo() + bar() + baz();
 #pragma omp declare target (c)
-// HOST-DAG: @[[C_CTOR:__omp_offloading__.+_c_l44_ctor]] = private constant i8 0
-// DEVICE-DAG: define internal void [[C_CTOR:@__omp_offloading__.+_c_l44_ctor]]()
-// DEVICE-DAG: call i32 [[FOO]]()
-// DEVICE-DAG: call i32 [[BAR]]()
-// DEVICE-DAG: call i32 [[BAZ]]()
-// DEVICE-DAG: ret void
+// HOST-DAG: @[[C_CTOR:__omp_offloading__.+_c_l39_ctor]] = private constant i8 0
+
+// DEVICE-DAG: define internal void [[C_CTOR:@__omp_offloading__.+_c_l39_ctor]]()
+// DEVICE-DAG: define{{ hidden | }}i32 [[FOO:@.*foo.*]]()
+// DEVICE-DAG: define{{ hidden | }}i32 [[BAZ:@.*baz.*]]()
+// DEVICE-DAG: define{{ hidden | }}i32 [[DOO:@.*doo.*]]()
 
 struct S {
   int a;
@@ -60,17 +55,14 @@
 #pragma omp declare target
 S cd = doo() + car() + caz() + baz();
 #pragma omp end declare target
-// HOST-DAG: @[[CD_CTOR:__omp_offloading__.+_cd_l61_ctor]] = private constant i8 0
-// DEVICE-DAG: define internal void [[CD_CTOR:@__omp_offloading__.+_cd_l61_ctor]]()
-// DEVICE-DAG: call i32 [[DOO]]()
-// DEVICE-DAG: call i32 [[CAR]]()
-// DEVICE-DAG: call i32 [[CAZ]]()
-// DEVICE-DAG: ret void
-
-// HOST-DAG: @[[CD_DTOR:__omp_offloading__.+_cd_l61_dtor]] = private constant i8 0
-// DEVICE-DAG: define internal void [[CD_DTOR:@__omp_offloading__.+_cd_l61_dtor]]()
-// DEVICE-DAG: call void
-// DEVICE-DAG: ret void
+// HOST-DAG: @[[CD_CTOR:__omp_offloading__.+_cd_l56_ctor]] = private constant i8 0
+// DEVICE-DAG: define internal void [[CD_CTOR:@__omp_offloading__.+_cd_l56_ctor]]()
+
+// DEVICE-DAG: define{{ hidden | }}i32 [[CAR:@.*car.*]

[PATCH] D101682: [Driver] Fix `ToolChain::getCompilerRTPath()` to return the correct path on Apple platforms.

2021-05-04 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM, the only suggestion I have is below.




Comment at: clang/lib/Driver/ToolChain.cpp:408
   default:
 return getOS();
   }

It might be cleaner to do a check for `isOSDarwin` here, as that will help with 
any other Darwin platforms that we need to support.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101682

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


[PATCH] D101755: Thread safety analysis: Eliminate parameter from intersectAndWarn (NFC)

2021-05-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101755

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


[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-05-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked 7 inline comments as done.
jdoerfert added inline comments.



Comment at: clang/lib/CodeGen/CGDecl.cpp:2618
+void CodeGenModule::EmitOMPAllocateDecl(const OMPAllocateDecl *D) {
+  for (Expr *E : const_cast(D)->varlists()) {
+auto *DE = cast(E);

jdoerfert wrote:
> ABataev wrote:
> > jdoerfert wrote:
> > > ABataev wrote:
> > > > jdoerfert wrote:
> > > > > ABataev wrote:
> > > > > > jdoerfert wrote:
> > > > > > > ABataev wrote:
> > > > > > > > Why need to remove constantness here?
> > > > > > > The problem is that the declaration, which might have been 
> > > > > > > already generated in IR or not, had no address space attached 
> > > > > > > before. Now we want to do that after the fact, potentially *way 
> > > > > > > later*. To reuse the general codegen mechanism I modify the 
> > > > > > > VarDecl (temporarily) by attaching the new address space and 
> > > > > > > calling codegen again. If you have a better idea, I'm happy to 
> > > > > > > change this.
> > > > > > Why not just create it manually rather than rely on 
> > > > > > `GetOrCreateLLVMGlobal`?
> > > > > I'm not sure I follow. Creating a global is complicated, need to make 
> > > > > sure all the linkage, visibility, address space stuff is set up, 
> > > > > mangling, etc. Why would we duplicate all that code and risk messing 
> > > > > things up now or in the future?
> > > > And what about just setting the address-space on the LLVM type directly?
> > > It's part of the type, we can't change it after the fact (at least that 
> > > is not an existing API). 
> > What about `Value::mutateType`?
> I'll give it a shot, though the comment makes me nervous:
> 
> ```
> /// Mutate the type of this Value to be of the specified type.
>   
>   
>  
> ///
> /// Note that this is an extremely dangerous operation which can create
> /// completely invalid IR very easily.  It is strongly recommended that 
> you
> /// recreate IR objects with the right types instead of mutating them in
> /// place.
> ```
> 
> 
Seems to work with the mutate API. Let's try it out ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

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


[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-05-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

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


[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-05-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a subscriber: ggeorgakoudis.
jdoerfert added a comment.

I'll wait for @ggeorgakoudis to update the tests with the script, then I'll 
adjust all clang tests again. FWIW, this also fixes an issue in OpenMC where 
declare target triggered this:

  llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:719: void 
clang::CodeGen::CodeGenFunction::StartFunction(clang::GlobalDecl, 
clang::QualType, llvm::Function *, const clang::CodeGen::CGFunctionInfo &, 
const clang::CodeGen::FunctionArgList &, clang::SourceLocation, 
clang::SourceLocation): Assertion `CurFn->isDeclaration() && "Function already 
has body?"' failed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

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


[clang] 5285748 - Fix assert on the variable which is used in omp clause is not marked

2021-05-04 Thread Jennifer Yu via cfe-commits

Author: Jennifer Yu
Date: 2021-05-04T09:07:35-07:00
New Revision: 5285748c2c764c1d7fb3f882ba9f11ed79f676a1

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

LOG: Fix assert on the variable which is used in omp clause is not marked
as used.

The problem only happens with constexpr variable, for constexpr variable,
variable is not marked during parser variable.   This is because compiler
might find some var's associate expressions may not actully an odr-used
later,  the variables get kept in MaybeODRUseExprs, in normal case, at
end of process fullExpr, the variable will be marked during the call to
CleanupVarDeclMarking(). Since we are processing expression of OpenMP
clauses, and the ActOnFinishFullExpr is not getting called that casue
variable is not get marked.

One way to fix this is to call CleanupVarDeclMarking() in EndOpenMPClause
for each omp directive.

This to fix https://bugs.llvm.org/show_bug.cgi?id=50206

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

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/constexpr_capture.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 25ee46d95aa55..9ac3e48781849 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -2527,6 +2527,7 @@ void Sema::StartOpenMPClause(OpenMPClauseKind K) {
 
 void Sema::EndOpenMPClause() {
   DSAStack->setClauseParsingMode(/*K=*/OMPC_unknown);
+  CleanupVarDeclMarking();
 }
 
 static std::pair

diff  --git a/clang/test/OpenMP/constexpr_capture.cpp 
b/clang/test/OpenMP/constexpr_capture.cpp
index 9577f6e0c0fe2..ba404d7fdafd0 100644
--- a/clang/test/OpenMP/constexpr_capture.cpp
+++ b/clang/test/OpenMP/constexpr_capture.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-linux 
-S -emit-llvm %s -o - -std=c++11 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++  
-fopenmp-targets=x86_64-pc-linux-gnu -triple powerpc64le-unknown-linux -S 
-emit-llvm %s -o - -std=c++11 2>&1 | FileCheck %s
 // expected-no-diagnostics
 
 template  struct integral_constant {
@@ -12,10 +13,24 @@ struct decay {
 struct V {
   template ::type> V();
 };
+
+constexpr double h_chebyshev_coefs[] = {
+1.020784639703, 0.0021491446496202074};
+
+void test(double *d_value)
+{
+#pragma omp target map(tofrom  \
+   : d_value [0:1]) map(always, to \
+: h_chebyshev_coefs [0:2])
+  *d_value = h_chebyshev_coefs[1];  return;
+}
+
+// CHECK: void @__omp_offloading_{{.+}}test{{.+}}(double* %0)
+
 int main() {
 #pragma omp target
   V v;
   return 0;
 }
 
-// CHECK: call void @__omp_offloading_{{.+}}_main_l16()
+// CHECK: call void @__omp_offloading_{{.+}}_main_{{.+}}()



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


[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-05-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D101030#2736508 , @jdoerfert wrote:

> I'll wait for @ggeorgakoudis to update the tests with the script, then I'll 
> adjust all clang tests again. FWIW, this also fixes an issue in OpenMC where 
> declare target triggered this:
>
>   llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:719: void 
> clang::CodeGen::CodeGenFunction::StartFunction(clang::GlobalDecl, 
> clang::QualType, llvm::Function *, const clang::CodeGen::CGFunctionInfo &, 
> const clang::CodeGen::FunctionArgList &, clang::SourceLocation, 
> clang::SourceLocation): Assertion `CurFn->isDeclaration() && "Function 
> already has body?"' failed.

Nice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

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


[PATCH] D101781: Fix assert on the variable which is used in omp clause is not marked as used

2021-05-04 Thread Jennifer Yu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5285748c2c76: Fix assert on the variable which is used in 
omp clause is not marked (authored by jyu2).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101781

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/constexpr_capture.cpp


Index: clang/test/OpenMP/constexpr_capture.cpp
===
--- clang/test/OpenMP/constexpr_capture.cpp
+++ clang/test/OpenMP/constexpr_capture.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-linux 
-S -emit-llvm %s -o - -std=c++11 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++  
-fopenmp-targets=x86_64-pc-linux-gnu -triple powerpc64le-unknown-linux -S 
-emit-llvm %s -o - -std=c++11 2>&1 | FileCheck %s
 // expected-no-diagnostics
 
 template  struct integral_constant {
@@ -12,10 +13,24 @@
 struct V {
   template ::type> V();
 };
+
+constexpr double h_chebyshev_coefs[] = {
+1.020784639703, 0.0021491446496202074};
+
+void test(double *d_value)
+{
+#pragma omp target map(tofrom  \
+   : d_value [0:1]) map(always, to \
+: h_chebyshev_coefs [0:2])
+  *d_value = h_chebyshev_coefs[1];  return;
+}
+
+// CHECK: void @__omp_offloading_{{.+}}test{{.+}}(double* %0)
+
 int main() {
 #pragma omp target
   V v;
   return 0;
 }
 
-// CHECK: call void @__omp_offloading_{{.+}}_main_l16()
+// CHECK: call void @__omp_offloading_{{.+}}_main_{{.+}}()
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -2527,6 +2527,7 @@
 
 void Sema::EndOpenMPClause() {
   DSAStack->setClauseParsingMode(/*K=*/OMPC_unknown);
+  CleanupVarDeclMarking();
 }
 
 static std::pair


Index: clang/test/OpenMP/constexpr_capture.cpp
===
--- clang/test/OpenMP/constexpr_capture.cpp
+++ clang/test/OpenMP/constexpr_capture.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-linux -S -emit-llvm %s -o - -std=c++11 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++  -fopenmp-targets=x86_64-pc-linux-gnu -triple powerpc64le-unknown-linux -S -emit-llvm %s -o - -std=c++11 2>&1 | FileCheck %s
 // expected-no-diagnostics
 
 template  struct integral_constant {
@@ -12,10 +13,24 @@
 struct V {
   template ::type> V();
 };
+
+constexpr double h_chebyshev_coefs[] = {
+1.020784639703, 0.0021491446496202074};
+
+void test(double *d_value)
+{
+#pragma omp target map(tofrom  \
+   : d_value [0:1]) map(always, to \
+: h_chebyshev_coefs [0:2])
+  *d_value = h_chebyshev_coefs[1];  return;
+}
+
+// CHECK: void @__omp_offloading_{{.+}}test{{.+}}(double* %0)
+
 int main() {
 #pragma omp target
   V v;
   return 0;
 }
 
-// CHECK: call void @__omp_offloading_{{.+}}_main_l16()
+// CHECK: call void @__omp_offloading_{{.+}}_main_{{.+}}()
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -2527,6 +2527,7 @@
 
 void Sema::EndOpenMPClause() {
   DSAStack->setClauseParsingMode(/*K=*/OMPC_unknown);
+  CleanupVarDeclMarking();
 }
 
 static std::pair
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101843: [OpenCL] Add clang extension for bitfields

2021-05-04 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: svenvh, olestrohm.
Herald added subscribers: ebevhan, kerbowa, yaxunl, nhaehnle, jvesely, 
jholewinski.
Anastasia requested review of this revision.

Bitfields result in struct/union layout that is implementation dependent and 
therefore it was excluded from OpenCL originally for portability reasons. In 
kernel prameters use of bitfields can result in functionality issues.

However, use of bitfields has been desirable feature for some applications, 
there was a discussion about allowing this in the next standards 
(https://github.com/KhronosGroup/OpenCL-Docs/issues/301) but regardless to that 
clang can expose this functionality as a compiler extension for the application 
that can take advanatge of it at the price of reduced portability.

This addresses PR45339!


https://reviews.llvm.org/D101843

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Misc/amdgcn.languageOptsOpenCL.cl
  clang/test/Misc/nvptx.languageOptsOpenCL.cl
  clang/test/Misc/r600.languageOptsOpenCL.cl
  clang/test/SemaOpenCL/unsupported.cl

Index: clang/test/SemaOpenCL/unsupported.cl
===
--- clang/test/SemaOpenCL/unsupported.cl
+++ clang/test/SemaOpenCL/unsupported.cl
@@ -1,7 +1,15 @@
 // RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify %s -DBITFIELDS_EXT
 
-struct {
-  int a : 1; // expected-error {{bit-fields are not supported in OpenCL}}
+#ifdef BITFIELDS_EXT
+#pragma OPENCL EXTENSION __cl_clang_bitfields : enable
+#endif
+
+struct test {
+  int a : 1;
+#ifndef BITFIELDS_EXT
+// expected-error@-2 {{bit-fields are not supported in OpenCL}}
+#endif
 };
 
 void no_vla(int n) {
Index: clang/test/Misc/r600.languageOptsOpenCL.cl
===
--- clang/test/Misc/r600.languageOptsOpenCL.cl
+++ clang/test/Misc/r600.languageOptsOpenCL.cl
@@ -34,6 +34,11 @@
 #endif
 #pragma OPENCL EXTENSION __cl_clang_variadic_functions : enable
 
+#ifndef __cl_clang_bitfields
+#error "Missing __cl_clang_bitfields define"
+#endif
+#pragma OPENCL EXTENSION __cl_clang_bitfields : enable
+
 #ifdef cl_khr_fp16
 #error "Incorrect cl_khr_fp16 define"
 #endif
Index: clang/test/Misc/nvptx.languageOptsOpenCL.cl
===
--- clang/test/Misc/nvptx.languageOptsOpenCL.cl
+++ clang/test/Misc/nvptx.languageOptsOpenCL.cl
@@ -28,6 +28,11 @@
 #endif
 #pragma OPENCL EXTENSION __cl_clang_variadic_functions : enable
 
+#ifndef __cl_clang_bitfields
+#error "Missing __cl_clang_bitfields define"
+#endif
+#pragma OPENCL EXTENSION __cl_clang_bitfields : enable
+
 #ifdef cl_khr_fp16
 #error "Incorrect cl_khr_fp16 define"
 #endif
Index: clang/test/Misc/amdgcn.languageOptsOpenCL.cl
===
--- clang/test/Misc/amdgcn.languageOptsOpenCL.cl
+++ clang/test/Misc/amdgcn.languageOptsOpenCL.cl
@@ -24,6 +24,11 @@
 #endif
 #pragma OPENCL EXTENSION __cl_clang_variadic_functions : enable
 
+#ifndef __cl_clang_bitfields
+#error "Missing __cl_clang_bitfields define"
+#endif
+#pragma OPENCL EXTENSION __cl_clang_bitfields : enable
+
 #ifndef cl_khr_fp16
 #error "Missing cl_khr_fp16 define"
 #endif
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -16796,7 +16796,8 @@
   InvalidDecl = true;
 }
 // OpenCL v1.2 s6.9.c: bitfields are not supported.
-if (BitWidth) {
+if (BitWidth && !getOpenCLOptions().isAvailableOption(
+"__cl_clang_bitfields", LangOpts)) {
   Diag(Loc, diag::err_opencl_bitfields);
   InvalidDecl = true;
 }
Index: clang/lib/Basic/Targets/NVPTX.h
===
--- clang/lib/Basic/Targets/NVPTX.h
+++ clang/lib/Basic/Targets/NVPTX.h
@@ -133,6 +133,7 @@
 Opts["cl_clang_storage_class_specifiers"] = true;
 Opts["__cl_clang_function_pointers"] = true;
 Opts["__cl_clang_variadic_functions"] = true;
+Opts["__cl_clang_bitfields"] = true;
 
 Opts["cl_khr_fp64"] = true;
 Opts["cl_khr_byte_addressable_store"] = true;
Index: clang/lib/Basic/Targets/AMDGPU.h
===
--- clang/lib/Basic/Targets/AMDGPU.h
+++ clang/lib/Basic/Targets/AMDGPU.h
@@ -287,6 +287,7 @@
 Opts["cl_clang_storage_class_specifiers"] = true;
 Opts["__cl_clang_variadic_functions"] = true;
 Opts["__cl_clang_function_pointers"] = true;
+Opts["__cl_clang_bitfields"] = true;
 
 bool IsAMDGCN = isAMDGCN(getTriple());
 
Index: clang/include/clang/Basic/OpenCLExtensions.def
===
--- clang/include/clang/Basic/Op

[PATCH] D101630: [HIP] Fix device-only compilation

2021-05-04 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/include/clang/Driver/Options.td:977
   NegFlag>;
+defm hip_bundle_device_output : BoolFOption<"hip-bundle-device-output", 
EmptyKPM, DefaultTrue,
+  PosFlag,

jansvoboda11 wrote:
> The TableGen marshalling infrastructure (`BoolFOption` et. al.) is only 
> intended for flags that map to the `-cc1` frontend and its 
> `CompilerInvocation` class. (`EmptyKPM` that disables this mapping shouldn't 
> even exist anymore.)
> 
> Since these flags only work on the driver level, use something like this 
> instead:
> 
> ```
> def fhip_bundle_device_output : Flag<["-"], "fhip-bundle-device-output">, 
> Group;
> def fno_hip_bundle_device_output : Flag<["-"], 
> "fno-hip-bundle-device-output">, Group, HelpText<"Do not bundle 
> output files of HIP device compilation">;
> ```

It would be great if `BoolFOption` would at least document that assumption.
It would be even better if it would be allowed to be used to implement a 
driver-only option, maybe with a flag.
The class is very useful to handle -fsomething/-fno-something and restricting 
it to cc1 only will continue to be a constant source of this kind of confusion. 
I think we've already seen handful of them in reviews since the flag tablegen 
got overhauled.


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

https://reviews.llvm.org/D101630

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


[PATCH] D99599: [NewPM] Add an option to dump pass structure

2021-05-04 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D99599#2735582 , @evgeny777 wrote:

>> I've already run into having to update these two golden file tests twice
>
> I think you can just reduce the tests. No need to revert the entire change, 
> unless there is a replacement for it (D101797 
>  is not)

Could you explain why -debug-pass-manager doesn't fit your use case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99599

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


[PATCH] D99599: [NewPM] Add an option to dump pass structure

2021-05-04 Thread Eugene Leviant via Phabricator via cfe-commits
evgeny777 added a comment.

> Could you explain why -debug-pass-manager doesn't fit your use case?

I wanted to have something similar to -debug-pass=Structure, because the above 
is too verbose and lacks identation. What's the problem with this one, anyway?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99599

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


[PATCH] D101628: [Format] Don't sort includes if DisableFormat is true

2021-05-04 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 342778.
njames93 added a comment.

Add test case demonstrating new behvaiour.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101628

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/SortIncludesTest.cpp


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -9,6 +9,7 @@
 #include "FormatTestUtils.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/None.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
@@ -1034,6 +1035,16 @@
   EXPECT_EQ(Expected, sort(Code, "a.cpp", 1));
 }
 
+TEST_F(SortIncludesTest, DisableFormatDisablesIncludeSorting) {
+  StringRef Sorted = "#include \n"
+ "#include \n";
+  StringRef Unsorted = "#include \n"
+   "#include \n";
+  EXPECT_EQ(Sorted, sort(Unsorted));
+  FmtStyle.DisableFormat = true;
+  EXPECT_EQ(Unsorted, sort(Unsorted, "input.cpp", 0));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2603,7 +2603,7 @@
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
   tooling::Replacements Replaces;
-  if (!Style.SortIncludes)
+  if (!Style.SortIncludes || Style.DisableFormat)
 return Replaces;
   if (isLikelyXml(Code))
 return Replaces;


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -9,6 +9,7 @@
 #include "FormatTestUtils.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/None.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
@@ -1034,6 +1035,16 @@
   EXPECT_EQ(Expected, sort(Code, "a.cpp", 1));
 }
 
+TEST_F(SortIncludesTest, DisableFormatDisablesIncludeSorting) {
+  StringRef Sorted = "#include \n"
+ "#include \n";
+  StringRef Unsorted = "#include \n"
+   "#include \n";
+  EXPECT_EQ(Sorted, sort(Unsorted));
+  FmtStyle.DisableFormat = true;
+  EXPECT_EQ(Unsorted, sort(Unsorted, "input.cpp", 0));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2603,7 +2603,7 @@
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
   tooling::Replacements Replaces;
-  if (!Style.SortIncludes)
+  if (!Style.SortIncludes || Style.DisableFormat)
 return Replaces;
   if (isLikelyXml(Code))
 return Replaces;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79714: [Diagnostics] Restore -Wdeprecated warning when user-declared copy assignment operator is defined as deleted (PR45634)

2021-05-04 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

In D79714#2735455 , @Abpostelnicu 
wrote:

> I'm seeing here something very strange, if the user provided copy assignment 
> operator is provided but is = delete and the copy constructor is default this 
> warning will still trigger. Is this something expected?
> I'm referring at this issue from the mozilla 
>  
> code-base.

Yes, that implicit default is deprecated.
If you want your copy constructor to be defaulted, even in the presence of 
deleted SMFs, you should explicitly `=default` it. Here's an example: 
https://godbolt.org/z/GaGn1638E


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79714

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


[PATCH] D101832: [clang] accept -fsanitize-ignorelist= in addition to -fsanitize-blacklist=

2021-05-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added subscribers: vitalybuka, MaskRay.
MaskRay added a comment.

I think @vitalybuka has concrete suggestion on the naming.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101832

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


[PATCH] D100983: [OpenCL] Fix optional image types

2021-05-04 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov accepted this revision.
azabaznov added a comment.

LGTM. Thanks!


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

https://reviews.llvm.org/D100983

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


[PATCH] D100980: [OpenCL] Allow use of double type without extension pragma

2021-05-04 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov accepted this revision.
azabaznov added a comment.
This revision is now accepted and ready to land.

Thanks! Looks good to me in general. See a comment.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:10006
   "use of %select{type|declaration}0 %1 requires %2 support">;
+def ext_opencl_double_without_pragma : Extension<
+  "Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is 
supported">;

nit: this can be extended to use arbitrary type and extension for other patches 
which will eliminate pragmas for types


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

https://reviews.llvm.org/D100980

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


[PATCH] D101572: Make `hasTypeLoc` matcher support more node types.

2021-05-04 Thread Weston Carvalho via Phabricator via cfe-commits
SilensAngelusNex updated this revision to Diff 342790.
SilensAngelusNex retitled this revision from "Make `hasTypeLoc` matcher support 
nodes of type `CXXFunctionalCastExpr` and `CXXTemporaryObjectExpr`." to "Make 
`hasTypeLoc` matcher support more node types.".
SilensAngelusNex added a comment.

Added support for node types in groups #1 and #3.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101572

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -11,6 +11,7 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Support/Host.h"
 #include "gtest/gtest.h"
@@ -375,15 +376,104 @@
   typedefNameDecl(hasType(asString("foo")), hasName("bar";
 }
 
-TEST(HasTypeLoc, MatchesDeclaratorDecls) {
+TEST(HasTypeLoc, MatchesBlockDecl) {
+  EXPECT_TRUE(matchesConditionally(
+  "auto x = ^int (int a, int b) { return a + b; };",
+  blockDecl(hasTypeLoc(loc(asString("int (int, int)", true,
+  {"-fblocks"}));
+}
+
+TEST(HasTypeLoc, MatchesCXXBaseSpecifierAndCtorInitializer) {
+  llvm::StringRef code = R"cpp(
+  class Foo {};
+  class Bar : public Foo {
+Bar() : Foo() {}
+  };
+  )cpp";
+
+  EXPECT_TRUE(matches(
+  code, cxxRecordDecl(hasAnyBase(hasTypeLoc(loc(asString("class Foo")));
+  EXPECT_TRUE(matches(
+  code, cxxCtorInitializer(hasTypeLoc(loc(asString("class Foo"));
+}
+
+TEST(HasTypeLoc, MatchesCXXFunctionalCastExpr) {
+  EXPECT_TRUE(matches("auto x = int(3);",
+  cxxFunctionalCastExpr(hasTypeLoc(loc(asString("int"));
+}
+
+TEST(HasTypeLoc, MatchesCXXNewExpr) {
+  EXPECT_TRUE(matches("auto* x = new int(3);",
+  cxxNewExpr(hasTypeLoc(loc(asString("int"));
+  EXPECT_TRUE(matches("class Foo{}; auto* x = new Foo();",
+  cxxNewExpr(hasTypeLoc(loc(asString("class Foo"));
+}
+
+TEST(HasTypeLoc, MatchesCXXTemporaryObjectExpr) {
+  EXPECT_TRUE(
+  matches("struct Foo { Foo(int, int); }; auto x = Foo(1, 2);",
+  cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("struct Foo"));
+}
+
+TEST(HasTypeLoc, MatchesCXXUnresolvedConstructExpr) {
+  EXPECT_TRUE(
+  matches("template  T make() { return T(); }",
+  cxxUnresolvedConstructExpr(hasTypeLoc(loc(asString("T"));
+}
+
+TEST(HasTypeLoc, MatchesClassTemplateSpecializationDecl) {
+  EXPECT_TRUE(matches(
+  "template  class Foo; template <> class Foo {};",
+  classTemplateSpecializationDecl(hasTypeLoc(loc(asString("Foo"));
+}
+
+TEST(HasTypeLoc, MatchesCompoundLiteralExpr) {
+  EXPECT_TRUE(
+  matches("int* x = (int [2]) { 0, 1 };",
+  compoundLiteralExpr(hasTypeLoc(loc(asString("int [2]"));
+}
+
+TEST(HasTypeLoc, MatchesDeclaratorDecl) {
   EXPECT_TRUE(matches("int x;",
   varDecl(hasName("x"), hasTypeLoc(loc(asString("int"));
+  EXPECT_TRUE(matches("int x(3);",
+  varDecl(hasName("x"), hasTypeLoc(loc(asString("int"));
+  EXPECT_TRUE(
+  matches("struct Foo { Foo(int, int); }; Foo x(1, 2);",
+  varDecl(hasName("x"), hasTypeLoc(loc(asString("struct Foo"));
 
   // Make sure we don't crash on implicit constructors.
   EXPECT_TRUE(notMatches("class X {}; X x;",
  declaratorDecl(hasTypeLoc(loc(asString("int"));
 }
 
+TEST(HasTypeLoc, MatchesExplicitCastExpr) {
+  EXPECT_TRUE(matches("auto x = (int) 3;",
+  explicitCastExpr(hasTypeLoc(loc(asString("int"));
+  EXPECT_TRUE(matches("auto x = static_cast(3);",
+  explicitCastExpr(hasTypeLoc(loc(asString("int"));
+}
+
+TEST(HasTypeLoc, MatchesObjCPropertyDecl) {
+  EXPECT_TRUE(matchesObjC(R"objc(
+  @interface Foo
+  @property int enabled;
+  @end
+)objc",
+  objcPropertyDecl(hasTypeLoc(loc(asString("int"));
+}
+
+TEST(HasTypeLoc, MatchesTemplateArgumentLoc) {
+  EXPECT_TRUE(matches("template  class Foo {}; Foo x;",
+  templateArgumentLoc(hasTypeLoc(loc(asString("int"));
+}
+
+TEST(HasTypeLoc, MatchesTypedefNameDecl) {
+  EXPECT_TRUE(matches("typedef int X;",
+  typedefNameDecl(hasTypeLoc(loc(asString("int"));
+  EXPECT_TRUE(matches("using X = int;",
+  typedefNameDecl(hasTypeLoc(loc(asString("int"));
+}
 
 TEST(Callee, MatchesDeclarations) {
   StatementMatcher CallMethodX = callExpr(

[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-05-04 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 342792.
mibintc added a comment.

I rebased the patch and responded to review comments from @aaron.ballman and 
@jansvoboda11


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93769

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/FPOptions.def
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/PragmaKinds.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Lex/PreprocessorOptions.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/fp-floatcontrol-pragma.cpp
  clang/test/Preprocessor/init-aarch64.c
  clang/test/Preprocessor/init-arm.c
  clang/test/Preprocessor/init-mips.c
  clang/test/Preprocessor/init-ppc.c
  clang/test/Preprocessor/init-ppc64.c
  clang/test/Preprocessor/init-s390x.c
  clang/test/Preprocessor/init-v7k-compat.c
  clang/test/Preprocessor/init-x86.c
  clang/test/Preprocessor/init.c
  clang/test/Preprocessor/predefined-flteval-macro.c

Index: clang/test/Preprocessor/predefined-flteval-macro.c
===
--- /dev/null
+++ clang/test/Preprocessor/predefined-flteval-macro.c
@@ -0,0 +1,346 @@
+// RUN: %clang_cc1 -std=c11  -E -triple=aarch64 -xc  %s | FileCheck %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=arm64 -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64_be -xc  -fsyntax-only %s
+// RUN: %clang_cc1  -triple=arm64 -xc++  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-apple-ios7.0 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-windows-msvc -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=small -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=tiny -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=large -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbv7-windows-msvc -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-none -fsyntax-only %s
+// RUN: %clang_cc1  -x c++ -ffreestanding -triple=arm-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple arm-none-none -target-abi apcs-gnu -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armeb-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-linux-gnueabi -target-feature +soft-float -target-feature +soft-float-abi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-linux-gnueabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armv6-unknown-cloudabi-eabihf -fsyntax-only %s
+// RUN: %clang -c -ffreestanding -target arm-netbsd-eabi -fsyntax-only %s
+// RUN: %clang -c -ffreestanding -target arm-netbsd-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-eabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-eabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-elf -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7s -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv6m -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7m -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7em -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7 -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mhwdiv=arm -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -mhwdiv=thumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mhwdiv=thumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -mhwdiv=arm -x c -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armv8-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armebv8-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbv8 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbebv8 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbv5 -fsyntax-only %s
+

[clang-tools-extra] e1c729c - [clang-tidy][NFC] Update tests and Default options to use boolean value

2021-05-04 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-05-04T18:17:56+01:00
New Revision: e1c729c56829d3b9502b9ac2439003f87231db50

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

LOG: [clang-tidy][NFC] Update tests and Default options to use boolean value

Change instances where options which are boolean are assigned the value 1|0 to 
use true|false instead.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-ignore-single-argument.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-strict.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-array-subscript-expression.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-int.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-pointer-offset.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-widening-cast-explicit-only.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-widening-cast-implicit-enabled.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-not-null-terminated-result-memcpy-before-safe.c

clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier-invert.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-enum-usage-strict.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-enum-usage.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-string-compare.c

clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-string-compare.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment-warn-only-if-this-has-suspicious-field.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage-caps-only.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage-command-line-macros.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-pedanticmode-option.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-modernize-use-default-member-init-assignment.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init-use-assignment.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-special-member-functions-allow-missing-move-when-copy-is-deleted.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-special-member-functions-relaxed.cpp

clang-tools-extra/test/clang-tidy/checkers/hicpp-multiway-paths-covered-else.cpp

clang-tools-extra/test/clang-tidy/checkers/hicpp-signed-bitwise-integer-literals.cpp

clang-tools-extra/test/clang-tidy/checkers/misc-non-private-member-variables-in-classes.cpp
clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters-strict.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind-permissive-parameter-list.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize-make-unique-macros.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-raw-string-literal-delimiter.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize-raw-string-literal.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-auto-cast-remove-stars.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-auto-min-type-name-length.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-auto-new-remove-stars.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-bool-literals-ignore-macros.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize-use-bool-literals.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init-assignment.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init-macros.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace-ignore-implicit-constructors.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-equals-default-copy.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-equals-default-macros.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-us

[PATCH] D100917: [NewPM] Only invalidate modified functions' analyses in CGSCC passes

2021-05-04 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D100917#2735651 , @nikic wrote:

> An unfortunate side-effect of this change is that NewPM uses even more 
> memory. tramp3d-v4 is up 20% in max-rss 
> (https://llvm-compile-time-tracker.com/compare.php?from=4ef1f90e4d564b872e3598ccef45adb740eb0f0d&to=d14d84af2f5ebb8ae2188ce6884a29a586dc0a40&stat=max-rss)

Hmm that is a concern. I'm not sure how we want to balance memory vs compile 
times. Any thoughts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100917

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


[PATCH] D101721: [clang-tidy][NFC] Update tests and Default options to use boolean value

2021-05-04 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe1c729c56829: [clang-tidy][NFC] Update tests and Default 
options to use boolean value (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101721

Files:
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-ignore-single-argument.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-strict.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-array-subscript-expression.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-int.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-pointer-offset.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-widening-cast-explicit-only.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-widening-cast-implicit-enabled.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-not-null-terminated-result-memcpy-before-safe.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier-invert.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-enum-usage-strict.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-enum-usage.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-string-compare.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-string-compare.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment-warn-only-if-this-has-suspicious-field.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage-caps-only.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage-command-line-macros.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-pedanticmode-option.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-modernize-use-default-member-init-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init-use-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-special-member-functions-allow-missing-move-when-copy-is-deleted.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-special-member-functions-relaxed.cpp
  
clang-tools-extra/test/clang-tidy/checkers/hicpp-multiway-paths-covered-else.cpp
  
clang-tools-extra/test/clang-tidy/checkers/hicpp-signed-bitwise-integer-literals.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc-non-private-member-variables-in-classes.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters-strict.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind-permissive-parameter-list.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-make-unique-macros.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-raw-string-literal-delimiter.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-raw-string-literal.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-auto-cast-remove-stars.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-auto-min-type-name-length.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-auto-new-remove-stars.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-bool-literals-ignore-macros.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-bool-literals.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init-macros.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace-ignore-implicit-constructors.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-equals-default-copy.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-equals-default-macros.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-equals-delete-macros.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-override-allow-override-and-final.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-override-no-destructors.cpp
  clang-tools-extra/test/clang-tidy/checkers/mo

[PATCH] D101572: Make `hasTypeLoc` matcher support more node types.

2021-05-04 Thread Weston Carvalho via Phabricator via cfe-commits
SilensAngelusNex added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:138-150
+template  struct disjunction;
+template  struct disjunction : public T {};
+template  struct disjunction {
+  using type =
+  typename std::conditional>::type;
+  static constexpr bool value = type::value;
+};

Is there a better way to express this? I was originally using

```
template  struct is_one_of {
  template 
  static constexpr bool value = (std::is_base_of_v || ...);
};
```
but that didn't compile because `is_base_of_v` and fold expressions are C++17 
features.

Maybe it would be better to just explicitly write out an overload of 
`GetTypeSourceInfo` for each type?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101572

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


[PATCH] D100917: [NewPM] Only invalidate modified functions' analyses in CGSCC passes

2021-05-04 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin added a comment.

In D100917#2736702 , @aeubanks wrote:

> In D100917#2735651 , @nikic wrote:
>
>> An unfortunate side-effect of this change is that NewPM uses even more 
>> memory. tramp3d-v4 is up 20% in max-rss 
>> (https://llvm-compile-time-tracker.com/compare.php?from=4ef1f90e4d564b872e3598ccef45adb740eb0f0d&to=d14d84af2f5ebb8ae2188ce6884a29a586dc0a40&stat=max-rss)
>
> Hmm that is a concern. I'm not sure how we want to balance memory vs compile 
> times. Any thoughts?

(Drive-by thought) - maybe this is because a bunch of analyses that are needed 
during function simplification aren't needed anymore after. We could quickly 
check by adding a pass at the end of all function simplification, module-wide, 
that clears all fct analyses, and see if the memory overhead is still there?

If that's the case, we could identify what's not needed after function 
simplification and scope it somehow in a less hacky way than my above 
suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100917

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


[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-05-04 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked 5 inline comments as done.
mibintc added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.h:234
+FEM_Extended,
+/// Use the default float eval method specified by Target
+FEM_TargetDefault

mibintc wrote:
> aaron.ballman wrote:
> > FYI: it may be somewhat confusing that we have an enumerator with `default` 
> > in the name but that enumerator isn't the default.
> That's true. I had a heck of a time getting the initialization of the lang 
> option setting correct: the setting should come from the TargetInfo if 
> command line options don't override. That seems simple enough but there's 
> somethng really odd about initialization. Adding the "default target" 
> enumeral allowed me to get it initialized the way I wanted.
I redid the comments to eliminate the confusion



Comment at: clang/lib/Sema/SemaAttr.cpp:429
+  case PFC_Source:
+//Builder.defineMacro("__FLT_EVAL_METHOD__", Twine("0"));
+NewFPFeatures.setFPEvalMethodOverride(LangOptions::FEM_Source);

mibintc wrote:
> @rjmccall I would like to push a new value for __FLT_EVAL_METHOD__ at the 
> start of the scope of this pragma, then pop that value of the macro to 
> restore the previous setting when the scope is exited, should I do that in 
> ParsePragma? Can I do that by injecting "pragma push_macro(...)" into the 
> token stream, do you have other suggestion or is there something similar in 
> clang that I can study how to do this? 
Nevermind, I found a way to set the macro.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93769

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


[PATCH] D101628: [Format] Don't sort includes if DisableFormat is true

2021-05-04 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.

LGTM. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101628

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


[clang] b451ecd - [Clang][AArch64] Disable rounding of return values for AArch64

2021-05-04 Thread Andrew Savonichev via cfe-commits

Author: Andrew Savonichev
Date: 2021-05-04T20:29:01+03:00
New Revision: b451ecd86e13ec6ef47caf37f62977645c4f748e

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

LOG: [Clang][AArch64] Disable rounding of return values for AArch64

If a return value is explicitly rounded to 64 bits, an additional zext
instruction is emitted, and in some cases it prevents tail call
optimization.

As discussed in D100225, this rounding is not necessary and can be
disabled.

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

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/aarch64-varargs.c
clang/test/CodeGen/arm64-arguments.c
clang/test/CodeGen/arm64-microsoft-arguments.cpp
clang/test/CodeGen/attr-noundef.cpp
clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
clang/test/CodeGenCXX/trivial_abi.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 9577b61ca6d0..633b963965ed 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -5781,6 +5781,18 @@ ABIArgInfo AArch64ABIInfo::classifyReturnType(QualType 
RetTy,
 if (getTarget().isRenderScriptTarget()) {
   return coerceToIntArray(RetTy, getContext(), getVMContext());
 }
+
+if (Size <= 64 && getDataLayout().isLittleEndian()) {
+  // Composite types are returned in lower bits of a 64-bit register for 
LE,
+  // and in higher bits for BE. However, integer types are always returned
+  // in lower bits for both LE and BE, and they are not rounded up to
+  // 64-bits. We can skip rounding up of composite types for LE, but not 
for
+  // BE, otherwise composite types will be indistinguishable from integer
+  // types.
+  return ABIArgInfo::getDirect(
+  llvm::IntegerType::get(getVMContext(), Size));
+}
+
 unsigned Alignment = getContext().getTypeAlign(RetTy);
 Size = llvm::alignTo(Size, 64); // round up to multiple of 8 bytes
 

diff  --git a/clang/test/CodeGen/aarch64-varargs.c 
b/clang/test/CodeGen/aarch64-varargs.c
index b71ec4af7aca..908fb4ae5d10 100644
--- a/clang/test/CodeGen/aarch64-varargs.c
+++ b/clang/test/CodeGen/aarch64-varargs.c
@@ -473,7 +473,8 @@ typedef struct __attribute__((packed,aligned(2))) {
   int val;
 } underaligned_int_struct;
 underaligned_int_struct underaligned_int_struct_test() {
-// CHECK-LABEL: define{{.*}} i64 @underaligned_int_struct_test()
+// CHECK-LE-LABEL: define{{.*}} i32 @underaligned_int_struct_test()
+// CHECK-BE-LABEL: define{{.*}} i64 @underaligned_int_struct_test()
   return va_arg(the_list, underaligned_int_struct);
 // CHECK: [[GR_OFFS:%[a-z_0-9]+]] = load i32, i32* getelementptr inbounds 
(%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 3)
 // CHECK: [[EARLY_ONSTACK:%[a-z_0-9]+]] = icmp sge i32 [[GR_OFFS]], 0
@@ -675,7 +676,8 @@ typedef struct {
   int val __attribute__((packed,aligned(2)));
 } underaligned_int_struct_member;
 underaligned_int_struct_member underaligned_int_struct_member_test() {
-// CHECK-LABEL: define{{.*}} i64 @underaligned_int_struct_member_test()
+// CHECK-LE-LABEL: define{{.*}} i32 @underaligned_int_struct_member_test()
+// CHECK-BE-LABEL: define{{.*}} i64 @underaligned_int_struct_member_test()
   return va_arg(the_list, underaligned_int_struct_member);
 // CHECK: [[GR_OFFS:%[a-z_0-9]+]] = load i32, i32* getelementptr inbounds 
(%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 3)
 // CHECK: [[EARLY_ONSTACK:%[a-z_0-9]+]] = icmp sge i32 [[GR_OFFS]], 0

diff  --git a/clang/test/CodeGen/arm64-arguments.c 
b/clang/test/CodeGen/arm64-arguments.c
index a40e5365cc51..b362346aa8a8 100644
--- a/clang/test/CodeGen/arm64-arguments.c
+++ b/clang/test/CodeGen/arm64-arguments.c
@@ -1,33 +1,41 @@
-// RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon -target-abi 
darwinpcs -ffreestanding -emit-llvm -w -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon -target-abi 
darwinpcs -ffreestanding -emit-llvm -w -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-LE
+// RUN: %clang_cc1 -triple aarch64_be-none-linux-gnu -target-feature +neon 
-target-abi darwinpcs -ffreestanding -emit-llvm -w -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-BE
 
 // CHECK: define{{.*}} signext i8 @f0()
 char f0(void) {
   return 0;
 }
 
-// Struct as return type. Aggregates <= 16 bytes are passed directly and round
-// up to multiple of 8 bytes.
-// CHECK: define{{.*}} i64 @f1()
+// Struct as return type. Aggregates <= 16 bytes are passed directly. For BE,
+// return values are round up to 64 bits.
+//
+// CHECK-LE: define{{.*}} i8 @f1()
+// CHECK-BE: define{{.*}} i64 @f1()
 struct s1 { char f0; };
 struct s1 f1(void) {}
 
-// CHECK: define{{.*}} i6

[PATCH] D100591: [Clang][AArch64] Disable rounding of return values for AArch64

2021-05-04 Thread Andrew Savonichev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb451ecd86e13: [Clang][AArch64] Disable rounding of return 
values for AArch64 (authored by asavonic).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100591

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aarch64-varargs.c
  clang/test/CodeGen/arm64-arguments.c
  clang/test/CodeGen/arm64-microsoft-arguments.cpp
  clang/test/CodeGen/attr-noundef.cpp
  clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
  clang/test/CodeGenCXX/trivial_abi.cpp

Index: clang/test/CodeGenCXX/trivial_abi.cpp
===
--- clang/test/CodeGenCXX/trivial_abi.cpp
+++ clang/test/CodeGenCXX/trivial_abi.cpp
@@ -198,12 +198,11 @@
   testReturnLarge();
 }
 
-// CHECK: define{{.*}} i64 @_Z20testReturnHasTrivialv()
+// CHECK: define{{.*}} i32 @_Z20testReturnHasTrivialv()
 // CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_TRIVIAL:.*]], align 4
 // CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_TRIVIAL]], %[[STRUCT_TRIVIAL]]* %[[RETVAL]], i32 0, i32 0
 // CHECK: %[[V0:.*]] = load i32, i32* %[[COERCE_DIVE]], align 4
-// CHECK: %[[COERCE_VAL_II:.*]] = zext i32 %[[V0]] to i64
-// CHECK: ret i64 %[[COERCE_VAL_II]]
+// CHECK: ret i32 %[[V0]]
 // CHECK: }
 
 Trivial testReturnHasTrivial() {
Index: clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
@@ -87,7 +87,7 @@
 // LINUX-LABEL: define{{.*}} void @_Z12small_returnv(%struct.Small* noalias sret(%struct.Small) align 4 %agg.result)
 // WIN32: define dso_local i32 @"?small_return@@YA?AUSmall@@XZ"()
 // WIN64: define dso_local i32 @"?small_return@@YA?AUSmall@@XZ"()
-// WOA64: define dso_local i64 @"?small_return@@YA?AUSmall@@XZ"()
+// WOA64: define dso_local i32 @"?small_return@@YA?AUSmall@@XZ"()
 
 Medium medium_return() { return Medium(); }
 // LINUX-LABEL: define{{.*}} void @_Z13medium_returnv(%struct.Medium* noalias sret(%struct.Medium) align 4 %agg.result)
Index: clang/test/CodeGen/attr-noundef.cpp
===
--- clang/test/CodeGen/attr-noundef.cpp
+++ clang/test/CodeGen/attr-noundef.cpp
@@ -11,7 +11,7 @@
 Trivial ret_trivial() { return {}; }
 void pass_trivial(Trivial e) {}
 // CHECK-INTEL: [[DEFINE:define( dso_local)?]] i32 @{{.*}}ret_trivial
-// CHECK-AARCH: [[DEFINE:define( dso_local)?]] i64 @{{.*}}ret_trivial
+// CHECK-AARCH: [[DEFINE:define( dso_local)?]] i32 @{{.*}}ret_trivial
 // CHECK-INTEL: [[DEFINE]] void @{{.*}}pass_trivial{{.*}}(i32 %
 // CHECK-AARCH: [[DEFINE]] void @{{.*}}pass_trivial{{.*}}(i64 %
 
@@ -43,7 +43,7 @@
 Trivial ret_trivial() { return {}; }
 void pass_trivial(Trivial e) {}
 // CHECK-INTEL: [[DEFINE]] i32 @{{.*}}ret_trivial
-// CHECK-AARCH: [[DEFINE]] i64 @{{.*}}ret_trivial
+// CHECK-AARCH: [[DEFINE]] i32 @{{.*}}ret_trivial
 // CHECK-INTEL: [[DEFINE]] void @{{.*}}pass_trivial{{.*}}(i32 %
 // CHECK-AARCH: [[DEFINE]] void @{{.*}}pass_trivial{{.*}}(i64 %
 
Index: clang/test/CodeGen/arm64-microsoft-arguments.cpp
===
--- clang/test/CodeGen/arm64-microsoft-arguments.cpp
+++ clang/test/CodeGen/arm64-microsoft-arguments.cpp
@@ -104,8 +104,8 @@
 
 // Pass and return an object with a non-trivial explicitly defaulted constructor
 // (passed directly, returned directly)
-// CHECK: define {{.*}} i64 @"?f6@@YA?AUS6@@XZ"()
-// CHECK: call i64 {{.*}}func6{{.*}}(i64 {{.*}})
+// CHECK: define {{.*}} i8 @"?f6@@YA?AUS6@@XZ"()
+// CHECK: call i8 {{.*}}func6{{.*}}(i64 {{.*}})
 struct S6a {
   S6a();
 };
@@ -123,8 +123,8 @@
 
 // Pass and return an object with a non-trivial implicitly defaulted constructor
 // (passed directly, returned directly)
-// CHECK: define {{.*}} i64 @"?f7@@YA?AUS7@@XZ"()
-// CHECK: call i64 {{.*}}func7{{.*}}(i64 {{.*}})
+// CHECK: define {{.*}} i8 @"?f7@@YA?AUS7@@XZ"()
+// CHECK: call i8 {{.*}}func7{{.*}}(i64 {{.*}})
 struct S7 {
   S6a x;
 };
Index: clang/test/CodeGen/arm64-arguments.c
===
--- clang/test/CodeGen/arm64-arguments.c
+++ clang/test/CodeGen/arm64-arguments.c
@@ -1,33 +1,41 @@
-// RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon -target-abi darwinpcs -ffreestanding -emit-llvm -w -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon -target-abi darwinpcs -ffreestanding -emit-llvm -w -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang_cc1 -triple aarch64_be-none-linux-gnu -target-feature +neon -target-abi darwinpcs -ffreestanding -emit-llvm -w -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 
 // CHECK: define{{.*}} signext i8 @f0()
 char f0(void) {
   re

[clang] 84c4754 - [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2021-05-04 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-05-04T10:52:13-07:00
New Revision: 84c475437267e7fffedc40029ce274b099d8f8f3

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

LOG: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

This implements the flag proposed in RFC
http://lists.llvm.org/pipermail/cfe-dev/2020-August/066437.html.

The goal is to add a way to override the default target C++ ABI through a
compiler flag. This makes it easier to test and transition between different
C++ ABIs through compile flags rather than build flags.

In this patch:

- Store -fc++-abi= in a LangOpt. This isn't stored in a CodeGenOpt because
  there are instances outside of codegen where Clang needs to know what the
  ABI is (particularly through ASTContext::createCXXABI), and we should be
  able to override the target default if the flag is provided at that point.
- Expose the existing ABIs in TargetCXXABI as values that can be passed
  through this flag.
  - Create a .def file for these ABIs to make it easier to check flag values.
  - Add an error for diagnosing bad ABI flag values.

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

Added: 
clang/include/clang/Basic/TargetCXXABI.def
clang/test/CodeGenCXX/cxx-abi-switch.cpp
clang/test/Frontend/invalid-cxx-abi.cpp

Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Basic/TargetCXXABI.h
clang/include/clang/Driver/Options.td
clang/lib/AST/ASTContext.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 1b73e4a2b8ee9..bef793831c6b2 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -40,6 +40,7 @@
 #include "clang/Basic/ProfileList.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
+#include "clang/Basic/TargetCXXABI.h"
 #include "clang/Basic/XRayLists.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -730,6 +731,11 @@ class ASTContext : public RefCountedBase {
 return FullSourceLoc(Loc,SourceMgr);
   }
 
+  /// Return the C++ ABI kind that should be used. The C++ ABI can be overriden
+  /// at compile time with `-fc++-abi=`. If this is not provided, we instead 
use
+  /// the default ABI set by the target.
+  TargetCXXABI::Kind getCXXABIKind() const;
+
   /// All comments in this translation unit.
   RawCommentList Comments;
 

diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 92ce91c11b71e..0e3ac3065ebc5 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -540,6 +540,9 @@ def err_drv_invalid_object_mode : Error<"OBJECT_MODE 
setting %0 is not recognize
 def err_aix_default_altivec_abi : Error<
   "The default Altivec ABI on AIX is not yet supported, use '-mabi=vec-extabi' 
for the extended Altivec ABI">;
 
+def err_invalid_cxx_abi : Error<"Invalid C++ ABI name '%0'">;
+def err_unsupported_cxx_abi : Error<"C++ ABI '%0' is not supported on target 
triple '%1'">;
+
 def note_cc1_round_trip_original : Note<"Original arguments in round-trip: 
%0">;
 def note_cc1_round_trip_generated : Note<"Generated arguments #%0 in 
round-trip: %1">;
 def remark_cc1_round_trip_generated : Remark<"Generated arguments #%0 in 
round-trip: %1">, InGroup;

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 85fe4af720235..5ccac6367a5f3 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -19,6 +19,7 @@
 #include "clang/Basic/LangStandard.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/Sanitizers.h"
+#include "clang/Basic/TargetCXXABI.h"
 #include "clang/Basic/Visibility.h"
 #include "llvm/ADT/FloatingPointMode.h"
 #include "llvm/ADT/StringRef.h"
@@ -337,6 +338,10 @@ class LangOptions : public LangOptionsBase {
   /// like CUDA/HIP.
   std::string CUID;
 
+  /// C++ ABI to compile with, if specified by the frontend through -fc++-abi=.
+  /// This overrides the default ABI used by the target.
+  llvm::Optional CXXABI;
+
   /// Indicates whether the front-end is explicitly told that the
   /// input is a header file (i.e. -x c-header).
   bool IsHeaderFile = false;

diff  --git a/clang/include/clang/Basic/TargetCXXABI.def 
b/clang/include/clang/Basic/TargetCXXABI.def
new file mode 100644
index 0..9501cca760945
--- /dev/null
+++ b/clang/include

[PATCH] D85802: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2021-05-04 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG84c475437267: [clang] Add -fc++-abi= flag for specifying 
which C++ ABI to use (authored by leonardchan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85802

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TargetCXXABI.def
  clang/include/clang/Basic/TargetCXXABI.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/cxx-abi-switch.cpp
  clang/test/Frontend/invalid-cxx-abi.cpp

Index: clang/test/Frontend/invalid-cxx-abi.cpp
===
--- /dev/null
+++ clang/test/Frontend/invalid-cxx-abi.cpp
@@ -0,0 +1,34 @@
+// These should succeed.
+// RUN: %clang -c -fc++-abi=itanium %s
+// RUN: %clang -c -fc++-abi=arm -target arm64 %s
+// RUN: %clang -c -fc++-abi=ios -target arm64-apple-ios %s
+// RUN: %clang -c -fc++-abi=aarch64 -target arm64 %s
+// RUN: %clang -c -fc++-abi=mips -target mips %s
+// RUN: %clang -c -fc++-abi=webassembly -target wasm64 %s
+// RUN: %clang -c -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s
+// RUN: %clang -S -fc++-abi=xl -target powerpc-unknown-aix %s -o /dev/null
+// RUN: %clang -c -fc++-abi=microsoft -target x86_64-windows-msvc %s
+// RUN: %clang_cc1 -fc++-abi=itanium %s
+// RUN: %clang_cc1 -fc++-abi=arm -triple arm64 %s
+// RUN: %clang_cc1 -fc++-abi=ios -triple arm64-apple-ios %s
+// RUN: %clang_cc1 -fc++-abi=aarch64 -triple arm64 %s
+// RUN: %clang_cc1 -fc++-abi=mips -triple mips %s
+// RUN: %clang_cc1 -fc++-abi=webassembly -triple wasm64 %s
+// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s
+// RUN: %clang_cc1 -S -fc++-abi=xl -triple powerpc-unknown-aix %s -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s
+
+// RUN: not %clang -c -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s -check-prefix=INVALID
+// RUN: not %clang -c -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s -check-prefix=CASE-SENSITIVE
+// RUN: not %clang_cc1 -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s -check-prefix=INVALID
+// RUN: not %clang_cc1 -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s -check-prefix=CASE-SENSITIVE
+// INVALID: error: Invalid C++ ABI name 'InvalidABI'
+// CASE-SENSITIVE: error: Invalid C++ ABI name 'Fuchsia'
+
+// The flag is propgated from the driver to cc1.
+// RUN: %clang -fc++-abi=InvalidABI %s -### 2>&1 | FileCheck %s -check-prefix=CC1-FLAG
+// CC1-FLAG: -fc++-abi=InvalidABI
+
+// Some C++ ABIs are not supported on some platforms.
+// RUN: not %clang_cc1 -c -fc++-abi=fuchsia -triple i386 %s 2>&1 | FileCheck %s -check-prefix=UNSUPPORTED-FUCHSIA
+// UNSUPPORTED-FUCHSIA: error: C++ ABI 'fuchsia' is not supported on target triple 'i386'
Index: clang/test/CodeGenCXX/cxx-abi-switch.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx-abi-switch.cpp
@@ -0,0 +1,28 @@
+// Assert that the ABI switch uses the proper codegen. Fuchsia uses the
+// "return this" ABI on constructors and destructors by default, but if we
+// explicitly choose the generic itanium C++ ABI, we should not return "this" on
+// ctors/dtors.
+//
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-unknown-fuchsia -fc++-abi=itanium | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=aarch64-unknown-fuchsia -fc++-abi=itanium | FileCheck %s
+
+class A {
+public:
+  virtual ~A();
+  int x_;
+};
+
+class B : public A {
+public:
+  B(int *i);
+  virtual ~B();
+  int *i_;
+};
+
+B::B(int *i) : i_(i) {}
+B::~B() {}
+
+// CHECK: define{{.*}} void @_ZN1BC2EPi(%class.B* {{[^,]*}} %this, i32* %i)
+// CHECK: define{{.*}} void @_ZN1BC1EPi(%class.B* {{[^,]*}} %this, i32* %i)
+// CHECK: define{{.*}} void @_ZN1BD2Ev(%class.B* {{[^,]*}} %this)
+// CHECK: define{{.*}} void @_ZN1BD1Ev(%class.B* {{[^,]*}} %this)
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3512,6 +3512,10 @@
   if (Opts.getSignReturnAddressKey() ==
   LangOptions::SignReturnAddressKeyKind::BKey)
 GenerateArg(Args, OPT_msign_return_address_key_EQ, "b_key", SA);
+
+  if (Opts.CXXABI)
+GenerateArg(Args, OPT_fcxx_abi_EQ, TargetCXXABI::getSpelling(*Opts.CXXABI),
+SA);
 }
 
 bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
@@ -3996,6 +4000,20 @@
 }
   }
 
+  // The value can be empty, which indicates the system default should be used.
+  StringRef CXXABI = Args.getLastArgValue(OPT_fcxx_abi_EQ);
+  if (!CXXABI.em

[clang] 61dc0f2 - [Format] Don't sort includes if DisableFormat is true

2021-05-04 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-05-04T19:04:12+01:00
New Revision: 61dc0f2b593da149a4c0cea67819cd7bdbdd50b8

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

LOG: [Format] Don't sort includes if DisableFormat is true

Fixes https://llvm.org/PR35099.

I'm not sure if this decision was intentional but its definitely confusing for 
users.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, curdeius

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

Added: 


Modified: 
clang/lib/Format/Format.cpp
clang/unittests/Format/SortIncludesTest.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index ba7b03de8b3d3..f1508b98653d7 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2605,7 +2605,7 @@ tooling::Replacements sortIncludes(const FormatStyle 
&Style, StringRef Code,
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
   tooling::Replacements Replaces;
-  if (!Style.SortIncludes)
+  if (!Style.SortIncludes || Style.DisableFormat)
 return Replaces;
   if (isLikelyXml(Code))
 return Replaces;

diff  --git a/clang/unittests/Format/SortIncludesTest.cpp 
b/clang/unittests/Format/SortIncludesTest.cpp
index 47ec319294bae..4efeb96124bf4 100644
--- a/clang/unittests/Format/SortIncludesTest.cpp
+++ b/clang/unittests/Format/SortIncludesTest.cpp
@@ -9,6 +9,7 @@
 #include "FormatTestUtils.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/None.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
@@ -1034,6 +1035,16 @@ TEST_F(SortIncludesTest, MergeLines) {
   EXPECT_EQ(Expected, sort(Code, "a.cpp", 1));
 }
 
+TEST_F(SortIncludesTest, DisableFormatDisablesIncludeSorting) {
+  StringRef Sorted = "#include \n"
+ "#include \n";
+  StringRef Unsorted = "#include \n"
+   "#include \n";
+  EXPECT_EQ(Sorted, sort(Unsorted));
+  FmtStyle.DisableFormat = true;
+  EXPECT_EQ(Unsorted, sort(Unsorted, "input.cpp", 0));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang



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


[PATCH] D101628: [Format] Don't sort includes if DisableFormat is true

2021-05-04 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG61dc0f2b593d: [Format] Don't sort includes if 
DisableFormat is true (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101628

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/SortIncludesTest.cpp


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -9,6 +9,7 @@
 #include "FormatTestUtils.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/None.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
@@ -1034,6 +1035,16 @@
   EXPECT_EQ(Expected, sort(Code, "a.cpp", 1));
 }
 
+TEST_F(SortIncludesTest, DisableFormatDisablesIncludeSorting) {
+  StringRef Sorted = "#include \n"
+ "#include \n";
+  StringRef Unsorted = "#include \n"
+   "#include \n";
+  EXPECT_EQ(Sorted, sort(Unsorted));
+  FmtStyle.DisableFormat = true;
+  EXPECT_EQ(Unsorted, sort(Unsorted, "input.cpp", 0));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2605,7 +2605,7 @@
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
   tooling::Replacements Replaces;
-  if (!Style.SortIncludes)
+  if (!Style.SortIncludes || Style.DisableFormat)
 return Replaces;
   if (isLikelyXml(Code))
 return Replaces;


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -9,6 +9,7 @@
 #include "FormatTestUtils.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/None.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
@@ -1034,6 +1035,16 @@
   EXPECT_EQ(Expected, sort(Code, "a.cpp", 1));
 }
 
+TEST_F(SortIncludesTest, DisableFormatDisablesIncludeSorting) {
+  StringRef Sorted = "#include \n"
+ "#include \n";
+  StringRef Unsorted = "#include \n"
+   "#include \n";
+  EXPECT_EQ(Sorted, sort(Unsorted));
+  FmtStyle.DisableFormat = true;
+  EXPECT_EQ(Unsorted, sort(Unsorted, "input.cpp", 0));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2605,7 +2605,7 @@
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
   tooling::Replacements Replaces;
-  if (!Style.SortIncludes)
+  if (!Style.SortIncludes || Style.DisableFormat)
 return Replaces;
   if (isLikelyXml(Code))
 return Replaces;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101682: [Driver] Fix `ToolChain::getCompilerRTPath()` to return the correct path on Apple platforms.

2021-05-04 Thread Dan Liew via Phabricator via cfe-commits
delcypher updated this revision to Diff 342809.
delcypher edited the summary of this revision.
delcypher added a comment.

Use `isOSDarwin()` instead of explicitly checking Darwin OS enum values.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101682

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/darwin-print-file-name.c
  clang/test/Driver/darwin-print-runtime-dir.c


Index: clang/test/Driver/darwin-print-runtime-dir.c
===
--- /dev/null
+++ clang/test/Driver/darwin-print-runtime-dir.c
@@ -0,0 +1,24 @@
+// Regression test. Previously the output returned the full OS name
+// (e.g. `darwin20.3.0`) instead of just `darwin`.
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-darwin20.3.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-macosx11.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-ios14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-tvos14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-watchos5.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// PRINT-RUNTIME-DIR: lib{{/|\\}}darwin{{$}}
Index: clang/test/Driver/darwin-print-file-name.c
===
--- /dev/null
+++ clang/test/Driver/darwin-print-file-name.c
@@ -0,0 +1,27 @@
+// Regression test. Previously Clang just returned the library name instead
+// of the full path.
+
+// RUN: %clang -print-file-name=libclang_rt.osx.a 
--target=x86_64-apple-darwin20.3.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-file-name=libclang_rt.osx.a 
--target=x86_64-apple-macosx11.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// PRINT-RUNTIME-DIR: lib{{/|\\}}darwin{{/|\\}}libclang_rt.osx.a
+
+// RUN: %clang -print-file-name=libclang_rt.ios.a 
--target=arm64-apple-ios14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-IOS %s
+// PRINT-RUNTIME-DIR-IOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.ios.a
+
+// RUN: %clang -print-file-name=libclang_rt.tvos.a 
--target=arm64-apple-tvos14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-TVOS %s
+// PRINT-RUNTIME-DIR-TVOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.tvos.a
+
+// RUN: %clang -print-file-name=libclang_rt.watchos.a 
--target=arm64-apple-watchos5.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-WATCHOS %s
+// PRINT-RUNTIME-DIR-WATCHOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.watchos.a
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -387,6 +387,9 @@
 }
 
 StringRef ToolChain::getOSLibName() const {
+  if (Triple.isOSDarwin())
+return "darwin";
+
   switch (Triple.getOS()) {
   case llvm::Triple::FreeBSD:
 return "freebsd";


Index: clang/test/Driver/darwin-print-runtime-dir.c
===
--- /dev/null
+++ clang/test/Driver/darwin-print-runtime-dir.c
@@ -0,0 +1,24 @@
+// Regression test. Previously the output returned the full OS name
+// (e.g. `darwin20.3.0`) instead of just `darwin`.
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-darwin20.3.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-macosx11.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-ios14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-tvos14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-watchos5.0.0 \
+// RUN:-resource-dir=%S/Inputs/

[PATCH] D101682: [Driver] Fix `ToolChain::getCompilerRTPath()` to return the correct path on Apple platforms.

2021-05-04 Thread Dan Liew via Phabricator via cfe-commits
delcypher marked an inline comment as done.
delcypher added inline comments.



Comment at: clang/lib/Driver/ToolChain.cpp:408
   default:
 return getOS();
   }

arphaman wrote:
> It might be cleaner to do a check for `isOSDarwin` here, as that will help 
> with any other Darwin platforms that we need to support.
@arphaman That seems like a good idea. I didn't know this API existed. I'll try 
to switch to that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101682

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


[clang] 1971823 - [Driver] Fix `ToolChain::getCompilerRTPath()` to return the correct path on Apple platforms.

2021-05-04 Thread Dan Liew via cfe-commits

Author: Dan Liew
Date: 2021-05-04T11:28:26-07:00
New Revision: 1971823ecb9eaa077554a5d268a44c7cb75eccce

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

LOG: [Driver] Fix `ToolChain::getCompilerRTPath()` to return the correct path 
on Apple platforms.

When the target triple was an Apple platform `ToolChain::getOSLibName()`
(called by `getCompilerRTPath()`) would return the full OS name
including the version number (e.g. `darwin20.3.0`). This is not correct
because the library directory for all Apple platforms is `darwin`.

This in turn caused

* `-print-runtime-dir` to return a non-existant path.
* `-print-file-name=` to return the filename
  instead of the full path to the library.

Two regression tests are included.

rdar://77417317

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

Added: 
clang/test/Driver/darwin-print-file-name.c
clang/test/Driver/darwin-print-runtime-dir.c

Modified: 
clang/lib/Driver/ToolChain.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 88bc640a0b2d..3342de85fc30 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -387,6 +387,9 @@ static StringRef getArchNameForCompilerRTLib(const 
ToolChain &TC,
 }
 
 StringRef ToolChain::getOSLibName() const {
+  if (Triple.isOSDarwin())
+return "darwin";
+
   switch (Triple.getOS()) {
   case llvm::Triple::FreeBSD:
 return "freebsd";

diff  --git a/clang/test/Driver/darwin-print-file-name.c 
b/clang/test/Driver/darwin-print-file-name.c
new file mode 100644
index ..91623a4c589f
--- /dev/null
+++ b/clang/test/Driver/darwin-print-file-name.c
@@ -0,0 +1,27 @@
+// Regression test. Previously Clang just returned the library name instead
+// of the full path.
+
+// RUN: %clang -print-file-name=libclang_rt.osx.a 
--target=x86_64-apple-darwin20.3.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-file-name=libclang_rt.osx.a 
--target=x86_64-apple-macosx11.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// PRINT-RUNTIME-DIR: lib{{/|\\}}darwin{{/|\\}}libclang_rt.osx.a
+
+// RUN: %clang -print-file-name=libclang_rt.ios.a 
--target=arm64-apple-ios14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-IOS %s
+// PRINT-RUNTIME-DIR-IOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.ios.a
+
+// RUN: %clang -print-file-name=libclang_rt.tvos.a 
--target=arm64-apple-tvos14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-TVOS %s
+// PRINT-RUNTIME-DIR-TVOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.tvos.a
+
+// RUN: %clang -print-file-name=libclang_rt.watchos.a 
--target=arm64-apple-watchos5.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-WATCHOS %s
+// PRINT-RUNTIME-DIR-WATCHOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.watchos.a

diff  --git a/clang/test/Driver/darwin-print-runtime-dir.c 
b/clang/test/Driver/darwin-print-runtime-dir.c
new file mode 100644
index ..967cdbfa94b7
--- /dev/null
+++ b/clang/test/Driver/darwin-print-runtime-dir.c
@@ -0,0 +1,24 @@
+// Regression test. Previously the output returned the full OS name
+// (e.g. `darwin20.3.0`) instead of just `darwin`.
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-darwin20.3.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-macosx11.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-ios14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-tvos14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-watchos5.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// PRINT-RUNTIME-DIR: lib{{/|\\}}darwin{{$}}



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


[PATCH] D101682: [Driver] Fix `ToolChain::getCompilerRTPath()` to return the correct path on Apple platforms.

2021-05-04 Thread Dan Liew 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 rG1971823ecb9e: [Driver] Fix `ToolChain::getCompilerRTPath()` 
to return the correct path on… (authored by delcypher).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101682

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/darwin-print-file-name.c
  clang/test/Driver/darwin-print-runtime-dir.c


Index: clang/test/Driver/darwin-print-runtime-dir.c
===
--- /dev/null
+++ clang/test/Driver/darwin-print-runtime-dir.c
@@ -0,0 +1,24 @@
+// Regression test. Previously the output returned the full OS name
+// (e.g. `darwin20.3.0`) instead of just `darwin`.
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-darwin20.3.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-macosx11.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-ios14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-tvos14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-watchos5.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// PRINT-RUNTIME-DIR: lib{{/|\\}}darwin{{$}}
Index: clang/test/Driver/darwin-print-file-name.c
===
--- /dev/null
+++ clang/test/Driver/darwin-print-file-name.c
@@ -0,0 +1,27 @@
+// Regression test. Previously Clang just returned the library name instead
+// of the full path.
+
+// RUN: %clang -print-file-name=libclang_rt.osx.a 
--target=x86_64-apple-darwin20.3.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-file-name=libclang_rt.osx.a 
--target=x86_64-apple-macosx11.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// PRINT-RUNTIME-DIR: lib{{/|\\}}darwin{{/|\\}}libclang_rt.osx.a
+
+// RUN: %clang -print-file-name=libclang_rt.ios.a 
--target=arm64-apple-ios14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-IOS %s
+// PRINT-RUNTIME-DIR-IOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.ios.a
+
+// RUN: %clang -print-file-name=libclang_rt.tvos.a 
--target=arm64-apple-tvos14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-TVOS %s
+// PRINT-RUNTIME-DIR-TVOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.tvos.a
+
+// RUN: %clang -print-file-name=libclang_rt.watchos.a 
--target=arm64-apple-watchos5.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-WATCHOS %s
+// PRINT-RUNTIME-DIR-WATCHOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.watchos.a
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -387,6 +387,9 @@
 }
 
 StringRef ToolChain::getOSLibName() const {
+  if (Triple.isOSDarwin())
+return "darwin";
+
   switch (Triple.getOS()) {
   case llvm::Triple::FreeBSD:
 return "freebsd";


Index: clang/test/Driver/darwin-print-runtime-dir.c
===
--- /dev/null
+++ clang/test/Driver/darwin-print-runtime-dir.c
@@ -0,0 +1,24 @@
+// Regression test. Previously the output returned the full OS name
+// (e.g. `darwin20.3.0`) instead of just `darwin`.
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-darwin20.3.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-macosx11.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-ios14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-tvos14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --targe

[clang] 9c72a21 - Fix for test failure caused by 84c475437267e7fffedc40029ce274b099d8f8f3.

2021-05-04 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-05-04T11:45:32-07:00
New Revision: 9c72a210b58f19632af0e91679da7aa63f51ad7a

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

LOG: Fix for test failure caused by 84c475437267e7fffedc40029ce274b099d8f8f3.

Reduces the number of targets/triples for this test since not all cmake
invocations will build for those targets.

Added: 


Modified: 
clang/test/Frontend/invalid-cxx-abi.cpp

Removed: 




diff  --git a/clang/test/Frontend/invalid-cxx-abi.cpp 
b/clang/test/Frontend/invalid-cxx-abi.cpp
index 95ee442f286d..2bc0aac52cc7 100644
--- a/clang/test/Frontend/invalid-cxx-abi.cpp
+++ b/clang/test/Frontend/invalid-cxx-abi.cpp
@@ -1,21 +1,11 @@
+// REQUIRES: x86-registered-target
+
 // These should succeed.
-// RUN: %clang -c -fc++-abi=itanium %s
-// RUN: %clang -c -fc++-abi=arm -target arm64 %s
-// RUN: %clang -c -fc++-abi=ios -target arm64-apple-ios %s
-// RUN: %clang -c -fc++-abi=aarch64 -target arm64 %s
-// RUN: %clang -c -fc++-abi=mips -target mips %s
-// RUN: %clang -c -fc++-abi=webassembly -target wasm64 %s
+// RUN: %clang -c -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s
 // RUN: %clang -c -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s
-// RUN: %clang -S -fc++-abi=xl -target powerpc-unknown-aix %s -o /dev/null
 // RUN: %clang -c -fc++-abi=microsoft -target x86_64-windows-msvc %s
-// RUN: %clang_cc1 -fc++-abi=itanium %s
-// RUN: %clang_cc1 -fc++-abi=arm -triple arm64 %s
-// RUN: %clang_cc1 -fc++-abi=ios -triple arm64-apple-ios %s
-// RUN: %clang_cc1 -fc++-abi=aarch64 -triple arm64 %s
-// RUN: %clang_cc1 -fc++-abi=mips -triple mips %s
-// RUN: %clang_cc1 -fc++-abi=webassembly -triple wasm64 %s
+// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s
 // RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s
-// RUN: %clang_cc1 -S -fc++-abi=xl -triple powerpc-unknown-aix %s -o /dev/null
 // RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s
 
 // RUN: not %clang -c -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s 
-check-prefix=INVALID



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


[PATCH] D101702: [clang-format] Add more support for C# 8 nullables

2021-05-04 Thread Eliza via Phabricator via cfe-commits
exv updated this revision to Diff 342813.
exv marked an inline comment as done.
exv added a comment.

- Remove obsolete comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101702

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/FormatTokenLexer.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -358,6 +358,39 @@
   verifyFormat("return _name ?? \"DEF\";");
 }
 
+TEST_F(FormatTestCSharp, CSharpNullCoalescingAssignment) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+  Style.SpaceBeforeAssignmentOperators = true;
+
+  verifyFormat("test \?\?= ABC;", Style);
+  verifyFormat("test \?\?= true;", Style);
+
+  Style.SpaceBeforeAssignmentOperators = false;
+
+  verifyFormat("test\?\?= ABC;", Style);
+  verifyFormat("test\?\?= true;", Style);
+}
+
+TEST_F(FormatTestCSharp, CSharpNullForgiving) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat("var test = null!;", Style);
+  verifyFormat("string test = someFunctionCall()! + \"ABC\"!", Style);
+  verifyFormat("int test = (1! + 2 + bar! + foo())!", Style);
+  verifyFormat("test \?\?= !foo!;", Style);
+  verifyFormat("test = !bar! \?\? !foo!;", Style);
+  verifyFormat("bool test = !(!true && !true! || !null && !null! || !false && "
+   "!false! && !bar()! + (!foo()))!",
+   Style);
+
+  // Check that line break keeps identifier with the bang.
+  Style.ColumnLimit = 14;
+
+  verifyFormat("var test =\n"
+   "foo!;",
+   Style);
+}
+
 TEST_F(FormatTestCSharp, AttributesIndentation) {
   FormatStyle Style = getMicrosoftStyle(FormatStyle::LK_CSharp);
   Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1048,13 +1048,6 @@
 CurrentToken->Previous->setType(TT_OverloadedOperator);
   break;
 case tok::question:
-  if (Tok->is(TT_CSharpNullConditionalLSquare)) {
-if (!parseSquare())
-  return false;
-break;
-  }
-  if (Tok->isOneOf(TT_CSharpNullConditional, TT_CSharpNullCoalescing))
-break;
   if (Style.Language == FormatStyle::LK_JavaScript && Tok->Next &&
   Tok->Next->isOneOf(tok::semi, tok::comma, tok::colon, tok::r_paren,
  tok::r_brace)) {
@@ -1078,7 +1071,7 @@
 (Tok->Next && Tok->Next->isOneOf(tok::r_paren, tok::greater)) ||
 (Tok->Next && Tok->Next->is(tok::identifier) && Tok->Next->Next &&
  Tok->Next->Next->is(tok::equal))) {
-  Tok->setType(TT_CSharpNullable);
+  Tok->setType(TT_JsTypeOptionalQuestion);
   break;
 }
   }
@@ -1564,39 +1557,29 @@
   // The token type is already known.
   return;
 
-if (Style.isCSharp() && CurrentToken->is(tok::question)) {
-  if (CurrentToken->TokenText == "??") {
-Current.setType(TT_CSharpNullCoalescing);
-return;
-  }
-  if (CurrentToken->TokenText == "?.") {
-Current.setType(TT_CSharpNullConditional);
-return;
-  }
-  if (CurrentToken->TokenText == "?[") {
-Current.setType(TT_CSharpNullConditionalLSquare);
-return;
-  }
-}
-
-if (Style.Language == FormatStyle::LK_JavaScript) {
-  if (Current.is(tok::exclaim)) {
-if (Current.Previous &&
-(Keywords.IsJavaScriptIdentifier(
- *Current.Previous, /* AcceptIdentifierName= */ true) ||
- Current.Previous->isOneOf(
- tok::kw_namespace, tok::r_paren, tok::r_square, tok::r_brace,
- Keywords.kw_type, Keywords.kw_get, Keywords.kw_set) ||
- Current.Previous->Tok.isLiteral())) {
-  Current.setType(TT_JsNonNullAssertion);
-  return;
-}
-if (Current.Next &&
-Current.Next->isOneOf(TT_BinaryOperator, Keywords.kw_as)) {
+if ((Style.Language == FormatStyle::LK_JavaScript || Style.isCSharp()) &&
+Current.is(tok::exclaim)) {
+  if (Current.Previous) {
+bool isIdentifier =
+Style.Language == FormatStyle::LK_JavaScript
+? Keywords.IsJavaScriptIdentifier(
+  *Current.Previous, /* AcceptIdentifierName= */ true)
+: Current.Previous->is(tok::identifier);
+if (isIdentifier ||
+Current.Previous->isOneOf(
+tok::kw_namespace, tok::r_paren, tok::r_square, tok::r_brace,
+tok::kw_false, tok::kw_tru

[PATCH] D101702: [clang-format] Add more support for C# 8 nullables

2021-05-04 Thread Eliza via Phabricator via cfe-commits
exv marked an inline comment as done.
exv added a comment.

According to the wiki, it seems like someone who has commit access must now 
submit this change.




Comment at: clang/lib/Format/FormatTokenLexer.cpp:102
+
+// FIXME: Investigate what token type gives the correct operator priority.
+if (tryMergeTokens(FatArrow, TT_JsFatArrow))

curdeius wrote:
> Could you explain in what case the operator precedence may be wrong here?
It's unlikely this comment is still relevant for this section. I will delete it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101702

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


[clang] 313ee60 - [OpenMP] Fix non-determinism in clang task codegen (lastprivates)

2021-05-04 Thread Giorgis Georgakoudis via cfe-commits

Author: Giorgis Georgakoudis
Date: 2021-05-04T11:56:31-07:00
New Revision: 313ee609e16b93a7d81cd595f8cffdb408390495

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

LOG: [OpenMP] Fix non-determinism in clang task codegen (lastprivates)

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index e7ddc0aa4c8d..1f714b01b3f1 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -4293,7 +4293,7 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
 }
   }
   // Get list of lastprivate variables (for taskloops).
-  llvm::DenseMap LastprivateDstsOrigs;
+  llvm::MapVector LastprivateDstsOrigs;
   for (const auto *C : S.getClausesOfKind()) {
 auto IRef = C->varlist_begin();
 auto ID = C->destination_exprs().begin();
@@ -4304,8 +4304,8 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
 Data.LastprivateCopies.push_back(IInit);
   }
   LastprivateDstsOrigs.insert(
-  {cast(cast(*ID)->getDecl()),
-   cast(*IRef)});
+  std::make_pair(cast(cast(*ID)->getDecl()),
+ cast(*IRef)));
   ++IRef;
   ++ID;
 }



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


  1   2   >