[PATCH] D124063: [LegacyPM] Rename and deprecate populateModulePassManager

2022-04-20 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

Please do not change names in the FFI API at least. It's okay to drop it 
entirely, but renaming is unnecessarily hostile for FFI APIs.




Comment at: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp:95
+#endif
+  Builder.populateModulePassManagerLegacy(MPM);
 }

This seems like an easy usage to replace?



Comment at: llvm/include/llvm-c/Transforms/PassManagerBuilder.h:72
+#ifdef __GNUC__
+__attribute__((deprecated("Migrate to new pass manager for optimization 
pipeline. This header will be removed in LLVM 16.")))
+#endif

Let's not promise any specific timeline. IMHO we should drop this as soon as 
there are no in-tree users anymore.



Comment at: llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp:313
+LLVMPassManagerBuilderPopulateModulePassManagerLegacy(passBuilder,
+  modulePasses);
+

This also looks like an easy usage to remove.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124063

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


[clang] d46fa02 - [clang-format] SortIncludes should support "@import" lines in Objective-C

2022-04-20 Thread Konrad Kleine via cfe-commits

Author: Konrad Kleine
Date: 2022-04-20T07:03:35Z
New Revision: d46fa023caa2db5a9f1e21dd038bcb626261d958

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

LOG: [clang-format] SortIncludes should support "@import" lines in Objective-C

Fixes [[ https://github.com/llvm/llvm-project/issues/38995 | #38995 ]]

This is an attempt to modify the regular expression to identify
`@import` and `import` alongside the regular `#include`. The challenging
part was not to support `@` in addition to `#` but how to handle
everything that comes after the `include|import` keywords. Previously
everything that wasn't `"` or `<` was consumed. But as you can see in
this example from the issue #38995, there is no `"` or `<` following the
keyword:

```
@import Foundation;
```

I experimented with a lot of fancy and useful expressions in [this
online regex tool](https://regex101.com) only to find out that some
things are simply not supported by the regex implementation in LLVM.

 * For example the beginning `[\t\ ]*` should be replacable by the
   horizontal whitespace character `\h*` but this will break the
   `SortIncludesTest.LeadingWhitespace` test.

That's why I've chosen to come back to the basic building blocks.

The essential change in this patch is the change from this regular
expression:

```
^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">])
~  ~~
^  ^
|  |
only support # prefix not @|
   only support "" and <> as
delimiters
   no support for C++ modules and ;
   ending. Also this allows for ">
   or <" or "" or <> which all seems
   either off or wrong.
```

to this:

```
^[\t\ ]*[@#][\t\ ]*(import|include)([^"]*("[^"]+")|[^<]*(<[^>]+>)|[\t\
]*([^;]+;))
~~ ~~
~~
^ ^   ^   ^   ^
| |   |   |   |
Now support @ and #.Clearly support "" and <> as
well as an
include name without enclosing
characters.
Allows for no mixture of "> or
<" or
empty include names.

```

Here is how I've tested this patch:

```
ninja clang-Format
ninja FormatTests
./tools/clang/unittests/Format/FormatTests
--gtest_filter=SortIncludesTest*
```

And if that worked I doubled checked that nothing else broke by running
all format checks:

```
./tools/clang/unittests/Format/FormatTests
```

One side effect of this change is it should partially support
[C++20 Module](https://en.cppreference.com/w/cpp/language/modules)
`import` lines without the optional `export` in front. Adding
this can be a change on its own that shouldn't be too hard. I say
partially because the `@` or `#` are currently *NOT* optional in the
regular expression.

I see an opportunity to optimized the matching to exclude `@include` for
example. But eventually these should be caught by the compiler, so...

With my change, the matching group is not at a fixed position any
longer. I decided to
choose the last match (group) that is not empty.

Reviewed By: HazardyKnusperkeks

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

Added: 


Modified: 
clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
clang/lib/Format/Format.cpp
clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
clang/unittests/Format/SortIncludesTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h 
b/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
index ea8ad896be89f..a5017bf84c24a 100644
--- a/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
+++ b/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
@@ -129,6 +129,23 @@ class HeaderIncludes {
   llvm::Regex IncludeRegex;
 };
 
+/// \returns a regex that can match various styles of C++ includes.
+/// For example:
+/// \code
+/// #include 
+/// @import bar;
+/// #include "bar.h"
+/// \endcode
+llvm::Regex getCppIncludeRegex();
+
+/// \returns the last match in the list of matches that is not empty.
+llvm::StringRef getIncludeNameFromMatches(
+const llvm::SmallVectorImpl &Matches);
+
+/// \returns the given include name and removes the following symbols from the
+/// beginning and ending of the include name: " > < ;
+llvm::StringRef trimInclude(llvm::StringRef IncludeName);
+
 } // namespace tooling
 } // namespace clang
 

diff  --git a/clang/lib/

[PATCH] D121370: [clang-format] SortIncludes should support "@import" lines in Objective-C

2022-04-20 Thread Konrad Wilhelm Kleine 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 rGd46fa023caa2: [clang-format] SortIncludes should support 
"@import" lines in Objective-C (authored by kwk).

Changed prior to commit:
  https://reviews.llvm.org/D121370?vs=423584&id=423829#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121370

Files:
  clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
  clang/lib/Format/Format.cpp
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
  clang/unittests/Format/SortIncludesTest.cpp

Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -458,6 +458,103 @@
  "#include \"b.h\"\n"));
 }
 
+TEST_F(SortIncludesTest, SupportAtImportLines) {
+  // Test from https://github.com/llvm/llvm-project/issues/38995
+  EXPECT_EQ("#import \"a.h\"\n"
+"#import \"b.h\"\n"
+"#import \"c.h\"\n"
+"#import \n"
+"@import Foundation;\n",
+sort("#import \"b.h\"\n"
+ "#import \"c.h\"\n"
+ "#import \n"
+ "@import Foundation;\n"
+ "#import \"a.h\"\n"));
+
+  // Slightly more complicated test that shows sorting in each priorities still
+  // works.
+  EXPECT_EQ("#import \"a.h\"\n"
+"#import \"b.h\"\n"
+"#import \"c.h\"\n"
+"#import \n"
+"@import Base;\n"
+"@import Foundation;\n"
+"@import base;\n"
+"@import foundation;\n",
+sort("#import \"b.h\"\n"
+ "#import \"c.h\"\n"
+ "@import Base;\n"
+ "#import \n"
+ "@import foundation;\n"
+ "@import Foundation;\n"
+ "@import base;\n"
+ "#import \"a.h\"\n"));
+
+  // Test that shows main headers in two groups are still found and sorting
+  // still works. The @import's are kept in their respective group but are
+  // put at the end of each group.
+  FmtStyle.IncludeStyle.IncludeBlocks = tooling::IncludeStyle::IBS_Preserve;
+  EXPECT_EQ("#import \"foo.hpp\"\n"
+"#import \"b.h\"\n"
+"#import \"c.h\"\n"
+"#import \n"
+"@import Base;\n"
+"@import Foundation;\n"
+"@import foundation;\n"
+"\n"
+"#import \"foo.h\"\n"
+"#include \"foobar\"\n"
+"#import \n"
+"@import ;\n"
+"@import ;\n",
+sort("#import \"b.h\"\n"
+ "@import Foundation;\n"
+ "@import foundation;\n"
+ "#import \"c.h\"\n"
+ "#import \n"
+ "@import Base;\n"
+ "#import \"foo.hpp\"\n"
+ "\n"
+ "@import ;\n"
+ "#import \n"
+ "@import ;\n"
+ "#include \"foobar\"\n"
+ "#import \"foo.h\"\n",
+ "foo.c", 2));
+
+  // Regrouping and putting @import's in the very last group
+  FmtStyle.IncludeStyle.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
+  EXPECT_EQ("#import \"foo.hpp\"\n"
+"\n"
+"#import \"b.h\"\n"
+"#import \"c.h\"\n"
+"#import \"foo.h\"\n"
+"#include \"foobar\"\n"
+"\n"
+"#import \n"
+"#import \n"
+"\n"
+"@import ;\n"
+"@import Base;\n"
+"@import Foundation;\n"
+"@import ;\n"
+"@import foundation;\n",
+sort("#import \"b.h\"\n"
+ "@import Foundation;\n"
+ "@import foundation;\n"
+ "#import \"c.h\"\n"
+ "#import \n"
+ "@import Base;\n"
+ "#import \"foo.hpp\"\n"
+ "\n"
+ "@import ;\n"
+ "#import \n"
+ "@import ;\n"
+ "#include \"foobar\"\n"
+ "#import \"foo.h\"\n",
+ "foo.c"));
+}
+
 TEST_F(SortIncludesTest, LeavesMainHeaderFirst) {
   Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
   EXPECT_EQ("#include \"llvm/a.h\"\n"
Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -169,13 +169,6 @@
   });
 }
 
-inline StringRef trimInclude(StringRef IncludeName) {
-  return IncludeName.trim("\"<>");
-}
-
-const char IncludeRegexPattern[] =
-R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))";
-
 // 

[PATCH] D124063: [LegacyPM] Rename and deprecate populateModulePassManager

2022-04-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked an inline comment as done.
MaskRay added a comment.

In D124063#3461133 , @nikic wrote:

> Please do not change names in the FFI API at least. It's okay to drop it 
> entirely, but renaming is unnecessarily hostile for FFI APIs.

Why?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124063

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


[PATCH] D124063: [LegacyPM] Rename and deprecate populateModulePassManager

2022-04-20 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

In D124063#3461171 , @MaskRay wrote:

> In D124063#3461133 , @nikic wrote:
>
>> Please do not change names in the FFI API at least. It's okay to drop it 
>> entirely, but renaming is unnecessarily hostile for FFI APIs.
>
> Why?

Users of the FFI interface generally target multiple LLVM versions, so they 
need to introduce checks to use one or the other API -- if lucky only 
compile-time checks, if not lucky it requires switching the code to use dlsym. 
This may be unavoidable if an API is removed, but it's an unnecessary 
complication for a rename.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124063

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


[PATCH] D123967: Disable update_cc_test_checks.py tests in stand-alone builds

2022-04-20 Thread Diana Picus via Phabricator via cfe-commits
rovka added a comment.

I just have a couple of nits, I'll leave it to the clang devs to properly 
review this.




Comment at: clang/test/CMakeLists.txt:17
   LLVM_WITH_Z3
+  CLANG_BUILT_STANDALONE
   )

Nit: These seem to be sorted alphabetically.



Comment at: clang/test/utils/update_cc_test_checks/lit.local.cfg:17
+# These tests are only relevant to developers working with the
+# update_cc_test_checks.py tool they don't don't provide any coverage
+# for any of the clang source code.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123967

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


[PATCH] D124067: [x86] Support 3 builtin functions for 32-bits targets

2022-04-20 Thread Xiang Zhang via Phabricator via cfe-commits
xiangzhangllvm added inline comments.



Comment at: clang/test/CodeGen/X86/sse2-builtins.c:560
   // CHECK: insertelement <2 x i64> %{{.*}}, i64 0, i32 1
+  // X86-LABEL: test_mm_cvtsi64_si128
+  // X86: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0

RKSimon wrote:
> xiangzhangllvm wrote:
> > craig.topper wrote:
> > > Do we need the X86 prefix because of the x86-64 #ifdefs? Or are there 
> > > other differences?
> > > 
> > > If it's just the x86-64, can we add -check-prefixes=CHECK,X64 to the 
> > > x86-64 run lines and use X64 for the x86-64 only functions. That way 
> > > CHECK can be used for all the common tests.
> > Before I change the test, it only build with "-triple=x86_64", So all the 
> > CHECK should be X64 prefix. 
> > So I add X86 prefix to just let "RUN ... -triple=i386" only check the 
> > updated 3 builtins. (let the change be small).
> > 
> I'd much prefer we have complete test check prefix coverage for every RUN - 
> and tbh we should be properly testing 32-bit on every x86 intrinsic test file.
Yes, testing 32-bit on every x86 intrinsic test file is make sense. I also 
confuse why this test not testing the 32-bit mode before. I think it is 
"defect" for the test.
But how can I well update the test by on checking the 3 updated intrinsics. 
Because it is strange to update the other intrinsics checking when I only 
update 3 intrinsics in clang.


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

https://reviews.llvm.org/D124067

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


[clang-tools-extra] f483481 - [clang-tidy] Fix crash on calls to overloaded operators in `llvmlibc-callee-namespace`

2022-04-20 Thread via cfe-commits

Author: Whisperity
Date: 2022-04-20T10:15:03+02:00
New Revision: f4834815f439d4b874e4b501f27a909f59f6a426

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

LOG: [clang-tidy] Fix crash on calls to overloaded operators in 
`llvmlibc-callee-namespace`

The routine that facilitated symbols to be explicitly allowed asked
the name of the called function, which resulted in a crash when the
check was accidentally run on non-trivial C++ code.

Differential Revision: http://reviews.llvm.org/D123992

Reviewed By: aaron.ballman

Added: 


Modified: 
clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-callee-namespace.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp 
b/clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp
index 91e9e026d0ad1..8f4f5452e9890 100644
--- a/clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp
@@ -52,7 +52,9 @@ void CalleeNamespaceCheck::check(const 
MatchFinder::MatchResult &Result) {
   if (NS && NS->getName() == "__llvm_libc")
 return;
 
-  if (IgnoredFunctions.contains(FuncDecl->getName()))
+  const DeclarationName &Name = FuncDecl->getDeclName();
+  if (Name.isIdentifier() &&
+  IgnoredFunctions.contains(Name.getAsIdentifierInfo()->getName()))
 return;
 
   diag(UsageSiteExpr->getBeginLoc(), "%0 must resolve to a function declared "

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 9472797eca86e..50d5b8ecc72c1 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -136,31 +136,39 @@ New check aliases
 Changes in existing checks
 ^^
 
-- Improved :doc:`performance-inefficient-vector-operation 
-  ` to work when
-  the vector is a member of a structure.
-
-- Fixed a false positive in :doc:`readability-non-const-parameter
-  ` when the parameter is 
referenced by an lvalue.
-
-- Fixed a crash in :doc:`readability-const-return-type
-  ` when a pure virtual 
function
-  overrided has a const return type. Removed the fix for a virtual function.
+- Fixed a crash in :doc:`bugprone-sizeof-expression
+  ` when `sizeof(...)` is
+  compared against a `__int128_t`.
 
-- Fixed a false positive in :doc:`misc-redundant-expression 
`
-  involving overloaded comparison operators.
-
-- Fixed a crash in :doc:`bugprone-sizeof-expression 
` when
-  `sizeof(...)` is compared agains a `__int128_t`.
-  
 - Improved :doc:`cppcoreguidelines-prefer-member-initializer
   ` check.
 
   Fixed an issue when there was already an initializer in the constructor and
   the check would try to create another initializer for the same member.
 
-- Fixed a false positive in :doc:`misc-redundant-expression 
`
-  involving assignments in conditions. This fixes `Issue 35853 
`_.
+- Fixed a crash in :doc:`llvmlibc-callee-namespace
+  ` when executing for C++ code
+  that contain calls to advanced constructs, e.g. overloaded operators.
+
+- Fixed a false positive in :doc:`misc-redundant-expression
+  ` involving overloaded
+  comparison operators.
+
+- Fixed a false positive in :doc:`misc-redundant-expression
+  ` involving assignments in
+  conditions. This fixes `Issue 35853 
`_.
+
+- Fixed a crash in :doc:`readability-const-return-type
+  ` when a pure virtual 
function
+  overrided has a const return type. Removed the fix for a virtual function.
+
+- Fixed a false positive in :doc:`readability-non-const-parameter
+  ` when the parameter is
+  referenced by an lvalue.
+
+- Improved :doc:`performance-inefficient-vector-operation
+  ` to work when
+  the vector is a member of a structure.
 
 Removed checks
 ^^

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/llvmlibc-callee-namespace.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/llvmlibc-callee-namespace.cpp
index 8ee968433f61c..f18ab2b89e786 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/llvmlibc-callee-namespace.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/llvmlibc-callee-namespace.cpp
@@ -5,6 +5,10 @@ namespace nested {
 void nested_func() {}
 } // namespace nested
 void libc_api_func() {}
+
+struct libc_api_struct {
+  int operator()() const { return 0; }
+};
 } // namespace __llvm_libc
 
 // Emulate a function from the public headers like string.h
@@ -13,6 +17,11 @@ void libc_api_func() {}
 // Emulate a function specifically allowed by the exception list.
 void malloc() {}
 
+// Emulate a non-trivially named symbol.
+struct globa

[PATCH] D123992: [clang-tidy] Fix crash on calls to overloaded operators in llvmlibc-callee-namespace

2022-04-20 Thread Whisperity via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf4834815f439: [clang-tidy] Fix crash on calls to overloaded 
operators in `llvmlibc-callee… (authored by whisperity).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123992

Files:
  clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/llvmlibc-callee-namespace.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/llvmlibc-callee-namespace.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvmlibc-callee-namespace.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvmlibc-callee-namespace.cpp
@@ -5,6 +5,10 @@
 void nested_func() {}
 } // namespace nested
 void libc_api_func() {}
+
+struct libc_api_struct {
+  int operator()() const { return 0; }
+};
 } // namespace __llvm_libc
 
 // Emulate a function from the public headers like string.h
@@ -13,6 +17,11 @@
 // Emulate a function specifically allowed by the exception list.
 void malloc() {}
 
+// Emulate a non-trivially named symbol.
+struct global_struct {
+  int operator()() const { return 0; }
+};
+
 namespace __llvm_libc {
 void Test() {
   // Allow calls with the fully qualified name.
@@ -30,19 +39,28 @@
   void (*barePtr)(void) = __llvm_libc::libc_api_func;
   barePtr();
 
+  // Allow calling entities defined in the namespace.
+  __llvm_libc::libc_api_struct{}();
+
   // Disallow calling into global namespace for implemented entrypoints.
   ::libc_api_func();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'libc_api_func' must resolve to a function declared within the '__llvm_libc' namespace
-  // CHECK-MESSAGES: :11:6: note: resolves to this declaration
+  // CHECK-MESSAGES: :15:6: note: resolves to this declaration
 
   // Disallow indirect references to functions in global namespace.
   void (*badPtr)(void) = ::libc_api_func;
   badPtr();
   // CHECK-MESSAGES: :[[@LINE-2]]:26: warning: 'libc_api_func' must resolve to a function declared within the '__llvm_libc' namespace
-  // CHECK-MESSAGES: :11:6: note: resolves to this declaration
+  // CHECK-MESSAGES: :15:6: note: resolves to this declaration
 
   // Allow calling into global namespace for specific functions.
   ::malloc();
+
+  // Disallow calling on entities that are not in the namespace, but make sure
+  // no crashes happen.
+  global_struct{}();
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'operator()' must resolve to a function declared within the '__llvm_libc' namespace
+  // CHECK-MESSAGES: :22:7: note: resolves to this declaration
 }
 
 } // namespace __llvm_libc
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -136,31 +136,39 @@
 Changes in existing checks
 ^^
 
-- Improved :doc:`performance-inefficient-vector-operation 
-  ` to work when
-  the vector is a member of a structure.
-
-- Fixed a false positive in :doc:`readability-non-const-parameter
-  ` when the parameter is referenced by an lvalue.
-
-- Fixed a crash in :doc:`readability-const-return-type
-  ` when a pure virtual function
-  overrided has a const return type. Removed the fix for a virtual function.
+- Fixed a crash in :doc:`bugprone-sizeof-expression
+  ` when `sizeof(...)` is
+  compared against a `__int128_t`.
 
-- Fixed a false positive in :doc:`misc-redundant-expression `
-  involving overloaded comparison operators.
-
-- Fixed a crash in :doc:`bugprone-sizeof-expression ` when
-  `sizeof(...)` is compared agains a `__int128_t`.
-  
 - Improved :doc:`cppcoreguidelines-prefer-member-initializer
   ` check.
 
   Fixed an issue when there was already an initializer in the constructor and
   the check would try to create another initializer for the same member.
 
-- Fixed a false positive in :doc:`misc-redundant-expression `
-  involving assignments in conditions. This fixes `Issue 35853 `_.
+- Fixed a crash in :doc:`llvmlibc-callee-namespace
+  ` when executing for C++ code
+  that contain calls to advanced constructs, e.g. overloaded operators.
+
+- Fixed a false positive in :doc:`misc-redundant-expression
+  ` involving overloaded
+  comparison operators.
+
+- Fixed a false positive in :doc:`misc-redundant-expression
+  ` involving assignments in
+  conditions. This fixes `Issue 35853 `_.
+
+- Fixed a crash in :doc:`readability-const-return-type
+  ` when a pure virtual function
+  overrided has a const return type. Removed the fix for a virtual function.
+
+- Fixed a false positive in :doc:`readability-non-const-parameter
+  ` when the parameter is
+  referenced by an lvalue.
+
+- Improved :doc

[PATCH] D123300: [Clang] Enable opaque pointers by default

2022-04-20 Thread Markus Lavin via Phabricator via cfe-commits
markus added a comment.

In D123300#3459023 , @nikic wrote:

> @markus Without tracing through it in detail, I'd guess that without opaque 
> pointers this creates two getelementptr constant expressions that get folded 
> together. With opaque pointers, the first one (which would be a zero-index 
> GEP) is omitted, and only the second one is left. ConstantFolding will later 
> canonicalize the GEP source type, but this only happens when InstCombine 
> runs, while you're looking at unoptimized IR.

Yes, that appears to have been the case. Thanks for explaining.

> Are you encountering some particular issue relating to this? For well-written 
> optimizations, the exact GEP representation shouldn't matter either way.

One of our target specific passes ran into problems with this as it made some 
assumptions that no longer hold with opaque pointers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123300

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


[clang] bd0d126 - [RISCV][Clang][NFC] Update vid intrinsic tests.

2022-04-20 Thread Zakk Chen via cfe-commits

Author: Zakk Chen
Date: 2022-04-20T01:35:53-07:00
New Revision: bd0d126302a870df15f60fde4925617c06a36e3f

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

LOG: [RISCV][Clang][NFC] Update vid intrinsic tests.

Re-run the update_cc_test_checks.py to update expected result.
I'm not sure why those tests are passed before.

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

Added: 


Modified: 
clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vid.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vid.c

Removed: 




diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vid.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vid.c
index f5d01e1de1240..ddf3bb2a12d2d 100644
--- a/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vid.c
+++ b/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vid.c
@@ -6,7 +6,7 @@
 
 // CHECK-RV64-LABEL: @test_vid_v_u8mf8_m(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vid.mask.nxv1i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vid.mask.nxv1i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vuint8mf8_t test_vid_v_u8mf8_m(vbool64_t mask, vuint8mf8_t maskedoff,
@@ -16,7 +16,7 @@ vuint8mf8_t test_vid_v_u8mf8_m(vbool64_t mask, vuint8mf8_t 
maskedoff,
 
 // CHECK-RV64-LABEL: @test_vid_v_u8mf4_m(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vid.mask.nxv2i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vid.mask.nxv2i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vuint8mf4_t test_vid_v_u8mf4_m(vbool32_t mask, vuint8mf4_t maskedoff,
@@ -26,7 +26,7 @@ vuint8mf4_t test_vid_v_u8mf4_m(vbool32_t mask, vuint8mf4_t 
maskedoff,
 
 // CHECK-RV64-LABEL: @test_vid_v_u8mf2_m(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vid.mask.nxv4i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vid.mask.nxv4i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vuint8mf2_t test_vid_v_u8mf2_m(vbool16_t mask, vuint8mf2_t maskedoff,
@@ -36,7 +36,7 @@ vuint8mf2_t test_vid_v_u8mf2_m(vbool16_t mask, vuint8mf2_t 
maskedoff,
 
 // CHECK-RV64-LABEL: @test_vid_v_u8m1_m(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vid.mask.nxv8i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vid.mask.nxv8i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vuint8m1_t test_vid_v_u8m1_m(vbool8_t mask, vuint8m1_t maskedoff, size_t vl) {
@@ -45,7 +45,7 @@ vuint8m1_t test_vid_v_u8m1_m(vbool8_t mask, vuint8m1_t 
maskedoff, size_t vl) {
 
 // CHECK-RV64-LABEL: @test_vid_v_u8m2_m(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vid.mask.nxv16i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vid.mask.nxv16i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vuint8m2_t test_vid_v_u8m2_m(vbool4_t mask, vuint8m2_t maskedoff, size_t vl) {
@@ -54,7 +54,7 @@ vuint8m2_t test_vid_v_u8m2_m(vbool4_t mask, vuint8m2_t 
maskedoff, size_t vl) {
 
 // CHECK-RV64-LABEL: @test_vid_v_u8m4_m(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vid.mask.nxv32i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vid.mask.nxv32i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vuint8m4_t test_vid_v_u8m4_m(vbool2_t mask, vuint8m4_t maskedoff, size_t vl) {
@@ -63,7 +63,7 @@ vuint8m4_t test_vid_v_u8m4_m(vbool2_t mask, vuint8m4_t 
maskedoff, size_t vl) {
 
 // CHECK-RV64-LABEL: @test_vid_v_u8m8_m(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vid.mask.nxv64i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vid.mask.nxv64i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vuint8m8_t test_vid_v_u8m8_m(vbool1_t mask, vuint8m8_t maskedoff, size_t vl) {
@@ -72,7 +72,7 @@ vuint8m8_t test_vid_v_u8m8_m(vbool1_t mask, vuint8m8_t 
maskedoff, size_t vl) {
 
 // CHECK-RV64-LABEL: @test_vid_v_u16mf4_m(
 // CHECK-RV64-NEXT:  e

[PATCH] D124062: [RISCV][Clang][NFC] Update vid intrinsic tests.

2022-04-20 Thread Zakk Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbd0d126302a8: [RISCV][Clang][NFC] Update vid intrinsic 
tests. (authored by khchen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124062

Files:
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vid.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vid.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vid.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics/vid.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vid.c
@@ -160,7 +160,7 @@
 
 // CHECK-RV64-LABEL: @test_vid_v_u8mf8_m(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vid.mask.nxv1i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vid.mask.nxv1i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vuint8mf8_t test_vid_v_u8mf8_m(vbool64_t mask, vuint8mf8_t maskedoff,
@@ -170,7 +170,7 @@
 
 // CHECK-RV64-LABEL: @test_vid_v_u8mf4_m(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vid.mask.nxv2i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vid.mask.nxv2i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vuint8mf4_t test_vid_v_u8mf4_m(vbool32_t mask, vuint8mf4_t maskedoff,
@@ -180,7 +180,7 @@
 
 // CHECK-RV64-LABEL: @test_vid_v_u8mf2_m(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vid.mask.nxv4i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vid.mask.nxv4i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vuint8mf2_t test_vid_v_u8mf2_m(vbool16_t mask, vuint8mf2_t maskedoff,
@@ -190,7 +190,7 @@
 
 // CHECK-RV64-LABEL: @test_vid_v_u8m1_m(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vid.mask.nxv8i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vid.mask.nxv8i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vuint8m1_t test_vid_v_u8m1_m(vbool8_t mask, vuint8m1_t maskedoff, size_t vl) {
@@ -199,7 +199,7 @@
 
 // CHECK-RV64-LABEL: @test_vid_v_u8m2_m(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vid.mask.nxv16i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vid.mask.nxv16i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vuint8m2_t test_vid_v_u8m2_m(vbool4_t mask, vuint8m2_t maskedoff, size_t vl) {
@@ -208,7 +208,7 @@
 
 // CHECK-RV64-LABEL: @test_vid_v_u8m4_m(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vid.mask.nxv32i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vid.mask.nxv32i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vuint8m4_t test_vid_v_u8m4_m(vbool2_t mask, vuint8m4_t maskedoff, size_t vl) {
@@ -217,7 +217,7 @@
 
 // CHECK-RV64-LABEL: @test_vid_v_u8m8_m(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vid.mask.nxv64i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vid.mask.nxv64i8.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vuint8m8_t test_vid_v_u8m8_m(vbool1_t mask, vuint8m8_t maskedoff, size_t vl) {
@@ -226,7 +226,7 @@
 
 // CHECK-RV64-LABEL: @test_vid_v_u16mf4_m(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vid.mask.nxv1i16.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vid.mask.nxv1i16.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vuint16mf4_t test_vid_v_u16mf4_m(vbool64_t mask, vuint16mf4_t maskedoff,
@@ -236,7 +236,7 @@
 
 // CHECK-RV64-LABEL: @test_vid_v_u16mf2_m(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vid.mask.nxv2i16.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vid.mask.nxv2i16.i64( [[MASKEDOFF:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vuint16mf2_t test_vid_v_u16mf2_m(vbool32_t mask, vuint16mf2_t maskedoff,
@@ -246,7 +246,7 @@
 
 // CHECK-RV64-LABEL: @test_vid_v_u16m1_m(

[PATCH] D124062: [RISCV][Clang][NFC] Update vid intrinsic tests.

2022-04-20 Thread Zakk Chen via Phabricator via cfe-commits
khchen added a comment.

In D124062#3461069 , @frasercrmck 
wrote:

> Were they perhaps passing because `i64 [[VL:%.*]]` was matching the `, i64 0` 
> too? Seems like a flaw in the checks generated by the script, but I can see 
> how the majority of the time the brevity is nice.

Yes, agree.

Thanks for reviewing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124062

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


[PATCH] D124067: [x86] Support 3 builtin functions for 32-bits targets

2022-04-20 Thread Xiang Zhang via Phabricator via cfe-commits
xiangzhangllvm added inline comments.



Comment at: clang/test/CodeGen/X86/sse2-builtins.c:560
   // CHECK: insertelement <2 x i64> %{{.*}}, i64 0, i32 1
+  // X86-LABEL: test_mm_cvtsi64_si128
+  // X86: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0

xiangzhangllvm wrote:
> RKSimon wrote:
> > xiangzhangllvm wrote:
> > > craig.topper wrote:
> > > > Do we need the X86 prefix because of the x86-64 #ifdefs? Or are there 
> > > > other differences?
> > > > 
> > > > If it's just the x86-64, can we add -check-prefixes=CHECK,X64 to the 
> > > > x86-64 run lines and use X64 for the x86-64 only functions. That way 
> > > > CHECK can be used for all the common tests.
> > > Before I change the test, it only build with "-triple=x86_64", So all the 
> > > CHECK should be X64 prefix. 
> > > So I add X86 prefix to just let "RUN ... -triple=i386" only check the 
> > > updated 3 builtins. (let the change be small).
> > > 
> > I'd much prefer we have complete test check prefix coverage for every RUN - 
> > and tbh we should be properly testing 32-bit on every x86 intrinsic test 
> > file.
> Yes, testing 32-bit on every x86 intrinsic test file is make sense. I also 
> confuse why this test not testing the 32-bit mode before. I think it is 
> "defect" for the test.
> But how can I well update the test by on checking the 3 updated intrinsics. 
> Because it is strange to update the other intrinsics checking when I only 
> update 3 intrinsics in clang.
Hi @craig.topper , @RKSimon, if the 32 and 64 has common prefix "CHECK", it 
means the line 4 (32 bits) need to check all other intrinsics. That means I 
need to updated a lot check string for the 32 bit mode. 
What's more, currently we have no tools to auto generate the checking code for 
clang test. 



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

https://reviews.llvm.org/D124067

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


[PATCH] D124067: [x86] Support 3 builtin functions for 32-bits targets

2022-04-20 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 added inline comments.



Comment at: clang/test/CodeGen/X86/sse2-builtins.c:560
   // CHECK: insertelement <2 x i64> %{{.*}}, i64 0, i32 1
+  // X86-LABEL: test_mm_cvtsi64_si128
+  // X86: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0

xiangzhangllvm wrote:
> xiangzhangllvm wrote:
> > RKSimon wrote:
> > > xiangzhangllvm wrote:
> > > > craig.topper wrote:
> > > > > Do we need the X86 prefix because of the x86-64 #ifdefs? Or are there 
> > > > > other differences?
> > > > > 
> > > > > If it's just the x86-64, can we add -check-prefixes=CHECK,X64 to the 
> > > > > x86-64 run lines and use X64 for the x86-64 only functions. That way 
> > > > > CHECK can be used for all the common tests.
> > > > Before I change the test, it only build with "-triple=x86_64", So all 
> > > > the CHECK should be X64 prefix. 
> > > > So I add X86 prefix to just let "RUN ... -triple=i386" only check the 
> > > > updated 3 builtins. (let the change be small).
> > > > 
> > > I'd much prefer we have complete test check prefix coverage for every RUN 
> > > - and tbh we should be properly testing 32-bit on every x86 intrinsic 
> > > test file.
> > Yes, testing 32-bit on every x86 intrinsic test file is make sense. I also 
> > confuse why this test not testing the 32-bit mode before. I think it is 
> > "defect" for the test.
> > But how can I well update the test by on checking the 3 updated intrinsics. 
> > Because it is strange to update the other intrinsics checking when I only 
> > update 3 intrinsics in clang.
> Hi @craig.topper , @RKSimon, if the 32 and 64 has common prefix "CHECK", it 
> means the line 4 (32 bits) need to check all other intrinsics. That means I 
> need to updated a lot check string for the 32 bit mode. 
> What's more, currently we have no tools to auto generate the checking code 
> for clang test. 
> 
Actually we have 'update_cc_test_checks.py', but little use.


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

https://reviews.llvm.org/D124067

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


[PATCH] D124036: [clang-format] Don't skip PP lines if original line was a PP line when trying to merge lines

2022-04-20 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:310-313
   for (; J != AnnotatedLines.begin(); --J)
-if (!(*J)->InPPDirective && (*J)->Level < TheLine->Level)
+if ((TheLine->InPPDirective || !(*J)->InPPDirective) &&
+(*J)->Level < TheLine->Level)
   break;

Or simply return before the `for` loop if `TheLine->InPPDirective` is true?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124036

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


[PATCH] D123775: [AST] Support template declaration found through using-decl for QualifiedTemplateName.

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

simplify the code in ASTImporter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123775

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/TemplateName.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/QualTypeNames.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/unittests/AST/TemplateNameTest.cpp

Index: clang/unittests/AST/TemplateNameTest.cpp
===
--- clang/unittests/AST/TemplateNameTest.cpp
+++ clang/unittests/AST/TemplateNameTest.cpp
@@ -58,5 +58,69 @@
 "vector");
 }
 
+TEST(TemplateName, QualifiedUsingTemplate) {
+  std::string Code = R"cpp(
+namespace std {
+  template  struct vector {};
+}
+namespace absl { using std::vector; }
+
+template class T> class X;
+
+using A = X; // QualifiedTemplateName in a template argument.
+  )cpp";
+  auto AST = tooling::buildASTFromCode(Code);
+  // Match the template argument absl::vector in X.
+  auto Matcher = templateArgumentLoc().bind("id");
+  auto MatchResults = match(Matcher, AST->getASTContext());
+  const auto *TAL = MatchResults.front().getNodeAs("id");
+  ASSERT_TRUE(TAL);
+  TemplateName TN = TAL->getArgument().getAsTemplate();
+  EXPECT_EQ(TN.getKind(), TemplateName::QualifiedTemplate);
+  const auto *QTN = TN.getAsQualifiedTemplateName();
+  // Verify that we have the Using template name in the QualifiedTemplateName.
+  const auto *USD = QTN->getUnderlyingTemplate().getAsUsingShadowDecl();
+  EXPECT_TRUE(USD);
+  EXPECT_EQ(USD->getTargetDecl(), TN.getAsTemplateDecl());
+}
+
+TEST(TemplateName, UsingTemplate) {
+  auto AST = tooling::buildASTFromCode(R"cpp(
+namespace std {
+  template  struct vector { vector(T); };
+}
+namespace absl { using std::vector; }
+// The "absl::vector" is an elaborated TemplateSpecializationType with
+// an inner Using TemplateName (not a Qualified TemplateName, the qualifiers
+// are rather part of the ElaboratedType)!
+absl::vector v(123);
+  )cpp");
+  auto Matcher = elaboratedTypeLoc(
+  hasNamedTypeLoc(loc(templateSpecializationType().bind("id";
+  auto MatchResults = match(Matcher, AST->getASTContext());
+  const auto *TST =
+  MatchResults.front().getNodeAs("id");
+  ASSERT_TRUE(TST);
+  EXPECT_EQ(TST->getTemplateName().getKind(), TemplateName::UsingTemplate);
+
+  AST = tooling::buildASTFromCodeWithArgs(R"cpp(
+namespace std {
+  template  struct vector { vector(T); };
+}
+namespace absl { using std::vector; }
+// Similiar to the TemplateSpecializationType, absl::vector is an elaborated
+// DeducedTemplateSpecializationType with an inner Using TemplateName!
+absl::vector DTST(123);
+)cpp",
+  {"-std=c++17"});
+  Matcher = elaboratedTypeLoc(
+  hasNamedTypeLoc(loc(deducedTemplateSpecializationType().bind("id";
+  MatchResults = match(Matcher, AST->getASTContext());
+  const auto *DTST =
+  MatchResults.front().getNodeAs("id");
+  ASSERT_TRUE(DTST);
+  EXPECT_EQ(DTST->getTemplateName().getKind(), TemplateName::UsingTemplate);
+}
+
 } // namespace
 } // namespace clang
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -14715,7 +14715,7 @@
 bool TemplateKW,
 TemplateDecl *Template) {
   return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
-  Template);
+  TemplateName(Template));
 }
 
 template
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -284,17 +284,13 @@
 }
 
 TemplateDecl *TD = cast(D);
-
+Template =
+FoundUsingShadow ? TemplateName(FoundUsingShadow) : TemplateName(TD);
+assert(!FoundUsingShadow || FoundUsingShadow->getTargetDecl() == TD);
 if (SS.isSet() && !SS.isInvalid()) {
   NestedNameSpecifier *Qualifier = SS.getScopeRep();
-  // FIXME: store the using TemplateName in QualifiedTemplateName if
-  // the TD is referred via a using-declaration.
-  Template =
-  Context.getQualifiedTemplateName(Qualifier, hasTemplateKeyword, TD);
-} else {
-  Template =
-  FoundUsingShadow ? TemplateName(FoundUsingShadow) : TemplateName(TD);
-  assert(!FoundUsingShadow || FoundUsingShadow->getTargetDecl() == TD);
+  Te

[PATCH] D123775: [AST] Support template declaration found through using-decl for QualifiedTemplateName.

2022-04-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:9189
+TemplateName UnderlyingTN = QTN->getUnderlyingTemplate();
+if (UsingShadowDecl *USD = UnderlyingTN.getAsUsingShadowDecl()) {
+  if (ExpectedDecl ToUSDOrErr = Import(USD))

sammccall wrote:
> why not just `import(UnderlyingTN)` directly, instead of importing its 
> shadowdecl or templatedecl case-by-case?
good catch, not sure how I missed this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123775

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


[PATCH] D115187: [clangd] Expose CoawaitExpr's operand in the AST

2022-04-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

This seems right to me!




Comment at: clang/lib/Sema/TreeTransform.h:7947
 
   // Always rebuild; we don't know if this needs to be injected into a new
   // context or if the promise type has changed.

nridge wrote:
> sammccall wrote:
> > (FWIW I don't know what "injected into a new context" means, but I don't 
> > think the promise type can change since DependentCoawaitExpr was added in 
> > 20f25cb6dfb3364847f4c570b1914fe51e585def.)
> > 
> Is the implication of this that there are some conditions under which we can 
> reuse the original CoawaitExpr rather than rebuilding it?
Yes, I think this is how instantiation of non-dependent code works, e.g. in the 
following TransformObjCAtTryStmt:

```
  // If nothing changed, just retain this statement.
  if (!getDerived().AlwaysRebuild() &&
  TryBody.get() == S->getTryBody() &&
  !AnyCatchChanged &&
  Finally.get() == S->getFinallyStmt())
return S;
```

I think missing this opportunity means that a non-dependent co_await will 
nevertheless be instantiated into a new node, which in turn means that every 
containing node will *also* be instantiated (because its child nodes changed 
during instantiation).
So this affects speed and memory usage, but I suppose not correctness.

Anyway I don't know exactly what the conditions are where it's safe to reuse 
the node, I suppose we leave this as-is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115187

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


[PATCH] D124067: [x86] Support 3 builtin functions for 32-bits targets

2022-04-20 Thread Xiang Zhang via Phabricator via cfe-commits
xiangzhangllvm added inline comments.



Comment at: clang/test/CodeGen/X86/sse2-builtins.c:560
   // CHECK: insertelement <2 x i64> %{{.*}}, i64 0, i32 1
+  // X86-LABEL: test_mm_cvtsi64_si128
+  // X86: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0

LiuChen3 wrote:
> xiangzhangllvm wrote:
> > xiangzhangllvm wrote:
> > > RKSimon wrote:
> > > > xiangzhangllvm wrote:
> > > > > craig.topper wrote:
> > > > > > Do we need the X86 prefix because of the x86-64 #ifdefs? Or are 
> > > > > > there other differences?
> > > > > > 
> > > > > > If it's just the x86-64, can we add -check-prefixes=CHECK,X64 to 
> > > > > > the x86-64 run lines and use X64 for the x86-64 only functions. 
> > > > > > That way CHECK can be used for all the common tests.
> > > > > Before I change the test, it only build with "-triple=x86_64", So all 
> > > > > the CHECK should be X64 prefix. 
> > > > > So I add X86 prefix to just let "RUN ... -triple=i386" only check the 
> > > > > updated 3 builtins. (let the change be small).
> > > > > 
> > > > I'd much prefer we have complete test check prefix coverage for every 
> > > > RUN - and tbh we should be properly testing 32-bit on every x86 
> > > > intrinsic test file.
> > > Yes, testing 32-bit on every x86 intrinsic test file is make sense. I 
> > > also confuse why this test not testing the 32-bit mode before. I think it 
> > > is "defect" for the test.
> > > But how can I well update the test by on checking the 3 updated 
> > > intrinsics. Because it is strange to update the other intrinsics checking 
> > > when I only update 3 intrinsics in clang.
> > Hi @craig.topper , @RKSimon, if the 32 and 64 has common prefix "CHECK", it 
> > means the line 4 (32 bits) need to check all other intrinsics. That means I 
> > need to updated a lot check string for the 32 bit mode. 
> > What's more, currently we have no tools to auto generate the checking code 
> > for clang test. 
> > 
> Actually we have 'update_cc_test_checks.py', but little use.
I do "./llvm/utils/update_cc_test_checks.py 
clang/test/CodeGen/X86/sse41-builtins.c"
It generate nothing.


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

https://reviews.llvm.org/D124067

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


[clang] 3c776c7 - [PowerPC] add XLC compat builtin __abs

2022-04-20 Thread Chen Zheng via cfe-commits

Author: Chen Zheng
Date: 2022-04-20T05:14:22-04:00
New Revision: 3c776c70a76e9fe51fd978595315e6cef8e7fbb0

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

LOG: [PowerPC] add XLC compat builtin __abs

Reviewed By: jsji

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

Added: 


Modified: 
clang/lib/Basic/Targets/PPC.cpp
clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 1f2f583b9462d..e3ee68cd1fa30 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -208,6 +208,7 @@ static void defineXLCompatMacros(MacroBuilder &Builder) {
   Builder.defineMacro("__dcbf", "__builtin_dcbf");
   Builder.defineMacro("__fmadd", "__builtin_fma");
   Builder.defineMacro("__fmadds", "__builtin_fmaf");
+  Builder.defineMacro("__abs", "__builtin_abs");
   Builder.defineMacro("__labs", "__builtin_labs");
   Builder.defineMacro("__llabs", "__builtin_llabs");
   Builder.defineMacro("__popcnt4", "__builtin_popcount");

diff  --git a/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c 
b/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
index 268dceaa06cb5..cec1ac6cd5655 100644
--- a/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
+++ b/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
@@ -12,6 +12,19 @@
 // Required for size_t. Usually found in stddef.h.
 typedef __SIZE_TYPE__ size_t;
 
+// BOTH-LABEL: @testabs(
+// BOTH-NEXT:  entry:
+// BOTH-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// BOTH-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// BOTH-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// BOTH-NEXT:[[NEG:%.*]] = sub nsw i32 0, [[TMP0]]
+// BOTH-NEXT:[[ABSCOND:%.*]] = icmp slt i32 [[TMP0]], 0
+// BOTH-NEXT:[[ABS:%.*]] = select i1 [[ABSCOND]], i32 [[NEG]], i32 [[TMP0]]
+// BOTH-NEXT:ret i32 [[ABS]]
+signed int testabs(signed int a) {
+  return __abs(a);
+}
+
 // 64BIT-LABEL: @testlabs(
 // 64BIT-NEXT:  entry:
 // 64BIT-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8



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


[PATCH] D123372: [PowerPC] add XLC compat builtin __abs

2022-04-20 Thread ChenZheng 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 rG3c776c70a76e: [PowerPC] add XLC compat builtin __abs 
(authored by shchenz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123372

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c


Index: clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
===
--- clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
+++ clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
@@ -12,6 +12,19 @@
 // Required for size_t. Usually found in stddef.h.
 typedef __SIZE_TYPE__ size_t;
 
+// BOTH-LABEL: @testabs(
+// BOTH-NEXT:  entry:
+// BOTH-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// BOTH-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// BOTH-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// BOTH-NEXT:[[NEG:%.*]] = sub nsw i32 0, [[TMP0]]
+// BOTH-NEXT:[[ABSCOND:%.*]] = icmp slt i32 [[TMP0]], 0
+// BOTH-NEXT:[[ABS:%.*]] = select i1 [[ABSCOND]], i32 [[NEG]], i32 [[TMP0]]
+// BOTH-NEXT:ret i32 [[ABS]]
+signed int testabs(signed int a) {
+  return __abs(a);
+}
+
 // 64BIT-LABEL: @testlabs(
 // 64BIT-NEXT:  entry:
 // 64BIT-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -208,6 +208,7 @@
   Builder.defineMacro("__dcbf", "__builtin_dcbf");
   Builder.defineMacro("__fmadd", "__builtin_fma");
   Builder.defineMacro("__fmadds", "__builtin_fmaf");
+  Builder.defineMacro("__abs", "__builtin_abs");
   Builder.defineMacro("__labs", "__builtin_labs");
   Builder.defineMacro("__llabs", "__builtin_llabs");
   Builder.defineMacro("__popcnt4", "__builtin_popcount");


Index: clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
===
--- clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
+++ clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
@@ -12,6 +12,19 @@
 // Required for size_t. Usually found in stddef.h.
 typedef __SIZE_TYPE__ size_t;
 
+// BOTH-LABEL: @testabs(
+// BOTH-NEXT:  entry:
+// BOTH-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// BOTH-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// BOTH-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// BOTH-NEXT:[[NEG:%.*]] = sub nsw i32 0, [[TMP0]]
+// BOTH-NEXT:[[ABSCOND:%.*]] = icmp slt i32 [[TMP0]], 0
+// BOTH-NEXT:[[ABS:%.*]] = select i1 [[ABSCOND]], i32 [[NEG]], i32 [[TMP0]]
+// BOTH-NEXT:ret i32 [[ABS]]
+signed int testabs(signed int a) {
+  return __abs(a);
+}
+
 // 64BIT-LABEL: @testlabs(
 // 64BIT-NEXT:  entry:
 // 64BIT-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -208,6 +208,7 @@
   Builder.defineMacro("__dcbf", "__builtin_dcbf");
   Builder.defineMacro("__fmadd", "__builtin_fma");
   Builder.defineMacro("__fmadds", "__builtin_fmaf");
+  Builder.defineMacro("__abs", "__builtin_abs");
   Builder.defineMacro("__labs", "__builtin_labs");
   Builder.defineMacro("__llabs", "__builtin_llabs");
   Builder.defineMacro("__popcnt4", "__builtin_popcount");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 88d61cc - [X86][SSE] Add i386 test coverage to sse3 intrinsic tests

2022-04-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-04-20T10:44:28+01:00
New Revision: 88d61cc6e934225059490249ce12e48f4559587d

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

LOG: [X86][SSE] Add i386 test coverage to sse3 intrinsic tests

Added: 


Modified: 
clang/test/CodeGen/X86/sse3-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/sse3-builtins.c 
b/clang/test/CodeGen/X86/sse3-builtins.c
index a5ac1cde77689..a93eb2d075373 100644
--- a/clang/test/CodeGen/X86/sse3-builtins.c
+++ b/clang/test/CodeGen/X86/sse3-builtins.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse3 -emit-llvm 
-o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=i386-apple-darwin -target-feature +sse3 -emit-llvm -o 
- -Wall -Werror | FileCheck %s
 
 
 #include 



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


[clang] 6574d75 - [XOP] Add i386 test coverage to xop intrinsic tests

2022-04-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-04-20T10:44:27+01:00
New Revision: 6574d75b8dae6219d003fe8b1046db34199248f2

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

LOG: [XOP] Add i386 test coverage to xop intrinsic tests

Added: 


Modified: 
clang/test/CodeGen/X86/xop-builtins-cmp.c
clang/test/CodeGen/X86/xop-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/xop-builtins-cmp.c 
b/clang/test/CodeGen/X86/xop-builtins-cmp.c
index 7a9554c333f2e..af7bc6ce25c4e 100644
--- a/clang/test/CodeGen/X86/xop-builtins-cmp.c
+++ b/clang/test/CodeGen/X86/xop-builtins-cmp.c
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +xop -emit-llvm -o - -Wall -Werror 
| FileCheck %s
 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +xop -fno-signed-char -emit-llvm -o 
- -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=i386-apple-darwin -target-feature +xop -emit-llvm -o - -Wall -Werror | 
FileCheck %s
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=i386-apple-darwin -target-feature +xop -fno-signed-char -emit-llvm -o - 
-Wall -Werror | FileCheck %s
 
 
 #include 

diff  --git a/clang/test/CodeGen/X86/xop-builtins.c 
b/clang/test/CodeGen/X86/xop-builtins.c
index 82f75049c5f7f..113af58a69339 100644
--- a/clang/test/CodeGen/X86/xop-builtins.c
+++ b/clang/test/CodeGen/X86/xop-builtins.c
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +xop -emit-llvm -o - -Wall -Werror 
| FileCheck %s
 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +xop -fno-signed-char -emit-llvm -o 
- -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=i386-apple-darwin -target-feature +xop -emit-llvm -o - -Wall -Werror | 
FileCheck %s
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=i386-apple-darwin -target-feature +xop -fno-signed-char -emit-llvm -o - 
-Wall -Werror | FileCheck %s
 
 
 #include 



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


[clang] c86588a - [X86][SSE] Add i386 test coverage to ssse3 intrinsic tests

2022-04-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-04-20T10:44:28+01:00
New Revision: c86588af6596d96d046513269dbb1284016391a4

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

LOG: [X86][SSE] Add i386 test coverage to ssse3 intrinsic tests

Added: 


Modified: 
clang/test/CodeGen/X86/ssse3-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/ssse3-builtins.c 
b/clang/test/CodeGen/X86/ssse3-builtins.c
index d72ca9dd5b41c..ea65af0447e91 100644
--- a/clang/test/CodeGen/X86/ssse3-builtins.c
+++ b/clang/test/CodeGen/X86/ssse3-builtins.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +ssse3 -emit-llvm -o - -Wall 
-Werror | FileCheck %s
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=i386-apple-darwin -target-feature +ssse3 -emit-llvm -o - -Wall -Werror 
| FileCheck %s
 
 
 #include 



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


[PATCH] D123783: [clang] Eliminate TypeProcessingState::trivial.

2022-04-20 Thread Martin Bƶhme via Phabricator via cfe-commits
mboehme marked an inline comment as done.
mboehme added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:170
 /// Whether we saved the attributes in the decl spec.
 bool hasSavedAttrs;
 

aaron.ballman wrote:
> mboehme wrote:
> > aaron.ballman wrote:
> > > Isn't the same true for this variable? It seems like:
> > > 
> > > `trivial` == `savedAttrs.empty()`
> > > `hasSavedAttrs` == `!savedAttrs.empty()`
> > That's what I also thought at first -- but the situation for 
> > `hasSavedAttrs` is a bit more complicated. It gets set whenever 
> > `saveDeclAttrs()` is called, even if it doesn't actually end up saving any 
> > attributes (i.e. if `spec.getAttributes()` is empty).
> > 
> > `hasSavedAttrs` is then used to prevent any further calls to 
> > `saveDeclSpecAttrs()` from doing anything:
> > 
> > ```
> > // Don't try to save them multiple times.
> > if (hasSavedAttrs) return;
> > ```
> > 
> > Conceivably, `spec` _might_ have had attributes added to it in the meantime 
> > -- not sure? It might be OK to just replace this logic with `if 
> > (!savedAttrs.empty()) return;` -- but I'm not familiar enough with how this 
> > code gets used and therefore decided it would be better not to change it. 
> > Can you give additional input on this?
> I have the impression that is an oversight in the code rather than an 
> intentional behavior. I think it may be okay to replace the logic with 
> `!savedAttrs.empty()` as well; if you do that, do you get any test failures? 
> (If you do, then that's a sign something else might be going on.)
I just tried:

```
// Don't try to save them multiple times.
if (!savedAttrs.empty()) return;
```

 I didn't get any test failures.

Of course, this isn't proof that this is _really_ OK, but it's an indication.

You know this code better than I do, so I would defer to you: How do you think 
I should proceed? Should I eliminate `hasSavedAttrs` too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123783

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


[clang] b402ea5 - [X86][SSE] Add i386 test coverage to sse4a intrinsic tests

2022-04-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-04-20T10:48:47+01:00
New Revision: b402ea55a834c956de87816143f05fab7fde74ca

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

LOG: [X86][SSE] Add i386 test coverage to sse4a intrinsic tests

Added: 


Modified: 
clang/test/CodeGen/X86/sse4a-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/sse4a-builtins.c 
b/clang/test/CodeGen/X86/sse4a-builtins.c
index 84b6cf1e56089..4ee7ea8f0beb5 100644
--- a/clang/test/CodeGen/X86/sse4a-builtins.c
+++ b/clang/test/CodeGen/X86/sse4a-builtins.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4a -emit-llvm 
-o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4a -emit-llvm 
-o - -Wall -Werror | FileCheck %s
 
 
 #include 



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


[PATCH] D111548: [Clang] Add the `annotate_type` attribute

2022-04-20 Thread Martin Bƶhme via Phabricator via cfe-commits
mboehme updated this revision to Diff 423856.
mboehme marked 2 inline comments as done.
mboehme added a comment.

Changes in response to review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111548

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/AST/attr-annotate-type.c
  clang/test/CodeGenCXX/annotate-type.cpp
  clang/test/Sema/annotate-type.c
  clang/test/SemaCXX/annotate-type.cpp
  clang/unittests/AST/AttrTest.cpp

Index: clang/unittests/AST/AttrTest.cpp
===
--- clang/unittests/AST/AttrTest.cpp
+++ clang/unittests/AST/AttrTest.cpp
@@ -7,7 +7,10 @@
 //===--===//
 
 #include "clang/AST/Attr.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Basic/AttrKinds.h"
+#include "clang/Tooling/Tooling.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -15,10 +18,154 @@
 
 namespace {
 
+using clang::ast_matchers::constantExpr;
+using clang::ast_matchers::equals;
+using clang::ast_matchers::functionDecl;
+using clang::ast_matchers::has;
+using clang::ast_matchers::hasDescendant;
+using clang::ast_matchers::hasName;
+using clang::ast_matchers::integerLiteral;
+using clang::ast_matchers::match;
+using clang::ast_matchers::selectFirst;
+using clang::ast_matchers::stringLiteral;
+using clang::ast_matchers::varDecl;
+using clang::tooling::buildASTFromCode;
+using clang::tooling::buildASTFromCodeWithArgs;
+
 TEST(Attr, Doc) {
   EXPECT_THAT(Attr::getDocumentation(attr::Used).str(),
   testing::HasSubstr("The compiler must emit the definition even "
  "if it appears to be unused"));
 }
 
+const FunctionDecl *getFunctionNode(ASTUnit *AST, const std::string &Name) {
+  auto Result =
+  match(functionDecl(hasName(Name)).bind("fn"), AST->getASTContext());
+  EXPECT_EQ(Result.size(), 1u);
+  return Result[0].getNodeAs("fn");
+}
+
+const VarDecl *getVariableNode(ASTUnit *AST, const std::string &Name) {
+  auto Result = match(varDecl(hasName(Name)).bind("var"), AST->getASTContext());
+  EXPECT_EQ(Result.size(), 1u);
+  return Result[0].getNodeAs("var");
+}
+
+template 
+void AssertAnnotatedAs(TypeLoc TL, llvm::StringRef annotation,
+   ModifiedTypeLoc &ModifiedTL,
+   const AnnotateTypeAttr **AnnotateOut = nullptr) {
+  const auto AttributedTL = TL.getAs();
+  ASSERT_FALSE(AttributedTL.isNull());
+  ModifiedTL = AttributedTL.getModifiedLoc().getAs();
+  ASSERT_TRUE(ModifiedTL);
+
+  ASSERT_NE(AttributedTL.getAttr(), nullptr);
+  const auto *Annotate = dyn_cast(AttributedTL.getAttr());
+  ASSERT_NE(Annotate, nullptr);
+  EXPECT_EQ(Annotate->getAnnotation(), annotation);
+  if (AnnotateOut) {
+*AnnotateOut = Annotate;
+  }
+}
+
+TEST(Attr, AnnotateType) {
+
+  // Test that the AnnotateType attribute shows up in the right places and that
+  // it stores its arguments correctly.
+
+  auto AST = buildASTFromCode(R"cpp(
+void f(int* [[clang::annotate_type("foo", "arg1", 2)]] *,
+   int [[clang::annotate_type("bar")]]);
+
+int [[clang::annotate_type("int")]] * [[clang::annotate_type("ptr")]]
+  array[10] [[clang::annotate_type("arr")]];
+
+void (* [[clang::annotate_type("funcptr")]] fp)(void);
+
+struct S { int mem; };
+int [[clang::annotate_type("int")]]
+S::* [[clang::annotate_type("ptr_to_mem")]] ptr_to_member = &S::mem;
+)cpp");
+
+  {
+const FunctionDecl *Func = getFunctionNode(AST.get(), "f");
+
+// First parameter.
+const auto PointerTL = Func->getParamDecl(0)
+   ->getTypeSourceInfo()
+   ->getTypeLoc()
+   .getAs();
+ASSERT_FALSE(PointerTL.isNull());
+PointerTypeLoc PointerPointerTL;
+const AnnotateTypeAttr *Annotate;
+AssertAnnotatedAs(PointerTL.getPointeeLoc(), "foo", PointerPointerTL,
+  &Annotate);
+
+EXPECT_EQ(Annotate->args_size(), 2);
+const auto *StringLit = selectFirst(
+"str", match(constantExpr(hasDescendant(stringLiteral().bind("str"))),
+ *Annotate->args_begin()[0], AST->getASTContext()));
+ASSERT_NE(StringLit, nullptr);
+EXPECT_EQ(StringLit->getString(), "arg1");
+EXPECT_EQ(match(constantExpr(has(integerLiteral(equals(2)).bind("int"))),
+*Annotate->args_begin()[1], AST->getASTContext())
+  .size(),
+  1);
+
+// Second parameter.
+BuiltinTypeLoc IntT

[clang] e67b1b0 - [OpenCL] Add missing __opencl_c_atomic_scope_device guards

2022-04-20 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-04-20T11:02:50+01:00
New Revision: e67b1b0ccf520a0168758d116e88f63160812e99

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

LOG: [OpenCL] Add missing __opencl_c_atomic_scope_device guards

Update opencl-c.h after the specification clarification in
https://github.com/KhronosGroup/OpenCL-Docs/pull/775

Added: 


Modified: 
clang/lib/Headers/opencl-c.h

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 7ea835ae5c2de..8d9af52481957 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -14376,6 +14376,7 @@ bool __ovld atomic_compare_exchange_weak(volatile 
__local atomic_ulong *, __priv
 #endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 
202100)
 #endif
 
+#if defined(__opencl_c_atomic_scope_device)
 #if defined(__opencl_c_generic_address_space)
 bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_int *, int 
*, int, memory_order, memory_order);
 bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_uint *, 
uint *, uint, memory_order, memory_order);
@@ -14472,6 +14473,7 @@ bool __ovld 
atomic_compare_exchange_weak_explicit(volatile __local atomic_ulong
 bool __ovld atomic_compare_exchange_weak_explicit(volatile __local 
atomic_ulong *, __private ulong *, ulong, memory_order, memory_order);
 #endif //defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 #endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 
202100)
+#endif //defined(__opencl_c_atomic_scope_device)
 
 #if defined(__opencl_c_generic_address_space)
 bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_int *, int 
*, int, memory_order, memory_order, memory_scope);



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


[clang] 90e5c69 - [X86][SSE] Add i386 test coverage to sse41 intrinsic tests

2022-04-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-04-20T11:06:06+01:00
New Revision: 90e5c690e2a0b4973e86fb6c010264e5452319f9

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

LOG: [X86][SSE] Add i386 test coverage to sse41 intrinsic tests

Added: 


Modified: 
clang/test/CodeGen/X86/sse41-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/sse41-builtins.c 
b/clang/test/CodeGen/X86/sse41-builtins.c
index 599c4bbd029f4..c09380bbe1de9 100644
--- a/clang/test/CodeGen/X86/sse41-builtins.c
+++ b/clang/test/CodeGen/X86/sse41-builtins.c
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.1 
-emit-llvm -o - -Wall -Werror | FileCheck %s
-// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.1 
-fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.1 
-emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X64
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.1 
-fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s 
--check-prefixes=CHECK,X64
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.1 -emit-llvm 
-o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.1 
-fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s 
--check-prefixes=CHECK
 
 
 #include 
@@ -184,8 +186,8 @@ int test_mm_extract_epi32(__m128i x) {
 
 #ifdef __x86_64__
 long long test_mm_extract_epi64(__m128i x) {
-  // CHECK-LABEL: test_mm_extract_epi64
-  // CHECK: extractelement <2 x i64> %{{.*}}, {{i32|i64}} 1
+  // X64-LABEL: test_mm_extract_epi64
+  // X64: extractelement <2 x i64> %{{.*}}, {{i32|i64}} 1
   return _mm_extract_epi64(x, 1);
 }
 #endif
@@ -234,8 +236,8 @@ __m128i test_mm_insert_epi32(__m128i x, int b) {
 
 #ifdef __x86_64__
 __m128i test_mm_insert_epi64(__m128i x, long long b) {
-  // CHECK-LABEL: test_mm_insert_epi64
-  // CHECK: insertelement <2 x i64> %{{.*}}, i64 %{{.*}}, {{i32|i64}} 1
+  // X64-LABEL: test_mm_insert_epi64
+  // X64: insertelement <2 x i64> %{{.*}}, i64 %{{.*}}, {{i32|i64}} 1
   return _mm_insert_epi64(x, b, 1);
 }
 #endif



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


[clang] ba2e567 - [X86][SSE] Add i386 test coverage to sse42 intrinsic tests

2022-04-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-04-20T11:06:07+01:00
New Revision: ba2e567f049df942b374c2002da9aef06e0b6dc4

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

LOG: [X86][SSE] Add i386 test coverage to sse42 intrinsic tests

Added: 


Modified: 
clang/test/CodeGen/X86/sse42-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/sse42-builtins.c 
b/clang/test/CodeGen/X86/sse42-builtins.c
index 93e4c3ac41120..92fc7b301a0e2 100644
--- a/clang/test/CodeGen/X86/sse42-builtins.c
+++ b/clang/test/CodeGen/X86/sse42-builtins.c
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +sse4.2 -emit-llvm -o - -Wall 
-Werror | FileCheck %s
-// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +sse4.2 -fno-signed-char -emit-llvm 
-o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +sse4.2 -emit-llvm -o - -Wall 
-Werror | FileCheck %s --check-prefixes=CHECK,X64
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +sse4.2 -fno-signed-char -emit-llvm 
-o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X64
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=i386-apple-darwin -target-feature +sse4.2 -emit-llvm -o - -Wall -Werror 
| FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=i386-apple-darwin -target-feature +sse4.2 -fno-signed-char -emit-llvm 
-o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK
 
 
 #include 
@@ -116,8 +118,8 @@ unsigned int test_mm_crc32_u32(unsigned int CRC, unsigned 
int V) {
 
 #ifdef __x86_64__
 unsigned long long test_mm_crc32_u64(unsigned long long CRC, unsigned long 
long V) {
-  // CHECK-LABEL: test_mm_crc32_u64
-  // CHECK: call i64 @llvm.x86.sse42.crc32.64.64(i64 %{{.*}}, i64 %{{.*}})
+  // X64-LABEL: test_mm_crc32_u64
+  // X64: call i64 @llvm.x86.sse42.crc32.64.64(i64 %{{.*}}, i64 %{{.*}})
   return _mm_crc32_u64(CRC, V);
 }
 #endif



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


[PATCH] D124081: [clang] Reject non-declaration C++11 attributes on declarations.

2022-04-20 Thread Martin Bƶhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added a reviewer: aaron.ballman.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Clang has allowed this so far, transferring the attributes to the declaration's
type instead, as would be done for GNU syntax attributes. However, the C++
standard is clear that attributes in certain positions appertain to the
declaration, so we shouldn't allow type attributes in these positions.

For backwards compatibility, we only warn on non-declaration attributes that we
have historically allowed to be put on declarations. We only produce errors for
new non-declaration attributes.

Depends On D111548 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124081

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Sema/annotate-type.c
  clang/test/SemaCXX/annotate-type.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -4220,6 +4220,9 @@
 OS << "/*IsStmt=*/";
 OS << (Attr.isSubClassOf("StmtAttr") || Attr.isSubClassOf("DeclOrStmtAttr"))
<< ",\n";
+OS << "/*IsDecl=*/";
+OS << (!Attr.isSubClassOf("TypeAttr") && !Attr.isSubClassOf("StmtAttr"))
+   << ",\n";
 OS << "/*IsKnownToGCC=*/";
 OS << IsKnownToGCC(Attr) << ",\n";
 OS << "/*IsSupportedByPragmaAttribute=*/";
Index: clang/test/SemaCXX/annotate-type.cpp
===
--- clang/test/SemaCXX/annotate-type.cpp
+++ clang/test/SemaCXX/annotate-type.cpp
@@ -2,10 +2,7 @@
 
 struct S1 {
   void f() [[clang::annotate_type("foo")]];
-  // FIXME: We would want to prohibit the attribute in the following location.
-  // However, Clang currently generally doesn't prohibit type-only C++11
-  // attributes on declarations. This should be fixed more generally.
-  [[clang::annotate_type("foo")]] void g();
+  [[clang::annotate_type("foo")]] void g(); // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
 };
 
 template  struct is_same {
@@ -50,10 +47,8 @@
 
 // More error cases: Prohibit adding the attribute to declarations.
 // Different declarations hit different code paths, so they need separate tests.
-// FIXME: Clang currently generally doesn't prohibit type-only C++11
-// attributes on declarations.
-namespace [[clang::annotate_type("foo")]] my_namespace {}
-struct [[clang::annotate_type("foo")]] S3{};
+namespace [[clang::annotate_type("foo")]] my_namespace {} // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
+struct [[clang::annotate_type("foo")]] S3{}; // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
 void f4() {
-  for ([[clang::annotate_type("foo")]] int i = 0; i < 42; ++i) {}
+  for ([[clang::annotate_type("foo")]] int i = 0; i < 42; ++i) {} // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
 }
Index: clang/test/Sema/annotate-type.c
===
--- clang/test/Sema/annotate-type.c
+++ clang/test/Sema/annotate-type.c
@@ -17,10 +17,7 @@
   int *__attribute__((annotate_type("bar"))) y2; // expected-warning {{unknown attribute 'annotate_type' ignored}}
 
   // Various error cases
-  // FIXME: We would want to prohibit the attribute in the following location.
-  // However, Clang currently generally doesn't prohibit type-only C++11
-  // attributes on declarations. This should be fixed more generally.
-  [[clang::annotate_type("bar")]] int *z1;
+  [[clang::annotate_type("bar")]] int *z1; // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
   int *z2 [[clang::annotate_type("bar")]]; // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
   [[clang::annotate_type("bar")]]; // expected-error {{'annotate_type' attribute cannot be applied to a statement}}
   int *[[clang::annotate_type(1)]] z3; // expected-error {{'annotate_type' attribute requires a string}}
@@ -33,7 +30,5 @@
 }
 // More error cases: Prohibit adding the attribute to declarations.
 // Different declarations hit different code paths, so they need separate tests.
-// FIXME: Clang currently generally doesn't prohibit type-only C++11
-// attributes on declarations.
-[[clang::annotate_type("bar")]] int *global;
-void g([[clang::annotate_type("bar")]] int);
+[[clang::annotate_type("bar")]] int *global; // expected-error {{'anno

[PATCH] D124067: [x86] Support 3 builtin functions for 32-bits targets

2022-04-20 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

I'm updating the sse builtin test files to include i386 coverage - should be 
done in an hour or so


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

https://reviews.llvm.org/D124067

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


[clang] 7c1bff3 - [X86][FMA4] Add i386 test coverage to fma4 intrinsic tests

2022-04-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-04-20T11:14:18+01:00
New Revision: 7c1bff3f7bc569fa2fcbc10365efc787552caa49

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

LOG: [X86][FMA4] Add i386 test coverage to fma4 intrinsic tests

Added: 


Modified: 
clang/test/CodeGen/X86/fma4-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/fma4-builtins.c 
b/clang/test/CodeGen/X86/fma4-builtins.c
index 274ca481fabf0..94dcaf61f2681 100644
--- a/clang/test/CodeGen/X86/fma4-builtins.c
+++ b/clang/test/CodeGen/X86/fma4-builtins.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +fma4 -emit-llvm -o - -Wall -Werror 
| FileCheck %s
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=i386-apple-darwin -target-feature +fma4 -emit-llvm -o - -Wall -Werror | 
FileCheck %s
 
 
 #include 



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


[PATCH] D124038: [clang] Prevent folding of non-const compound expr

2022-04-20 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

In D124038#3460731 , @efriedma wrote:

> The fix doesn't look right.
>
> A CompoundLiteralExpr is itself an lvalue; we should catch any issues when we 
> visit it, not a VarDecl that contains a pointer to it.

Well, the visitor for CompoundLiteralExpr explicitly states

>   // Defer visiting the literal until the lvalue-to-rvalue conversion. We can
>   // only see this when folding in C, so there's no standard to follow here.

Which is what I was trying to do in this patch.
We only visit CompoundLiteralExpr once, during initialization of the VarDecl, 
and that initialization is correct. We don't visit it again during checking of 
expression constness because we stop at the VarDecl level. I'm checking if we 
could peform an extra check at that point. But maybe I'm totally taking a wrong 
turn, feel free to advise :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124038

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


[PATCH] D123837: [C++20] [Modules] Judge isInCurrentModule currently

2022-04-20 Thread Iain Sandoe via Phabricator via cfe-commits
iains accepted this revision.
iains added a comment.
This revision is now accepted and ready to land.

thanks for multiple iterations!

I think maybe you are using a too old clang-format?
it seems that clang-format >= llvm-14  removes spaces around module partition 
colons  ... so `A : Part`==>`A:Part` and `: Impl` => `:Impl`.
IMO this is the correct formatting (since it follows the examples in the 
standard).

Anyway, this is most likely the reason for the clang format fails on the CI.

This now LGTM - but please fix the formatting in the test cases.




Comment at: clang/lib/Sema/SemaLookup.cpp:1567-1568
+
+  return M->getPrimaryModuleInterfaceName() ==
+ Module::getPrimaryModuleInterfaceName(LangOpts.CurrentModule);
 }

ChuanqiXu wrote:
> ChuanqiXu wrote:
> > iains wrote:
> > > iains wrote:
> > > > ChuanqiXu wrote:
> > > > > iains wrote:
> > > > > > ChuanqiXu wrote:
> > > > > > > iains wrote:
> > > > > > > > ... of course, "correctness before optimisation", but this test 
> > > > > > > > function seems like it would benefit from some refactoring as 
> > > > > > > > suggested below.
> > > > > > > > 
> > > > > > > > it seems a bit unfortunate that we are placing a string 
> > > > > > > > comparison in the "acceptable decl" lookup path, which might be 
> > > > > > > > made many times (the previous use of the string compare was in 
> > > > > > > > making the module decl - which only happens once in a TU).
> > > > > > > > 
> > > > > > > > * Sema has visibility of the import graph of modules (via 
> > > > > > > > DirectModuleImports and Exports).
> > > > > > > > * We also know what the module parse state is (FirstDecl, GMF 
> > > > > > > > etc)
> > > > > > > > * If were are not parsing a module (i.e. 
> > > > > > > > LangOpts.CurrentModule.empty()) the we could return false early?
> > > > > > > > * if ModuleScopes is empty we know we are not (yet) parsing a 
> > > > > > > > module
> > > > > > > > * Once we are parsing a module then we can test 
> > > > > > > > ModuleScopes.back() to find the current module 
> > > > > > > > 
> > > > > > > > there are only two users of isInCurrentModule() - so maybe we 
> > > > > > > > refactor could make more use of the higher level state 
> > > > > > > > information - and / or cache information on the parents of 
> > > > > > > > partitions  to  avoid the complexity of parsing strings each 
> > > > > > > > time.
> > > > > > > > 
> > > > > > > > what do you think?
> > > > > > > Yeah, string comparison is relatively expensive and we should 
> > > > > > > avoid that. I added a search cache here and I thought it should 
> > > > > > > handle the most cases.
> > > > > > > 
> > > > > > > For the solution you described, I am not sure if I understood 
> > > > > > > correctly. It looks like a quick return path if we found we are 
> > > > > > > not parsing a module? If yes, I think the current check could do 
> > > > > > > similar works. 
> > > > > > That looks good.
> > > > > > 
> > > > > > On the actual test itself:
> > > > > > 
> > > > > > 1/
> > > > > > we have the check of  `(M->isGlobalModule() && !M->Parent)`
> > > > > > 
> > > > > > So that answers "this decl is part of the global module", since 
> > > > > > that fires when we are parsing the GMF.  What will we answer,
> > > > > >  if `M->isGlobalModule() && M->Parent` ?
> > > > > >  it seems that with the changes above we will now answer that the 
> > > > > > decl is part of the Parent - not part of the GM?
> > > > > > 
> > > > > > 2/
> > > > > > When we are actually  parsing the PMF we have a similar case, no?
> > > > > >  (so that there is no Parent pointer set yet, and I think that 
> > > > > > means that we would need to examine ModuleScopes to find the Parent 
> > > > > > module?)
> > > > > > 
> > > > > > 
> > > > > > 1/
> > > > > > we have the check of  (M->isGlobalModule() && !M->Parent)
> > > > > >
> > > > > > So that answers "this decl is part of the global module", since 
> > > > > > that fires when we are parsing the GMF. What will we answer,
> > > > > > if M->isGlobalModule() && M->Parent ?
> > > > > > it seems that with the changes above we will now answer that the 
> > > > > > decl is part of the Parent - not part of the GM?
> > > > > 
> > > > > Good Catcha! Now in this revision, the function would return false 
> > > > > for the case of `M->isGlobalModule() && M->Parent`. Another point I 
> > > > > found is that the name of the function is not quite right. Since 
> > > > > global module fragment belongs to global module, it wouldn't be 
> > > > > within the current module. So I chose a new name `isUsableModule` for 
> > > > > it from the wording  of `[module.global.frag]p1`. I tried to call it 
> > > > > `isVisibleModule` but I found there is already one... I feel 
> > > > > `isUsableModule` is not perfectly good... Any suggestion?
> > > > > 
> > > > > > 2/
> > > > > > When we are actually parsing the PMF we have a similar case, no?
> > > > > 
> > > > > There might not be a 

[PATCH] D124039: [OpenMP] Add better testing for the linker wrapper

2022-04-20 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests on Mac: http://45.33.8.238/macm1/33656/step_7.txt

Please take a look and revert for now if it takes a while to fix. (Maybe just 
needs an explicit triple?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124039

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


[PATCH] D124083: [clang] [draft] Reject C++ 11 attributes appertaining to the wrong entity type.

2022-04-20 Thread Martin Bƶhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added a reviewer: aaron.ballman.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

DRAFT -- do not review.

Depends On D111548 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124083

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/Sema/annotate-type.c
  clang/test/SemaCXX/annotate-type.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3728,7 +3728,7 @@
 if (!StmtSubjects.empty()) {
   OS << "bool diagAppertainsToDecl(Sema &S, const ParsedAttr &AL, ";
   OS << "const Decl *D) const override {\n";
-  OS << "  S.Diag(AL.getLoc(), diag::err_stmt_attribute_invalid_on_decl)\n";
+  OS << "  S.Diag(AL.getLoc(), diag::err_attribute_invalid_on_decl)\n";
   OS << "<< AL << D->getLocation();\n";
   OS << "  return false;\n";
   OS << "}\n\n";
@@ -3772,7 +3772,7 @@
 if (!DeclSubjects.empty()) {
   OS << "bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, ";
   OS << "const Stmt *St) const override {\n";
-  OS << "  S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt)\n";
+  OS << "  S.Diag(AL.getLoc(), diag::err_attribute_invalid_on_stmt)\n";
   OS << "<< AL << St->getBeginLoc();\n";
   OS << "  return false;\n";
   OS << "}\n\n";
@@ -4220,6 +4220,9 @@
 OS << "/*IsStmt=*/";
 OS << (Attr.isSubClassOf("StmtAttr") || Attr.isSubClassOf("DeclOrStmtAttr"))
<< ",\n";
+OS << "/*IsDecl=*/";
+OS << (!Attr.isSubClassOf("TypeAttr") && !Attr.isSubClassOf("StmtAttr"))
+   << ",\n";
 OS << "/*IsKnownToGCC=*/";
 OS << IsKnownToGCC(Attr) << ",\n";
 OS << "/*IsSupportedByPragmaAttribute=*/";
Index: clang/test/SemaCXX/annotate-type.cpp
===
--- clang/test/SemaCXX/annotate-type.cpp
+++ clang/test/SemaCXX/annotate-type.cpp
@@ -2,10 +2,7 @@
 
 struct S1 {
   void f() [[clang::annotate_type("foo")]];
-  // FIXME: We would want to prohibit the attribute in the following location.
-  // However, Clang currently generally doesn't prohibit type-only C++11
-  // attributes on declarations. This should be fixed more generally.
-  [[clang::annotate_type("foo")]] void g();
+  [[clang::annotate_type("foo")]] void g(); // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
 };
 
 template  struct is_same {
@@ -52,8 +49,8 @@
 // Different declarations hit different code paths, so they need separate tests.
 // FIXME: Clang currently generally doesn't prohibit type-only C++11
 // attributes on declarations.
-namespace [[clang::annotate_type("foo")]] my_namespace {}
-struct [[clang::annotate_type("foo")]] S3{};
+namespace [[clang::annotate_type("foo")]] my_namespace {} // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
+struct [[clang::annotate_type("foo")]] S3{}; // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
 void f4() {
-  for ([[clang::annotate_type("foo")]] int i = 0; i < 42; ++i) {}
+  for ([[clang::annotate_type("foo")]] int i = 0; i < 42; ++i) {} // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
 }
Index: clang/test/Sema/annotate-type.c
===
--- clang/test/Sema/annotate-type.c
+++ clang/test/Sema/annotate-type.c
@@ -17,10 +17,7 @@
   int *__attribute__((annotate_type("bar"))) y2; // expected-warning {{unknown attribute 'annotate_type' ignored}}
 
   // Various error cases
-  // FIXME: We would want to prohibit the attribute in the following location.
-  // However, Clang currently generally doesn't prohibit type-only C++11
-  // attributes on declarations. This should be fixed more generally.
-  [[clang::annotate_type("bar")]] int *z1;
+  [[clang::annotate_type("bar")]] int *z1; // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
   int *z2 [[clang::annotate_type("bar")]]; // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
   [[clang::annotate_type("bar")]]; // expect

[clang] 3949c2d - [X86][SSE] Add i386 test coverage to sse2 intrinsic tests

2022-04-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-04-20T12:05:10+01:00
New Revision: 3949c2de79813231492e631cfd3680198d146fe9

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

LOG: [X86][SSE] Add i386 test coverage to sse2 intrinsic tests

Added: 


Modified: 
clang/test/CodeGen/X86/sse2-builtins-constrained-cmp.c
clang/test/CodeGen/X86/sse2-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/sse2-builtins-constrained-cmp.c 
b/clang/test/CodeGen/X86/sse2-builtins-constrained-cmp.c
index 95384a13605b4..f430bba9d06e8 100644
--- a/clang/test/CodeGen/X86/sse2-builtins-constrained-cmp.c
+++ b/clang/test/CodeGen/X86/sse2-builtins-constrained-cmp.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +sse2 -emit-llvm -ffp-exception-behavior=strict -o - -Wall 
-Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=i386-apple-darwin -target-feature 
+sse2 -emit-llvm -ffp-exception-behavior=strict -o - -Wall -Werror | FileCheck 
%s
 
 
 #include 
@@ -8,7 +9,6 @@ __m128d test_mm_cmpeq_pd(__m128d A, __m128d B) {
   // CHECK: [[CMP:%.*]] = call <2 x i1> 
@llvm.experimental.constrained.fcmp.v2f64(<2 x double> %{{.*}}, <2 x double> 
%{{.*}}, metadata !"oeq", metadata !"fpexcept.strict")
   // CHECK-NEXT:[[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
   // CHECK-NEXT:[[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
-  // CHECK-NEXT:ret <2 x double> [[BC]]
   return _mm_cmpeq_pd(A, B);
 }
 
@@ -17,7 +17,6 @@ __m128d test_mm_cmpge_pd(__m128d A, __m128d B) {
   // CHECK: [[CMP:%.*]] = call <2 x i1> 
@llvm.experimental.constrained.fcmps.v2f64(<2 x double> %{{.*}}, <2 x double> 
%{{.*}}, metadata !"ole", metadata !"fpexcept.strict")
   // CHECK-NEXT:[[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
   // CHECK-NEXT:[[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
-  // CHECK-NEXT:ret <2 x double> [[BC]]
   return _mm_cmpge_pd(A, B);
 }
 
@@ -26,7 +25,6 @@ __m128d test_mm_cmpgt_pd(__m128d A, __m128d B) {
   // CHECK: [[CMP:%.*]] = call <2 x i1> 
@llvm.experimental.constrained.fcmps.v2f64(<2 x double> %{{.*}}, <2 x double> 
%{{.*}}, metadata !"olt", metadata !"fpexcept.strict")
   // CHECK-NEXT:[[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
   // CHECK-NEXT:[[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
-  // CHECK-NEXT:ret <2 x double> [[BC]]
   return _mm_cmpgt_pd(A, B);
 }
 
@@ -35,7 +33,6 @@ __m128d test_mm_cmple_pd(__m128d A, __m128d B) {
   // CHECK: [[CMP:%.*]] = call <2 x i1> 
@llvm.experimental.constrained.fcmps.v2f64(<2 x double> %{{.*}}, <2 x double> 
%{{.*}}, metadata !"ole", metadata !"fpexcept.strict")
   // CHECK-NEXT:[[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
   // CHECK-NEXT:[[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
-  // CHECK-NEXT:ret <2 x double> [[BC]]
   return _mm_cmple_pd(A, B);
 }
 
@@ -44,7 +41,6 @@ __m128d test_mm_cmplt_pd(__m128d A, __m128d B) {
   // CHECK: [[CMP:%.*]] = call <2 x i1> 
@llvm.experimental.constrained.fcmps.v2f64(<2 x double> %{{.*}}, <2 x double> 
%{{.*}}, metadata !"olt", metadata !"fpexcept.strict")
   // CHECK-NEXT:[[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
   // CHECK-NEXT:[[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
-  // CHECK-NEXT:ret <2 x double> [[BC]]
   return _mm_cmplt_pd(A, B);
 }
 
@@ -53,7 +49,6 @@ __m128d test_mm_cmpneq_pd(__m128d A, __m128d B) {
   // CHECK: [[CMP:%.*]] = call <2 x i1> 
@llvm.experimental.constrained.fcmp.v2f64(<2 x double> %{{.*}}, <2 x double> 
%{{.*}}, metadata !"une", metadata !"fpexcept.strict")
   // CHECK-NEXT:[[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
   // CHECK-NEXT:[[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
-  // CHECK-NEXT:ret <2 x double> [[BC]]
   return _mm_cmpneq_pd(A, B);
 }
 
@@ -62,7 +57,6 @@ __m128d test_mm_cmpnge_pd(__m128d A, __m128d B) {
   // CHECK: [[CMP:%.*]] = call <2 x i1> 
@llvm.experimental.constrained.fcmps.v2f64(<2 x double> %{{.*}}, <2 x double> 
%{{.*}}, metadata !"ugt", metadata !"fpexcept.strict")
   // CHECK-NEXT:[[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
   // CHECK-NEXT:[[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
-  // CHECK-NEXT:ret <2 x double> [[BC]]
   return _mm_cmpnge_pd(A, B);
 }
 
@@ -71,7 +65,6 @@ __m128d test_mm_cmpngt_pd(__m128d A, __m128d B) {
   // CHECK: [[CMP:%.*]] = call <2 x i1> 
@llvm.experimental.constrained.fcmps.v2f64(<2 x double> %{{.*}}, <2 x double> 
%{{.*}}, metadata !"uge", metadata !"fpexcept.strict")
   // CHECK-NEXT:[[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
   // CHECK-NEXT:[[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
-  /

[PATCH] D123610: [Testing] Drop clangTesting from clang's public library interface

2022-04-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/lib/Testing/CMakeLists.txt:6
+# Not add_clang_library: this is not part of clang's public library interface.
+# Unit tests should depend on this with target_link_libraries, not clang_TLL.
+add_llvm_library(clangTesting

hokein wrote:
> OOO, what is `clang_TLL`?
clang_target_link_libraries, spelled it out



Comment at: clang/lib/Testing/CMakeLists.txt:7
+# Unit tests should depend on this with target_link_libraries, not clang_TLL.
+add_llvm_library(clangTesting
   CommandLineArgs.cpp

hokein wrote:
> no related to this patch, I think `clangTestingSupport` is a better name 
> (also align with the LLVM one). 
The LLVM one is called that because it's in llvm/Testing/Support, because it's 
associated with llvm/Support (but not all the parts are!).
There's nothing else in llvm/Testing, I think it should probably be flattened 
out instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123610

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


[PATCH] D124067: [x86] Support 3 builtin functions for 32-bits targets

2022-04-20 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

OK - SSE2/SSE41 now have i386 coverage - please can you rebase and update the 
checks to use CHECK/X64/X86 ?


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

https://reviews.llvm.org/D124067

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


[PATCH] D124081: [clang] [draft] Reject non-declaration C++11 attributes on declarations.

2022-04-20 Thread Martin Bƶhme via Phabricator via cfe-commits
mboehme added a comment.

I'd like to mark this patch as a draft so that Herald doesn't keep adding 
reviewers -- but I'm not sure how?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124081

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


[PATCH] D123212: [clangd] Handle the new UsingTemplateName.

2022-04-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

(Would be great to land this in some form if you get a chance!)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123212

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


[PATCH] D123212: [clangd] Handle the new UsingTemplateName.

2022-04-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D123212#3461557 , @sammccall wrote:

> (Would be great to land this in some form if you get a chance!)

sure, I plan to land it today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123212

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


[clang] 1dfe027 - [OpenMP] Add explicit triple to linker wrapper test

2022-04-20 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-04-20T07:24:51-04:00
New Revision: 1dfe0273fda3972662bd979de3c216155b18f6ed

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

LOG: [OpenMP] Add explicit triple to linker wrapper test

Summary:
Some platforms like Mach-O require different handling of section names.
This is not supported on Mac-OS or Windows yet so we shouldn't be
testing the compilation there. Add an explicit triple to the tests.

Added: 


Modified: 
clang/test/Driver/linker-wrapper-image.c
clang/test/Driver/linker-wrapper.c

Removed: 




diff  --git a/clang/test/Driver/linker-wrapper-image.c 
b/clang/test/Driver/linker-wrapper-image.c
index 00d8e235255fa..3b1ece08950ed 100644
--- a/clang/test/Driver/linker-wrapper-image.c
+++ b/clang/test/Driver/linker-wrapper-image.c
@@ -2,7 +2,7 @@
 // REQUIRES: nvptx-registered-target
 // REQUIRES: amdgpu-registered-target
 
-// RUN: %clang -cc1 %s -emit-obj -o %t.o \
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
 // RUN:   
-fembed-offload-object=%S/Inputs/dummy-elf.o,openmp,nvptx64-nvida-cuda,sm_70
 // RUN: clang-linker-wrapper --print-wrapped-module --dry-run -linker-path 
/usr/bin/ld \
 // RUN:   -- %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=OPENMP

diff  --git a/clang/test/Driver/linker-wrapper.c 
b/clang/test/Driver/linker-wrapper.c
index a2c2777c3ce2d..bcec3e183fcaf 100644
--- a/clang/test/Driver/linker-wrapper.c
+++ b/clang/test/Driver/linker-wrapper.c
@@ -2,7 +2,7 @@
 // REQUIRES: nvptx-registered-target
 // REQUIRES: amdgpu-registered-target
 
-// RUN: %clang -cc1 %s -emit-obj -o %t.o \
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
 // RUN:   
-fembed-offload-object=%S/Inputs/dummy-elf.o,openmp,nvptx64-nvida-cuda,sm_70 \
 // RUN:   
-fembed-offload-object=%S/Inputs/dummy-elf.o,openmp,nvptx64-nvida-cuda,sm_70
 // RUN: clang-linker-wrapper --dry-run -linker-path /usr/bin/ld -- %t.o -o 
a.out \
@@ -10,7 +10,7 @@
 
 // NVPTX_LINK: nvlink{{.*}}-m64 -o {{.*}}.out -arch sm_70 {{.*}}.o {{.*}}.o
 
-// RUN: %clang -cc1 %s -emit-obj -o %t.o \
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
 // RUN:   
-fembed-offload-object=%S/Inputs/dummy-elf.o,openmp,amdgcn-amd-amdhsa,gfx908 \
 // RUN:   
-fembed-offload-object=%S/Inputs/dummy-elf.o,openmp,amdgcn-amd-amdhsa,gfx908
 // RUN: clang-linker-wrapper --dry-run -linker-path /usr/bin/ld -- %t.o -o 
a.out \
@@ -18,7 +18,7 @@
 
 // AMDGPU_LINK: lld{{.*}}-flavor gnu --no-undefined -shared -o {{.*}}.out 
{{.*}}.o {{.*}}.o
 
-// RUN: %clang -cc1 %s -emit-obj -o %t.o \
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
 // RUN:   
-fembed-offload-object=%S/Inputs/dummy-elf.o,openmp,x86_64-unknown-linux-gnu, \
 // RUN:   
-fembed-offload-object=%S/Inputs/dummy-elf.o,openmp,x86_64-unknown-linux-gnu,
 // RUN: clang-linker-wrapper --dry-run -linker-path /usr/bin/ld.lld -- %t.o -o 
a.out \
@@ -26,13 +26,13 @@
 
 // CPU_LINK: ld.lld{{.*}}-m elf_x86_64 -shared -Bsymbolic -o {{.*}}.out 
{{.*}}.o {{.*}}.o
 
-// RUN: %clang -cc1 %s -emit-obj -o %t.o
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o
 // RUN: clang-linker-wrapper --dry-run -linker-path /usr/bin/ld.lld -- -a -b 
-c %t.o -o a.out \
 // RUN:   2>&1 | FileCheck %s --check-prefix=HOST_LINK
 
 // HOST_LINK: ld.lld{{.*}}-a -b -c {{.*}}.o -o a.out
 
-// RUN: %clang -cc1 %s -emit-obj -o %t.o \
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
 // RUN:   
-fembed-offload-object=%S/Inputs/dummy-bc.bc,openmp,nvptx64-nvida-cuda,sm_70 \
 // RUN:   
-fembed-offload-object=%S/Inputs/dummy-bc.bc,openmp,nvptx64-nvida-cuda,sm_70
 // RUN: clang-linker-wrapper --dry-run -linker-path /usr/bin/ld -- %t.o -o 
a.out \



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


[PATCH] D124039: [OpenMP] Add better testing for the linker wrapper

2022-04-20 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D124039#3461482 , @thakis wrote:

> Looks like this breaks tests on Mac: http://45.33.8.238/macm1/33656/step_7.txt
>
> Please take a look and revert for now if it takes a while to fix. (Maybe just 
> needs an explicit triple?)

Yeah I probably just need to specify the triple, I forgot that Mach-O doesn't 
like these section names. I pushed rG1dfe0273fda3 
 to 
address this, let me know if it's still broken.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124039

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


[clang] 4cec789 - [Testing] Drop clangTesting from clang's public library interface

2022-04-20 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-04-20T13:28:44+02:00
New Revision: 4cec789c177d4d69d9e313db1369a0df097362c8

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

LOG: [Testing] Drop clangTesting from clang's public library interface

This was probably not particularly intended to be public, and disallows deps
on gtest which are useful in test helpers.

https://discourse.llvm.org/t/stop-exporting-clangtesting-library/61672

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

Added: 


Modified: 
clang/lib/CMakeLists.txt
clang/lib/Testing/CMakeLists.txt
clang/unittests/AST/CMakeLists.txt
clang/unittests/ASTMatchers/CMakeLists.txt
clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
clang/unittests/Analysis/CMakeLists.txt
clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
clang/unittests/Sema/CMakeLists.txt
clang/unittests/StaticAnalyzer/CMakeLists.txt
clang/unittests/Tooling/Syntax/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/CMakeLists.txt b/clang/lib/CMakeLists.txt
index cc98efcf433a3..50bd0cb55059e 100644
--- a/clang/lib/CMakeLists.txt
+++ b/clang/lib/CMakeLists.txt
@@ -25,5 +25,7 @@ add_subdirectory(Index)
 add_subdirectory(IndexSerialization)
 add_subdirectory(StaticAnalyzer)
 add_subdirectory(Format)
-add_subdirectory(Testing)
+if(CLANG_INCLUDE_TESTS)
+  add_subdirectory(Testing)
+endif()
 add_subdirectory(Interpreter)

diff  --git a/clang/lib/Testing/CMakeLists.txt 
b/clang/lib/Testing/CMakeLists.txt
index 4a8d436aab664..dbaba54bb8cab 100644
--- a/clang/lib/Testing/CMakeLists.txt
+++ b/clang/lib/Testing/CMakeLists.txt
@@ -2,6 +2,13 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
-add_clang_library(clangTesting
+# Not add_clang_library: this is not part of clang's public library interface.
+# Unit tests should depend on this with target_link_libraries(), rather
+# than with clang_target_link_libraries().
+add_llvm_library(clangTesting
   CommandLineArgs.cpp
+  BUILDTREE_ONLY
+
+  LINK_COMPONENTS
+  Support
   )

diff  --git a/clang/unittests/AST/CMakeLists.txt 
b/clang/unittests/AST/CMakeLists.txt
index 48a610c98138a..ef0207c382dfb 100644
--- a/clang/unittests/AST/CMakeLists.txt
+++ b/clang/unittests/AST/CMakeLists.txt
@@ -43,11 +43,11 @@ clang_target_link_libraries(ASTTests
   clangFrontend
   clangLex
   clangSerialization
-  clangTesting
   clangTooling
   )
 
 target_link_libraries(ASTTests
   PRIVATE
+  clangTesting
   LLVMTestingSupport
 )

diff  --git a/clang/unittests/ASTMatchers/CMakeLists.txt 
b/clang/unittests/ASTMatchers/CMakeLists.txt
index b40b3886dcd2b..38f7178954b41 100644
--- a/clang/unittests/ASTMatchers/CMakeLists.txt
+++ b/clang/unittests/ASTMatchers/CMakeLists.txt
@@ -18,12 +18,12 @@ clang_target_link_libraries(ASTMatchersTests
   clangBasic
   clangFrontend
   clangSerialization
-  clangTesting
   clangTooling
   )
 
 target_link_libraries(ASTMatchersTests
   PRIVATE
+  clangTesting
   LLVMTestingSupport
 )
 

diff  --git a/clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt 
b/clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
index 7a0ba01f838b7..6d0e12bcb0759 100644
--- a/clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
+++ b/clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
@@ -17,6 +17,10 @@ clang_target_link_libraries(DynamicASTMatchersTests
   clangDynamicASTMatchers
   clangFrontend
   clangSerialization
-  clangTesting
   clangTooling
   )
+
+target_link_libraries(DynamicASTMatchersTests
+  PRIVATE
+  clangTesting
+  )

diff  --git a/clang/unittests/Analysis/CMakeLists.txt 
b/clang/unittests/Analysis/CMakeLists.txt
index 7e2a00b96057a..619f2fc8b8581 100644
--- a/clang/unittests/Analysis/CMakeLists.txt
+++ b/clang/unittests/Analysis/CMakeLists.txt
@@ -20,12 +20,12 @@ clang_target_link_libraries(ClangAnalysisTests
   clangFrontend
   clangLex
   clangSerialization
-  clangTesting
   clangTooling
   )
 
 target_link_libraries(ClangAnalysisTests
   PRIVATE
+  clangTesting
   LLVMTestingSupport
   )
 

diff  --git a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt 
b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
index c299e039ff822..e908c7d2747c7 100644
--- a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
+++ b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
@@ -31,11 +31,11 @@ clang_target_link_libraries(ClangAnalysisFlowSensitiveTests
   clangFrontend
   clangLex
   clangSerialization
-  clangTesting
   clangTooling
   )
 
 target_link_libraries(ClangAnalysisFlowSensitiveTests
   PRIVATE
+  clangTesting
   LLVMTestingSupport
   )

diff  --git a/clang/unittests/Sema/CMakeLists.txt 
b/clang/unittests/Sema/CMakeLists.txt
index 455c321d541b2..0ba2e1c314551 100644
--- a/clang/unittests/Sema/CMakeLists.txt
+++ b/clang/unittests/Sema/CMakeLists.txt
@@ -19,11 +19,11 @@ clang_target_li

[PATCH] D123610: [Testing] Drop clangTesting from clang's public library interface

2022-04-20 Thread Sam McCall 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 rG4cec789c177d: [Testing] Drop clangTesting from clang's 
public library interface (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D123610?vs=46&id=423869#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123610

Files:
  clang/lib/CMakeLists.txt
  clang/lib/Testing/CMakeLists.txt
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/ASTMatchers/CMakeLists.txt
  clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
  clang/unittests/Analysis/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Sema/CMakeLists.txt
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/Tooling/Syntax/CMakeLists.txt

Index: clang/unittests/Tooling/Syntax/CMakeLists.txt
===
--- clang/unittests/Tooling/Syntax/CMakeLists.txt
+++ clang/unittests/Tooling/Syntax/CMakeLists.txt
@@ -18,7 +18,6 @@
   clangFrontend
   clangLex
   clangSerialization
-  clangTesting
   clangTooling
   clangToolingCore
   clangToolingSyntax
@@ -26,5 +25,6 @@
 
 target_link_libraries(SyntaxTests
   PRIVATE
+  clangTesting
   LLVMTestingSupport
 )
Index: clang/unittests/StaticAnalyzer/CMakeLists.txt
===
--- clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -31,6 +31,10 @@
   clangSerialization
   clangStaticAnalyzerCore
   clangStaticAnalyzerFrontend
-  clangTesting
   clangTooling
   )
+
+target_link_libraries(StaticAnalysisTests
+  PRIVATE
+  clangTesting
+  )
Index: clang/unittests/Sema/CMakeLists.txt
===
--- clang/unittests/Sema/CMakeLists.txt
+++ clang/unittests/Sema/CMakeLists.txt
@@ -19,11 +19,11 @@
   clangParse
   clangSema
   clangSerialization
-  clangTesting
   clangTooling
   )
 
 target_link_libraries(SemaTests
   PRIVATE
+  clangTesting
   LLVMTestingSupport
 )
Index: clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
===
--- clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
+++ clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
@@ -31,11 +31,11 @@
   clangFrontend
   clangLex
   clangSerialization
-  clangTesting
   clangTooling
   )
 
 target_link_libraries(ClangAnalysisFlowSensitiveTests
   PRIVATE
+  clangTesting
   LLVMTestingSupport
   )
Index: clang/unittests/Analysis/CMakeLists.txt
===
--- clang/unittests/Analysis/CMakeLists.txt
+++ clang/unittests/Analysis/CMakeLists.txt
@@ -20,12 +20,12 @@
   clangFrontend
   clangLex
   clangSerialization
-  clangTesting
   clangTooling
   )
 
 target_link_libraries(ClangAnalysisTests
   PRIVATE
+  clangTesting
   LLVMTestingSupport
   )
 
Index: clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
===
--- clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
+++ clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
@@ -17,6 +17,10 @@
   clangDynamicASTMatchers
   clangFrontend
   clangSerialization
-  clangTesting
   clangTooling
   )
+
+target_link_libraries(DynamicASTMatchersTests
+  PRIVATE
+  clangTesting
+  )
Index: clang/unittests/ASTMatchers/CMakeLists.txt
===
--- clang/unittests/ASTMatchers/CMakeLists.txt
+++ clang/unittests/ASTMatchers/CMakeLists.txt
@@ -18,12 +18,12 @@
   clangBasic
   clangFrontend
   clangSerialization
-  clangTesting
   clangTooling
   )
 
 target_link_libraries(ASTMatchersTests
   PRIVATE
+  clangTesting
   LLVMTestingSupport
 )
 
Index: clang/unittests/AST/CMakeLists.txt
===
--- clang/unittests/AST/CMakeLists.txt
+++ clang/unittests/AST/CMakeLists.txt
@@ -43,11 +43,11 @@
   clangFrontend
   clangLex
   clangSerialization
-  clangTesting
   clangTooling
   )
 
 target_link_libraries(ASTTests
   PRIVATE
+  clangTesting
   LLVMTestingSupport
 )
Index: clang/lib/Testing/CMakeLists.txt
===
--- clang/lib/Testing/CMakeLists.txt
+++ clang/lib/Testing/CMakeLists.txt
@@ -2,6 +2,13 @@
   Support
   )
 
-add_clang_library(clangTesting
+# Not add_clang_library: this is not part of clang's public library interface.
+# Unit tests should depend on this with target_link_libraries(), rather
+# than with clang_target_link_libraries().
+add_llvm_library(clangTesting
   CommandLineArgs.cpp
+  BUILDTREE_ONLY
+
+  LINK_COMPONENTS
+  Support
   )
Index: clang/lib/CMakeLists.txt
===
--- clang/lib/CMakeList

[PATCH] D111548: [Clang] Add the `annotate_type` attribute

2022-04-20 Thread Martin Bƶhme via Phabricator via cfe-commits
mboehme marked 5 inline comments as done.
mboehme added inline comments.



Comment at: clang/lib/AST/TypePrinter.cpp:1686
+  // would require retrieving the attribute arguments, which we don't have 
here.
+  if (T->getAttrKind() == attr::AnnotateType)
+return;

aaron.ballman wrote:
> mboehme wrote:
> > aaron.ballman wrote:
> > > mboehme wrote:
> > > > xazax.hun wrote:
> > > > > Would it make sense to print something without the arguments? I 
> > > > > wonder which behavior would be less confusing.
> > > > TBH I'm not sure. Is TypePrinter used only to produce debug output or 
> > > > is it required that the output of TypePrinter will parse again 
> > > > correctly?
> > > > 
> > > > The reason I'm asking is because `annotate_type` has a mandatory first 
> > > > argument; if we need the output to be parseable, we would have to print 
> > > > some dummy string, e.g. 
> > > > `[[clang::annotate_type("arguments_omitted")]]`. This seems a bit 
> > > > strange, but maybe it's still worth doing. OTOH, if the output is used 
> > > > only for debugging, I guess we could print something like 
> > > > `[[clang::annotate_type(...)]]`, which doesn't parse but by that very 
> > > > nature makes it clear that we don't have all the information here.
> > > > 
> > > > I guess both of these options could have limited use -- they would at 
> > > > least make it clear that there is an annotation on the type, though 
> > > > without the arguments, we can't know what the actual annotation is.
> > > > 
> > > > Would appreciate some more input on the wider context here.
> > > Yeah, the trouble is that you need a `TypeLoc` in order to get back to 
> > > the actual attribute information that stores the arguments. But the type 
> > > printer is printing types not specific instances of types at the location 
> > > they're used.
> > > 
> > > The goal with the pretty printers is to print something back that the 
> > > user actually wrote, but it's not always possible and so this is sort of 
> > > a best-effort.
> > So what's your position -- should I not print the attribute at all (which 
> > is what I'm doing right now) or should I print it as something like 
> > `[[clang::annotate_type(...)]]`?
> I think we need to print *something* here because the type printer is used by 
> `QualType::getAsStringInternal()` and `QualType::print()` which are used to 
> produce diagnostics when giving a `QualType` argument. So I would  print 
> `[[clang::annotate]]` as a stop-gap with a FIXME comment that it would be 
> nice to print the arguments here some day.
Makes sense -- done!



Comment at: clang/lib/Parse/ParseDecl.cpp:3184
+continue;
+  // We reject AT_LifetimeBound and AT_AnyX86NoCfCheck, even though 
they
+  // are type attributes, because we historically haven't allowed these

aaron.ballman wrote:
> I think this is a FIXME situation -- our policy is to diagnose attributes 
> that are being ignored, and it seems pretty important to (someday, not part 
> of this patch) diagnose these. Especially the lifetime bound attribute given 
> that it's intended to help harden code.
Maybe I should clarify what's happening here: We _do_ produce diagnostics 
(errors) for AT_LifetimeBound and AT_AnyX86NoCfCheck, both before and after 
this patch. (For these attributes, the code falls through to the 
`Diag(PA.getLoc(), diag::err_attribute_not_type_attr)` call below.)

Before this patch, we would reject (produce errors for) _all_ C++11 attributes 
here. Now, we only reject non-type attributes, and in addition, we also reject 
AT_LifetimeBound and AT_AnyX86NoCfCheck (even though they are type attributes) 
because we historically haven't allowed them to be used in this way. There are 
tests for this behavior, so it seemed important to preserve it.



Comment at: clang/lib/Sema/SemaAttr.cpp:396-408
+if (E->getType()->isArrayType())
+  E = ImpCastExprToType(E, Context.getPointerType(E->getType()),
+clang::CK_ArrayToPointerDecay)
+  .get();
+if (E->getType()->isFunctionType())
+  E = ImplicitCastExpr::Create(Context,
+   Context.getPointerType(E->getType()),

aaron.ballman wrote:
> mboehme wrote:
> > aaron.ballman wrote:
> > > This seems an awful lot like doing 
> > > `DefaultFunctionArrayLValueConversion()` here -- can you call that to do 
> > > the heavy lifting?
> > > 
> > > Oh, I see we're just shuffling code around. Feel free to ignore or make 
> > > as an NFC change if you'd prefer.
> > By "NFC change", you mean I could submit this separately as an NFC change?
> > 
> > Since this change is already part of this patch, I think I'd prefer to just 
> > keep it in here, if that's OK?
> > By "NFC change", you mean I could submit this separately as an NFC change?
> 
> Yup!
> 
> > Since this change is already part of this patch, I think I'd prefer to ju

[PATCH] D123668: [Testing] TestAST, a helper for writing straight-line AST tests

2022-04-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

ping :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123668

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


[PATCH] D123289: [clangd][SymbolCollector] Introduce a cache for SymbolID generation and some cleanups

2022-04-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

(This is ready to land, right?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123289

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


[PATCH] D115232: [clangd] Indexing of standard library

2022-04-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

This had a "LG" comment above... want to take another pass?
(Not urgent, just checking)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115232

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


[PATCH] D123289: [clangd][SymbolCollector] Introduce a cache for SymbolID generation and some cleanups

2022-04-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet closed this revision.
kadircet added a comment.

Landed in 001e88ac83b5c3a4d4f4e61480953ebcabc82b88 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123289

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


[PATCH] D123668: [Testing] TestAST, a helper for writing straight-line AST tests

2022-04-20 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev accepted this revision.
kbobyrev added a comment.
This revision is now accepted and ready to land.

Thanks, this looks good; just few nits regarding the comments.




Comment at: clang/include/clang/Testing/TestAST.h:9
+//
+// In normal operation of clang, the FrontendAction's lifecycle both creates
+// and destroys the AST, and code should operate on it during callbacks in

nit: capitalization



Comment at: clang/include/clang/Testing/TestAST.h:33
+
+/// TestInputs specifies a virtual source file to be parsed as part of a test.
+struct TestInputs {

nit: omit `TestInputs` since it's the document for that.



Comment at: clang/include/clang/Testing/TestAST.h:54
+
+/// TestAST is the result of parsing a file, as specified by TestInputs.
+///





Comment at: clang/include/clang/Testing/TestAST.h:70
+
+  /// Provides access to the AST context and other parts of clang.
+





Comment at: clang/lib/Testing/TestAST.cpp:1
+//===--- TestAST.cpp
+//===//

nit: comment seems broken


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123668

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


[PATCH] D124038: [clang] Prevent folding of non-const compound expr

2022-04-20 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

Alternatively, the following also works, but it splits the logic into 
anotherplace, while current patch is at least consistent with existing state

  diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
  index 498f0d4..233307f 100644
  --- a/clang/lib/AST/ExprConstant.cpp
  +++ b/clang/lib/AST/ExprConstant.cpp
  @@ -3352,6 +3352,17 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const 
Expr *E,
   NoteLValueLocation(Info, Base);
 }
   
  +  // In the particular case of CompoundLiteralExpr initialization, check 
that it is itself
  +  // constant.
  +  if (Info.InConstantContext)
  +if (const CompoundLiteralExpr *CLE = 
dyn_cast_or_null(
  +VD->getAnyInitializer()->IgnoreCasts())) {
  +  QualType CLET = CLE->getType().getCanonicalType();
  +  if (!CLET.isConstant(Info.Ctx)) {
  +Info.FFDiag(E);
  +  }
  +}
  +


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124038

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


[clang] ee74aba - [OpenMP] Add triple to the linker wrapper job

2022-04-20 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-04-20T08:23:43-04:00
New Revision: ee74abaad71e80628540ca7e8abc42ba0cde2101

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

LOG: [OpenMP] Add triple to the linker wrapper job

Summary:
I forgot to add the triple to the linker wrapper job, so we were still
generating code for the unintended platforms.

Added: 


Modified: 
clang/test/Driver/linker-wrapper-image.c
clang/test/Driver/linker-wrapper.c

Removed: 




diff  --git a/clang/test/Driver/linker-wrapper-image.c 
b/clang/test/Driver/linker-wrapper-image.c
index 3b1ece08950ed..c10b4c5a45e03 100644
--- a/clang/test/Driver/linker-wrapper-image.c
+++ b/clang/test/Driver/linker-wrapper-image.c
@@ -4,8 +4,8 @@
 
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
 // RUN:   
-fembed-offload-object=%S/Inputs/dummy-elf.o,openmp,nvptx64-nvida-cuda,sm_70
-// RUN: clang-linker-wrapper --print-wrapped-module --dry-run -linker-path 
/usr/bin/ld \
-// RUN:   -- %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=OPENMP
+// RUN: clang-linker-wrapper --print-wrapped-module --dry-run --host-triple 
x86_64-unknown-linux-gnu \
+// RUN:   -linker-path /usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=OPENMP
 
 // OPENMP: @__start_omp_offloading_entries = external hidden constant 
%__tgt_offload_entry
 // OPENMP-NEXT: @__stop_omp_offloading_entries = external hidden constant 
%__tgt_offload_entry

diff  --git a/clang/test/Driver/linker-wrapper.c 
b/clang/test/Driver/linker-wrapper.c
index bcec3e183fcaf..5ec99f5fe5b03 100644
--- a/clang/test/Driver/linker-wrapper.c
+++ b/clang/test/Driver/linker-wrapper.c
@@ -5,38 +5,38 @@
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
 // RUN:   
-fembed-offload-object=%S/Inputs/dummy-elf.o,openmp,nvptx64-nvida-cuda,sm_70 \
 // RUN:   
-fembed-offload-object=%S/Inputs/dummy-elf.o,openmp,nvptx64-nvida-cuda,sm_70
-// RUN: clang-linker-wrapper --dry-run -linker-path /usr/bin/ld -- %t.o -o 
a.out \
-// RUN:   2>&1 | FileCheck %s --check-prefix=NVPTX_LINK
+// RUN: clang-linker-wrapper --host-triple x86_64-unknown-linux-gnu --dry-run 
-linker-path \
+// RUN:   /usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=NVPTX_LINK
 
 // NVPTX_LINK: nvlink{{.*}}-m64 -o {{.*}}.out -arch sm_70 {{.*}}.o {{.*}}.o
 
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
 // RUN:   
-fembed-offload-object=%S/Inputs/dummy-elf.o,openmp,amdgcn-amd-amdhsa,gfx908 \
 // RUN:   
-fembed-offload-object=%S/Inputs/dummy-elf.o,openmp,amdgcn-amd-amdhsa,gfx908
-// RUN: clang-linker-wrapper --dry-run -linker-path /usr/bin/ld -- %t.o -o 
a.out \
-// RUN:   2>&1 | FileCheck %s --check-prefix=AMDGPU_LINK
+// RUN: clang-linker-wrapper --host-triple x86_64-unknown-linux-gnu --dry-run 
-linker-path \
+// RUN:   /usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=AMDGPU_LINK
 
 // AMDGPU_LINK: lld{{.*}}-flavor gnu --no-undefined -shared -o {{.*}}.out 
{{.*}}.o {{.*}}.o
 
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
 // RUN:   
-fembed-offload-object=%S/Inputs/dummy-elf.o,openmp,x86_64-unknown-linux-gnu, \
 // RUN:   
-fembed-offload-object=%S/Inputs/dummy-elf.o,openmp,x86_64-unknown-linux-gnu,
-// RUN: clang-linker-wrapper --dry-run -linker-path /usr/bin/ld.lld -- %t.o -o 
a.out \
-// RUN:   2>&1 | FileCheck %s --check-prefix=CPU_LINK
+// RUN: clang-linker-wrapper --host-triple x86_64-unknown-linux-gnu --dry-run 
-linker-path \
+// RUN:   /usr/bin/ld.lld -- %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=CPU_LINK
 
 // CPU_LINK: ld.lld{{.*}}-m elf_x86_64 -shared -Bsymbolic -o {{.*}}.out 
{{.*}}.o {{.*}}.o
 
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o
-// RUN: clang-linker-wrapper --dry-run -linker-path /usr/bin/ld.lld -- -a -b 
-c %t.o -o a.out \
-// RUN:   2>&1 | FileCheck %s --check-prefix=HOST_LINK
+// RUN: clang-linker-wrapper --dry-run --host-triple x86_64-unknown-linux-gnu 
-linker-path \
+// RUN:  /usr/bin/ld.lld -- -a -b -c %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=HOST_LINK
 
 // HOST_LINK: ld.lld{{.*}}-a -b -c {{.*}}.o -o a.out
 
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
 // RUN:   
-fembed-offload-object=%S/Inputs/dummy-bc.bc,openmp,nvptx64-nvida-cuda,sm_70 \
 // RUN:   
-fembed-offload-object=%S/Inputs/dummy-bc.bc,openmp,nvptx64-nvida-cuda,sm_70
-// RUN: clang-linker-wrapper --dry-run -linker-path /usr/bin/ld -- %t.o -o 
a.out \
-// RUN:   2>&1 | FileCheck %s --check-prefix=LTO
+// RUN: clang-linker-wrapper --host-triple x86_64-unknown-linux-gnu --dry-run 
-linker-path \
+// RUN:   /usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=LTO
 
 // LTO: ptxas{{.*}}-m64 -o {{.*}}.c

[PATCH] D121868: [cc1as] Add support for emitting the build version load command for -darwin-target-variant

2022-04-20 Thread Byoungchan Lee via Phabricator via cfe-commits
bc-lee updated this revision to Diff 423878.
bc-lee added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121868

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/test/Misc/cc1as-darwin-target-variant-triple.s
  clang/tools/driver/cc1as_main.cpp

Index: clang/tools/driver/cc1as_main.cpp
===
--- clang/tools/driver/cc1as_main.cpp
+++ clang/tools/driver/cc1as_main.cpp
@@ -144,6 +144,9 @@
   /// otherwise.
   std::string TargetABI;
 
+  /// Darwin target variant triple, the variant of the deployment target
+  /// for which the code is being compiled.
+  llvm::Optional DarwinTargetVariantTriple;
   /// @}
 
 public:
@@ -209,6 +212,9 @@
 
   // Target Options
   Opts.Triple = llvm::Triple::normalize(Args.getLastArgValue(OPT_triple));
+  if (Arg *A = Args.getLastArg(options::OPT_darwin_target_variant_triple))
+Opts.DarwinTargetVariantTriple = llvm::Triple(A->getValue());
+
   Opts.CPU = std::string(Args.getLastArgValue(OPT_target_cpu));
   Opts.Features = Args.getAllArgValues(OPT_target_feature);
 
@@ -407,6 +413,8 @@
   // MCObjectFileInfo needs a MCContext reference in order to initialize itself.
   std::unique_ptr MOFI(
   TheTarget->createMCObjectFileInfo(Ctx, PIC));
+  if (Opts.DarwinTargetVariantTriple)
+MOFI->setDarwinTargetVariantTriple(*Opts.DarwinTargetVariantTriple);
   Ctx.setObjectFileInfo(MOFI.get());
 
   if (Opts.SaveTemporaryLabels)
Index: clang/test/Misc/cc1as-darwin-target-variant-triple.s
===
--- /dev/null
+++ clang/test/Misc/cc1as-darwin-target-variant-triple.s
@@ -0,0 +1,33 @@
+// Run cc1as using darwin-target-variant-triple
+// RUN: %clang -cc1as -triple x86_64-apple-macos10.9 -darwin-target-variant-triple x86_64-apple-ios13.1-macabi -filetype obj %s -o - \
+// RUN: | llvm-readobj --file-headers --macho-version-min - \
+// RUN: | FileCheck --check-prefix=CHECK %s
+
+// CHECK: File: 
+// CHECK-NEXT: Format: Mach-O 64-bit x86-64
+// CHECK-NEXT: Arch: x86_64
+// CHECK-NEXT: AddressSize: 64bit
+// CHECK-NEXT: MachHeader {
+// CHECK-NEXT:   Magic: Magic64 (0xFEEDFACF)
+// CHECK-NEXT:   CpuType: X86-64 (0x107)
+// CHECK-NEXT:   CpuSubType: CPU_SUBTYPE_X86_64_ALL (0x3)
+// CHECK-NEXT:   FileType: Relocatable (0x1)
+// CHECK-NEXT:   NumOfLoadCommands: 3
+// CHECK-NEXT:   SizeOfLoadCommands: 192
+// CHECK-NEXT:   Flags [ (0x0)
+// CHECK-NEXT:   ]
+// CHECK-NEXT:   Reserved: 0x0
+// CHECK-NEXT: }
+// CHECK-NEXT: MinVersion {
+// CHECK-NEXT:   Cmd: LC_VERSION_MIN_MACOSX
+// CHECK-NEXT:   Size: 16
+// CHECK-NEXT:   Version: 10.9
+// CHECK-NEXT:   SDK: n/a
+// CHECK-NEXT: }
+// CHECK-NEXT: MinVersion {
+// CHECK-NEXT:   Cmd: LC_BUILD_VERSION
+// CHECK-NEXT:   Size: 24
+// CHECK-NEXT:   Platform: macCatalyst
+// CHECK-NEXT:   Version: 13.1
+// CHECK-NEXT:   SDK: n/a
+// CHECK-NEXT: }
Index: clang/lib/Driver/ToolChains/Darwin.h
===
--- clang/lib/Driver/ToolChains/Darwin.h
+++ clang/lib/Driver/ToolChains/Darwin.h
@@ -489,6 +489,12 @@
 : TargetVersion) < VersionTuple(V0, V1, V2);
   }
 
+  /// Returns the darwin target variant triple, the variant of the deployment
+  /// target for which the code is being compiled.
+  Optional getTargetVariantTriple() const override {
+return TargetVariantTriple;
+  }
+
 protected:
   /// Return true if c++17 aligned allocation/deallocation functions are not
   /// implemented in the c++ standard library of the deployment target we are
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7719,6 +7719,8 @@
 
   const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
   const std::string &TripleStr = Triple.getTriple();
+  const Optional TargetVariantTriple =
+  getToolChain().getTargetVariantTriple();
   const auto &D = getToolChain().getDriver();
 
   // Don't warn about "clang -w -c foo.s"
@@ -7736,6 +7738,10 @@
   // Add the "effective" target triple.
   CmdArgs.push_back("-triple");
   CmdArgs.push_back(Args.MakeArgString(TripleStr));
+  if (TargetVariantTriple) {
+CmdArgs.push_back("-darwin-target-variant-triple");
+CmdArgs.push_back(Args.MakeArgString(TargetVariantTriple->getTriple()));
+  }
 
   // Set the output mode, we currently only expect to be used as a real
   // assembler.
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -717,6 +717,10 @@
 return llvm::DenormalMode::getIE

[PATCH] D121868: [cc1as] Add support for emitting the build version load command for -darwin-target-variant

2022-04-20 Thread Byoungchan Lee via Phabricator via cfe-commits
bc-lee marked 3 inline comments as done.
bc-lee added inline comments.



Comment at: clang/test/Misc/cc1as-darwin-target-variant-triple.s:2
+// Run cc1as using darwin-target-variant-triple
+// RUN: %clang -cc1as -triple x86_64-apple-macos10.9 
-darwin-target-variant-triple x86_64-apple-ios13.1-macabi -filetype obj %s -o - 
\
+// RUN: | llvm-readobj --file-headers --macho-version-min - \

MaskRay wrote:
> `-filetype obj` on the `%clang -cc1as` line seems weird.
Without this, I cannot create object file and validate it using `llvm-readobj`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121868

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


[PATCH] D122663: Mark identifier prefixes as substitutable

2022-04-20 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk updated this revision to Diff 423879.
hvdijk added a comment.

Fixed release notes to use correct RST syntax.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122663

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/LangOptions.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/clang-abi-compat.cpp
  clang/test/CodeGenCXX/mangle.cpp

Index: clang/test/CodeGenCXX/mangle.cpp
===
--- clang/test/CodeGenCXX/mangle.cpp
+++ clang/test/CodeGenCXX/mangle.cpp
@@ -1155,3 +1155,15 @@
   // CHECK-LABEL: @_ZN6test601fIiEEvDTplL_ZNS_1aEEcvT__EE
   template void f(int);
 }
+
+namespace test61 {
+  struct X {
+struct Y {
+  using a = int;
+  using b = int;
+};
+  };
+  template  void f(typename T::Y::a, typename T::Y::b) {}
+  // CHECK-LABEL: @_ZN6test611fINS_1XEEEvNT_1Y1aENS3_1bE
+  template void f(int, int);
+}
Index: clang/test/CodeGenCXX/clang-abi-compat.cpp
===
--- clang/test/CodeGenCXX/clang-abi-compat.cpp
+++ clang/test/CodeGenCXX/clang-abi-compat.cpp
@@ -1,25 +1,27 @@
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++98 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=3.0 %s -emit-llvm -o - -Wno-c++11-extensions \
-// RUN: | FileCheck --check-prefixes=CHECK,PRE39,PRE5,PRE12 %s
+// RUN: | FileCheck --check-prefixes=CHECK,PRE39,PRE5,PRE12,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=3.0 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,PRE39,PRE5,PRE12 %s
+// RUN: | FileCheck --check-prefixes=CHECK,PRE39,PRE5,PRE12,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=3.8 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,PRE39,PRE5,PRE12 %s
+// RUN: | FileCheck --check-prefixes=CHECK,PRE39,PRE5,PRE12,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=3.9 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,PRE5,PRE12 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,PRE5,PRE12,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=4.0 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,PRE5,PRE12 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,PRE5,PRE12,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=5 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=11 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=11 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17,PRE12-CXX20,PRE13-CXX20 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17,PRE12-CXX20,PRE13-CXX20,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=12 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,PRE13-CXX20 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,PRE13-CXX20,PRE15 %s
+// RUN: %clang_cc1 -no-opaque-pointers -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=14 %s -emit-llvm -o - \
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,V13-CXX20,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++98 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=latest %s -emit-llvm -o - -Wno-c++11-extensions \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=latest %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,V13-CXX20 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,V13-CXX20,V15 %s
 
 typedef __attribute__((vector_size(8))) long long v1xi64;
 void clang39(v1xi64) {}
@@ -147,3 +149,14 @@
 inline auto inline_var_lambda = observe_lambdas([]{}, []{}, (int*)0, (int*)0);
 int use_inline_var_lambd

[PATCH] D124039: [OpenMP] Add better testing for the linker wrapper

2022-04-20 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Thanks, that did the trick :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124039

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


[PATCH] D123958: [randstruct] Randomize all elements of a record

2022-04-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D123958#3461020 , @void wrote:

> In D123958#3459205 , @aaron.ballman 
> wrote:
>
>> I think you'll need a more targeted approach than assuming the only kinds of 
>> declarations in a struct are field-like in C.
>>
>> It seems that the issue you've got is with anonymous objects in a structure 
>> where the inner fields are available for lookup in the outer structure. One 
>> question I have is: what's the expectation for the user? There's two ways to 
>> look at this. 1) The anonymous object is a single field; that its members 
>> can be found in the outer object is not relevant. 2) The fields of the 
>> anonymous object should also be randomized. The same is true for any inner 
>> structure, not just anonymous ones.
>>
>> I had assumed that any structure not marked for randomization would not be 
>> randomized. Based on that, I don't think inner structure objects (anonymous 
>> or otherwise) should automatically randomize their fields. WDYT?
>
> We don't randomize inner structures unless they have the `randomize_layout` 
> flag. That's always been the case, and this patch doesn't change that.

That's good, I misunderstood originally, so thanks!

> The issue is that we were dropping the inner structures/unions because they 
> aren't `FieldDecl`s, but `RecordDecl`s, with an `IndirectFieldDecl` if the 
> inner structure is anonymous. The `IndirectFieldDecl` bits appear after the 
> `RecordDecl` they're attached to, but doesn't seem like the ordering is 
> important. The `IndirectFieldDecl` thing is there so that the anonymous 
> fields are available in the outer structure.

Agreed that we need to fix that behavior, but I think it's pretty fragile to 
assume every declaration in a struct can be reordered. I mentioned static 
assert decls above as one obvious example, but also consider things like:

  struct S {
enum E {
  One,
};
  
enum E whatever;
  } __attribute__((randomize_layout));

We currently drop the enumeration declaration entirely (oops), but if we 
rearrange all declaration orders, then the declaration of `whatever` may 
suddenly look to come BEFORE we know what the type of `enum E` will be.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123958

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


[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Hi, this patch seems to break the following code which was previously compiled:

  #include 
  #include 
  #include 
  
  template 
  auto MapJoin(It first, It last, MapFn map_fn) {
return std::accumulate(
first, last, map_fn(*first),
[=](typename std::result_of::type result) {  
}); // a new diagnostic: error: captured variable 'first' cannot appear here
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

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


[PATCH] D123783: [clang] Eliminate TypeProcessingState::trivial.

2022-04-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:170
 /// Whether we saved the attributes in the decl spec.
 bool hasSavedAttrs;
 

mboehme wrote:
> aaron.ballman wrote:
> > mboehme wrote:
> > > aaron.ballman wrote:
> > > > Isn't the same true for this variable? It seems like:
> > > > 
> > > > `trivial` == `savedAttrs.empty()`
> > > > `hasSavedAttrs` == `!savedAttrs.empty()`
> > > That's what I also thought at first -- but the situation for 
> > > `hasSavedAttrs` is a bit more complicated. It gets set whenever 
> > > `saveDeclAttrs()` is called, even if it doesn't actually end up saving 
> > > any attributes (i.e. if `spec.getAttributes()` is empty).
> > > 
> > > `hasSavedAttrs` is then used to prevent any further calls to 
> > > `saveDeclSpecAttrs()` from doing anything:
> > > 
> > > ```
> > > // Don't try to save them multiple times.
> > > if (hasSavedAttrs) return;
> > > ```
> > > 
> > > Conceivably, `spec` _might_ have had attributes added to it in the 
> > > meantime -- not sure? It might be OK to just replace this logic with `if 
> > > (!savedAttrs.empty()) return;` -- but I'm not familiar enough with how 
> > > this code gets used and therefore decided it would be better not to 
> > > change it. Can you give additional input on this?
> > I have the impression that is an oversight in the code rather than an 
> > intentional behavior. I think it may be okay to replace the logic with 
> > `!savedAttrs.empty()` as well; if you do that, do you get any test 
> > failures? (If you do, then that's a sign something else might be going on.)
> I just tried:
> 
> ```
> // Don't try to save them multiple times.
> if (!savedAttrs.empty()) return;
> ```
> 
>  I didn't get any test failures.
> 
> Of course, this isn't proof that this is _really_ OK, but it's an indication.
> 
> You know this code better than I do, so I would defer to you: How do you 
> think I should proceed? Should I eliminate `hasSavedAttrs` too?
I think you should eliminate it -- I don't think the behavior here was 
intentional (based on what I can tell from the code).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123783

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


[PATCH] D124081: [clang] [draft] Reject non-declaration C++11 attributes on declarations.

2022-04-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D124081#3461556 , @mboehme wrote:

> I'd like to mark this patch as a draft so that Herald doesn't keep adding 
> reviewers -- but I'm not sure how?

In that case, I usually set the permissions on the review explicitly so that 
I'm the only one who can view the draft (but this means precommit CI won't run 
on it). Most often folks just add [WIP] to the title and reviewers know to 
ignore the review until the [WIP] is removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124081

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


[PATCH] D124081: [clang] [draft] Reject non-declaration C++11 attributes on declarations.

2022-04-20 Thread Martin Bƶhme via Phabricator via cfe-commits
mboehme added a comment.

In D124081#3461731 , @aaron.ballman 
wrote:

> In D124081#3461556 , @mboehme wrote:
>
>> I'd like to mark this patch as a draft so that Herald doesn't keep adding 
>> reviewers -- but I'm not sure how?
>
> In that case, I usually set the permissions on the review explicitly so that 
> I'm the only one who can view the draft (but this means precommit CI won't 
> run on it).

In this case, though, I want to be able to show the draft to others and discuss 
it with them. I guess this technique doesn't work for that?

> Most often folks just add [WIP] to the title and reviewers know to ignore the 
> review until the [WIP] is removed.

Ah -- thanks. I'll add [WIP[ then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124081

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


[PATCH] D124081: [clang] [WIP] Reject non-declaration C++11 attributes on declarations.

2022-04-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D124081#3461742 , @mboehme wrote:

> In D124081#3461731 , @aaron.ballman 
> wrote:
>
>> In D124081#3461556 , @mboehme 
>> wrote:
>>
>>> I'd like to mark this patch as a draft so that Herald doesn't keep adding 
>>> reviewers -- but I'm not sure how?
>>
>> In that case, I usually set the permissions on the review explicitly so that 
>> I'm the only one who can view the draft (but this means precommit CI won't 
>> run on it).
>
> In this case, though, I want to be able to show the draft to others and 
> discuss it with them. I guess this technique doesn't work for that?

FWIW, you can pick the specific list of folks you want to give permissions to 
if you know it's a limited group. (I've done this with Erich from time to time 
when I want a second set of eyes on an NFC change but don't want to bother the 
mailing lists with it.) However, it sounds to me like you want anyone to be 
able to come by and comment if they'd like while you're prepping the patch, so 
I'd stick with the [WIP] in the title like you've got.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124081

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


[clang] f26c41e - [RISCV] Moving RVV intrinsic type related util to clang/Support

2022-04-20 Thread Kito Cheng via cfe-commits

Author: Kito Cheng
Date: 2022-04-20T21:13:13+08:00
New Revision: f26c41e8dd28d86030cd0f5a6e9c11036acea5d2

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

LOG: [RISCV] Moving RVV intrinsic type related util to clang/Support

We add a new clang library called `clangSupport` for putting those utils which 
can be used in clang table-gen and other clang component.

We tried to put that into `llvm/Support`, but actually those stuffs only used 
in clang* and clang-tblgen, so I think that might be better to create 
`clang/Support`

* clang will used that in https://reviews.llvm.org/D111617.

Reviewed By: khchen, MaskRay, aaron.ballman

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

Added: 
clang/include/clang/Support/RISCVVIntrinsicUtils.h
clang/lib/Support/CMakeLists.txt
clang/lib/Support/RISCVVIntrinsicUtils.cpp

Modified: 
clang/lib/CMakeLists.txt
clang/utils/TableGen/CMakeLists.txt
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Support/RISCVVIntrinsicUtils.h 
b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
new file mode 100644
index 0..1a4947d0c3df3
--- /dev/null
+++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -0,0 +1,215 @@
+//===--- RISCVVIntrinsicUtils.h - RISC-V Vector Intrinsic Utils -*- C++ 
-*-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef CLANG_SUPPORT_RISCVVINTRINSICUTILS_H
+#define CLANG_SUPPORT_RISCVVINTRINSICUTILS_H
+
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace RISCV {
+
+using BasicType = char;
+using VScaleVal = llvm::Optional;
+
+// Exponential LMUL
+struct LMULType {
+  int Log2LMUL;
+  LMULType(int Log2LMUL);
+  // Return the C/C++ string representation of LMUL
+  std::string str() const;
+  llvm::Optional getScale(unsigned ElementBitwidth) const;
+  void MulLog2LMUL(int Log2LMUL);
+  LMULType &operator*=(uint32_t RHS);
+};
+
+// This class is compact representation of a valid and invalid RVVType.
+class RVVType {
+  enum ScalarTypeKind : uint32_t {
+Void,
+Size_t,
+Ptr
diff _t,
+UnsignedLong,
+SignedLong,
+Boolean,
+SignedInteger,
+UnsignedInteger,
+Float,
+Invalid,
+  };
+  BasicType BT;
+  ScalarTypeKind ScalarType = Invalid;
+  LMULType LMUL;
+  bool IsPointer = false;
+  // IsConstant indices are "int", but have the constant expression.
+  bool IsImmediate = false;
+  // Const qualifier for pointer to const object or object of const type.
+  bool IsConstant = false;
+  unsigned ElementBitwidth = 0;
+  VScaleVal Scale = 0;
+  bool Valid;
+
+  std::string BuiltinStr;
+  std::string ClangBuiltinStr;
+  std::string Str;
+  std::string ShortStr;
+
+public:
+  RVVType() : RVVType(BasicType(), 0, llvm::StringRef()) {}
+  RVVType(BasicType BT, int Log2LMUL, llvm::StringRef prototype);
+
+  // Return the string representation of a type, which is an encoded string for
+  // passing to the BUILTIN() macro in Builtins.def.
+  const std::string &getBuiltinStr() const { return BuiltinStr; }
+
+  // Return the clang builtin type for RVV vector type which are used in the
+  // riscv_vector.h header file.
+  const std::string &getClangBuiltinStr() const { return ClangBuiltinStr; }
+
+  // Return the C/C++ string representation of a type for use in the
+  // riscv_vector.h header file.
+  const std::string &getTypeStr() const { return Str; }
+
+  // Return the short name of a type for C/C++ name suffix.
+  const std::string &getShortStr() {
+// Not all types are used in short name, so compute the short name by
+// demanded.
+if (ShortStr.empty())
+  initShortStr();
+return ShortStr;
+  }
+
+  bool isValid() const { return Valid; }
+  bool isScalar() const { return Scale.hasValue() && Scale.getValue() == 0; }
+  bool isVector() const { return Scale.hasValue() && Scale.getValue() != 0; }
+  bool isVector(unsigned Width) const {
+return isVector() && ElementBitwidth == Width;
+  }
+  bool isFloat() const { return ScalarType == ScalarTypeKind::Float; }
+  bool isSignedInteger() const {
+return ScalarType == ScalarTypeKind::SignedInteger;
+  }
+  bool isFloatVector(unsigned Width) const {
+return isVector() && isFloat() && ElementBitwidth == Width;
+  }
+  bool isFloat(unsigned Width) const {
+return isFloat() && ElementBitwidth == Width;
+  }
+
+private:
+  // Verify RVV vector type and set Valid.
+  bool verifyType() const;
+
+  // Creates a type based on basic type

[PATCH] D121984: [RISCV] Moving RVV intrinsic type related util to clang/Support

2022-04-20 Thread Kito Cheng 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 rGf26c41e8dd28: [RISCV] Moving RVV intrinsic type related util 
to clang/Support (authored by kito-cheng).

Changed prior to commit:
  https://reviews.llvm.org/D121984?vs=422786&id=423887#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121984

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/CMakeLists.txt
  clang/lib/Support/CMakeLists.txt
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/utils/TableGen/CMakeLists.txt
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -14,6 +14,7 @@
 //
 //===--===//
 
+#include "clang/Support/RISCVVIntrinsicUtils.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringExtras.h"
@@ -25,206 +26,9 @@
 #include 
 
 using namespace llvm;
-using BasicType = char;
-using VScaleVal = Optional;
+using namespace clang::RISCV;
 
 namespace {
-
-// Exponential LMUL
-struct LMULType {
-  int Log2LMUL;
-  LMULType(int Log2LMUL);
-  // Return the C/C++ string representation of LMUL
-  std::string str() const;
-  Optional getScale(unsigned ElementBitwidth) const;
-  void MulLog2LMUL(int Log2LMUL);
-  LMULType &operator*=(uint32_t RHS);
-};
-
-// This class is compact representation of a valid and invalid RVVType.
-class RVVType {
-  enum ScalarTypeKind : uint32_t {
-Void,
-Size_t,
-Ptrdiff_t,
-UnsignedLong,
-SignedLong,
-Boolean,
-SignedInteger,
-UnsignedInteger,
-Float,
-Invalid,
-  };
-  BasicType BT;
-  ScalarTypeKind ScalarType = Invalid;
-  LMULType LMUL;
-  bool IsPointer = false;
-  // IsConstant indices are "int", but have the constant expression.
-  bool IsImmediate = false;
-  // Const qualifier for pointer to const object or object of const type.
-  bool IsConstant = false;
-  unsigned ElementBitwidth = 0;
-  VScaleVal Scale = 0;
-  bool Valid;
-
-  std::string BuiltinStr;
-  std::string ClangBuiltinStr;
-  std::string Str;
-  std::string ShortStr;
-
-public:
-  RVVType() : RVVType(BasicType(), 0, StringRef()) {}
-  RVVType(BasicType BT, int Log2LMUL, StringRef prototype);
-
-  // Return the string representation of a type, which is an encoded string for
-  // passing to the BUILTIN() macro in Builtins.def.
-  const std::string &getBuiltinStr() const { return BuiltinStr; }
-
-  // Return the clang builtin type for RVV vector type which are used in the
-  // riscv_vector.h header file.
-  const std::string &getClangBuiltinStr() const { return ClangBuiltinStr; }
-
-  // Return the C/C++ string representation of a type for use in the
-  // riscv_vector.h header file.
-  const std::string &getTypeStr() const { return Str; }
-
-  // Return the short name of a type for C/C++ name suffix.
-  const std::string &getShortStr() {
-// Not all types are used in short name, so compute the short name by
-// demanded.
-if (ShortStr.empty())
-  initShortStr();
-return ShortStr;
-  }
-
-  bool isValid() const { return Valid; }
-  bool isScalar() const { return Scale.hasValue() && Scale.getValue() == 0; }
-  bool isVector() const { return Scale.hasValue() && Scale.getValue() != 0; }
-  bool isVector(unsigned Width) const {
-return isVector() && ElementBitwidth == Width;
-  }
-  bool isFloat() const { return ScalarType == ScalarTypeKind::Float; }
-  bool isSignedInteger() const {
-return ScalarType == ScalarTypeKind::SignedInteger;
-  }
-  bool isFloatVector(unsigned Width) const {
-return isVector() && isFloat() && ElementBitwidth == Width;
-  }
-  bool isFloat(unsigned Width) const {
-return isFloat() && ElementBitwidth == Width;
-  }
-
-private:
-  // Verify RVV vector type and set Valid.
-  bool verifyType() const;
-
-  // Creates a type based on basic types of TypeRange
-  void applyBasicType();
-
-  // Applies a prototype modifier to the current type. The result maybe an
-  // invalid type.
-  void applyModifier(StringRef prototype);
-
-  // Compute and record a string for legal type.
-  void initBuiltinStr();
-  // Compute and record a builtin RVV vector type string.
-  void initClangBuiltinStr();
-  // Compute and record a type string for used in the header.
-  void initTypeStr();
-  // Compute and record a short name of a type for C/C++ name suffix.
-  void initShortStr();
-};
-
-using RVVTypePtr = RVVType *;
-using RVVTypes = std::vector;
-using RISCVPredefinedMacroT = uint8_t;
-
-enum RISCVPredefinedMacro : RISCVPredefinedMacroT {
-  Basic = 0,
-  V = 1 << 1,
-  Zvfh = 1 << 2,
-  RV64 = 1 << 3,
-  VectorMaxELen64 = 1 << 4,
-  VectorMaxELenFp32 = 1 << 5,
-  Vec

[PATCH] D124081: [clang] [WIP] Reject non-declaration C++11 attributes on declarations.

2022-04-20 Thread Martin Bƶhme via Phabricator via cfe-commits
mboehme added a comment.

In D124081#3461761 , @aaron.ballman 
wrote:

> 

[snip]

> However, it sounds to me like you want anyone to be able to come by and 
> comment if they'd like while you're prepping the patch, so I'd stick with the 
> [WIP] in the title like you've got.

Exactly. Thanks for the explanations!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124081

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


[PATCH] D124012: [Clang] Fix references to captured variables in dependant context.

2022-04-20 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

@erichkeane I will land that later today to unstuck people relying on main, let 
me know if you still want to have a look


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124012

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


[PATCH] D124012: [Clang] Fix references to captured variables in dependant context.

2022-04-20 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D124012#3461781 , @cor3ntin wrote:

> @erichkeane I will land that later today to unstuck people relying on main, 
> let me know if you still want to have a look

I didn't see anything on a quick pass, so LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124012

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


[PATCH] D121984: [RISCV] Moving RVV intrinsic type related util to clang/Support

2022-04-20 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Please add a clear comment to the new library's CMakeLists.txt file that 
explains when to put code there and when in clang/lib/Basic. (The patch 
description does say it, but the patch description is harder to find than a 
comment in the cmake file.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121984

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


[PATCH] D123682: [clang-tblgen] Automatically document options values

2022-04-20 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 423890.
serge-sans-paille marked an inline comment as done.
serge-sans-paille added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Adopt a better wording.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123682

Files:
  clang/utils/TableGen/ClangOptionDocEmitter.cpp
  llvm/utils/TableGen/OptRSTEmitter.cpp


Index: llvm/utils/TableGen/OptRSTEmitter.cpp
===
--- llvm/utils/TableGen/OptRSTEmitter.cpp
+++ llvm/utils/TableGen/OptRSTEmitter.cpp
@@ -85,15 +85,13 @@
   if (!isa(R->getValueInit("Values"))) {
 SmallVector Values;
 SplitString(R->getValueAsString("Values"), Values, ",");
-HelpText += (" " + MetaVarName + " can be ").str();
+HelpText += (" " + MetaVarName + " must be '").str();
 
-if (Values.size() == 1) {
-  HelpText += ("'" + Values.front() + "'.").str();
-} else {
-  HelpText += "one of '";
+if (Values.size() > 1) {
   HelpText += join(Values.begin(), Values.end() - 1, "', '");
-  HelpText += ("' or '" + Values.back() + "'.").str();
+  HelpText += "' or '";
 }
+HelpText += (Values.front() + "'.").str();
   }
 
   if (!HelpText.empty()) {
Index: clang/utils/TableGen/ClangOptionDocEmitter.cpp
===
--- clang/utils/TableGen/ClangOptionDocEmitter.cpp
+++ clang/utils/TableGen/ClangOptionDocEmitter.cpp
@@ -238,6 +238,8 @@
   }
 }
 
+constexpr StringLiteral DefaultMetaVarName = "";
+
 void emitOptionName(StringRef Prefix, const Record *Option, raw_ostream &OS) {
   // Find the arguments to list after the option.
   unsigned NumArgs = getNumArgsForKind(Option->getValueAsDef("Kind"), Option);
@@ -247,7 +249,7 @@
   if (HasMetaVarName)
 Args.push_back(std::string(Option->getValueAsString("MetaVarName")));
   else if (NumArgs == 1)
-Args.push_back("");
+Args.push_back(DefaultMetaVarName.str());
 
   // Fill up arguments if this option didn't provide a meta var name or it
   // supports an unlimited number of arguments. We can't see how many arguments
@@ -341,8 +343,30 @@
   OS << "\n\n";
 
   // Emit the description, if we have one.
+  const Record *R = Option.Option;
   std::string Description =
-  getRSTStringWithTextFallback(Option.Option, "DocBrief", "HelpText");
+  getRSTStringWithTextFallback(R, "DocBrief", "HelpText");
+
+  if (!isa(R->getValueInit("Values"))) {
+if (!Description.empty() && Description.back() != '.')
+  Description.push_back('.');
+
+StringRef MetaVarName;
+if (!isa(R->getValueInit("MetaVarName")))
+  MetaVarName = R->getValueAsString("MetaVarName");
+else
+  MetaVarName = DefaultMetaVarName;
+
+SmallVector Values;
+SplitString(R->getValueAsString("Values"), Values, ",");
+Description += (" " + MetaVarName + " must be '").str();
+if (Values.size() > 1) {
+  Description += join(Values.begin(), Values.end() - 1, "', '");
+  Description += "' or '";
+}
+Description += (Values.back() + "'.").str();
+  }
+
   if (!Description.empty())
 OS << Description << "\n\n";
 }


Index: llvm/utils/TableGen/OptRSTEmitter.cpp
===
--- llvm/utils/TableGen/OptRSTEmitter.cpp
+++ llvm/utils/TableGen/OptRSTEmitter.cpp
@@ -85,15 +85,13 @@
   if (!isa(R->getValueInit("Values"))) {
 SmallVector Values;
 SplitString(R->getValueAsString("Values"), Values, ",");
-HelpText += (" " + MetaVarName + " can be ").str();
+HelpText += (" " + MetaVarName + " must be '").str();
 
-if (Values.size() == 1) {
-  HelpText += ("'" + Values.front() + "'.").str();
-} else {
-  HelpText += "one of '";
+if (Values.size() > 1) {
   HelpText += join(Values.begin(), Values.end() - 1, "', '");
-  HelpText += ("' or '" + Values.back() + "'.").str();
+  HelpText += "' or '";
 }
+HelpText += (Values.front() + "'.").str();
   }
 
   if (!HelpText.empty()) {
Index: clang/utils/TableGen/ClangOptionDocEmitter.cpp
===
--- clang/utils/TableGen/ClangOptionDocEmitter.cpp
+++ clang/utils/TableGen/ClangOptionDocEmitter.cpp
@@ -238,6 +238,8 @@
   }
 }
 
+constexpr StringLiteral DefaultMetaVarName = "";
+
 void emitOptionName(StringRef Prefix, const Record *Option, raw_ostream &OS) {
   // Find the arguments to list after the option.
   unsigned NumArgs = getNumArgsForKind(Option->getValueAsDef("Kind"), Option);
@@ -247,7 +249,7 @@
   if (HasMetaVarName)
 Args.push_back(std::string(Option->getValueAsString("MetaVarName")));
   else if (NumArgs == 1)
-Args.push_back("");
+Args.push_back(DefaultMetaVar

[clang] 69dd89f - [Clang] Fix references to captured variables in dependant context.

2022-04-20 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2022-04-20T15:35:20+02:00
New Revision: 69dd89fdcbd846375a45e2fe3a88710887236d7a

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

LOG: [Clang] Fix references to captured variables in dependant context.

D119136 changed how captures are handled in a lambda call operator
declaration, but did not properly handled dependant context,
which led to crash when refering to init-captures in
a trailing return type.

We fix that bug by making transformations more symetric with parsing,
ie. we first create the call operator, then transform the capture,
then compute the type of the lambda call operaror.

This ensures captures exist and have the right type when
we parse a trailing requires-clause / return type.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/TreeTransform.h
clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
clang/test/SemaCXX/lambda-capture-type-deduction.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index d5b73686e84a7..6298838d60855 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -6828,15 +6828,6 @@ class Sema final {
  unsigned LambdaDependencyKind,
  LambdaCaptureDefault CaptureDefault);
 
-  /// Start the definition of a lambda expression.
-  CXXMethodDecl *startLambdaDefinition(CXXRecordDecl *Class,
-   SourceRange IntroducerRange,
-   TypeSourceInfo *MethodType,
-   SourceLocation EndLoc,
-   ArrayRef Params,
-   ConstexprSpecKind ConstexprKind,
-   Expr *TrailingRequiresClause);
-
   /// Number lambda for linkage purposes if necessary.
   void handleLambdaNumbering(
   CXXRecordDecl *Class, CXXMethodDecl *Method,
@@ -6849,9 +6840,16 @@ class Sema final {
 LambdaCaptureDefault CaptureDefault,
 SourceLocation CaptureDefaultLoc,
 bool ExplicitParams,
-bool ExplicitResultType,
 bool Mutable);
 
+  CXXMethodDecl *CreateLambdaCallOperator(SourceRange IntroducerRange,
+  CXXRecordDecl *Class);
+  void CompleteLambdaCallOperator(
+  CXXMethodDecl *Method, SourceLocation LambdaLoc,
+  SourceLocation CallOperatorLoc, Expr *TrailingRequiresClause,
+  TypeSourceInfo *MethodTyInfo, ConstexprSpecKind ConstexprKind,
+  ArrayRef Params, bool HasExplicitResultType);
+
   /// Perform initialization analysis of the init-capture and perform
   /// any implicit conversions such as an lvalue-to-rvalue conversion if
   /// not being used to initialize a reference.

diff  --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index d5918a28d9f06..e1086adcdb73b 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -377,76 +377,6 @@ buildTypeForLambdaCallOperator(Sema &S, 
clang::CXXRecordDecl *Class,
   return MethodType;
 }
 
-/// Start the definition of a lambda expression.
-/// In this overload, we do not know the type yet
-CXXMethodDecl *Sema::startLambdaDefinition(CXXRecordDecl *Class,
-   SourceRange IntroducerRange,
-   TypeSourceInfo *MethodTypeInfo,
-   SourceLocation EndLoc,
-   ArrayRef Params,
-   ConstexprSpecKind ConstexprKind,
-   Expr *TrailingRequiresClause) {
-
-  LambdaScopeInfo *LSI = getCurLambda();
-
-  TemplateParameterList *TemplateParams =
-  getGenericLambdaTemplateParameterList(LSI, *this);
-
-  // At this point, we may not know the type of the lambda, if we have not
-  // parsed a trailing return type yet
-  QualType MethodType = MethodTypeInfo
-? buildTypeForLambdaCallOperator(
-  *this, Class, TemplateParams, MethodTypeInfo)
-: QualType();
-
-  // C++11 [expr.prim.lambda]p5:
-  //   The closure type for a lambda-expression has a public inline function
-  //   call operator (13.5.4) whose parameters and return type are described
-  //   by the lambda-expression's parameter-declaration-clause and
-  //   trailing-return-type respectively.
-  DeclarationName Me

[PATCH] D124012: [Clang] Fix references to captured variables in dependant context.

2022-04-20 Thread Corentin Jabot 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 rG69dd89fdcbd8: [Clang] Fix references to captured variables 
in dependant context. (authored by cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124012

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp

Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- clang/test/SemaCXX/lambda-capture-type-deduction.cpp
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -163,6 +163,35 @@
   [&]() requires is_same {}();
 }
 
+template 
+void dependent_init_capture(T x = 0) {
+  [ y = x + 1, x ]() mutable -> decltype(y + x) requires(is_same && is_same) {
+return y;
+  }
+  ();
+  [ y = x + 1, x ]() -> decltype(y + x) requires(is_same && is_same) {
+return y;
+  }
+  ();
+}
+
+template 
+struct extract_type {
+  using type = T;
+};
+
+template 
+void dependent_variadic_capture(T... x) {
+  [... y = x, x... ](auto...) mutable -> typename extract_type::type requires((is_same && ...) && (is_same && ...)) {
+return 0;
+  }
+  (x...);
+  [... y = x, x... ](auto...) -> typename extract_type::type requires((is_same && ...) && (is_same && ...)) {
+return 0;
+  }
+  (x...);
+}
+
 void test_dependent() {
   int v   = 0;
   int & r = v;
@@ -170,6 +199,8 @@
   dependent(v);
   dependent(r);
   dependent(cr);
+  dependent_init_capture(0);
+  dependent_variadic_capture(1, 2, 3, 4);
 }
 
 void test_CWG2569_tpl(auto a) {
Index: clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
===
--- clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
+++ clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
@@ -43,10 +43,21 @@
   }(5);
 }
 
-struct Incomplete; // expected-note{{forward declaration of 'Incomplete'}}
+struct Incomplete; // expected-note 2{{forward declaration of 'Incomplete'}}
 void test_result_type(int N) {
   auto l1 = [] () -> Incomplete { }; // expected-error{{incomplete result type 'Incomplete' in lambda expression}}
 
   typedef int vla[N];
   auto l2 = [] () -> vla { }; // expected-error{{function cannot return array type 'vla' (aka 'int[N]')}}
 }
+
+template 
+void test_result_type_tpl(int N) {
+  auto l1 = []() -> T {}; // expected-error{{incomplete result type 'Incomplete' in lambda expression}}
+  typedef int vla[N];
+  auto l2 = []() -> vla {}; // expected-error{{function cannot return array type 'vla' (aka 'int[N]')}}
+}
+
+void test_result_type_call() {
+  test_result_type_tpl(10); // expected-note {{requested here}}
+}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -12966,44 +12966,6 @@
   LambdaScopeInfo *LSI = getSema().PushLambdaScope();
   Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
 
-  // Transform the template parameters, and add them to the current
-  // instantiation scope. The null case is handled correctly.
-  auto TPL = getDerived().TransformTemplateParameterList(
-  E->getTemplateParameterList());
-  LSI->GLTemplateParameterList = TPL;
-
-  // Transform the type of the original lambda's call operator.
-  // The transformation MUST be done in the CurrentInstantiationScope since
-  // it introduces a mapping of the original to the newly created
-  // transformed parameters.
-  TypeSourceInfo *NewCallOpTSI = nullptr;
-  {
-TypeSourceInfo *OldCallOpTSI = E->getCallOperator()->getTypeSourceInfo();
-FunctionProtoTypeLoc OldCallOpFPTL =
-OldCallOpTSI->getTypeLoc().getAs();
-
-TypeLocBuilder NewCallOpTLBuilder;
-SmallVector ExceptionStorage;
-TreeTransform *This = this; // Work around gcc.gnu.org/PR56135.
-QualType NewCallOpType = TransformFunctionProtoType(
-NewCallOpTLBuilder, OldCallOpFPTL, nullptr, Qualifiers(),
-[&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
-  return This->TransformExceptionSpec(OldCallOpFPTL.getBeginLoc(), ESI,
-  ExceptionStorage, Changed);
-});
-if (NewCallOpType.isNull())
-  return ExprError();
-NewCallOpTSI = NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context,
-NewCallOpType);
-  }
-
-  // Transform the trailing requires clause
-  ExprResult NewTrailingRequiresClause;
-  if (Expr *TRC = E->getCallOperator()->getTrailingRequiresClause())
-// FIXME: Concepts: Substitution into requires clause should only happen
-//  when checking satisfaction.
-NewTrailing

[PATCH] D123212: [clangd] Handle the new UsingTemplateName.

2022-04-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 423892.
hokein added a comment.

implement a pseudo-VisitTemplateName locally.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123212

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp

Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -79,9 +79,22 @@
   "using namespace ns;",
   },
   {
+  // Refs from UsingTypeLoc and implicit constructor!
   "struct ^A {}; using B = A; using ^C = B;",
   "C a;",
   },
+  {"namespace ns { template class A {}; } using ns::^A;",
+   "A* a;"},
+  {"namespace ns { template class A {}; } using ns::^A;",
+   R"cpp(
+  template  class T> class X {};
+  X x;
+)cpp"},
+  {R"cpp(
+  namespace ns { template struct ^A { ^A(T); }; }
+  using ns::^A;
+   )cpp",
+   "A CATD(123);"},
   {
   "typedef bool ^Y; template  struct ^X {};",
   "X x;",
@@ -227,6 +240,7 @@
 TU.Code = T.MainCode;
 Annotations Header(T.HeaderCode);
 TU.HeaderCode = Header.code().str();
+TU.ExtraArgs.push_back("-std=c++17");
 auto AST = TU.build();
 
 std::vector Points;
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -229,6 +229,45 @@
 )cpp";
   EXPECT_DECLS("UnresolvedUsingValueDecl", {"using Base::waldo", Rel::Alias},
{"void waldo()"});
+
+  Code = R"cpp(
+namespace ns {
+template class S {};
+}
+
+using ns::S;
+
+template
+using A = [[S]];
+  )cpp";
+  EXPECT_DECLS("TemplateSpecializationTypeLoc", {"using ns::S", Rel::Alias},
+   {"template  class S"},
+   {"class S", Rel::TemplatePattern});
+
+  Code = R"cpp(
+namespace ns {
+template class S {};
+}
+
+using ns::S;
+template  class T> class X {};
+using B = X<[[S]]>;
+  )cpp";
+  EXPECT_DECLS("TemplateArgumentLoc", {"using ns::S", Rel::Alias},
+   {"template  class S"});
+
+  Code = R"cpp(
+namespace ns {
+template class S { public: S(T); };
+}
+
+using ns::S;
+[[S]] s(123);
+  )cpp";
+  Flags.push_back("-std=c++17"); // For CTAD feature.
+  EXPECT_DECLS("DeducedTemplateSpecializationTypeLoc",
+   {"using ns::S", Rel::Alias}, {"template  class S"},
+   {"class S", Rel::TemplatePattern});
 }
 
 TEST_F(TargetDeclTest, BaseSpecifier) {
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -79,11 +79,29 @@
   }
 
   bool VisitTemplateSpecializationType(TemplateSpecializationType *TST) {
-add(TST->getTemplateName().getAsTemplateDecl()); // Primary template.
+// Using templateName case is handled by the override TraverseTemplateName.
+if (TST->getTemplateName().getKind() == TemplateName::UsingTemplate)
+  return true;
 add(TST->getAsCXXRecordDecl());  // Specialization
 return true;
   }
 
+  // There is no VisitTemplateName in RAV, thus we override the Traverse version
+  // to handle the Using TemplateName case.
+  bool TraverseTemplateName(TemplateName TN) {
+VisitTemplateName(TN);
+return Base::TraverseTemplateName(TN);
+  }
+  // A pseudo VisitTemplateName, dispatched by the above TraverseTemplateName!
+  bool VisitTemplateName(TemplateName TN) {
+if (const auto *USD = TN.getAsUsingShadowDecl()) {
+  add(USD);
+  return true;
+}
+add(TN.getAsTemplateDecl()); // Primary template.
+return true;
+  }
+
   bool VisitUsingType(UsingType *UT) {
 add(UT->getFoundDecl());
 return true;
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -384,11 +384,14 @@
   }
   void VisitDeducedTemplateSpecializationType(
   const DeducedTemplateSpecializationType *DTST) {
+if (const auto *USD = DTST->getTemplateName().getAsUsingShadowDecl())
+  Outer.add(USD, Flags);
+
 // FIXME: This is a workaround for https://llvm.org/PR42914,
 // which is causing DTST->getDeducedType() to be empty. We
 // fall back to the template pattern and miss the instantiati

[PATCH] D123212: [clangd] Handle the new UsingTemplateName.

2022-04-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:82
   bool VisitTemplateSpecializationType(TemplateSpecializationType *TST) {
-add(TST->getTemplateName().getAsTemplateDecl()); // Primary template.
+// Using templateName case is handled by the override TraverseTemplateName.
+if (TST->getTemplateName().getKind() == TemplateName::UsingTemplate)

maybe instead:
"Use of a template through an alias only uses the alias (see 
VisitTemplateName), not the underlying template"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123212

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


[clang-tools-extra] 95f0f69 - [clangd] Handle the new Using TemplateName.

2022-04-20 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-04-20T15:42:24+02:00
New Revision: 95f0f69441fb8b33528d25ba2b40e3fa703c6ea5

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

LOG: [clangd] Handle the new Using TemplateName.

Add supports in FindTarget and IncludeCleaner. This would
improve AST-based features on a tempalte which is found via a using
declaration. For example, go-to-def on `vect^or v;` gives us the
location of `using std::vector`, which was not previously.

Base on https://reviews.llvm.org/D123127

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 404e852e179ca..dcdac55c26b70 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -384,11 +384,14 @@ struct TargetFinder {
   }
   void VisitDeducedTemplateSpecializationType(
   const DeducedTemplateSpecializationType *DTST) {
+if (const auto *USD = DTST->getTemplateName().getAsUsingShadowDecl())
+  Outer.add(USD, Flags);
+
 // FIXME: This is a workaround for https://llvm.org/PR42914,
 // which is causing DTST->getDeducedType() to be empty. We
 // fall back to the template pattern and miss the instantiation
 // even when it's known in principle. Once that bug is fixed,
-// this method can be removed (the existing handling in
+// the following code can be removed (the existing handling in
 // VisitDeducedType() is sufficient).
 if (auto *TD = DTST->getTemplateName().getAsTemplateDecl())
   Outer.add(TD->getTemplatedDecl(), Flags | Rel::TemplatePattern);
@@ -419,6 +422,9 @@ struct TargetFinder {
   VisitTemplateSpecializationType(const TemplateSpecializationType *TST) {
 // Have to handle these case-by-case.
 
+if (const auto *UTN = TST->getTemplateName().getAsUsingShadowDecl())
+  Outer.add(UTN, Flags);
+
 // templated type aliases: there's no specialized/instantiated using
 // decl to point to. So try to find a decl for the underlying type
 // (after substitution), and failing that point to the (templated) 
using
@@ -508,6 +514,9 @@ struct TargetFinder {
   Arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl()) {
 report(TD, Flags);
   }
+  if (const auto *USD =
+  Arg.getAsTemplateOrTemplatePattern().getAsUsingShadowDecl())
+add(USD, Flags);
 }
   }
 };

diff  --git a/clang-tools-extra/clangd/IncludeCleaner.cpp 
b/clang-tools-extra/clangd/IncludeCleaner.cpp
index e6c8d9e76ed67..5b7f01d82fbac 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -79,11 +79,29 @@ class ReferencedLocationCrawler
   }
 
   bool VisitTemplateSpecializationType(TemplateSpecializationType *TST) {
-add(TST->getTemplateName().getAsTemplateDecl()); // Primary template.
+// Using templateName case is handled by the override TraverseTemplateName.
+if (TST->getTemplateName().getKind() == TemplateName::UsingTemplate)
+  return true;
 add(TST->getAsCXXRecordDecl());  // Specialization
 return true;
   }
 
+  // There is no VisitTemplateName in RAV, thus we override the Traverse 
version
+  // to handle the Using TemplateName case.
+  bool TraverseTemplateName(TemplateName TN) {
+VisitTemplateName(TN);
+return Base::TraverseTemplateName(TN);
+  }
+  // A pseudo VisitTemplateName, dispatched by the above TraverseTemplateName!
+  bool VisitTemplateName(TemplateName TN) {
+if (const auto *USD = TN.getAsUsingShadowDecl()) {
+  add(USD);
+  return true;
+}
+add(TN.getAsTemplateDecl()); // Primary template.
+return true;
+  }
+
   bool VisitUsingType(UsingType *UT) {
 add(UT->getFoundDecl());
 return true;

diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 7026f7fced3c9..c21114fa45b07 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -229,6 +229,45 @@ TEST_F(TargetDeclTest, UsingDecl) {
 )cpp";
   EXPECT_DECLS("UnresolvedUsingValueDecl", {"using Base::waldo", 
Rel::Alias},
{"void waldo()"});
+
+  Code = R"cpp(
+namespace ns {
+template class S {};
+}
+
+using ns::S;
+
+template
+using A = [[S]];
+  )cpp";
+  EXPECT_DECLS("TemplateSpe

[PATCH] D123212: [clangd] Handle the new UsingTemplateName.

2022-04-20 Thread Haojian Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rG95f0f69441fb: [clangd] Handle the new Using TemplateName. 
(authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123212

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp

Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -79,9 +79,22 @@
   "using namespace ns;",
   },
   {
+  // Refs from UsingTypeLoc and implicit constructor!
   "struct ^A {}; using B = A; using ^C = B;",
   "C a;",
   },
+  {"namespace ns { template class A {}; } using ns::^A;",
+   "A* a;"},
+  {"namespace ns { template class A {}; } using ns::^A;",
+   R"cpp(
+  template  class T> class X {};
+  X x;
+)cpp"},
+  {R"cpp(
+  namespace ns { template struct ^A { ^A(T); }; }
+  using ns::^A;
+   )cpp",
+   "A CATD(123);"},
   {
   "typedef bool ^Y; template  struct ^X {};",
   "X x;",
@@ -227,6 +240,7 @@
 TU.Code = T.MainCode;
 Annotations Header(T.HeaderCode);
 TU.HeaderCode = Header.code().str();
+TU.ExtraArgs.push_back("-std=c++17");
 auto AST = TU.build();
 
 std::vector Points;
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -229,6 +229,45 @@
 )cpp";
   EXPECT_DECLS("UnresolvedUsingValueDecl", {"using Base::waldo", Rel::Alias},
{"void waldo()"});
+
+  Code = R"cpp(
+namespace ns {
+template class S {};
+}
+
+using ns::S;
+
+template
+using A = [[S]];
+  )cpp";
+  EXPECT_DECLS("TemplateSpecializationTypeLoc", {"using ns::S", Rel::Alias},
+   {"template  class S"},
+   {"class S", Rel::TemplatePattern});
+
+  Code = R"cpp(
+namespace ns {
+template class S {};
+}
+
+using ns::S;
+template  class T> class X {};
+using B = X<[[S]]>;
+  )cpp";
+  EXPECT_DECLS("TemplateArgumentLoc", {"using ns::S", Rel::Alias},
+   {"template  class S"});
+
+  Code = R"cpp(
+namespace ns {
+template class S { public: S(T); };
+}
+
+using ns::S;
+[[S]] s(123);
+  )cpp";
+  Flags.push_back("-std=c++17"); // For CTAD feature.
+  EXPECT_DECLS("DeducedTemplateSpecializationTypeLoc",
+   {"using ns::S", Rel::Alias}, {"template  class S"},
+   {"class S", Rel::TemplatePattern});
 }
 
 TEST_F(TargetDeclTest, BaseSpecifier) {
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -79,11 +79,29 @@
   }
 
   bool VisitTemplateSpecializationType(TemplateSpecializationType *TST) {
-add(TST->getTemplateName().getAsTemplateDecl()); // Primary template.
+// Using templateName case is handled by the override TraverseTemplateName.
+if (TST->getTemplateName().getKind() == TemplateName::UsingTemplate)
+  return true;
 add(TST->getAsCXXRecordDecl());  // Specialization
 return true;
   }
 
+  // There is no VisitTemplateName in RAV, thus we override the Traverse version
+  // to handle the Using TemplateName case.
+  bool TraverseTemplateName(TemplateName TN) {
+VisitTemplateName(TN);
+return Base::TraverseTemplateName(TN);
+  }
+  // A pseudo VisitTemplateName, dispatched by the above TraverseTemplateName!
+  bool VisitTemplateName(TemplateName TN) {
+if (const auto *USD = TN.getAsUsingShadowDecl()) {
+  add(USD);
+  return true;
+}
+add(TN.getAsTemplateDecl()); // Primary template.
+return true;
+  }
+
   bool VisitUsingType(UsingType *UT) {
 add(UT->getFoundDecl());
 return true;
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -384,11 +384,14 @@
   }
   void VisitDeducedTemplateSpecializationType(
   const DeducedTemplateSpecializationType *DTST) {
+if (const auto *USD = DTST->getTemplateName().getAsUsingShadowDecl())
+  Outer.add(USD, Flags);
+
 // FIXME: This is a workaround for https://ll

[clang] bea5e88 - [clang][Sema] Fix typo in checkBuiltinArgument helper

2022-04-20 Thread Alex Bradbury via cfe-commits

Author: Alex Bradbury
Date: 2022-04-20T14:42:41+01:00
New Revision: bea5e88bcf5908b676da35fb8c64f9f8449ba73b

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

LOG: [clang][Sema] Fix typo in checkBuiltinArgument helper

The checkBuiltinArgument helper takes an integer ArgIndex and is
documented as performing normal type-checking on that argument. However,
it mistakenly hardcodes the argument index to zero when retrieving the
argument from the call expression.

This hadn't been noticed previously as all in-tree uses typecheck the
0th argument anyway.

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index cd069d5664571..f575c0775e7f9 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -6222,7 +6222,7 @@ static bool checkBuiltinArgument(Sema &S, CallExpr *E, 
unsigned ArgIndex) {
   InitializedEntity Entity =
 InitializedEntity::InitializeParameter(S.Context, Param);
 
-  ExprResult Arg = E->getArg(0);
+  ExprResult Arg = E->getArg(ArgIndex);
   Arg = S.PerformCopyInitialization(Entity, SourceLocation(), Arg);
   if (Arg.isInvalid())
 return true;



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


[PATCH] D122983: [C11/C2x] Change the behavior of the implicit function declaration warning

2022-04-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 423895.
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

Updated the diagnostic wording, putting it through precommit CI again to see if 
I missed any tests.


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

https://reviews.llvm.org/D122983

Files:
  clang-tools-extra/clangd/IncludeFixer.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/ARCMT/objcmt-arc-cf-annotations.m
  clang/test/ARCMT/objcmt-arc-cf-annotations.m.result
  clang/test/Analysis/OSAtomic_mac.c
  clang/test/Analysis/ObjCProperties.m
  clang/test/Analysis/PR49642.c
  clang/test/Analysis/dead-stores.c
  clang/test/Analysis/diagnostics/no-store-func-path-notes.c
  clang/test/Analysis/exercise-ps.c
  clang/test/Analysis/malloc-three-arg.c
  clang/test/Analysis/misc-ps-region-store.m
  clang/test/Analysis/novoidtypecrash.c
  clang/test/Analysis/plist-macros-with-expansion.c
  clang/test/CodeGen/2002-07-14-MiscTests3.c
  clang/test/CodeGen/2002-07-31-SubregFailure.c
  clang/test/CodeGen/2003-08-18-SigSetJmp.c
  clang/test/CodeGen/2004-11-27-StaticFunctionRedeclare.c
  clang/test/CodeGen/2005-01-02-ConstantInits.c
  clang/test/CodeGen/2005-01-02-VAArgError-ICE.c
  clang/test/CodeGen/2005-02-20-AggregateSAVEEXPR.c
  clang/test/CodeGen/2006-01-13-StackSave.c
  clang/test/CodeGen/2006-03-03-MissingInitializer.c
  clang/test/CodeGen/2007-09-27-ComplexIntCompare.c
  clang/test/CodeGen/2008-05-12-TempUsedBeforeDef.c
  clang/test/CodeGen/2008-07-30-redef-of-bitcasted-decl.c
  clang/test/CodeGen/2008-08-19-cast-of-typedef.c
  clang/test/CodeGen/2008-10-13-FrontendCrash.c
  clang/test/CodeGen/2009-01-05-BlockInlining.c
  clang/test/CodeGen/PowerPC/builtins-ppc-p8vector.c
  clang/test/CodeGen/X86/bmi2-builtins.c
  clang/test/CodeGen/aarch64-mops.c
  clang/test/CodeGen/aarch64-neon-sm4-sm3.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create3-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create4-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_get2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_get3-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_get4-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1rq-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnt1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_rev-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_set2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_set3-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_set4-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_stnt1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef3-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef4-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_aba.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_abalb.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_abalt.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_abdlb.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_abdlt.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_adalp.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_adclb.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_adclt.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_addhnb.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_addhnt.c
  clang/

[PATCH] D124012: [Clang] Fix references to captured variables in dependant context.

2022-04-20 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

@erichkeane @aaron.ballman Thanks! I'll keep an eye out for further issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124012

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


[PATCH] D123858: [clang][dataflow] Ensure well-formed flow conditions.

2022-04-20 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev accepted this revision.
sgatev added inline comments.



Comment at: 
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp:884
+//
+// Note: currently, abstract function calls are uninterpreted, so the test
+// exercises this case. If and when we change that, this test will not add to

What does "abstract" mean here? Perhaps "arbitrary"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123858

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


[PATCH] D123682: [clang-tblgen] Automatically document options values

2022-04-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123682

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


[PATCH] D124091: [clang][AArch64][SVE] Implement conditional operator for SVE vectors

2022-04-20 Thread David Truby via Phabricator via cfe-commits
DavidTruby created this revision.
Herald added subscribers: ctetreau, psnobl, kristof.beyls, tschuett.
Herald added a reviewer: efriedma.
Herald added a project: All.
DavidTruby requested review of this revision.
Herald added subscribers: cfe-commits, alextsao1999.
Herald added a project: clang.

This patch adds support for the conditional (ternary) operator on SVE
scalable vector types in C++, matching the behaviour for NEON vector
types. Like the conditional operator for NEON types, this is disabled in
C mode.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124091

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CodeGenCXX/aarch64-sve-vector-conditional-op.cpp
  clang/test/SemaCXX/aarch64-sve-vector-conditional-op.cpp

Index: clang/test/SemaCXX/aarch64-sve-vector-conditional-op.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/aarch64-sve-vector-conditional-op.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -verify -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only %s
+
+// REQUIRES: aarch64-registered-target
+
+#include 
+
+void cond(svint8_t i8, svint16_t i16, svint32_t i32, svint64_t i64,
+  svuint8_t u8, svuint16_t u16, svuint32_t u32, svuint64_t u64,
+  svfloat16_t f16, svfloat32_t f32, svfloat64_t f64,
+  svbool_t b) {
+  (void) i8 < i8 ? i16 : i16; // expected-error{{invalid operands to binary expression}}
+  (void) i8 < i8 ? i32 : i32; // expected-error{{invalid operands to binary expression}}
+  (void) i8 < i8 ? i64 : i64; // expected-error{{invalid operands to binary expression}}
+
+  (void) i16 < i16 ? i16 : i8; // expected-error{{invalid operands to binary expression}}
+  (void) i16 < i16 ? i16 : i32; // expected-error{{invalid operands to binary expression}}
+  (void) i16 < i16 ? i16 : i64; // expected-error{{invalid operands to binary expression}}
+
+  (void) i16 < i16 ? i8 : i16; // expected-error{{invalid operands to binary expression}}
+  (void) i16 < i16 ? i32 : i16; // expected-error{{invalid operands to binary expression}}
+  (void) i16 < i16 ? i64 : i16; // expected-error{{invalid operands to binary expression}}
+}
\ No newline at end of file
Index: clang/test/CodeGenCXX/aarch64-sve-vector-conditional-op.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/aarch64-sve-vector-conditional-op.cpp
@@ -0,0 +1,151 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve \
+// RUN: -fallow-half-arguments-and-returns -disable-O0-optnone \
+// RUN:  -emit-llvm -o - %s | opt -S -sroa | FileCheck %s
+
+// REQUIRES: aarch64-registered-target
+
+#include 
+
+// CHECK-LABEL: @_Z9cond_boolu10__SVBool_tu10__SVBool_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CMP:%.*]] = icmp ult  [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:[[VECTOR_COND:%.*]] = icmp ne  [[CMP]], zeroinitializer
+// CHECK-NEXT:[[VECTOR_SELECT:%.*]] = select  [[VECTOR_COND]],  [[A]],  [[B]]
+// CHECK-NEXT:ret  [[VECTOR_SELECT]]
+//
+svbool_t cond_bool(svbool_t a, svbool_t b) {
+return a < b ? a : b;
+}
+
+// CHECK-LABEL: @_Z7cond_i8u10__SVInt8_tu10__SVInt8_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CMP:%.*]] = icmp ult  [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:[[CONV:%.*]] = zext  [[CMP]] to 
+// CHECK-NEXT:[[VECTOR_COND:%.*]] = icmp ne  [[CONV]], zeroinitializer
+// CHECK-NEXT:[[VECTOR_SELECT:%.*]] = select  [[VECTOR_COND]],  [[A]],  [[B]]
+// CHECK-NEXT:ret  [[VECTOR_SELECT]]
+//
+svint8_t cond_i8(svint8_t a, svint8_t b) {
+return a < b ? a : b;
+}
+
+// CHECK-LABEL: @_Z7cond_u8u11__SVUint8_tu11__SVUint8_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CMP:%.*]] = icmp ult  [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:[[CONV:%.*]] = zext  [[CMP]] to 
+// CHECK-NEXT:[[VECTOR_COND:%.*]] = icmp ne  [[CONV]], zeroinitializer
+// CHECK-NEXT:[[VECTOR_SELECT:%.*]] = select  [[VECTOR_COND]],  [[A]],  [[B]]
+// CHECK-NEXT:ret  [[VECTOR_SELECT]]
+//
+svuint8_t cond_u8(svuint8_t a, svuint8_t b) {
+return a < b ? a : b;
+}
+
+// CHECK-LABEL: @_Z8cond_i16u11__SVInt16_tu11__SVInt16_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CMP:%.*]] = icmp ult  [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:[[CONV:%.*]] = zext  [[CMP]] to 
+// CHECK-NEXT:[[VECTOR_COND:%.*]] = icmp ne  [[CONV]], zeroinitializer
+// CHECK-NEXT:[[VECTOR_SELECT:%.*]] = select  [[VECTOR_COND]],  [[A]],  [[B]]
+// CHECK-NEXT:ret  [[VECTOR_SELECT]]
+//
+svint16_t cond_i16(svint16_t a, svint16_t b) {
+return a < b ? a : b;
+}
+
+// CHECK-LABEL: @_Z8cond_u16u12__SVUint16_tu12__SVUint16_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CMP:%.*]] = icmp ult  [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:[[CONV:%.*]] = zext  [[CMP]] to 
+// CHECK-NEXT:[[VECTOR_COND:%.*]]

[clang] 2c176f2 - [X86][AVX] Add i386 test coverage to avx intrinsic tests

2022-04-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-04-20T15:12:11+01:00
New Revision: 2c176f2f1ed7b4dcad3d229b9a61e77e17370baf

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

LOG: [X86][AVX] Add i386 test coverage to avx intrinsic tests

Added: 


Modified: 
clang/test/CodeGen/X86/avx-builtins-constrained-cmp.c
clang/test/CodeGen/X86/avx-builtins.c
clang/test/CodeGen/X86/avx-cmp-builtins.c
clang/test/CodeGen/X86/avx-shuffle-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/avx-builtins-constrained-cmp.c 
b/clang/test/CodeGen/X86/avx-builtins-constrained-cmp.c
index a23f5586816f9..570c9c942cca6 100644
--- a/clang/test/CodeGen/X86/avx-builtins-constrained-cmp.c
+++ b/clang/test/CodeGen/X86/avx-builtins-constrained-cmp.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +avx -emit-llvm 
-ffp-exception-behavior=maytrap -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=i386-apple-darwin -target-feature +avx -emit-llvm 
-ffp-exception-behavior=maytrap -o - -Wall -Werror | FileCheck %s
 
 // Test that the constrained intrinsics are picking up the exception
 // metadata from the AST instead of the global default from the command line.

diff  --git a/clang/test/CodeGen/X86/avx-builtins.c 
b/clang/test/CodeGen/X86/avx-builtins.c
index 65b783911bd98..03ba2028deb43 100644
--- a/clang/test/CodeGen/X86/avx-builtins.c
+++ b/clang/test/CodeGen/X86/avx-builtins.c
@@ -1,6 +1,8 @@
-// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx -emit-llvm 
-o - -Wall -Werror | FileCheck %s
-// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx 
-fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s
-// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-fms-extensions -fms-compatibility -ffreestanding %s 
-triple=x86_64-windows-msvc -target-feature +avx -emit-llvm -o - -Wall -Werror 
| FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx -emit-llvm 
-o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X64
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx 
-fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s 
--check-prefixes=CHECK,X64
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=i386-apple-darwin -target-feature +avx -emit-llvm -o 
- -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X86
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=i386-apple-darwin -target-feature +avx 
-fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s 
--check-prefixes=CHECK,X86
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-fms-extensions -fms-compatibility -ffreestanding %s 
-triple=x86_64-windows-msvc -target-feature +avx -emit-llvm -o - -Wall -Werror 
| FileCheck %s --check-prefixes=CHECK,X64
 
 
 #include 
@@ -1081,8 +1083,8 @@ int test_mm256_extract_epi32(__m256i A) {
 
 #if __x86_64__
 long long test_mm256_extract_epi64(__m256i A) {
-  // CHECK-LABEL: test_mm256_extract_epi64
-  // CHECK: extractelement <4 x i64> %{{.*}}, {{i32|i64}} 3
+  // X64-LABEL: test_mm256_extract_epi64
+  // X64: extractelement <4 x i64> %{{.*}}, {{i32|i64}} 3
   return _mm256_extract_epi64(A, 3);
 }
 #endif
@@ -1161,8 +1163,8 @@ __m256i test_mm256_insert_epi32(__m256i x, int b) {
 
 #if __x86_64__
 __m256i test_mm256_insert_epi64(__m256i x, long long b) {
-  // CHECK-LABEL: test_mm256_insert_epi64
-  // CHECK: insertelement <4 x i64> %{{.*}}, i64 %{{.*}}, {{i32|i64}} 2
+  // X64-LABEL: test_mm256_insert_epi64
+  // X64: insertelement <4 x i64> %{{.*}}, i64 %{{.*}}, {{i32|i64}} 2
   return _mm256_insert_epi64(x, b, 2);
 }
 #endif
@@ -2056,20 +2058,29 @@ int test_mm256_testz_si256(__m256i A, __m256i B) {
 }
 
 __m256 test_mm256_undefined_ps(void) {
-  // CHECK-LABEL: test_mm256_undefined_ps
-  // CHECK: ret <8 x float> zeroinitializer
+  // X64-LABEL: test_mm256_undefined_ps
+  // X64: ret <8 x float> zeroinitializer
+  //
+  // X86-LABEL: test_mm256_undefined_ps
+  // X86: store <8 x float> zeroinitializer
   return _mm256_undefined_ps();
 }
 
 __m256d test_mm256_undefined_pd(void) {
-  // CHECK-LABEL: test_mm256_undefined_pd
-  // CHECK: ret <4 x double> zeroinitializer
+  // X64-LABEL: test_mm256_undefined_pd
+  // X64: ret <4 x double> zeroinitializer
+  //
+  // X86-LABEL: test_mm256_un

[clang] 0140a67 - [X86][AVX] Add i386 test coverage to avx-vnni intrinsic tests

2022-04-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-04-20T15:12:12+01:00
New Revision: 0140a672a62b9a01742d0c449adc3a710e446ad7

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

LOG: [X86][AVX] Add i386 test coverage to avx-vnni intrinsic tests

Added: 


Modified: 
clang/test/CodeGen/X86/avxvnni-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/avxvnni-builtins.c 
b/clang/test/CodeGen/X86/avxvnni-builtins.c
index 1e9bb091c68d5..089578df78e0c 100644
--- a/clang/test/CodeGen/X86/avxvnni-builtins.c
+++ b/clang/test/CodeGen/X86/avxvnni-builtins.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +avxvnni -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=i386-apple-darwin -target-feature 
+avxvnni -emit-llvm -o - -Wall -Werror | FileCheck %s
 
 #include 
 



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


[clang] 72d4e3d - [X86][AVX] Add i386 test coverage to avx2 intrinsic tests

2022-04-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-04-20T15:12:12+01:00
New Revision: 72d4e3dc2d6f560e44fffefd7fc6987e9083698f

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

LOG: [X86][AVX] Add i386 test coverage to avx2 intrinsic tests

Added: 


Modified: 
clang/test/CodeGen/X86/avx2-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/avx2-builtins.c 
b/clang/test/CodeGen/X86/avx2-builtins.c
index 056e072569e7f..16a9fbfa1388a 100644
--- a/clang/test/CodeGen/X86/avx2-builtins.c
+++ b/clang/test/CodeGen/X86/avx2-builtins.c
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx2 -emit-llvm 
-o - -Wall -Werror | FileCheck %s
-// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx2 
-fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx2 -emit-llvm 
-o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X64
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx2 
-fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s 
--check-prefixes=CHECK,X64
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=i386-apple-darwin -target-feature +avx2 -emit-llvm -o 
- -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X86
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none 
-ffreestanding %s -triple=i386-apple-darwin -target-feature +avx2 
-fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s 
--check-prefixes=CHECK,X86
 
 
 #include 
@@ -466,8 +468,11 @@ __m128i test_mm_mask_i32gather_epi64(__m128i a, long long 
const *b, __m128i c, _
 }
 
 __m256i test_mm256_i32gather_epi64(long long const *b, __m128i c) {
-  // CHECK-LABEL: test_mm256_i32gather_epi64
-  // CHECK: call <4 x i64> @llvm.x86.avx2.gather.d.q.256(<4 x i64> 
zeroinitializer, i8* %{{.*}}, <4 x i32> %{{.*}}, <4 x i64> %{{.*}}, i8 2)
+  // X64-LABEL: test_mm256_i32gather_epi64
+  // X64: call <4 x i64> @llvm.x86.avx2.gather.d.q.256(<4 x i64> 
zeroinitializer, i8* %{{.*}}, <4 x i32> %{{.*}}, <4 x i64> %{{.*}}, i8 2)
+  //
+  // X86-LABEL: test_mm256_i32gather_epi64
+  // X86: call <4 x i64> @llvm.x86.avx2.gather.d.q.256(<4 x i64> %{{.*}}, i8* 
%{{.*}}, <4 x i32> %{{.*}}, <4 x i64> %{{.*}}, i8 2)
   return _mm256_i32gather_epi64(b, c, 2);
 }
 
@@ -478,11 +483,17 @@ __m256i test_mm256_mask_i32gather_epi64(__m256i a, long 
long const *b, __m128i c
 }
 
 __m128d test_mm_i32gather_pd(double const *b, __m128i c) {
-  // CHECK-LABEL: test_mm_i32gather_pd
-  // CHECK: [[CMP:%.*]] = fcmp oeq <2 x double>
-  // CHECK-NEXT:[[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
-  // CHECK-NEXT:[[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
-  // CHECK: call <2 x double> @llvm.x86.avx2.gather.d.pd(<2 x double> 
zeroinitializer, i8* %{{.*}}, <4 x i32> %{{.*}}, <2 x double> %{{.*}}, i8 2)
+  // X64-LABEL: test_mm_i32gather_pd
+  // X64: [[CMP:%.*]] = fcmp oeq <2 x double>
+  // X64-NEXT:[[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
+  // X64-NEXT:[[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
+  // X64: call <2 x double> @llvm.x86.avx2.gather.d.pd(<2 x double> 
zeroinitializer, i8* %{{.*}}, <4 x i32> %{{.*}}, <2 x double> %{{.*}}, i8 2)
+  //
+  // X86-LABEL: test_mm_i32gather_pd
+  // X86: [[CMP:%.*]] = fcmp oeq <2 x double>
+  // X86-NEXT:[[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
+  // X86-NEXT:[[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
+  // X86: call <2 x double> @llvm.x86.avx2.gather.d.pd(<2 x double> %{{.*}}, 
i8* %{{.*}}, <4 x i32> %{{.*}}, <2 x double> %{{.*}}, i8 2)
   return _mm_i32gather_pd(b, c, 2);
 }
 
@@ -493,11 +504,17 @@ __m128d test_mm_mask_i32gather_pd(__m128d a, double const 
*b, __m128i c, __m128d
 }
 
 __m256d test_mm256_i32gather_pd(double const *b, __m128i c) {
-  // CHECK-LABEL: test_mm256_i32gather_pd
-  // CHECK: [[CMP:%.*]] = fcmp oeq <4 x double>
-  // CHECK-NEXT:[[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i64>
-  // CHECK-NEXT:[[BC:%.*]] = bitcast <4 x i64> [[SEXT]] to <4 x double>
-  // CHECK: call <4 x double> @llvm.x86.avx2.gather.d.pd.256(<4 x double> 
zeroinitializer, i8* %{{.*}}, <4 x i32> %{{.*}}, <4 x double> %{{.*}}, i8 2)
+  // X64-LABEL: test_mm256_i32gather_pd
+  // X64: [[CMP:%.*]] = fcmp oeq <4 x double>
+  // X64-NEXT:[[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i64>
+  // X64-NEXT:[[BC:%.*]] = bitcast <4 x i64> [[

[clang] 1226d27 - [X86][AVX512] Rename avx512popcntdq intrinsics tests files to match *-builtins.c naming convention

2022-04-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-04-20T15:12:12+01:00
New Revision: 1226d276b46d084e4c39357d0d6d72827e88c7b4

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

LOG: [X86][AVX512] Rename avx512popcntdq intrinsics tests files to match 
*-builtins.c naming convention

Added: 
clang/test/CodeGen/X86/avx512vpopcntdq-builtins.c
clang/test/CodeGen/X86/avx512vpopcntdqvl-builtins.c

Modified: 


Removed: 
clang/test/CodeGen/X86/avx512vpopcntdqintrin.c
clang/test/CodeGen/X86/avx512vpopcntdqvlintrin.c



diff  --git a/clang/test/CodeGen/X86/avx512vpopcntdqintrin.c 
b/clang/test/CodeGen/X86/avx512vpopcntdq-builtins.c
similarity index 100%
rename from clang/test/CodeGen/X86/avx512vpopcntdqintrin.c
rename to clang/test/CodeGen/X86/avx512vpopcntdq-builtins.c

diff  --git a/clang/test/CodeGen/X86/avx512vpopcntdqvlintrin.c 
b/clang/test/CodeGen/X86/avx512vpopcntdqvl-builtins.c
similarity index 100%
rename from clang/test/CodeGen/X86/avx512vpopcntdqvlintrin.c
rename to clang/test/CodeGen/X86/avx512vpopcntdqvl-builtins.c



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


[PATCH] D119544: Deferred Concept Instantiation Implementation

2022-04-20 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 10 inline comments as done.
erichkeane added inline comments.



Comment at: clang/include/clang/AST/Decl.h:1891
+TK_DependentFunctionTemplateSpecialization,
+// A Dependent function that itself is not a function.
+TK_DependentNonTemplate

ChuanqiXu wrote:
> hmmm, what does this literally mean? In my understanding, it should be:
> 
>A non template function which is in a dependent scope.
> 
> I am just wondering if this is covered by `TK_NonTemplate`.
Woops, I DID mess that up :)  I will switch to basically your wording.

This _IS_ generally covered by TK_NonTemplate (and was before), and I 
considered not adding it at all, but it is really nice to check 
`getTemplatedKind` to see if the value I need is going to be there.



Comment at: clang/include/clang/AST/Decl.h:1942
+  /// For non-templates, this value will be NULL, unless this was instantiated
+  /// as an inner-declared function in another function template, which will
+  /// cause this to have a pointer to a FunctionDecl. For function declarations

ChuanqiXu wrote:
> > an inner-declared function in another function template
> 
> Does this refer to local lambdas or functions in local classes of a template 
> function **only**? If yes, I recommend to reword this. Since I understand it 
> by the review comment instead of the comments itself.
This is actually the cases where it is NOT a local lambda or function object 
inside a function template.  I'll give a reword a go.



Comment at: clang/include/clang/AST/Decl.h:2691-2692
 
+  /// Specify the function that this was instantiated from, despite it not,
+  /// itself being a template.
+  void setInstantiatedFromDecl(FunctionDecl *FD);

ChuanqiXu wrote:
> I can't read the original comment... I am not sure if it is my problem but I 
> think it may be better to reword it.
Yeah, thats a pretty low quality comment as well :/  I'll give it another shot 
that will hopefully be more understandable.  It isn't quite what you said 
though.



Comment at: clang/lib/AST/Decl.cpp:3787
+  assert(TemplateOrSpecialization.isNull() &&
+ "Member function is already a specialization");
+  TemplateOrSpecialization = FD;

ChuanqiXu wrote:
> Do I understand incorrectly? Must it be a member function?
You do not understand incorrectly :/  Copy-paste error.  I'll remove 'member'.



Comment at: clang/lib/AST/DeclBase.cpp:299
+   DC && !DC->isTranslationUnit() && !DC->isNamespace();
+   DC = DC->getParent())
+if (DC->isFunctionOrMethod())

ChuanqiXu wrote:
> From the function name, I image it should be `DC = DC->getLexicalParent`. Is 
> it incorrect?
This is 'exactly' the function above (`getParentFunctionOrMethod`), except it 
uses the `Lexical` context instead of the semantic context.  Would you prefer a 
name of 'getParentFunctionOrMethodLexically`?



Comment at: clang/lib/Sema/SemaConcept.cpp:480-488
+  if (DeclContext *ParentFunc = FD->getParentFunctionOrMethod()) {
+return SetupConstraintScope(cast(ParentFunc), TemplateArgs,
+MLTAL, Scope);
+  } else if (DeclContext *ParentFunc = FD->getLexicalParentFunctionOrMethod()) 
{
+// In the case of functions-declared-in-functions, the DeclContext is the
+// TU, so make sure we get the LEXICAL decl context in this case.
+return SetupConstraintScope(cast(ParentFunc), TemplateArgs,

ChuanqiXu wrote:
> Don't use else-after-return: 
> https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return.
> 
> And I am wondering if we could hit these 2 checks only if the FD is 
> TK_DependentNonTemplate. If yes, I think we could move these two checks in 
> the above block. In this way, the code could be simplified further.
Changes made!


>And I am wondering if we could hit these 2 checks only...
We cannot, this applies generally, including in cases where the current 
function is a local lambda or function object.


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

https://reviews.llvm.org/D119544

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


[PATCH] D119544: Deferred Concept Instantiation Implementation

2022-04-20 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 423901.
erichkeane marked 6 inline comments as done.
erichkeane added a comment.

Thanks for the review @ChuanqiXu !


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

https://reviews.llvm.org/D119544

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/Template.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/non-function-templates.cpp
  clang/test/SemaTemplate/concepts.cpp
  clang/test/SemaTemplate/deferred-concept-inst.cpp
  clang/test/SemaTemplate/instantiate-requires-clause.cpp
  clang/test/SemaTemplate/trailing-return-short-circuit.cpp

Index: clang/test/SemaTemplate/trailing-return-short-circuit.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/trailing-return-short-circuit.cpp
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+template 
+requires(sizeof(T) > 2) || T::value // #FOO_REQ
+void Foo(T){};  // #FOO
+
+template 
+void TrailingReturn(T) // #TRAILING
+requires(sizeof(T) > 2) || // #TRAILING_REQ
+T::value{};// #TRAILING_REQ_VAL
+template 
+struct HasValue {
+  static constexpr bool value = B;
+};
+static_assert(sizeof(HasValue) <= 2);
+
+template 
+struct HasValueLarge {
+  static constexpr bool value = B;
+  int I;
+};
+static_assert(sizeof(HasValueLarge) > 2);
+
+void usage() {
+  // Passes the 1st check, short-circuit so the 2nd ::value is not evaluated.
+  Foo(1.0);
+  TrailingReturn(1.0);
+
+  // Fails the 1st check, but has a ::value, so the check happens correctly.
+  Foo(HasValue{});
+  TrailingReturn(HasValue{});
+
+  // Passes the 1st check, but would have passed the 2nd one.
+  Foo(HasValueLarge{});
+  TrailingReturn(HasValueLarge{});
+
+  // Fails the 1st check, fails 2nd because there is no ::value.
+  Foo(true);
+  // expected-error@-1{{no matching function for call to 'Foo'}}
+  // expected-note@#FOO{{candidate template ignored: constraints not satisfied [with T = bool]}}
+  // expected-note@#FOO_REQ{{because 'sizeof(_Bool) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#FOO_REQ{{because substituted constraint expression is ill-formed: type 'bool' cannot be used prior to '::' because it has no members}}
+
+  TrailingReturn(true);
+  // expected-error@-1{{no matching function for call to 'TrailingReturn'}}
+  // expected-note@#TRAILING{{candidate template ignored: constraints not satisfied [with T = bool]}}
+  // expected-note@#TRAILING_REQ{{because 'sizeof(_Bool) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#TRAILING_REQ_VAL{{because substituted constraint expression is ill-formed: type 'bool' cannot be used prior to '::' because it has no members}}
+
+  // Fails the 1st check, fails 2nd because ::value is false.
+  Foo(HasValue{});
+  // expected-error@-1 {{no matching function for call to 'Foo'}}
+  // expected-note@#FOO{{candidate template ignored: constraints not satisfied [with T = HasValue]}}
+  // expected-note@#FOO_REQ{{because 'sizeof(HasValue) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#FOO_REQ{{and 'HasValue::value' evaluated to false}}
+  TrailingReturn(HasValue{});
+  // expected-error@-1 {{no matching function for call to 'TrailingReturn'}}
+  // expected-note@#TRAILING{{candidate template ignored: constraints not satisfied [with T = HasValue]}}
+  // expected-note@#TRAILING_REQ{{because 'sizeof(HasValue) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#TRAILING_REQ_VAL{{and 'HasValue::value' evaluated to false}}
+}
Index: clang/test/SemaTemplate/instantiate-requires-clause.cpp
===
--- clang/test/SemaTemplate/instantiate-requires-clause.cpp
+++ clang/test/SemaTemplate/instantiate-requires-clause.cpp
@@ -40,6 +40,18 @@
 
 static_assert(S::f(1));
 
+// Similar to the 'S' test, but tries to use 'U' in the requires clause.
+template 
+struct S1 {
+  // expected-note@+3 {{candidate template ignored: constraints not satisfied [with U = int]}}
+  // expected-note@+2 {{because substituted constraint expression is ill-formed: type 'int' cannot be used prior to '::' because it has no members}}
+  template 
+  static constexpr auto f(U const index) requires(U::foo) { return true; }
+};
+
+// expected-error@+1 {{no matching function for call to 'f'}}
+static_assert(S1::f(1));
+
 constexpr auto value = 0;
 
 template
Index: clang/

[PATCH] D122983: [C11/C2x] Change the behavior of the implicit function declaration warning

2022-04-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 423902.
aaron.ballman added a comment.

Rebased to hopefully get precommit CI to test it.


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

https://reviews.llvm.org/D122983

Files:
  clang-tools-extra/clangd/IncludeFixer.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/ARCMT/objcmt-arc-cf-annotations.m
  clang/test/ARCMT/objcmt-arc-cf-annotations.m.result
  clang/test/Analysis/OSAtomic_mac.c
  clang/test/Analysis/ObjCProperties.m
  clang/test/Analysis/PR49642.c
  clang/test/Analysis/dead-stores.c
  clang/test/Analysis/diagnostics/no-store-func-path-notes.c
  clang/test/Analysis/exercise-ps.c
  clang/test/Analysis/malloc-three-arg.c
  clang/test/Analysis/misc-ps-region-store.m
  clang/test/Analysis/novoidtypecrash.c
  clang/test/Analysis/plist-macros-with-expansion.c
  clang/test/CodeGen/2002-07-14-MiscTests3.c
  clang/test/CodeGen/2002-07-31-SubregFailure.c
  clang/test/CodeGen/2003-08-18-SigSetJmp.c
  clang/test/CodeGen/2004-11-27-StaticFunctionRedeclare.c
  clang/test/CodeGen/2005-01-02-ConstantInits.c
  clang/test/CodeGen/2005-01-02-VAArgError-ICE.c
  clang/test/CodeGen/2005-02-20-AggregateSAVEEXPR.c
  clang/test/CodeGen/2006-01-13-StackSave.c
  clang/test/CodeGen/2006-03-03-MissingInitializer.c
  clang/test/CodeGen/2007-09-27-ComplexIntCompare.c
  clang/test/CodeGen/2008-05-12-TempUsedBeforeDef.c
  clang/test/CodeGen/2008-07-30-redef-of-bitcasted-decl.c
  clang/test/CodeGen/2008-08-19-cast-of-typedef.c
  clang/test/CodeGen/2008-10-13-FrontendCrash.c
  clang/test/CodeGen/2009-01-05-BlockInlining.c
  clang/test/CodeGen/PowerPC/builtins-ppc-p8vector.c
  clang/test/CodeGen/X86/bmi2-builtins.c
  clang/test/CodeGen/aarch64-mops.c
  clang/test/CodeGen/aarch64-neon-sm4-sm3.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create3-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create4-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_get2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_get3-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_get4-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1rq-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnt1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_rev-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_set2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_set3-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_set4-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_stnt1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef3-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef4-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_aba.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_abalb.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_abalt.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_abdlb.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_abdlt.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_adalp.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_adclb.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_adclt.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_addhnb.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_addhnt.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_addlb.c
  clang/test/CodeGen/aarch64-sve2-intrinsics

[PATCH] D123955: [C2x] Disallow functions without prototypes/functions with identifier lists

2022-04-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked 2 inline comments as done.
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:6664-
+// OpenCL disallows variadic functions, so it also disallows a function
+// without a prototype. However, it doesn't enforce strict prototypes
+// because it allows function definitions with an identifier list.

rsmith wrote:
> aaron.ballman wrote:
> > aaron.ballman wrote:
> > > rsmith wrote:
> > > > I don't follow this comment: functions without a prototype are not 
> > > > variadic (they're compatible with any *non-variadic* prototype), so 
> > > > OpenCL disallowing variadic functions seems irrelevant here.
> > > Heh, this comment came from feedback I got from someone on IRC when I was 
> > > asking what OpenCL actually supports. As best I found, OpenCL allows 
> > > `void f();` to mean `void f(void);` as in C++, but also allows `void f(a, 
> > > b) int a, b; {}` (despite having no way to actually declare this 
> > > function).
> > > 
> > > I'll take a pass at fixing up the comment to be more clear, thanks!
> > I updated both comments.
> Fascinating! There's a common confusion and misapprehension that `void f()` 
> declares a variadic function in C, and that confusion has made its way into 
> the OpenCL specification. The relevant rule there is 6.11/g:
> 
> > e. Variadic functions are not supported, with the exception of printf and 
> > enqueue_kernel.
> > g. If a list of parameters in a function declaration is empty, the function 
> > takes no arguments. **This is due to the above restriction on variadic 
> > functions.**
> 
> (Emphasis mine.) So I think this implementation is correct, and your earlier 
> comment correctly reflected the confusion in the OpenCL spec :-)
> 
> A comment with a direct reference to this part of the [OpenCL C 3.0 
> specification](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/pdf/OpenCL_C.pdf)
>  would be nice.
> Fascinating! There's a common confusion and misapprehension that void f() 
> declares a variadic function in C, and that confusion has made its way into 
> the OpenCL specification. 

I think it's understandable confusion. `void f(...);` in C++ and `void f();` in 
C89 say the "same" thing: this function can be called with zero or more 
arguments, YOLO. The fact that the standards made `...` mean "variadic" but 
functions without a prototype mean "magic" is mostly lost on users, I think.

> A comment with a direct reference to this part of the OpenCL C 3.0 
> specification would be nice.

I'll add that link in, good call!



Comment at: clang/lib/Parse/ParseDecl.cpp:6667
+// have an identifier list.
+HasProto = ParamInfo.size() || getLangOpts().requiresStrictPrototypes() ||
+   getLangOpts().OpenCL;

rsmith wrote:
> Hm, so `-fstrict-prototypes` causes us to treat `void f()` as `void f(void)`? 
> That's not normally how our `-fstrict-` flags work: normally they mean 
> "strictly enforce this language rule, even though that may result in programs 
> having UB that we could define away with a more permissive rule". (For 
> example, `-fstrict-aliasing`, `-fstrict-float-cast-overflow`, 
> `-fstrict-enums`, `-fstrict-overflow`, `-fstrict-vtable-pointers`, 
> `-fstrict-return` all work like that.) I wonder if a different flag name 
> would work better, eg `-fno-unprototyped-functions`. Is `-fstrict-prototypes` 
> a GCC flag that we're trying to be compatible with, or our own invention?
> 
> If you can't find a better name, I'm not dead set against the current one, 
> but it does seem a little inconsistent.
> Hm, so -fstrict-prototypes causes us to treat void f() as void f(void)?

Yup, the idea is that it is strictly enforcing that all functions have a 
prototype.

>  Is -fstrict-prototypes a GCC flag that we're trying to be compatible with, 
> or our own invention?

It's our invention, and I'm not strongly tied to the name. It's the one that 
came up during the RFC and I suspect it's influenced by the name of the warning 
group `-Wstrict-prototypes`.

I think `-fno-` would be a bit of a weird way to spell the flag as that usually 
disables something rather than enables it. I'll switch to `-fforce-prototypes` 
because that's basically what this does. WDYT?



Comment at: clang/test/Driver/strict-prototypes.c:5
+// RUN: not %clang -fno-strict-prototypes -x c %s 2>&1 | FileCheck %s
+// RUN: not %clang -fno-strict-prototypes -std=c89 -x c %s 2>&1 | FileCheck %s
+

rsmith wrote:
> I would expect this case (`-std=c89 -fno-strict-prototypes`) to work: we 
> usually allow ` -fno-X` flag to override an earlier `-fX` flag in the same 
> command line. Not a big deal, though.
I think it's better to disallow the user from ever uttering 
`-fno-strict-prototypes` even when it's behavior would be benign. But I'm happy 
to revisit later if it becomes an issue.


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

[PATCH] D124093: [PowerPC] Fixing implicit castings in altivec for -fno-lax-vector-conversions

2022-04-20 Thread Maryam Moghadas via Phabricator via cfe-commits
maryammo created this revision.
Herald added subscribers: shchenz, kbarton, nemanjai.
Herald added a project: All.
maryammo requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

XL considers different vector types to be incompatible with each other.
For example assignment between variables of types vector float and vector
long long or even vector signed int and vector unsigned int are diagnosed.
clang, however does not diagnose such cases and does a simple bitcast between
the two types. This could easily result in program errors. This patch is to
fix the implicit casts in altivec.h so that there is no incompatible vector
type errors whit -fno-lax-vector-conversions, this is the prerequisite patch
to switch the default to -fno-lax-vector-conversions later.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124093

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/PowerPC/builtins-ppc-p10vector.c
  clang/test/CodeGen/PowerPC/builtins-ppc-quadword-noi128.c

Index: clang/test/CodeGen/PowerPC/builtins-ppc-quadword-noi128.c
===
--- clang/test/CodeGen/PowerPC/builtins-ppc-quadword-noi128.c
+++ clang/test/CodeGen/PowerPC/builtins-ppc-quadword-noi128.c
@@ -7,7 +7,7 @@
 // RUN:   -triple powerpc64-aix-unknown -emit-llvm %s -o - | FileCheck \
 // RUN:   %s -check-prefix=CHECK-AIX
 // RUN: %clang_cc1 -O2 -target-feature +altivec -target-feature +power8-vector \
-// RUN:   -triple powerpc-aix-unknown -emit-llvm %s -o - | FileCheck \
+// RUN:   -triple powerpc-aix-unknown -emit-llvm -fforce-enable-int128 %s -o - | FileCheck \
 // RUN:   %s -check-prefix=CHECK-AIX
 #include 
 // CHECK-LE-LABEL: @test_subc(
Index: clang/test/CodeGen/PowerPC/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/PowerPC/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/PowerPC/builtins-ppc-p10vector.c
@@ -1952,7 +1952,7 @@
 vector signed __int128 test_vec_rl_s128(void) {
   // CHECK-LABEL: @test_vec_rl_s128(
   // CHECK: sub <1 x i128>
-  // CHECK-NEXT: lshr <1 x i128>
+  // CHECK-NEXT: ashr <1 x i128>
   // CHECK-NEXT: or <1 x i128>
   // CHECK-NEXT: ret <1 x i128>
   return vec_rl(vsi128a, vsi128b);
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ -311,7 +311,7 @@
 
 static __inline__ vector unsigned char __attribute__((__always_inline__))
 vec_add_u128(vector unsigned char __a, vector unsigned char __b) {
-  return __builtin_altivec_vadduqm(__a, __b);
+  return (vector unsigned char)__builtin_altivec_vadduqm(__a, __b);
 }
 #elif defined(__VSX__)
 static __inline__ vector signed long long __ATTRS_o_ai
@@ -325,9 +325,10 @@
   (vector unsigned int)__a + (vector unsigned int)__b;
   vector unsigned int __carry = __builtin_altivec_vaddcuw(
   (vector unsigned int)__a, (vector unsigned int)__b);
-  __carry = __builtin_shufflevector((vector unsigned char)__carry,
-(vector unsigned char)__carry, 0, 0, 0, 7,
-0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0);
+  __carry = (vector unsigned int)__builtin_shufflevector(
+		 (vector unsigned char)__carry,
+ (vector unsigned char)__carry, 0, 0, 0, 7,
+ 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0);
   return (vector signed long long)(__res + __carry);
 #endif
 }
@@ -358,7 +359,10 @@
 static __inline__ vector signed __int128 __ATTRS_o_ai
 vec_adde(vector signed __int128 __a, vector signed __int128 __b,
  vector signed __int128 __c) {
-  return __builtin_altivec_vaddeuqm(__a, __b, __c);
+  return (vector signed __int128)__builtin_altivec_vaddeuqm(
+(vector unsigned __int128)__a,
+		(vector unsigned __int128)__b,
+			(vector unsigned __int128)__c);
 }
 
 static __inline__ vector unsigned __int128 __ATTRS_o_ai
@@ -366,14 +370,17 @@
  vector unsigned __int128 __c) {
   return __builtin_altivec_vaddeuqm(__a, __b, __c);
 }
-#endif
 
 static __inline__ vector unsigned char __attribute__((__always_inline__))
 vec_adde_u128(vector unsigned char __a, vector unsigned char __b,
   vector unsigned char __c) {
-  return (vector unsigned char)__builtin_altivec_vaddeuqm(__a, __b, __c);
+  return (vector unsigned char)__builtin_altivec_vaddeuqm(
+		   (vector unsigned __int128)__a,
+		   (vector unsigned __int128)__b,
+	   (vector unsigned __int128)__c);
 }
 #endif
+#endif
 
 static __inline__ vector signed int __ATTRS_o_ai
 vec_adde(vector signed int __a, vector signed int __b,
@@ -398,7 +405,10 @@
 static __inline__ vector signed __int128 __ATTRS_o_ai
 vec_addec(vector signed __int128 __a, vector signed __int128 __b,
   

[clang-tools-extra] f25935a - [clang-tidy] Fix `altera-struct-pack-align` check for empty structs

2022-04-20 Thread Fabian Wolff via cfe-commits

Author: Fabian Wolff
Date: 2022-04-20T16:55:29+02:00
New Revision: f25935a000917f2c06b52bbc7273e20a82543782

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

LOG: [clang-tidy] Fix `altera-struct-pack-align` check for empty structs

Fixes https://github.com/llvm/llvm-project/issues/50962.

Reviewed By: whisperity, aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp 
b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
index 6ae53512fca5e..b5f8d082d8877 100644
--- a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
@@ -77,7 +77,8 @@ void StructPackAlignCheck::check(const 
MatchFinder::MatchResult &Result) {
   uint64_t CharSize = Result.Context->getCharWidth();
   CharUnits CurrSize = Result.Context->getASTRecordLayout(Struct).getSize();
   CharUnits MinByteSize =
-  CharUnits::fromQuantity(ceil((float)TotalBitSize / CharSize));
+  CharUnits::fromQuantity(std::max(
+  ceil(static_cast(TotalBitSize) / CharSize), 1));
   CharUnits MaxAlign = CharUnits::fromQuantity(
   ceil((float)Struct->getMaxAlignment() / CharSize));
   CharUnits CurrAlign =

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 50d5b8ecc72c1..491bc92f4ef38 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -170,6 +170,9 @@ Changes in existing checks
   ` to work when
   the vector is a member of a structure.
 
+- Fixed nonsensical suggestion of :doc:`altera-struct-pack-align
+  ` check for empty structs.
+
 Removed checks
 ^^
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
index 615b6cafe87a2..472372ffe35c1 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
@@ -99,3 +99,22 @@ void no_trigger_on_instantiation() {
   struct bad_align3 instantiated { 'a', 0.001, 'b' };
 }
 
+// Make sure that we don't recommend aligning an empty struct to zero bytes 
(PR#51620)
+struct StructWithNoFields {};
+
+struct ContainsStructWithNoFields {
+  StructWithNoFields s;
+};
+
+// Make sure that an empty struct is treated like "char" for padding and 
alignment purposes
+struct ContainsStructWithNoFields2 {
+  StructWithNoFields s;
+  double d;
+  StructWithNoFields t;
+};
+// CHECK-MESSAGES: :[[@LINE-5]]:8: warning: accessing fields in struct 
'ContainsStructWithNoFields2' is inefficient due to padding; only needs 10 
bytes but is using 24 bytes [altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-6]]:8: note: use "__attribute__((packed))" to 
reduce the amount of padding applied to struct 'ContainsStructWithNoFields2'
+// CHECK-MESSAGES: :[[@LINE-7]]:8: warning: accessing fields in struct 
'ContainsStructWithNoFields2' is inefficient due to poor alignment; currently 
aligned to 8 bytes, but recommended alignment is 16 bytes 
[altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-8]]:8: note: use "__attribute__((aligned(16)))" to 
align struct 'ContainsStructWithNoFields2' to 16 bytes
+// CHECK-FIXES: __attribute__((packed))
+// CHECK-FIXES: __attribute__((aligned(16)));



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


[PATCH] D114292: [clang-tidy] Fix `altera-struct-pack-align` check for empty structs

2022-04-20 Thread Fabian Wolff via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf25935a00091: [clang-tidy] Fix `altera-struct-pack-align` 
check for empty structs (authored by fwolff).

Changed prior to commit:
  https://reviews.llvm.org/D114292?vs=400634&id=423908#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114292

Files:
  clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
@@ -99,3 +99,22 @@
   struct bad_align3 instantiated { 'a', 0.001, 'b' };
 }
 
+// Make sure that we don't recommend aligning an empty struct to zero bytes 
(PR#51620)
+struct StructWithNoFields {};
+
+struct ContainsStructWithNoFields {
+  StructWithNoFields s;
+};
+
+// Make sure that an empty struct is treated like "char" for padding and 
alignment purposes
+struct ContainsStructWithNoFields2 {
+  StructWithNoFields s;
+  double d;
+  StructWithNoFields t;
+};
+// CHECK-MESSAGES: :[[@LINE-5]]:8: warning: accessing fields in struct 
'ContainsStructWithNoFields2' is inefficient due to padding; only needs 10 
bytes but is using 24 bytes [altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-6]]:8: note: use "__attribute__((packed))" to 
reduce the amount of padding applied to struct 'ContainsStructWithNoFields2'
+// CHECK-MESSAGES: :[[@LINE-7]]:8: warning: accessing fields in struct 
'ContainsStructWithNoFields2' is inefficient due to poor alignment; currently 
aligned to 8 bytes, but recommended alignment is 16 bytes 
[altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-8]]:8: note: use "__attribute__((aligned(16)))" to 
align struct 'ContainsStructWithNoFields2' to 16 bytes
+// CHECK-FIXES: __attribute__((packed))
+// CHECK-FIXES: __attribute__((aligned(16)));
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -170,6 +170,9 @@
   ` to work when
   the vector is a member of a structure.
 
+- Fixed nonsensical suggestion of :doc:`altera-struct-pack-align
+  ` check for empty structs.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
===
--- clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
+++ clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
@@ -77,7 +77,8 @@
   uint64_t CharSize = Result.Context->getCharWidth();
   CharUnits CurrSize = Result.Context->getASTRecordLayout(Struct).getSize();
   CharUnits MinByteSize =
-  CharUnits::fromQuantity(ceil((float)TotalBitSize / CharSize));
+  CharUnits::fromQuantity(std::max(
+  ceil(static_cast(TotalBitSize) / CharSize), 1));
   CharUnits MaxAlign = CharUnits::fromQuantity(
   ceil((float)Struct->getMaxAlignment() / CharSize));
   CharUnits CurrAlign =


Index: clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
@@ -99,3 +99,22 @@
   struct bad_align3 instantiated { 'a', 0.001, 'b' };
 }
 
+// Make sure that we don't recommend aligning an empty struct to zero bytes (PR#51620)
+struct StructWithNoFields {};
+
+struct ContainsStructWithNoFields {
+  StructWithNoFields s;
+};
+
+// Make sure that an empty struct is treated like "char" for padding and alignment purposes
+struct ContainsStructWithNoFields2 {
+  StructWithNoFields s;
+  double d;
+  StructWithNoFields t;
+};
+// CHECK-MESSAGES: :[[@LINE-5]]:8: warning: accessing fields in struct 'ContainsStructWithNoFields2' is inefficient due to padding; only needs 10 bytes but is using 24 bytes [altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-6]]:8: note: use "__attribute__((packed))" to reduce the amount of padding applied to struct 'ContainsStructWithNoFields2'
+// CHECK-MESSAGES: :[[@LINE-7]]:8: warning: accessing fields in struct 'ContainsStructWithNoFields2' is inefficient due to poor alignment; currently aligned to 8 bytes, but recommended alignment is 16 bytes [altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-8]]:8: note: use "__attribute__((aligned(16)))" to align struct 'ContainsStructWithNoFields2' to 16 bytes
+// CHECK-FIXES: __attribute__((packed))
+// CHECK-FIXES: __attribute__((aligned(16)));
Index: clang-tools-extra/docs/ReleaseNotes.rst
==

[clang-tools-extra] fb3b3f7 - [clang-tidy] Fix `readability-container-size-empty` check for smart pointers

2022-04-20 Thread Fabian Wolff via cfe-commits

Author: Fabian Wolff
Date: 2022-04-20T17:03:30+02:00
New Revision: fb3b3f76bf75875684eedfe0711424e7ceba4b41

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

LOG: [clang-tidy] Fix `readability-container-size-empty` check for smart 
pointers

Fixes https://github.com/llvm/llvm-project/issues/51118.

Reviewed By: Sockke

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst

clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
index d399c957c7c73..cc7a6834e3b6e 100644
--- a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
@@ -191,10 +191,17 @@ void ContainerSizeEmptyCheck::check(const 
MatchFinder::MatchResult &Result) {
   std::string ReplacementText = std::string(
   Lexer::getSourceText(CharSourceRange::getTokenRange(E->getSourceRange()),
*Result.SourceManager, getLangOpts()));
-  if (isBinaryOrTernary(E) || isa(E)) {
+  const auto *OpCallExpr = dyn_cast(E);
+  if (isBinaryOrTernary(E) || isa(E) ||
+  (OpCallExpr && (OpCallExpr->getOperator() == OO_Star))) {
 ReplacementText = "(" + ReplacementText + ")";
   }
-  if (E->getType()->isPointerType())
+  if (OpCallExpr &&
+  OpCallExpr->getOperator() == OverloadedOperatorKind::OO_Arrow) {
+// This can happen if the object is a smart pointer. Don't add anything
+// because a '->' is already there (PR#51776), just call the method.
+ReplacementText += "empty()";
+  } else if (E->getType()->isPointerType())
 ReplacementText += "->empty()";
   else
 ReplacementText += ".empty()";

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 491bc92f4ef38..541ff89c14803 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -173,6 +173,9 @@ Changes in existing checks
 - Fixed nonsensical suggestion of :doc:`altera-struct-pack-align
   ` check for empty structs.
 
+- Fixed incorrect suggestions for :doc:`readability-container-size-empty
+  ` when smart pointers 
are involved.
+
 Removed checks
 ^^
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
index 31dccd20427e2..0759e0308e91a 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
@@ -696,3 +696,25 @@ void instantiator() {
   instantiatedTemplateWithSizeCall();
   instantiatedTemplateWithSizeCall>();
 }
+
+namespace std {
+template 
+struct unique_ptr {
+  T *operator->() const;
+  T &operator*() const;
+};
+} // namespace std
+
+bool call_through_unique_ptr(const std::unique_ptr> &ptr) {
+  return ptr->size() > 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: the 'empty' method should be 
used
+  // CHECK-MESSAGES: :9:8: note: method 'vector'::empty() defined here
+  // CHECK-FIXES: {{^  }}return !ptr->empty();
+}
+
+bool call_through_unique_ptr_deref(const std::unique_ptr> 
&ptr) {
+  return (*ptr).size() > 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: the 'empty' method should be 
used
+  // CHECK-MESSAGES: :9:8: note: method 'vector'::empty() defined here
+  // CHECK-FIXES: {{^  }}return !(*ptr).empty();
+}



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


[PATCH] D115124: [clang-tidy] Fix `readability-container-size-empty` check for smart pointers

2022-04-20 Thread Fabian Wolff via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb3b3f76bf75: [clang-tidy] Fix 
`readability-container-size-empty` check for smart pointers (authored by 
fwolff).
Herald added a project: All.

Changed prior to commit:
  https://reviews.llvm.org/D115124?vs=400625&id=423909#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115124

Files:
  clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
@@ -696,3 +696,25 @@
   instantiatedTemplateWithSizeCall();
   instantiatedTemplateWithSizeCall>();
 }
+
+namespace std {
+template 
+struct unique_ptr {
+  T *operator->() const;
+  T &operator*() const;
+};
+} // namespace std
+
+bool call_through_unique_ptr(const std::unique_ptr> &ptr) {
+  return ptr->size() > 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: the 'empty' method should be 
used
+  // CHECK-MESSAGES: :9:8: note: method 'vector'::empty() defined here
+  // CHECK-FIXES: {{^  }}return !ptr->empty();
+}
+
+bool call_through_unique_ptr_deref(const std::unique_ptr> 
&ptr) {
+  return (*ptr).size() > 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: the 'empty' method should be 
used
+  // CHECK-MESSAGES: :9:8: note: method 'vector'::empty() defined here
+  // CHECK-FIXES: {{^  }}return !(*ptr).empty();
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -173,6 +173,9 @@
 - Fixed nonsensical suggestion of :doc:`altera-struct-pack-align
   ` check for empty structs.
 
+- Fixed incorrect suggestions for :doc:`readability-container-size-empty
+  ` when smart pointers 
are involved.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
@@ -191,10 +191,17 @@
   std::string ReplacementText = std::string(
   Lexer::getSourceText(CharSourceRange::getTokenRange(E->getSourceRange()),
*Result.SourceManager, getLangOpts()));
-  if (isBinaryOrTernary(E) || isa(E)) {
+  const auto *OpCallExpr = dyn_cast(E);
+  if (isBinaryOrTernary(E) || isa(E) ||
+  (OpCallExpr && (OpCallExpr->getOperator() == OO_Star))) {
 ReplacementText = "(" + ReplacementText + ")";
   }
-  if (E->getType()->isPointerType())
+  if (OpCallExpr &&
+  OpCallExpr->getOperator() == OverloadedOperatorKind::OO_Arrow) {
+// This can happen if the object is a smart pointer. Don't add anything
+// because a '->' is already there (PR#51776), just call the method.
+ReplacementText += "empty()";
+  } else if (E->getType()->isPointerType())
 ReplacementText += "->empty()";
   else
 ReplacementText += ".empty()";


Index: clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
@@ -696,3 +696,25 @@
   instantiatedTemplateWithSizeCall();
   instantiatedTemplateWithSizeCall>();
 }
+
+namespace std {
+template 
+struct unique_ptr {
+  T *operator->() const;
+  T &operator*() const;
+};
+} // namespace std
+
+bool call_through_unique_ptr(const std::unique_ptr> &ptr) {
+  return ptr->size() > 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: the 'empty' method should be used
+  // CHECK-MESSAGES: :9:8: note: method 'vector'::empty() defined here
+  // CHECK-FIXES: {{^  }}return !ptr->empty();
+}
+
+bool call_through_unique_ptr_deref(const std::unique_ptr> &ptr) {
+  return (*ptr).size() > 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: the 'empty' method should be used
+  // CHECK-MESSAGES: :9:8: note: method 'vector'::empty() defined here
+  // CHECK-FIXES: {{^  }}return !(*ptr).empty();
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -173,6 +173,9 @@
 - Fixed nonsensical suggestion of :doc:`altera-struct-pack-align
   ` check for empty structs.
 
+- Fixed incorrect suggestions f

[PATCH] D121868: [cc1as] Add support for emitting the build version load command for -darwin-target-variant

2022-04-20 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Hm, is adding this flag the right thing to do? Looking at clang's -S output for 
(say) ` -target arm64-apple-macos -darwin-target-variant 
arm64-apple-ios13.1-macab`, it emits lines like:

.build_version macos, 12, 0 sdk_version 12, 3
.build_version macCatalyst, 14, 0   sdk_version 15, 4

That suggests that this should be part of the .s file instead of a flag to 
cc1as (?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121868

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


[PATCH] D113499: [clang-tidy] Reduce false positives for `bugprone-infinite-loop` with dependent expressions

2022-04-20 Thread Fabian Wolff via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcce79514ff40: [clang-tidy] Reduce false positives for 
`bugprone-infinite-loop` with dependent… (authored by fwolff).
Herald added a project: All.

Changed prior to commit:
  https://reviews.llvm.org/D113499?vs=386244&id=423911#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113499

Files:
  clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -1,5 +1,5 @@
 // RUN: %check_clang_tidy %s bugprone-infinite-loop %t \
-// RUN:   -- -- -fexceptions -fblocks
+// RUN:   -- -- -fexceptions -fblocks -fno-delayed-template-parsing
 
 void simple_infinite_loop1() {
   int i = 0;
@@ -622,3 +622,31 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (size) are updated in the loop body [bugprone-infinite-loop]
   }
 }
+
+template 
+int some_template_fn() { return 1; }
+
+template 
+void test_dependent_condition() {
+  const int error = some_template_fn();
+  do {
+  } while (false && error == 0);
+
+  const int val = some_template_fn();
+  for (; !(val == 0 || true);) {
+  }
+
+  const int val2 = some_template_fn();
+  for (; !(val2 == 0 || false);) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (val2) are updated in the loop body [bugprone-infinite-loop]
+  }
+
+  const int val3 = some_template_fn();
+  do {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (val3) are updated in the loop body [bugprone-infinite-loop]
+  } while (1, (true) && val3 == 1);
+
+  const int val4 = some_template_fn();
+  do {
+  } while (1, (false) && val4 == 1);
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -176,6 +176,9 @@
 - Fixed incorrect suggestions for :doc:`readability-container-size-empty
   ` when smart pointers are involved.
 
+- Fixed some false positives in :doc:`bugprone-infinite-loop
+  ` involving dependent expressions.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
@@ -117,12 +117,32 @@
   return Result;
 }
 
-static bool isKnownFalse(const Expr &Cond, const ASTContext &Ctx) {
-  if (Cond.isValueDependent())
+static bool isKnownToHaveValue(const Expr &Cond, const ASTContext &Ctx,
+   bool ExpectedValue) {
+  if (Cond.isValueDependent()) {
+if (const auto *BinOp = dyn_cast(&Cond)) {
+  // Conjunctions (disjunctions) can still be handled if at least one
+  // conjunct (disjunct) is known to be false (true).
+  if (!ExpectedValue && BinOp->getOpcode() == BO_LAnd)
+return isKnownToHaveValue(*BinOp->getLHS(), Ctx, false) ||
+   isKnownToHaveValue(*BinOp->getRHS(), Ctx, false);
+  if (ExpectedValue && BinOp->getOpcode() == BO_LOr)
+return isKnownToHaveValue(*BinOp->getLHS(), Ctx, true) ||
+   isKnownToHaveValue(*BinOp->getRHS(), Ctx, true);
+  if (BinOp->getOpcode() == BO_Comma)
+return isKnownToHaveValue(*BinOp->getRHS(), Ctx, ExpectedValue);
+} else if (const auto *UnOp = dyn_cast(&Cond)) {
+  if (UnOp->getOpcode() == UO_LNot)
+return isKnownToHaveValue(*UnOp->getSubExpr(), Ctx, !ExpectedValue);
+} else if (const auto *Paren = dyn_cast(&Cond))
+  return isKnownToHaveValue(*Paren->getSubExpr(), Ctx, ExpectedValue);
+else if (const auto *ImplCast = dyn_cast(&Cond))
+  return isKnownToHaveValue(*ImplCast->getSubExpr(), Ctx, ExpectedValue);
 return false;
+  }
   bool Result = false;
   if (Cond.EvaluateAsBooleanCondition(Result, Ctx))
-return !Result;
+return Result == ExpectedValue;
   return false;
 }
 
@@ -144,7 +164,7 @@
   const auto *LoopStmt = Result.Nodes.getNodeAs("loop-stmt");
   const auto *Func = Result.Nodes.getNodeAs("func");
 
-  if (isKnownFalse(*Cond, *Result.Context))
+  if (isKnownToHaveValue(*Cond, *Result.Context, false))
 return;
 
   bool ShouldHaveConditionVariables = true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
ht

  1   2   3   >