[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-12-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D92361#2459513 , @zoecarver wrote:

>> I think that as long as the class leaves a copy/move constructor defaulted, 
>> there's no need for a new trivial_abi attribute.
>
> Sorry, I'm not sure I follow. Could you elaborate a bit or provide an 
> example? What do you mean by "new" trivial_abi attribute?

Sorry, I mean that I think Akira's example should be passed directly.  It 
shouldn't require its own trivial_abi attribute in order to get the treatment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D68410: [AttrDocs] document always_inline

2020-12-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri resigned from this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

Seems fine to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68410

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


[clang] c70f368 - Use basic_string::find(char) instead of basic_string::find(const char *s, size_type pos=0)

2020-12-16 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-12-16T23:28:32-08:00
New Revision: c70f36865e040840f4c4a82108f5e356d92a2923

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

LOG: Use basic_string::find(char) instead of basic_string::find(const char *s, 
size_type pos=0)

Many (StringRef) cannot be detected by clang-tidy 
performance-faster-string-find.

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang/lib/Basic/Module.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/CrossTU/CrossTranslationUnit.cpp
clang/utils/TableGen/NeonEmitter.cpp
clang/utils/TableGen/SveEmitter.cpp
lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
llvm/lib/FileCheck/FileCheck.cpp
llvm/lib/Support/Host.cpp
llvm/lib/Target/SystemZ/SystemZHazardRecognizer.cpp
llvm/tools/gold/gold-plugin.cpp
llvm/tools/llvm-lto/llvm-lto.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
index 41f38ed00fc8..4130140d549c 100644
--- a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -176,7 +176,7 @@ void MakeSmartPtrCheck::checkConstruct(SourceManager , 
ASTContext *Ctx,
   }
 
   // Find the location of the template's left angle.
-  size_t LAngle = ExprStr.find("<");
+  size_t LAngle = ExprStr.find('<');
   SourceLocation ConstructCallEnd;
   if (LAngle == StringRef::npos) {
 // If the template argument is missing (because it is part of the alias)

diff  --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 9284c5947893..2dd53b05d442 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -75,7 +75,7 @@ static bool isPlatformEnvironment(const TargetInfo , 
StringRef Feature) {
 return true;
 
   auto CmpPlatformEnv = [](StringRef LHS, StringRef RHS) {
-auto Pos = LHS.find("-");
+auto Pos = LHS.find('-');
 if (Pos == StringRef::npos)
   return false;
 SmallString<128> NewLHS = LHS.slice(0, Pos);

diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index e61daa7775f2..7adfd14a4108 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -2603,7 +2603,7 @@ static std::string qualifyWindowsLibrary(llvm::StringRef 
Lib) {
   // If the argument does not end in .lib, automatically add the suffix.
   // If the argument contains a space, enclose it in quotes.
   // This matches the behavior of MSVC.
-  bool Quote = (Lib.find(" ") != StringRef::npos);
+  bool Quote = (Lib.find(' ') != StringRef::npos);
   std::string ArgStr = Quote ? "\"" : "";
   ArgStr += Lib;
   if (!Lib.endswith_lower(".lib") && !Lib.endswith_lower(".a"))

diff  --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp 
b/clang/lib/CrossTU/CrossTranslationUnit.cpp
index 45a2a91616b8..e27779f91abc 100644
--- a/clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -157,7 +157,7 @@ parseCrossTUIndex(StringRef IndexPath) {
   unsigned LineNo = 1;
   while (std::getline(ExternalMapFile, Line)) {
 StringRef LineRef{Line};
-const size_t Delimiter = LineRef.find(" ");
+const size_t Delimiter = LineRef.find(' ');
 if (Delimiter > 0 && Delimiter != std::string::npos) {
   StringRef LookupName = LineRef.substr(0, Delimiter);
 

diff  --git a/clang/utils/TableGen/NeonEmitter.cpp 
b/clang/utils/TableGen/NeonEmitter.cpp
index e8340d976f5e..8ca5404508b1 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -382,7 +382,7 @@ class Intrinsic {
 StringRef Mods = getNextModifiers(Proto, Pos);
 while (!Mods.empty()) {
   Types.emplace_back(InTS, Mods);
-  if (Mods.find("!") != StringRef::npos)
+  if (Mods.find('!') != StringRef::npos)
 PolymorphicKeyType = Types.size() - 1;
 
   Mods = getNextModifiers(Proto, Pos);

diff  --git a/clang/utils/TableGen/SveEmitter.cpp 
b/clang/utils/TableGen/SveEmitter.cpp
index 8a705bc4b5b8..0e69600ef861 100644
--- a/clang/utils/TableGen/SveEmitter.cpp
+++ b/clang/utils/TableGen/SveEmitter.cpp
@@ -207,7 +207,7 @@ class Intrinsic {
   /// a short form without the type-specifiers, e.g. 'svld1(..)' instead of
   /// 'svld1_u32(..)'.
   static bool isOverloadedIntrinsic(StringRef Name) {
-auto BrOpen = Name.find("[");
+auto BrOpen = Name.find('[');
 auto BrClose = Name.find(']');
 return BrOpen != std::string::npos && BrClose != std::string::npos;
   }
@@ -893,14 +893,14 @@ std::string Intrinsic::mangleName(ClassKind LocalCK) 
const {
 
   if (LocalCK == ClassG) {
 // Remove 

[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-12-16 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:6502
+  // except that it has a non-trivial member *with* the trivial_abi attribute.
+  for (auto Base : D->bases()) {
+if (auto CxxRecord = Base.getType()->getAsCXXRecordDecl())

ahatanak wrote:
> zoecarver wrote:
> > ahatanak wrote:
> > > It looks like this patch changes the way `D` is passed in the following 
> > > code:
> > > 
> > > ```
> > > struct B {
> > >   int i[4];
> > >   B();
> > >   B(const B &) = default;
> > >   B(B &&);
> > > };
> > > 
> > > struct D : B {
> > >   D();
> > >   D(const D &) = default;
> > >   D(D &&) = delete;
> > > };
> > > 
> > > void testB(B a);
> > > void testD(D a);
> > > 
> > > void testCallB() {
> > >   B b;
> > >   testB(b);
> > > }
> > > 
> > > void testCallD() {
> > >   D d;
> > >   testD(d);
> > > }
> > > ```
> > > 
> > > `B` cannot be passed in registers because it has a non-trivial move 
> > > constructor, whereas `D` can be passed in registers because the move 
> > > constructor is deleted and the copy constructor is trivial.
> > > 
> > > I'm not sure what the best way to handle this is, but I just wanted to 
> > > point this out.
> > Hmm. Good catch. One way to fix this would be to simply create a 
> > `HasPassableSubobject` variable and add that to the conditions below 
> > (instead of returning false here). But, it seems that `D` isn't passed by 
> > registers (even though, maybe it should be) on ToT: 
> > https://godbolt.org/z/4xevW5 
> > 
> > Given that, do you think it's OK to return false here, or should I update 
> > this patch to use the logic I just described (even though that would be a 
> > nfc)? 
> The argument is byval, so `D` is passed directly. If you remove `-O3` and add 
> `-target aarch64`, you'll see that `[2 x i64]` is being passed
Ah, I see now. Great. Thanks. I'll update the patch. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-12-16 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:6502
+  // except that it has a non-trivial member *with* the trivial_abi attribute.
+  for (auto Base : D->bases()) {
+if (auto CxxRecord = Base.getType()->getAsCXXRecordDecl())

zoecarver wrote:
> ahatanak wrote:
> > It looks like this patch changes the way `D` is passed in the following 
> > code:
> > 
> > ```
> > struct B {
> >   int i[4];
> >   B();
> >   B(const B &) = default;
> >   B(B &&);
> > };
> > 
> > struct D : B {
> >   D();
> >   D(const D &) = default;
> >   D(D &&) = delete;
> > };
> > 
> > void testB(B a);
> > void testD(D a);
> > 
> > void testCallB() {
> >   B b;
> >   testB(b);
> > }
> > 
> > void testCallD() {
> >   D d;
> >   testD(d);
> > }
> > ```
> > 
> > `B` cannot be passed in registers because it has a non-trivial move 
> > constructor, whereas `D` can be passed in registers because the move 
> > constructor is deleted and the copy constructor is trivial.
> > 
> > I'm not sure what the best way to handle this is, but I just wanted to 
> > point this out.
> Hmm. Good catch. One way to fix this would be to simply create a 
> `HasPassableSubobject` variable and add that to the conditions below (instead 
> of returning false here). But, it seems that `D` isn't passed by registers 
> (even though, maybe it should be) on ToT: https://godbolt.org/z/4xevW5 
> 
> Given that, do you think it's OK to return false here, or should I update 
> this patch to use the logic I just described (even though that would be a 
> nfc)? 
The argument is byval, so `D` is passed directly. If you remove `-O3` and add 
`-target aarch64`, you'll see that `[2 x i64]` is being passed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-12-16 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:6502
+  // except that it has a non-trivial member *with* the trivial_abi attribute.
+  for (auto Base : D->bases()) {
+if (auto CxxRecord = Base.getType()->getAsCXXRecordDecl())

ahatanak wrote:
> It looks like this patch changes the way `D` is passed in the following code:
> 
> ```
> struct B {
>   int i[4];
>   B();
>   B(const B &) = default;
>   B(B &&);
> };
> 
> struct D : B {
>   D();
>   D(const D &) = default;
>   D(D &&) = delete;
> };
> 
> void testB(B a);
> void testD(D a);
> 
> void testCallB() {
>   B b;
>   testB(b);
> }
> 
> void testCallD() {
>   D d;
>   testD(d);
> }
> ```
> 
> `B` cannot be passed in registers because it has a non-trivial move 
> constructor, whereas `D` can be passed in registers because the move 
> constructor is deleted and the copy constructor is trivial.
> 
> I'm not sure what the best way to handle this is, but I just wanted to point 
> this out.
Hmm. Good catch. One way to fix this would be to simply create a 
`HasPassableSubobject` variable and add that to the conditions below (instead 
of returning false here). But, it seems that `D` isn't passed by registers 
(even though, maybe it should be) on ToT: https://godbolt.org/z/4xevW5 

Given that, do you think it's OK to return false here, or should I update this 
patch to use the logic I just described (even though that would be a nfc)? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-12-16 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

> I think that as long as the class leaves a copy/move constructor defaulted, 
> there's no need for a new trivial_abi attribute.

Sorry, I'm not sure I follow. Could you elaborate a bit or provide an example? 
What do you mean by "new" trivial_abi attribute?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D83979: [clang][cli] Port LangOpts option flags to new option parsing system

2020-12-16 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1001
+  "LangOpts->AccessControl", DefaultsToTrue,
+  ChangedBy,
+  ResetBy>;

`ChangedBy` are a bit verbose. How about a 
shorthand for this most common form?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83979

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


[PATCH] D92245: -fstack-clash-protection: Return an actual error when used on unsupported OS

2020-12-16 Thread Ed Maste via Phabricator via cfe-commits
emaste added a comment.

> I think it's ok to only warn on Windows.

IMO that's sensible


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92245

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


[PATCH] D91556: [OpenMPIRBuilder} Add capturing of parameters to pass to omp::parallel

2020-12-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Thanks for continuing to work on this.

Change the commit message as it is working for non integer types now, just not 
for "too many". Some more comments below.




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:119
   ///  should be placed.
-  /// \param Original The value being copied/created, should not be used in the
-  /// generated IR.
-  /// \param Inner The equivalent of \p Original that should be used in the
-  ///  generated IR; this is equal to \p Original if the value is
-  ///  a pointer and can thus be passed directly, otherwise it is
-  ///  an equivalent but different value.
+  /// \param \param Val The value beeing copied/created.
   /// \param ReplVal The replacement value, thus a copy or new created version

wasn't that a spelling error before? and one `\param` is enough ;)



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:126
   /// \param ReplVal The replacement value, thus a copy or new created version
-  ///of \p Inner.
   ///

I believe we need to keep the `Inner` parameter here. The reasons can be found 
in the discussion of D92476. Short story: The callback might have the original 
value in a map with information attached. If we pass in only the "reloaded" 
value the callback cannot determine what the original was.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:441
+  IRBuilder<>::InsertPoint CaptureAllocaInsPoint(Builder.GetInsertBlock(),
+ --Builder.GetInsertPoint());
+

How do we know that `--` is valid here? Couldn't `Loc` point to the begin of a 
function? If possible, let's just use `Loc.IP`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91556

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


[PATCH] D92788: [clangd] NFC: Use SmallVector where possible

2020-12-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: clang-tools-extra/clangd/Headers.h:139
   // Maps a file's index to that of the files it includes.
-  llvm::DenseMap> IncludeChildren;
+  llvm::DenseMap> IncludeChildren;
 };

sammccall wrote:
> kbobyrev wrote:
> > arphaman wrote:
> > > It looks like the change on this line is failing to compile on Ubuntu 
> > > 16.04 with the System GCC. 
> > > (https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04-next/23655/console).
> > > 
> > > Can I reinstate the `llvm::DenseMap>` 
> > > for now until we drop support for Ubuntu 16.04?
> > Uh, didn't see that one, I'm sorry to hear that. Yes, sure, feel free to 
> > change it to make your setup work!
> From the error message, it looks like the declarations of clang::SmallVector 
> in LLVM.h are missing the default template arguments (not sure why this is 
> different in the swift CI).
> 
> Does changing to qualifying as llvm::SmallVector work here, rather than 
> adding the explicit size? (We usually do this anyway as a matter of style)
It looks like the GCC there might have a bug and is picking up the 
`template class SmallVector;` in 
`clang/include/clang/Basic/LLVM.h` without taking the declaration from the LLVM 
headers into account. I'm not quite sure why it does that, but it seems to be 
fixed in GCC included in Ubuntu 18.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92788

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


[clang] 2e6e4e6 - [OpenMP] Add initial support for `omp [begin/end] assumes`

2020-12-16 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2020-12-16T20:02:49-06:00
New Revision: 2e6e4e6aeef71dd8fba038177a34a82b574d2126

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

LOG: [OpenMP] Add initial support for `omp [begin/end] assumes`

The `assumes` directive is an OpenMP 5.1 feature that allows the user to
provide assumptions to the optimizer. Assumptions can refer to
directives (`absent` and `contains` clauses), expressions (`holds`
clause), or generic properties (`no_openmp_routines`, `ext_ABCD`, ...).

The `assumes` spelling is used for assumptions in the global scope while
`assume` is used for executable contexts with an associated structured
block.

This patch only implements the global spellings. While clauses with
arguments are "accepted" by the parser, they will simply be ignored for
now. The implementation lowers the assumptions directly to the
`AssumptionAttr`.

Reviewed By: ABataev

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

Added: 
clang/test/OpenMP/assumes_codegen.cpp
clang/test/OpenMP/assumes_include_nvptx.cpp
clang/test/OpenMP/assumes_messages.c
clang/test/OpenMP/assumes_print.cpp
clang/test/OpenMP/assumes_template_print.cpp

Modified: 
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaOpenMP.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td
llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index c0a5a2b4c144..8f78bbfc4e70 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1291,6 +1291,16 @@ def err_expected_end_declare_target_or_variant : Error<
 def err_expected_begin_declare_variant
 : Error<"'#pragma omp end declare variant' with no matching '#pragma omp "
 "begin declare variant'">;
+def err_expected_begin_assumes
+: Error<"'#pragma omp end assumes' with no matching '#pragma omp begin 
assumes'">;
+def warn_omp_unknown_assumption_clause_missing_id
+: Warning<"valid %0 clauses start with %1; %select{token|tokens}2 will be 
ignored">,
+  InGroup;
+def warn_omp_unknown_assumption_clause_without_args
+: Warning<"%0 clause should not be followed by arguments; tokens will be 
ignored">,
+  InGroup;
+def note_omp_assumption_clause_continue_here
+: Note<"the ignored tokens spans until here">;
 def err_omp_declare_target_unexpected_clause: Error<
   "unexpected '%0' clause, only %select{'to' or 'link'|'to', 'link' or 
'device_type'}1 clauses expected">;
 def err_omp_expected_clause: Error<

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 73943ed5f0a6..02aab3b43be0 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -3104,6 +3104,13 @@ class Parser : public CodeCompletionHandler {
   void ParseOMPDeclareVariantClauses(DeclGroupPtrTy Ptr, CachedTokens ,
  SourceLocation Loc);
 
+  /// Parse 'omp [begin] assume[s]' directive.
+  void ParseOpenMPAssumesDirective(OpenMPDirectiveKind DKind,
+   SourceLocation Loc);
+
+  /// Parse 'omp end assumes' directive.
+  void ParseOpenMPEndAssumesDirective(SourceLocation Loc);
+
   /// Parse clauses for '#pragma omp declare target'.
   DeclGroupPtrTy ParseOMPDeclareTargetClauses();
   /// Parse '#pragma omp end declare target'.

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index eb6429912bf6..ff0257634d9d 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10128,6 +10128,13 @@ class Sema final {
   /// The current `omp begin/end declare variant` scopes.
   SmallVector OMPDeclareVariantScopes;
 
+  /// The current `omp begin/end assumes` scopes.
+  SmallVector OMPAssumeScoped;
+
+  /// All `omp assumes` we encountered so far.
+  SmallVector OMPAssumeGlobal;
+
+public:
   /// The declarator \p D defines a function in the scope \p S which is nested
   /// in an `omp begin/end declare variant` scope. In this method we create a
   /// declaration for \p D and rename \p D according to the OpenMP context
@@ -10141,10 +10148,11 @@ class Sema final {
   void ActOnFinishedFunctionDefinitionInOpenMPDeclareVariantScope(
   Decl *D, SmallVectorImpl );
 
-public:
+  /// Act on \p D, a function definition inside of an `omp [begin/end] 
assumes`.
+  void ActOnFinishedFunctionDefinitionInOpenMPAssumeScope(Decl *D);
 

[PATCH] D93436: [clangd] Print .clang-tidy configuration parsing errors using [ev]?log.

2020-12-16 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
njames93 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

Currently warnings when parsing .clang-tidy are printed directly to errs.
This is less than ideal as there is no synchronisation printing to errs, 
leading to potential races.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93436

Files:
  clang-tools-extra/clangd/TidyProvider.cpp


Index: clang-tools-extra/clangd/TidyProvider.cpp
===
--- clang-tools-extra/clangd/TidyProvider.cpp
+++ clang-tools-extra/clangd/TidyProvider.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Process.h"
+#include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include 
 
@@ -44,8 +45,25 @@
 [this](llvm::Optional Data) {
   Value.reset();
   if (Data && !Data->empty()) {
-if (auto Parsed = tidy::parseConfiguration(
-llvm::MemoryBufferRef(*Data, path(
+tidy::DiagCallback Diagnostics = [](const llvm::SMDiagnostic ) {
+  switch (D.getKind()) {
+  case llvm::SourceMgr::DK_Error:
+elog("tidy-config error at {0}:{1}:{2}: {3}", D.getFilename(),
+ D.getLineNo(), D.getColumnNo(), D.getMessage());
+break;
+  case llvm::SourceMgr::DK_Warning:
+log("tidy-config warning at {0}:{1}:{2}: {3}", D.getFilename(),
+D.getLineNo(), D.getColumnNo(), D.getMessage());
+break;
+  case llvm::SourceMgr::DK_Note:
+  case llvm::SourceMgr::DK_Remark:
+vlog("tidy-config note at {0}:{1}:{2}: {3}", D.getFilename(),
+ D.getLineNo(), D.getColumnNo(), D.getMessage());
+break;
+  }
+};
+if (auto Parsed = tidy::parseConfigurationWithDiags(
+llvm::MemoryBufferRef(*Data, path()), Diagnostics))
   Value = std::make_shared(
   std::move(*Parsed));
 else


Index: clang-tools-extra/clangd/TidyProvider.cpp
===
--- clang-tools-extra/clangd/TidyProvider.cpp
+++ clang-tools-extra/clangd/TidyProvider.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Process.h"
+#include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include 
 
@@ -44,8 +45,25 @@
 [this](llvm::Optional Data) {
   Value.reset();
   if (Data && !Data->empty()) {
-if (auto Parsed = tidy::parseConfiguration(
-llvm::MemoryBufferRef(*Data, path(
+tidy::DiagCallback Diagnostics = [](const llvm::SMDiagnostic ) {
+  switch (D.getKind()) {
+  case llvm::SourceMgr::DK_Error:
+elog("tidy-config error at {0}:{1}:{2}: {3}", D.getFilename(),
+ D.getLineNo(), D.getColumnNo(), D.getMessage());
+break;
+  case llvm::SourceMgr::DK_Warning:
+log("tidy-config warning at {0}:{1}:{2}: {3}", D.getFilename(),
+D.getLineNo(), D.getColumnNo(), D.getMessage());
+break;
+  case llvm::SourceMgr::DK_Note:
+  case llvm::SourceMgr::DK_Remark:
+vlog("tidy-config note at {0}:{1}:{2}: {3}", D.getFilename(),
+ D.getLineNo(), D.getColumnNo(), D.getMessage());
+break;
+  }
+};
+if (auto Parsed = tidy::parseConfigurationWithDiags(
+llvm::MemoryBufferRef(*Data, path()), Diagnostics))
   Value = std::make_shared(
   std::move(*Parsed));
 else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92800: [Clang] Make nomerge attribute a function attribute as well as a statement attribute.

2020-12-16 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added inline comments.



Comment at: clang/utils/TableGen/ClangAttrEmitter.cpp:3438-3439
   }
+  if (DeclOrStmt)
+DiagList.push_back("statements");
 }

aaron.ballman wrote:
> I think this will do the wrong thing when the subject list has more than one 
> entry (I think this will add `statements` to the list once for each subject). 
> As an experiment, can you add `ObjCMethod` to the list of subjects for 
> `NoMerge` in Attr.td? Do the resulting diagnostics list "statements" once or 
> twice?
> 
> Thinking a bit deeper on this -- I think my original advice may have been too 
> ambitious (we don't yet have support for automatically grabbing the names of 
> statements for diagnostics like we do for declarations). Trying to add that 
> as part of this patch would be a big ask, so I think a better approach is to 
> use a custom diagnostic in Attr.td. I'll add a comment there to this effect.
You're right. If I just add `ObjCMethod` to the list of subjects for `NoMerge`, 
the "statements" shows twice in the diag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92800

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


[PATCH] D92800: [Clang] Make nomerge attribute a function attribute as well as a statement attribute.

2020-12-16 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 312348.
zequanwu marked 2 inline comments as done.
zequanwu added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92800

Files:
  clang/include/clang/AST/Attr.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-nomerge.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-nomerge.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp
  llvm/include/llvm/IR/Attributes.td

Index: llvm/include/llvm/IR/Attributes.td
===
--- llvm/include/llvm/IR/Attributes.td
+++ llvm/include/llvm/IR/Attributes.td
@@ -121,7 +121,7 @@
 /// Function is called early and/or often, so lazy binding isn't worthwhile.
 def NonLazyBind : EnumAttr<"nonlazybind">;
 
-/// Disable merging for call sites
+/// Disable merging for specified functions or call sites.
 def NoMerge : EnumAttr<"nomerge">;
 
 /// Pointer is known to be not null.
Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -2682,6 +2682,7 @@
   { "ATTR", "Attr" },
   { "TYPE_ATTR", "TypeAttr" },
   { "STMT_ATTR", "StmtAttr" },
+  { "DECL_OR_STMT_ATTR", "DeclOrStmtAttr" },
   { "INHERITABLE_ATTR", "InheritableAttr" },
   { "DECL_OR_TYPE_ATTR", "DeclOrTypeAttr" },
   { "INHERITABLE_PARAM_ATTR", "InheritableParamAttr" },
@@ -3767,7 +3768,8 @@
 OS << (Attr.isSubClassOf("TypeAttr") ||
Attr.isSubClassOf("DeclOrTypeAttr")) << ";\n";
 OS << "IsStmt = ";
-OS << Attr.isSubClassOf("StmtAttr") << ";\n";
+OS << (Attr.isSubClassOf("StmtAttr") || Attr.isSubClassOf("DeclOrStmtAttr"))
+   << ";\n";
 OS << "IsKnownToGCC = ";
 OS << IsKnownToGCC(Attr) << ";\n";
 OS << "IsSupportedByPragmaAttribute = ";
Index: clang/test/Sema/attr-nomerge.cpp
===
--- clang/test/Sema/attr-nomerge.cpp
+++ clang/test/Sema/attr-nomerge.cpp
@@ -8,10 +8,10 @@
   int x;
   [[clang::nomerge]] x = 10; // expected-warning {{nomerge attribute is ignored because there exists no call expression inside the statement}}
 
-  [[clang::nomerge]] label: bar(); // expected-error {{'nomerge' attribute cannot be applied to a declaration}}
+  [[clang::nomerge]] label: bar(); // expected-error {{'nomerge' attribute only applies to functions and statements}}
 
 }
 
-int f();
+[[clang::nomerge]] int f();
 
-[[clang::nomerge]] static int i = f(); // expected-error {{'nomerge' attribute cannot be applied to a declaration}}
+[[clang::nomerge]] static int i = f(); // expected-error {{'nomerge' attribute only applies to functions and statements}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -90,6 +90,7 @@
 // CHECK-NEXT: NoEscape (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NoInline (SubjectMatchRule_function)
 // CHECK-NEXT: NoInstrumentFunction (SubjectMatchRule_function)
+// CHECK-NEXT: NoMerge (SubjectMatchRule_function)
 // CHECK-NEXT: NoMicroMips (SubjectMatchRule_function)
 // CHECK-NEXT: NoMips16 (SubjectMatchRule_function)
 // CHECK-NEXT: NoSanitize (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_variable_is_global)
Index: clang/test/CodeGen/attr-nomerge.cpp
===
--- clang/test/CodeGen/attr-nomerge.cpp
+++ clang/test/CodeGen/attr-nomerge.cpp
@@ -1,9 +1,23 @@
 // RUN: %clang_cc1 -S -emit-llvm %s -triple x86_64-unknown-linux-gnu -o - | FileCheck %s
 
-bool bar();
-void f(bool, bool);
+class A {
+public:
+  [[clang::nomerge]] A();
+  [[clang::nomerge]] ~A();
+  [[clang::nomerge]] void f();
+  [[clang::nomerge]] virtual void g();
+  [[clang::nomerge]] static void f1();
+};
 
-void foo(int i) {
+class B : public A {
+public:
+  void g() override;
+};
+
+[[clang::nomerge]] bool bar();
+[[clang::nomerge]] void f(bool, bool);
+
+void foo(int i, A *ap, B *bp) {
   [[clang::nomerge]] bar();
   [[clang::nomerge]] (i = 4, bar());
   [[clang::nomerge]] (void)(bar());
@@ -12,18 +26,68 @@
   [[clang::nomerge]] for (bar(); bar(); bar()) {}
   [[clang::nomerge]] { asm("nop"); }
   bar();
+
+  ap->g();
+  bp->g();
+
+  A a;
+  a.f();
+  a.g();
+  A::f1();
+
+  B b;
+  b.g();
+}
+
+int g(int i);
+
+void something() {
+  g(1);
+}
+
+[[clang::nomerge]] int g(int i);
+
+void something_else() {
+  g(1);
+}
+
+int g(int i) { return i; }
+
+void 

[PATCH] D93264: [CSSPGO] Introducing distribution factor for pseudo probe.

2020-12-16 Thread Hongtao Yu via Phabricator via cfe-commits
hoy updated this revision to Diff 312339.
hoy added a comment.

Rebasing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93264

Files:
  clang/test/CodeGen/pseudo-probe-emit.c
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/PseudoProbe.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
  llvm/lib/IR/PseudoProbe.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
  llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-update.prof
  llvm/test/Transforms/SampleProfile/pseudo-probe-emit-inline.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-update.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll

Index: llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll
===
--- /dev/null
+++ llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll
@@ -0,0 +1,77 @@
+; REQUIRES: x86_64-linux
+; RUN: opt < %s -passes='pseudo-probe,loop-unroll-full' -verify-pseudo-probe -S -o %t 2>&1 | FileCheck %s --check-prefix=VERIFY
+; RUN: FileCheck %s < %t
+
+; VERIFY: *** Pseudo Probe Verification After LoopFullUnrollPass ***
+; VERIFY: Function foo:
+; VERIFY-DAG: Probe 6	previous factor 1.00	current factor 5.00
+; VERIFY-DAG: Probe 4	previous factor 1.00	current factor 5.00
+
+declare void @foo2() nounwind
+
+define void @foo(i32 %x) {
+bb:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 1, i32 0, i64 -1)
+  %tmp = alloca [5 x i32*], align 16
+  br label %bb7.preheader
+
+bb3.loopexit:
+  %spec.select.lcssa = phi i32 [ %spec.select, %bb10 ]
+  %tmp5.not = icmp eq i32 %spec.select.lcssa, 0
+  br i1 %tmp5.not, label %bb24, label %bb7.preheader
+
+bb7.preheader:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 3, i32 0, i64 -1)
+  %tmp1.06 = phi i32 [ 5, %bb ], [ %spec.select.lcssa, %bb3.loopexit ]
+  br label %bb10
+
+bb10:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 2, i32 0, i64 -1)
+  %indvars.iv = phi i64 [ 0, %bb7.preheader ], [ %indvars.iv.next, %bb10 ]
+  %tmp1.14 = phi i32 [ %tmp1.06, %bb7.preheader ], [ %spec.select, %bb10 ]
+  %tmp13 = getelementptr inbounds [5 x i32*], [5 x i32*]* %tmp, i64 0, i64 %indvars.iv
+  %tmp14 = load i32*, i32** %tmp13, align 8
+  %tmp15.not = icmp ne i32* %tmp14, null
+  %tmp18 = sext i1 %tmp15.not to i32
+  %spec.select = add nsw i32 %tmp1.14, %tmp18
+  call void @foo2(), !dbg !12
+  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+  %exitcond.not = icmp eq i64 %indvars.iv.next, 5
+  br i1 %exitcond.not, label %bb3.loopexit, label %bb10, !llvm.loop !13
+
+bb24:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 5, i32 0, i64 -1)
+  ret void
+}
+
+;; A discriminator of 186646583 which is 0xb200037 in hexdecimal, stands for a direct call probe
+;; with an index of 6 and a scale of -1%.
+; CHECK: ![[#PROBE6]] = !DILocation(line: 2, column: 20, scope: ![[#SCOPE:]])
+; CHECK: ![[#SCOPE]] = !DILexicalBlockFile(scope: ![[#]], file: ![[#]], discriminator: 186646583)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!9, !10}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: 1, enums: !2)
+!1 = !DIFile(filename: "test.c", directory: "")
+!2 = !{}
+!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0, retainedNodes: !2)
+!5 = !DISubroutineType(types: !6)
+!6 = !{!7}
+!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!9 = !{i32 2, !"Dwarf Version", i32 4}
+!10 = !{i32 2, !"Debug Info Version", i32 3}
+!11 = !{!"clang version 3.9.0"}
+!12 = !DILocation(line: 2, column: 20, scope: !4)
+!13 = distinct !{!13, !14}
+!14 = !{!"llvm.loop.unroll.full"}
Index: llvm/test/Transforms/SampleProfile/pseudo-probe-update.ll
===
--- /dev/null
+++ 

[PATCH] D93428: [AArch64] Add bti note property when compiling asm files with -mbranch-protection=bti

2020-12-16 Thread Ana Pazos via Phabricator via cfe-commits
apazos added a comment.

So the intention here is to generate the property when BTI branch protection is 
enabled, to guarantee the generate .o indeed has the property set, without 
requiring to pass the flag -mmark-bti-property explicitly. This is convenient 
for users.

Or is there a clear reason why one would enable BIT branch protection and not 
have the property set? What would be that use case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93428

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


[PATCH] D93428: [AArch64] Add bti note property when compiling asm files with -mbranch-protection=bti

2020-12-16 Thread Stephen Long via Phabricator via cfe-commits
steplong created this revision.
Herald added subscribers: danielkiss, kristof.beyls.
steplong requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Generate the .note.gnu.property section with GNU_PROPERTY_AARCH64_FEATURE_1_BTI
when compiling assembly files with -mbranch-protection=bti.

See https://reviews.llvm.org/D81930 for generating the section when compiling
C/C++ files with -mbranch-protection=bti.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93428

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/test/Driver/arm64-markbti.S


Index: clang/test/Driver/arm64-markbti.S
===
--- clang/test/Driver/arm64-markbti.S
+++ clang/test/Driver/arm64-markbti.S
@@ -1,10 +1,12 @@
 // REQUIRES: aarch64-registered-target
 
-// When -mmark-bti-property is passed the generated file object gets BTI 
marking.
+// When -mmark-bti-property or -mbranch-protection=bti is passed the generated 
file object gets BTI marking.
 // RUN: %clang -target arm64-linux-none -mmark-bti-property -c -o - %s | 
llvm-readobj -n - | FileCheck -check-prefix=CHECK  -check-prefix=CHECK_GEN %s
 // RUN: %clang -target arm64-linux-none -DNOTE_PRESENT -c %s -o - | 
llvm-readobj -n - | FileCheck -check-prefix=CHECK  -check-prefix=CHECK_PRESET %s
 // RUN: %clang -target arm64-linux-none -mmark-bti-property -DNOTE_PRESENT -c 
%s -o - | llvm-readobj -n - | FileCheck -check-prefix=CHECK  
-check-prefix=CHECK_PRESET %s
 // RUN: %clang -target arm64-linux-none -mmark-bti-property -DNOTE_PRESENT -c 
%s -o - 2>&1 |  FileCheck -check-prefix=CHECK_WARNING %s
+// RUN: %clang -target arm64-linux-none -mbranch-protection=bti -c -o - %s | 
llvm-readobj -n - | FileCheck -check-prefix=CHECK  -check-prefix=CHECK_GEN %s
+// RUN: %clang -target arm64-linux-none -mbranch-protection=bti -DNOTE_PRESENT 
-c %s -o - 2>&1 |  FileCheck -check-prefix=CHECK_WARNING %s
 //
 // CHECK_WARNING: The .note.gnu.property is not emitted because it is already 
present.
 // CHECK: Name: .note.gnu.property
Index: clang/lib/Driver/ToolChains/Clang.h
===
--- clang/lib/Driver/ToolChains/Clang.h
+++ clang/lib/Driver/ToolChains/Clang.h
@@ -128,6 +128,8 @@
 llvm::opt::ArgStringList ) const;
   void AddRISCVTargetArgs(const llvm::opt::ArgList ,
   llvm::opt::ArgStringList ) const;
+  void AddAArch64TargetArgs(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const;
   bool hasGoodDiagnostics() const override { return true; }
   bool hasIntegratedAssembler() const override { return false; }
   bool hasIntegratedCPP() const override { return false; }
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7015,6 +7015,29 @@
   CmdArgs.push_back(ABIName.data());
 }
 
+void ClangAs::AddAArch64TargetArgs(const ArgList ,
+   ArgStringList ) const {
+  bool BranchTargetEnforce = false;
+  const auto  = getToolChain().getDriver();
+
+  if (Arg *A = Args.getLastArg(options::OPT_mbranch_protection_EQ)) {
+StringRef Err;
+llvm::AArch64::ParsedBranchProtection PBP;
+
+if (!llvm::AArch64::parseBranchProtection(A->getValue(), PBP, Err)) {
+  D.Diag(diag::err_invalid_branch_protection)
+  << Err << A->getAsString(Args);
+} else {
+  BranchTargetEnforce = PBP.BranchTargetEnforcement;
+}
+  }
+
+  if (Args.hasArg(options::OPT_mmark_bti_property) || BranchTargetEnforce) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-aarch64-mark-bti-property");
+  }
+}
+
 void ClangAs::ConstructJob(Compilation , const JobAction ,
const InputInfo , const InputInfoList 
,
const ArgList ,
@@ -7193,10 +7216,7 @@
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_32:
   case llvm::Triple::aarch64_be:
-if (Args.hasArg(options::OPT_mmark_bti_property)) {
-  CmdArgs.push_back("-mllvm");
-  CmdArgs.push_back("-aarch64-mark-bti-property");
-}
+AddAArch64TargetArgs(Args, CmdArgs);
 break;
 
   case llvm::Triple::riscv32:


Index: clang/test/Driver/arm64-markbti.S
===
--- clang/test/Driver/arm64-markbti.S
+++ clang/test/Driver/arm64-markbti.S
@@ -1,10 +1,12 @@
 // REQUIRES: aarch64-registered-target
 
-// When -mmark-bti-property is passed the generated file object gets BTI marking.
+// When -mmark-bti-property or -mbranch-protection=bti is passed the generated file object gets BTI marking.
 // RUN: %clang -target arm64-linux-none -mmark-bti-property -c -o - %s | llvm-readobj -n - | FileCheck -check-prefix=CHECK  -check-prefix=CHECK_GEN %s
 // 

[clang-tools-extra] ddffcdf - [clang-tidy] Add a diagnostic callback to parseConfiguration

2020-12-16 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-12-17T00:24:58Z
New Revision: ddffcdf0a6603747a6734dcf23dfe81476b5523c

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

LOG: [clang-tidy] Add a diagnostic callback to parseConfiguration

Currently errors detected when parsing the YAML for .clang-tidy files are 
always printed to errs.
For clang-tidy binary workflows this usually isn't an issue, but using 
clang-tidy as a library for integrations may want to handle displaying those 
errors in their own specific way.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/clang-tidy/ClangTidyOptions.h
clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index f17ef716d60f..197552acf927 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -13,6 +13,7 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBufferRef.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/YAMLTraits.h"
 #include "llvm/Support/raw_ostream.h"
@@ -390,6 +391,22 @@ parseConfiguration(llvm::MemoryBufferRef Config) {
   return Options;
 }
 
+static void diagHandlerImpl(const llvm::SMDiagnostic , void *Ctx) {
+  (*reinterpret_cast(Ctx))(Diag);
+};
+
+llvm::ErrorOr
+parseConfigurationWithDiags(llvm::MemoryBufferRef Config,
+DiagCallback Handler) {
+  llvm::yaml::Input Input(Config, nullptr, Handler ? diagHandlerImpl : nullptr,
+  );
+  ClangTidyOptions Options;
+  Input >> Options;
+  if (Input.error())
+return Input.error();
+  return Options;
+}
+
 std::string configurationAsText(const ClangTidyOptions ) {
   std::string Text;
   llvm::raw_string_ostream Stream(Text);

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.h 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
index e7cd89951ff9..d8a4a14f5b52 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -14,6 +14,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/MemoryBufferRef.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include 
 #include 
@@ -311,6 +312,11 @@ std::error_code parseLineFilter(llvm::StringRef LineFilter,
 llvm::ErrorOr
 parseConfiguration(llvm::MemoryBufferRef Config);
 
+using DiagCallback = llvm::function_ref;
+
+llvm::ErrorOr
+parseConfigurationWithDiags(llvm::MemoryBufferRef Config, DiagCallback 
Handler);
+
 /// Serializes configuration to a YAML-encoded string.
 std::string configurationAsText(const ClangTidyOptions );
 

diff  --git a/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt 
b/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
index 5b0cbac3a61e..be35b71d15cf 100644
--- a/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ b/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   FrontendOpenMP
   Support
+  TestingSupport
   )
 
 get_filename_component(CLANG_LINT_SOURCE_DIR

diff  --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp 
b/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
index db9624684dfe..6447f34661e9 100644
--- a/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -2,6 +2,9 @@
 #include "ClangTidyCheck.h"
 #include "ClangTidyDiagnosticConsumer.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Testing/Support/Annotations.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -123,6 +126,100 @@ TEST(ParseConfiguration, MergeConfigurations) {
   EXPECT_TRUE(*Options.UseColor);
 }
 
+namespace {
+class DiagCollecter {
+public:
+  struct Diag {
+  private:
+static size_t posToOffset(const llvm::SMLoc Loc,
+  const llvm::SourceMgr *Src) {
+  return Loc.getPointer() -
+ Src->getMemoryBuffer(Src->FindBufferContainingLoc(Loc))
+ ->getBufferStart();
+}
+
+  public:
+Diag(const llvm::SMDiagnostic )
+: Message(D.getMessage()), Kind(D.getKind()),
+  Pos(posToOffset(D.getLoc(), D.getSourceMgr())) {
+  if (!D.getRanges().empty()) {
+// Ranges are stored as column numbers on the line that has the error.
+

[PATCH] D92920: [clang-tidy] Add a diagnostic callback to parseConfiguration

2020-12-16 Thread Nathan James 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 rGddffcdf0a660: [clang-tidy] Add a diagnostic callback to 
parseConfiguration (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92920

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -2,6 +2,9 @@
 #include "ClangTidyCheck.h"
 #include "ClangTidyDiagnosticConsumer.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Testing/Support/Annotations.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -123,6 +126,100 @@
   EXPECT_TRUE(*Options.UseColor);
 }
 
+namespace {
+class DiagCollecter {
+public:
+  struct Diag {
+  private:
+static size_t posToOffset(const llvm::SMLoc Loc,
+  const llvm::SourceMgr *Src) {
+  return Loc.getPointer() -
+ Src->getMemoryBuffer(Src->FindBufferContainingLoc(Loc))
+ ->getBufferStart();
+}
+
+  public:
+Diag(const llvm::SMDiagnostic )
+: Message(D.getMessage()), Kind(D.getKind()),
+  Pos(posToOffset(D.getLoc(), D.getSourceMgr())) {
+  if (!D.getRanges().empty()) {
+// Ranges are stored as column numbers on the line that has the error.
+unsigned Offset = Pos - D.getColumnNo();
+Range.emplace();
+Range->Begin = Offset + D.getRanges().front().first,
+Range->End = Offset + D.getRanges().front().second;
+  }
+}
+std::string Message;
+llvm::SourceMgr::DiagKind Kind;
+size_t Pos;
+Optional Range;
+
+friend void PrintTo(const Diag , std::ostream *OS) {
+  *OS << (D.Kind == llvm::SourceMgr::DK_Error ? "error: " : "warning: ")
+  << D.Message << "@" << llvm::to_string(D.Pos);
+  if (D.Range)
+*OS << ":[" << D.Range->Begin << ", " << D.Range->End << ")";
+}
+  };
+
+  DiagCollecter() = default;
+  DiagCollecter(const DiagCollecter &) = delete;
+
+  std::function
+  getCallback(bool Clear = true) & {
+if (Clear)
+  Diags.clear();
+return [&](const llvm::SMDiagnostic ) { Diags.emplace_back(Diag); };
+  }
+
+  std::function
+  getCallback(bool Clear = true) && = delete;
+
+  llvm::ArrayRef getDiags() const { return Diags; }
+
+private:
+  std::vector Diags;
+};
+
+MATCHER_P(DiagMessage, M, "") { return arg.Message == M; }
+MATCHER_P(DiagKind, K, "") { return arg.Kind == K; }
+MATCHER_P(DiagPos, P, "") { return arg.Pos == P; }
+MATCHER_P(DiagRange, P, "") { return arg.Range && *arg.Range == P; }
+} // namespace
+
+using ::testing::AllOf;
+using ::testing::ElementsAre;
+
+TEST(ParseConfiguration, CollectDiags) {
+  DiagCollecter Collector;
+  auto ParseWithDiags = [&](llvm::StringRef Buffer) {
+return parseConfigurationWithDiags(llvm::MemoryBufferRef(Buffer, "Options"),
+   Collector.getCallback());
+  };
+  llvm::Annotations Options(R"(
+[[Check]]: llvm-include-order
+  )");
+  llvm::ErrorOr ParsedOpt = ParseWithDiags(Options.code());
+  EXPECT_TRUE(!ParsedOpt);
+  EXPECT_THAT(Collector.getDiags(),
+  testing::ElementsAre(AllOf(DiagMessage("unknown key 'Check'"),
+ DiagKind(llvm::SourceMgr::DK_Error),
+ DiagPos(Options.range().Begin),
+ DiagRange(Options.range();
+
+  Options = llvm::Annotations(R"(
+UseColor: [[NotABool]]
+  )");
+  ParsedOpt = ParseWithDiags(Options.code());
+  EXPECT_TRUE(!ParsedOpt);
+  EXPECT_THAT(Collector.getDiags(),
+  testing::ElementsAre(AllOf(DiagMessage("invalid boolean"),
+ DiagKind(llvm::SourceMgr::DK_Error),
+ DiagPos(Options.range().Begin),
+ DiagRange(Options.range();
+}
+
 namespace {
 class TestCheck : public ClangTidyCheck {
 public:
Index: clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   FrontendOpenMP
   Support
+  TestingSupport
   )
 
 get_filename_component(CLANG_LINT_SOURCE_DIR
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h

[PATCH] D90507: [Driver] Add DWARF64 flag: -gdwarf64

2020-12-16 Thread Alexander Yermolovich via Phabricator via cfe-commits
ayermolo updated this revision to Diff 312327.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90507

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/debug-options.c

Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -374,3 +374,20 @@
 // RUN:| FileCheck -check-prefix=NO_DEBUG_UNUSED_TYPES %s
 // NO_DEBUG_UNUSED_TYPES: "-debug-info-kind={{limited|line-tables-only|standalone}}"
 // NO_DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=unused-types"
+//
+// VALIDT: x86_64
+// RUN: %clang -### -c -gdwarf-5 -gdwarf64 -target VALIDT %s 2>&1 | FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -c -gdwarf-4 -gdwarf64 -target VALIDT %s 2>&1 | FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -c -gdwarf-3 -gdwarf64 -target VALIDT %s 2>&1 | FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -c -gdwarf-2 -gdwarf64 -target VALIDT %s 2>&1 | FileCheck -check-prefix=GDWARF64_OFF %s
+// RUN: %clang -### -c -gdwarf-4 -gdwarf64 -target VALIDT -target VALIDT %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -c -gdwarf-4 -gdwarf64 -target i386-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_32ARCH %s
+// RUN: %clang -### -c -gdwarf-4 -gdwarf64 -target x86_64-apple-darwin %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_ELF %s
+//
+// GDWARF64_ON:  "-gdwarf64"
+// GDWARF64_OFF:  error: invalid argument '-gdwarf64' only allowed with 'DWARFv3 or greater'
+// GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 bit architecture'
+// GDWARF64_ELF: error: invalid argument '-gdwarf64' only allowed with 'ELF platforms'
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1024,6 +1024,7 @@
   Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping, false);
   Opts.DumpCoverageMapping = Args.hasArg(OPT_dump_coverage_mapping);
   Opts.AsmVerbose = !Args.hasArg(OPT_fno_verbose_asm);
+  Opts.Dwarf64 = Args.hasArg(OPT_gdwarf64);
   Opts.PreserveAsmComments = !Args.hasArg(OPT_fno_preserve_as_comments);
   Opts.AssumeSaneOperatorNew = !Args.hasArg(OPT_fno_assume_sane_operator_new);
   Opts.ObjCAutoRefCountExceptions = Args.hasArg(OPT_fobjc_arc_exceptions);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4013,6 +4013,24 @@
   if (DebuggerTuning == llvm::DebuggerKind::SCE)
 CmdArgs.push_back("-dwarf-explicit-import");
 
+  auto *dwarfArgs =
+  Args.getLastArg(options::OPT_gdwarf64, options::OPT_gdwarf32);
+  if (dwarfArgs && dwarfArgs->getOption().matches(options::OPT_gdwarf64)) {
+const llvm::Triple  = TC.getTriple();
+if (EffectiveDWARFVersion < 3)
+  D.Diag(diag::err_drv_argument_only_allowed_with)
+  << dwarfArgs->getAsString(Args) << "DWARFv3 or greater";
+else if (!RawTriple.isArch64Bit())
+  D.Diag(diag::err_drv_argument_only_allowed_with)
+  << dwarfArgs->getAsString(Args) << "64 bit architecture";
+else if (!RawTriple.isOSBinFormatELF())
+  D.Diag(diag::err_drv_argument_only_allowed_with)
+  << dwarfArgs->getAsString(Args) << "ELF platforms";
+  }
+
+  if (dwarfArgs)
+dwarfArgs->render(Args, CmdArgs);
+
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
 
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -570,6 +570,7 @@
   Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
   Options.MCOptions.MCNoWarn = CodeGenOpts.NoWarn;
   Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
+  Options.MCOptions.Dwarf64 = CodeGenOpts.Dwarf64;
   Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments;
   Options.MCOptions.ABIName = TargetOpts.ABI;
   for (const auto  : HSOpts.UserEntries)
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2423,6 +2423,10 @@
   HelpText<"Generate source-level debug information with dwarf version 4">;
 def gdwarf_5 : Flag<["-"], "gdwarf-5">, Group,
   HelpText<"Generate source-level debug information with dwarf version 5">;
+def gdwarf64 : Flag<["-"], "gdwarf64">, Group, Flags<[CC1Option]>,
+  

[PATCH] D92600: [ASTImporter] Add support for importing GenericSelectionExpr AST nodes.

2020-12-16 Thread Tom Roeder 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 rG1844ab770cb9: [ASTImporter] Add support for importing 
GenericSelectionExpr AST nodes. (authored by tmroeder).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92600

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/lib/Analysis/ExprMutationAnalyzer.cpp
  clang/test/ASTMerge/generic-selection-expr/Inputs/generic.c
  clang/test/ASTMerge/generic-selection-expr/Inputs/generic.cpp
  clang/test/ASTMerge/generic-selection-expr/test.c
  clang/test/ASTMerge/generic-selection-expr/test.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/StructuralEquivalenceTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -982,6 +982,11 @@
   EXPECT_TRUE(matches("int* i = __null;", gnuNullExpr()));
 }
 
+TEST_P(ASTMatchersTest, GenericSelectionExpr) {
+  EXPECT_TRUE(matches("void f() { (void)_Generic(1, int: 1, float: 2.0); }",
+  genericSelectionExpr()));
+}
+
 TEST_P(ASTMatchersTest, AtomicExpr) {
   EXPECT_TRUE(matches("void foo() { int *ptr; __atomic_load_n(ptr, 1); }",
   atomicExpr()));
Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -1598,6 +1598,72 @@
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
+TEST_F(StructuralEquivalenceStmtTest, GenericSelectionExprSame) {
+  auto t = makeWrappedStmts("_Generic(0u, unsigned int: 0, float: 1)",
+"_Generic(0u, unsigned int: 0, float: 1)", Lang_C99,
+genericSelectionExpr());
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceStmtTest, GenericSelectionExprSignsDiffer) {
+  auto t = makeWrappedStmts("_Generic(0u, unsigned int: 0, float: 1)",
+"_Generic(0, int: 0, float: 1)", Lang_C99,
+genericSelectionExpr());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceStmtTest, GenericSelectionExprOrderDiffers) {
+  auto t = makeWrappedStmts("_Generic(0u, unsigned int: 0, float: 1)",
+"_Generic(0u, float: 1, unsigned int: 0)", Lang_C99,
+genericSelectionExpr());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceStmtTest, GenericSelectionExprDependentResultSame) {
+  auto t = makeStmts(
+  R"(
+  template 
+  void f() {
+T x;
+(void)_Generic(x, int: 0, float: 1);
+  }
+  void g() { f(); }
+  )",
+  R"(
+  template 
+  void f() {
+T x;
+(void)_Generic(x, int: 0, float: 1);
+  }
+  void g() { f(); }
+  )",
+  Lang_CXX03, genericSelectionExpr());
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceStmtTest,
+   GenericSelectionExprDependentResultOrderDiffers) {
+  auto t = makeStmts(
+  R"(
+  template 
+  void f() {
+T x;
+(void)_Generic(x, float: 1, int: 0);
+  }
+  void g() { f(); }
+  )",
+  R"(
+  template 
+  void f() {
+T x;
+(void)_Generic(x, int: 0, float: 1);
+  }
+  void g() { f(); }
+  )",
+  Lang_CXX03, genericSelectionExpr());
+
+  EXPECT_FALSE(testStructuralMatch(t));
+}
 TEST_F(StructuralEquivalenceStmtTest, IntegerLiteral) {
   auto t = makeWrappedStmts("1", "1", Lang_CXX03, integerLiteral());
   EXPECT_TRUE(testStructuralMatch(t));
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -279,6 +279,15 @@
  functionDecl(hasDescendant(gnuNullExpr(hasType(isInteger());
 }
 
+TEST_P(ImportExpr, ImportGenericSelectionExpr) {
+  MatchVerifier Verifier;
+
+  testImport(
+  "void declToImport() { int x; (void)_Generic(x, int: 0, float: 1); }",
+  Lang_C99, "", Lang_C99, Verifier,
+  functionDecl(hasDescendant(genericSelectionExpr(;
+}
+
 TEST_P(ImportExpr, ImportCXXNullPtrLiteralExpr) {
   MatchVerifier Verifier;
   testImport(
@@ -1087,6 +1096,36 @@
 ToChooseExpr->isConditionDependent());
 }
 

[clang] 1844ab7 - [ASTImporter] Add support for importing GenericSelectionExpr AST nodes.

2020-12-16 Thread Tom Roeder via cfe-commits

Author: Tom Roeder
Date: 2020-12-16T15:39:50-08:00
New Revision: 1844ab770cb9380a1896d83b1863b93766ffdf22

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

LOG: [ASTImporter] Add support for importing GenericSelectionExpr AST nodes.

This allows ASTs to be merged when they contain GenericSelectionExpr
nodes (this is _Generic from C11). This is needed, for example, for
CTU analysis of C code that makes use of _Generic, like the Linux
kernel.

The node is already supported in the AST, but it didn't have a matcher
in ASTMatchers. So, this change adds the matcher and adds support to
ASTImporter. Additionally, this change adds support for structural
equivalence of _Generic in the AST.

Reviewed By: martong, aaron.ballman

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

Added: 
clang/test/ASTMerge/generic-selection-expr/Inputs/generic.c
clang/test/ASTMerge/generic-selection-expr/Inputs/generic.cpp
clang/test/ASTMerge/generic-selection-expr/test.c
clang/test/ASTMerge/generic-selection-expr/test.cpp

Modified: 
clang/docs/LibASTMatchersReference.html
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/lib/Analysis/ExprMutationAnalyzer.cpp
clang/unittests/AST/ASTImporterTest.cpp
clang/unittests/AST/StructuralEquivalenceTest.cpp
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Removed: 




diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index 203840c214a2..18acfc48 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -1704,6 +1704,11 @@ Node Matchers
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtgenericSelectionExprMatcherhttps://clang.llvm.org/doxygen/classclang_1_1GenericSelectionExpr.html;>GenericSelectionExpr...
+Matches C11 
_Generic expression.
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtgnuNullExprMatcherhttps://clang.llvm.org/doxygen/classclang_1_1GNUNullExpr.html;>GNUNullExpr...
 Matches GNU __null 
expression.
 

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 0da469ea0f78..ba2dd862f171 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2362,6 +2362,10 @@ extern const internal::VariadicDynCastAllOfMatcher
 extern const internal::VariadicDynCastAllOfMatcher
 gnuNullExpr;
 
+/// Matches C11 _Generic expression.
+extern const internal::VariadicDynCastAllOfMatcher
+genericSelectionExpr;
+
 /// Matches atomic builtins.
 /// Example matches __atomic_load_n(ptr, 1)
 /// \code

diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 9374e9316ce8..54816b721a4a 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -577,6 +577,7 @@ namespace clang {
 ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
 ExpectedStmt VisitChooseExpr(ChooseExpr *E);
 ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E);
+ExpectedStmt VisitGenericSelectionExpr(GenericSelectionExpr *E);
 ExpectedStmt VisitPredefinedExpr(PredefinedExpr *E);
 ExpectedStmt VisitDeclRefExpr(DeclRefExpr *E);
 ExpectedStmt VisitImplicitValueInitExpr(ImplicitValueInitExpr *E);
@@ -6526,6 +6527,40 @@ ExpectedStmt 
ASTNodeImporter::VisitGNUNullExpr(GNUNullExpr *E) {
   return new (Importer.getToContext()) GNUNullExpr(*TypeOrErr, *BeginLocOrErr);
 }
 
+ExpectedStmt
+ASTNodeImporter::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
+  Error Err = Error::success();
+  auto ToGenericLoc = importChecked(Err, E->getGenericLoc());
+  auto *ToControllingExpr = importChecked(Err, E->getControllingExpr());
+  auto ToDefaultLoc = importChecked(Err, E->getDefaultLoc());
+  auto ToRParenLoc = importChecked(Err, E->getRParenLoc());
+  if (Err)
+return std::move(Err);
+
+  ArrayRef 
FromAssocTypes(E->getAssocTypeSourceInfos());
+  SmallVector ToAssocTypes(FromAssocTypes.size());
+  if (Error Err = ImportContainerChecked(FromAssocTypes, ToAssocTypes))
+return std::move(Err);
+
+  ArrayRef FromAssocExprs(E->getAssocExprs());
+  SmallVector ToAssocExprs(FromAssocExprs.size());
+  if (Error Err = ImportContainerChecked(FromAssocExprs, ToAssocExprs))
+return std::move(Err);
+
+  const ASTContext  = Importer.getToContext();
+  if (E->isResultDependent()) {
+return GenericSelectionExpr::Create(
+ToCtx, ToGenericLoc, ToControllingExpr,
+llvm::makeArrayRef(ToAssocTypes), llvm::makeArrayRef(ToAssocExprs),
+ToDefaultLoc, ToRParenLoc, 

[clang] f31e9bc - Test commit: add valid punctuation to a comment. NFC.

2020-12-16 Thread Tom Roeder via cfe-commits

Author: Tom Roeder
Date: 2020-12-16T15:33:19-08:00
New Revision: f31e9bcd73eb5f99256a19ae8ed958140ba58a42

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

LOG: Test commit: add valid punctuation to a comment. NFC.

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 9c0a7320e5f2..9374e9316ce8 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -8223,7 +8223,7 @@ Expected ASTImporter::Import(Decl *FromD) {
   return make_error(*Error);
 }
 
-// If FromD has some updated flags after last import, apply it
+// If FromD has some updated flags after last import, apply it.
 updateFlags(FromD, ToD);
 // If we encounter a cycle during an import then we save the relevant part
 // of the import path associated to the Decl.



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


[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-12-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I think that as long as the class leaves a copy/move constructor defaulted, 
there's no need for a new trivial_abi attribute.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D91659: Allow enum typedefs to be referenced with the 'enum' specifier under MSVC compat mode

2020-12-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D91659#2458872 , @rnk wrote:

> In D91659#2458639 , @rsmith wrote:
>
>> 
>
> What is the issue with the current structure, ActOnTag produces the wrong AST 
> node, an ElaboratedType, but we want to produce a TypedefType?

I don't think we want to introduce a new declaration at all in this 
compatibility case; I think we want to act as if the `enum` keyword were 
omitted entirely (the caller should set a different kind of `TypeSpecType` on 
the `DeclSpec` in this case). Maybe the simplest thing would be to add a new 
optional `TypeResult*` out parameter to `ActOnTag` that's only set by the call 
in `ParseEnumSpecifier` (and then only for the `TUK_Reference` case). Then 
`ParseEnumSpecifier` can set a `TST_typename` type specifier in this case 
instead of a `TST_enum`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91659

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


[PATCH] D93350: [Test] Fix undef var in catch-undef-behavior.c

2020-12-16 Thread Thomas Preud'homme 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 rG150fe05db441: [Test] Fix undef var in catch-undef-behavior.c 
(authored by thopre).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93350

Files:
  clang/test/CodeGen/catch-undef-behavior.c


Index: clang/test/CodeGen/catch-undef-behavior.c
===
--- clang/test/CodeGen/catch-undef-behavior.c
+++ clang/test/CodeGen/catch-undef-behavior.c
@@ -275,7 +275,7 @@
 
 // CHECK-COMMON-LABEL: @float_float_overflow
 float float_float_overflow(double f) {
-  // CHECK-UBSAN-NOT: call {{.*}} @__ubsan_handle_float_cast_overflow(i8* 
bitcast ({{.*}} @[[LINE_1600]] to i8*),
+  // CHECK-UBSAN-NOT: call {{.*}} @__ubsan_handle_float_cast_overflow(
   // CHECK-TRAP-NOT:  call {{.*}} @llvm.ubsantrap(i8 19) [[NR_NUW]]
   // CHECK-COMMON: }
   return f;


Index: clang/test/CodeGen/catch-undef-behavior.c
===
--- clang/test/CodeGen/catch-undef-behavior.c
+++ clang/test/CodeGen/catch-undef-behavior.c
@@ -275,7 +275,7 @@
 
 // CHECK-COMMON-LABEL: @float_float_overflow
 float float_float_overflow(double f) {
-  // CHECK-UBSAN-NOT: call {{.*}} @__ubsan_handle_float_cast_overflow(i8* bitcast ({{.*}} @[[LINE_1600]] to i8*),
+  // CHECK-UBSAN-NOT: call {{.*}} @__ubsan_handle_float_cast_overflow(
   // CHECK-TRAP-NOT:  call {{.*}} @llvm.ubsantrap(i8 19) [[NR_NUW]]
   // CHECK-COMMON: }
   return f;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 150fe05 - [Test] Fix undef var in catch-undef-behavior.c

2020-12-16 Thread Thomas Preud'homme via cfe-commits

Author: Thomas Preud'homme
Date: 2020-12-16T22:39:41Z
New Revision: 150fe05db4417c3ed9e4470b7bbd1a6aee7fe505

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

LOG: [Test] Fix undef var in catch-undef-behavior.c

Commit 9e52c43090f8cd980167bbd2719878ae36bcf6b5 removed the directive
defining LINE_1600 but left a string substitution to that variable in a
CHECK-NOT directive. This will make that CHECK-NOT directive always fail
to match, no matter the string.

This commit follows the pattern done in
9e52c43090f8cd980167bbd2719878ae36bcf6b5 of simplifying the CHECK-NOT to
only look for the function name and the opening parenthesis, thereby not
requiring the LINE_1600 variable.

Reviewed By: rnk

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

Added: 


Modified: 
clang/test/CodeGen/catch-undef-behavior.c

Removed: 




diff  --git a/clang/test/CodeGen/catch-undef-behavior.c 
b/clang/test/CodeGen/catch-undef-behavior.c
index be185f925b19..55f6e420a4fc 100644
--- a/clang/test/CodeGen/catch-undef-behavior.c
+++ b/clang/test/CodeGen/catch-undef-behavior.c
@@ -275,7 +275,7 @@ signed char fp16_char_overflow(__fp16 *p) {
 
 // CHECK-COMMON-LABEL: @float_float_overflow
 float float_float_overflow(double f) {
-  // CHECK-UBSAN-NOT: call {{.*}} @__ubsan_handle_float_cast_overflow(i8* 
bitcast ({{.*}} @[[LINE_1600]] to i8*),
+  // CHECK-UBSAN-NOT: call {{.*}} @__ubsan_handle_float_cast_overflow(
   // CHECK-TRAP-NOT:  call {{.*}} @llvm.ubsantrap(i8 19) [[NR_NUW]]
   // CHECK-COMMON: }
   return f;



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


[PATCH] D92577: Don't reject tag declarations in for loop clause-1

2020-12-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Please test that there's actually an object declared and that it's not *just* a 
tag declaration.


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

https://reviews.llvm.org/D92577

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


[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-12-16 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:6502
+  // except that it has a non-trivial member *with* the trivial_abi attribute.
+  for (auto Base : D->bases()) {
+if (auto CxxRecord = Base.getType()->getAsCXXRecordDecl())

It looks like this patch changes the way `D` is passed in the following code:

```
struct B {
  int i[4];
  B();
  B(const B &) = default;
  B(B &&);
};

struct D : B {
  D();
  D(const D &) = default;
  D(D &&) = delete;
};

void testB(B a);
void testD(D a);

void testCallB() {
  B b;
  testB(b);
}

void testCallD() {
  D d;
  testD(d);
}
```

`B` cannot be passed in registers because it has a non-trivial move 
constructor, whereas `D` can be passed in registers because the move 
constructor is deleted and the copy constructor is trivial.

I'm not sure what the best way to handle this is, but I just wanted to point 
this out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D92788: [clangd] NFC: Use SmallVector where possible

2020-12-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/Headers.h:139
   // Maps a file's index to that of the files it includes.
-  llvm::DenseMap> IncludeChildren;
+  llvm::DenseMap> IncludeChildren;
 };

kbobyrev wrote:
> arphaman wrote:
> > It looks like the change on this line is failing to compile on Ubuntu 16.04 
> > with the System GCC. 
> > (https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04-next/23655/console).
> > 
> > Can I reinstate the `llvm::DenseMap>` 
> > for now until we drop support for Ubuntu 16.04?
> Uh, didn't see that one, I'm sorry to hear that. Yes, sure, feel free to 
> change it to make your setup work!
From the error message, it looks like the declarations of clang::SmallVector in 
LLVM.h are missing the default template arguments (not sure why this is 
different in the swift CI).

Does changing to qualifying as llvm::SmallVector work here, rather than adding 
the explicit size? (We usually do this anyway as a matter of style)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92788

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


[PATCH] D93103: Enable the _ExtInt extension on the BPF Target

2020-12-16 Thread Sean Young via Phabricator via cfe-commits
seanyoung added a comment.

Ok, I'll do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93103

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


[PATCH] D91659: Allow enum typedefs to be referenced with the 'enum' specifier under MSVC compat mode

2020-12-16 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D91659#2458639 , @rsmith wrote:

> @rnk Your thoughts on this would be appreciated.

I think it's important to make MIDL happy if we can. As to how to restructure 
the code to get there, I took a look, but wasn't able to come up with any 
helpful suggestions without putting a lot more time into this.

What is the issue with the current structure, ActOnTag produces the wrong AST 
node, an ElaboratedType, but we want to produce a TypedefType?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91659

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


[clang] b7905e8 - Fix split-debug.c test on Windows

2020-12-16 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-12-16T13:48:57-08:00
New Revision: b7905e81fc3d7b045a5346442ce92ee87bdb7b21

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

LOG: Fix split-debug.c test on Windows

Added: 


Modified: 
clang/test/Driver/split-debug.c

Removed: 




diff  --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c
index 7d3fcf078c56..de1258dcb13c 100644
--- a/clang/test/Driver/split-debug.c
+++ b/clang/test/Driver/split-debug.c
@@ -59,8 +59,8 @@
 
 /// Invoke objcopy if not using the integrated assembler.
 // RUN: %clang -### -c -target x86_64-unknown-linux-gnu -fno-integrated-as 
-gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=OBJCOPY
-// OBJCOPY:  objcopy" "--extract-dwo"
-// OBJCOPY-NEXT: objcopy" "--strip-dwo"
+// OBJCOPY:  objcopy{{(.exe)?}}" "--extract-dwo"
+// OBJCOPY-NEXT: objcopy{{(.exe)?}}" "--strip-dwo"
 
 /// ... but not for assembly output.
 // RUN: %clang -### -S -target x86_64-unknown-linux-gnu -fno-integrated-as 
-gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=NOOBJCOPY



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


[PATCH] D92797: APINotes: add initial stub of APINotesWriter

2020-12-16 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: clang/include/clang/APINotes/APINotesWriter.h:1
+//===-- APINotesWriter.h - API Notes Writer -*- C++ 
-*-===//
+//

martong wrote:
> How are we going to use this class? I mean what are the use cases to call the 
> Writer from inside Clang?
> I understand that the Reader might be used to read up the serialized APINotes 
> file.
> 
> What will be the usual process of using an APINotes file? Is it like:
> ```
> 1) Edit `APINotesX.yaml` by hand (by a library author)
> 2) Serialize `APINotesX.yaml` -> `APINotesX.serialized` (Would this require a 
> special Clang invocation?)
> 3) Run Clang for the usual tasks (analysis, etc) but with feeding it with 
> `APINotesX.serialized`
> ```
> Would it be possible to feed the raw `APINotesX.yaml` to Clang and skip the 
> whole serialize/deserialize steps? If yes, then maybe we should put more 
> focus on that first  (but maybe it's already too late since we added the 
> serialization format and the reader).
As to the question of the expected usage: if a user wishes to alter the 
behavior of a library (the library is missing nullability annotation!?  I want 
that checking!) they add a supplement APINotes for the library, and pass that 
to the compiler when using the library via flags.  When clang goes through and 
finds that the cache is not populated, it will process the API Notes and 
compile it.  Then it apply the API Notes to the compilation as it goes through 
(looking up the interfaces it encounters).

This class is going to be used by the APINotes Compiler, which will read the 
YAML input and then serialize it out to bitcode encoded format.  This will 
occur implicitly by the compiler consulting a cache (similar in spirit to how 
modules are cached).  If the APINotes Manager finds the cached copy that is 
used, otherwise the contents can be processed and emitted into the cache.  This 
basically is similar in spirit to a PCH/PCM.

I dont mind switching to focus on a different part of the API if it:
a) makes it easier to understand and review, OR
b) makes it easier to test

The intent here is to chunk the pieces so that there is a way to process the 
changes logically and with testing.  I was simply taking an approach to make 
progress, but as long as we can make progress, Im not really tied to a specific 
path through this.

In fact, I was struggling with how to create a custom compiler to serialize, 
deserialize the input so that it can be verified (namely a question of how to 
query/compare - is the best that we can do diff against a golden master?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92797

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


[PATCH] D93182: [clang-tidy] Add linux kernel log functions checker

2020-12-16 Thread Tom Rix via Phabricator via cfe-commits
trixirt added a comment.

Yes, this change has problems, I will resubmit.
There are many log function checks in checkpatch, and i need to write another 
one to find the unattibuted decls. 
I don't think adding linux specific warnings is -Wformat is needed, that 
doesn't scale with all the other projects wanting special attention
There may be a lot of checks and fixits added to linuxkernel/  .  checkpatch 
only checks for new problems.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93182

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


[PATCH] D92577: Don't reject tag declarations in for loop clause-1

2020-12-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D92577#2445714 , @aaron.ballman 
wrote:

> Ping

Ping


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

https://reviews.llvm.org/D92577

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


[PATCH] D93103: Enable the _ExtInt extension on the BPF Target

2020-12-16 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

We could enable ExtIntType in bpf backend. But we need some kernel changes 
related to BTF to accommodate the new types.
Currently, the kernel uapi file (linux/include/uapi/linux/btf.h) defines

  #define BTF_INT_BITS(VAL)   ((VAL)  & 0x00ff)

which means the maximum permitted number of bits for int type is 255.

Here, we try to define an int type 256 which will not fit in the BTF. Currently 
llvm can encode 256 in BTF as the last 4 bytes are available and llvm did not 
do strict checking.
But kernel will reject it. Based on available bits, the maximum allowed bits are

  #define BTF_INT_BITS(VAL)   ((VAL)  & 0x)

But I do not think we need that big range, maybe

  #define BTF_INT_BITS(VAL)   ((VAL)  & 0x03ff)

which encode up to 512 bit integer (for power-of-2)? Do you have an use case 
for even bigger number of int?

Anyway, in parallel to this llvm patch, you need to have kernel change to 
accept such ext int's, the following are main changes in kernel:

- extend the above uapi to allow more bits in int type.
- make sure btf pretty print can work properly with these big ints, it can 
handle __int128 (in both kernel and bpftool), you will need to extend to make 
it generic to handler 128/192/256/... bytes, I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93103

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


[PATCH] D92600: [ASTImporter] Add support for importing GenericSelectionExpr AST nodes.

2020-12-16 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder added a comment.

In D92600#2458715 , @tmroeder wrote:

> Looks like I missed the transition of my credentials from SVN from github, so 
> I can't currently commit this.
>
> How do I go about getting those credentials restored?

Never mind, I found it in the Developer Policy document


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92600

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


[PATCH] D83892: [clang][cli] Port CodeGen option flags to new option parsing system

2020-12-16 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

Thanks Duncan!  I (or someone) will play around with that and see what we need 
to do.  May take a little while, as we're about to freeze a release and then go 
on break for two weeks, but good to know there's a straightforward path.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83892

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


[PATCH] D92600: [ASTImporter] Add support for importing GenericSelectionExpr AST nodes.

2020-12-16 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder added a comment.

Looks like I missed the transition of my credentials from SVN from github, so I 
can't currently commit this.

How do I go about getting those credentials restored?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92600

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


[PATCH] D91129: Print source location in the error message when parens are missing around sizeof typename and the expression is inside macro expansion

2020-12-16 Thread Richard Smith - zygoloid 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 rGe53b9f733a7c: Print source location in the error message 
when parens are missing around… (authored by shivanshu3, committed by rsmith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91129

Files:
  clang/lib/Parse/ParseExpr.cpp
  clang/test/Parser/sizeof-missing-parens.c


Index: clang/test/Parser/sizeof-missing-parens.c
===
--- /dev/null
+++ clang/test/Parser/sizeof-missing-parens.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void Foo(int);
+
+#define Bar(x) Foo(x)
+
+void Baz() {
+  Foo(sizeof int); // expected-error {{expected parentheses around type name 
in sizeof expression}}
+  Bar(sizeof int); // expected-error {{expected parentheses around type name 
in sizeof expression}}
+}
Index: clang/lib/Parse/ParseExpr.cpp
===
--- clang/lib/Parse/ParseExpr.cpp
+++ clang/lib/Parse/ParseExpr.cpp
@@ -2266,10 +2266,15 @@
 
 SourceLocation LParenLoc = PP.getLocForEndOfToken(OpTok.getLocation());
 SourceLocation RParenLoc = PP.getLocForEndOfToken(PrevTokLocation);
-Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
-  << OpTok.getName()
-  << FixItHint::CreateInsertion(LParenLoc, "(")
-  << FixItHint::CreateInsertion(RParenLoc, ")");
+if (LParenLoc.isInvalid() || RParenLoc.isInvalid()) {
+  Diag(OpTok.getLocation(),
+   diag::err_expected_parentheses_around_typename)
+  << OpTok.getName();
+} else {
+  Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
+  << OpTok.getName() << FixItHint::CreateInsertion(LParenLoc, "(")
+  << FixItHint::CreateInsertion(RParenLoc, ")");
+}
 isCastExpr = true;
 return ExprEmpty();
   }


Index: clang/test/Parser/sizeof-missing-parens.c
===
--- /dev/null
+++ clang/test/Parser/sizeof-missing-parens.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void Foo(int);
+
+#define Bar(x) Foo(x)
+
+void Baz() {
+  Foo(sizeof int); // expected-error {{expected parentheses around type name in sizeof expression}}
+  Bar(sizeof int); // expected-error {{expected parentheses around type name in sizeof expression}}
+}
Index: clang/lib/Parse/ParseExpr.cpp
===
--- clang/lib/Parse/ParseExpr.cpp
+++ clang/lib/Parse/ParseExpr.cpp
@@ -2266,10 +2266,15 @@
 
 SourceLocation LParenLoc = PP.getLocForEndOfToken(OpTok.getLocation());
 SourceLocation RParenLoc = PP.getLocForEndOfToken(PrevTokLocation);
-Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
-  << OpTok.getName()
-  << FixItHint::CreateInsertion(LParenLoc, "(")
-  << FixItHint::CreateInsertion(RParenLoc, ")");
+if (LParenLoc.isInvalid() || RParenLoc.isInvalid()) {
+  Diag(OpTok.getLocation(),
+   diag::err_expected_parentheses_around_typename)
+  << OpTok.getName();
+} else {
+  Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
+  << OpTok.getName() << FixItHint::CreateInsertion(LParenLoc, "(")
+  << FixItHint::CreateInsertion(RParenLoc, ")");
+}
 isCastExpr = true;
 return ExprEmpty();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e53b9f7 - Print source location in the error message when parens are missing around sizeof typename and the expression is inside macro expansion

2020-12-16 Thread Richard Smith via cfe-commits

Author: Shivanshu Goyal
Date: 2020-12-16T12:03:31-08:00
New Revision: e53b9f733a7cb0a5da372b73ab6b7711c0300d65

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

LOG: Print source location in the error message when parens are missing around 
sizeof typename and the expression is inside macro expansion

Given the following code:

```
void Foo(int);

void Baz()
{
Bar(sizeof int);
}
```

The error message which is printed today is this:
```
error: expected parentheses around type name in sizeof expression
```

There is no source location printed whatsoever, so fixing a compile break like 
this becomes extremely hard in a large codebase.

My change improves the error message. But it doesn't output a FixItHint because 
I wasn't able to figure out how to get the locations for left and right parens. 
So any tips would be appreciated.

```
:7:6: error: expected parentheses around type name in sizeof expression
Bar(sizeof int);
^
```

Reviewed By: rsmith

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

Added: 
clang/test/Parser/sizeof-missing-parens.c

Modified: 
clang/lib/Parse/ParseExpr.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index d993d9ce4bdb..6acf76d713fd 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -2266,10 +2266,15 @@ Parser::ParseExprAfterUnaryExprOrTypeTrait(const Token 
,
 
 SourceLocation LParenLoc = PP.getLocForEndOfToken(OpTok.getLocation());
 SourceLocation RParenLoc = PP.getLocForEndOfToken(PrevTokLocation);
-Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
-  << OpTok.getName()
-  << FixItHint::CreateInsertion(LParenLoc, "(")
-  << FixItHint::CreateInsertion(RParenLoc, ")");
+if (LParenLoc.isInvalid() || RParenLoc.isInvalid()) {
+  Diag(OpTok.getLocation(),
+   diag::err_expected_parentheses_around_typename)
+  << OpTok.getName();
+} else {
+  Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
+  << OpTok.getName() << FixItHint::CreateInsertion(LParenLoc, "(")
+  << FixItHint::CreateInsertion(RParenLoc, ")");
+}
 isCastExpr = true;
 return ExprEmpty();
   }

diff  --git a/clang/test/Parser/sizeof-missing-parens.c 
b/clang/test/Parser/sizeof-missing-parens.c
new file mode 100644
index ..527f74151be1
--- /dev/null
+++ b/clang/test/Parser/sizeof-missing-parens.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void Foo(int);
+
+#define Bar(x) Foo(x)
+
+void Baz() {
+  Foo(sizeof int); // expected-error {{expected parentheses around type name 
in sizeof expression}}
+  Bar(sizeof int); // expected-error {{expected parentheses around type name 
in sizeof expression}}
+}



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


[PATCH] D93325: Add srcloc output to clang-query

2020-12-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for this, it looks really useful!




Comment at: clang-tools-extra/clang-query/Query.cpp:94
 
+void dumpLocations(llvm::raw_ostream , ast_type_traits::DynTypedNode node,
+   ASTContext , const DiagnosticsEngine ,





Comment at: clang-tools-extra/clang-query/Query.cpp:97
+   SourceManager const ) {
+  auto locs = clang::tooling::NodeLocationIntrospection::GetLocations(node);
+

It should be named `Locs` per the usual coding conventions.

(I'll hold my nose on the use of `auto` here, but if it got spelled out since 
you're touching the line anyway, that would not be a terrible thing.)



Comment at: clang-tools-extra/clang-query/Query.cpp:99
+
+  for (auto it = locs.LocationAccessors.begin();
+   it != locs.LocationAccessors.end(); ++it) {

`it` -> `Iter`



Comment at: clang-tools-extra/clang-query/Query.cpp:106
+TD.emitDiagnostic(FullSourceLoc(it->first, SM), DiagnosticsEngine::Note,
+  "SourceLocations here", None, None);
+

`SourceLocations` -> `source locations` ?



Comment at: clang-tools-extra/clang-query/Query.cpp:108
+
+auto commonLoc = it->first;
+auto scout = it;

`CommonLoc` and the type should definitely be spelled out.



Comment at: clang-tools-extra/clang-query/Query.cpp:109
+auto commonLoc = it->first;
+auto scout = it;
+while (scout->first == commonLoc) {

`Scout`



Comment at: clang-tools-extra/clang-query/Query.cpp:123
+
+  for (auto it = locs.RangeAccessors.begin(); it != locs.RangeAccessors.end();
+   ++it) {

`it` -> `Iter`



Comment at: clang-tools-extra/clang-query/Query.cpp:136
+  DiagnosticsEngine::Note,
+  "SourceRanges here " + it->first.printToString(SM),
+  CharSourceRange::getTokenRange(it->first), None);

`SourceRanges` -> `source ranges` ?



Comment at: clang-tools-extra/clang-query/Query.cpp:139-140
+
+auto commonLoc = it->first;
+auto scout = it;
+while (scout->first == commonLoc) {

Same here as above.

Given how common this code seems to be with the first block of code, would it 
make sense to turn some of this code into a lambda?



Comment at: clang-tools-extra/clang-query/Query.cpp:152
+  }
+  for (auto it = locs.RangeAccessors.begin(); it != locs.RangeAccessors.end();
+   ++it) {

`it` -> `Iter`



Comment at: clang-tools-extra/clang-query/Query.cpp:165
+FullSourceLoc(it->first.getBegin(), SM), DiagnosticsEngine::Note,
+"SourceRange " + it->first.printToString(SM) + " starting here...",
+CharSourceRange::getTokenRange(it->first), None);

`SourceRange` -> `source range` ?



Comment at: clang-tools-extra/clang-query/Query.cpp:168-169
+
+auto colNum = SM.getPresumedColumnNumber(it->first.getEnd());
+auto lastLineLoc = it->first.getEnd().getLocWithOffset(-(colNum - 1));
+

More names to correct for conventions. Can you also spell out at least the 
location datatype?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93325

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


[clang] 735ab86 - PR47474: Add test for Clang's current behavior.

2020-12-16 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-12-16T12:01:00-08:00
New Revision: 735ab86b811e40f1533ced98dfc4b7a0c09c545b

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

LOG: PR47474: Add test for Clang's current behavior.

Our current behavior rejects the example, following the current language
rules, but it's likely the rules will be revised to allow this example.

Added: 


Modified: 
clang/test/SemaCXX/cxx2a-destroying-delete.cpp

Removed: 




diff  --git a/clang/test/SemaCXX/cxx2a-destroying-delete.cpp 
b/clang/test/SemaCXX/cxx2a-destroying-delete.cpp
index 015d11e65526..46e5228ec6be 100644
--- a/clang/test/SemaCXX/cxx2a-destroying-delete.cpp
+++ b/clang/test/SemaCXX/cxx2a-destroying-delete.cpp
@@ -141,3 +141,29 @@ namespace templated {
 void operator delete(typename id_struct::type *, 
std::destroying_delete_t); // expected-error {{use 'D *'}}
   };
 }
+
+namespace dtor_access {
+  struct S {
+void operator delete(S *p, std::destroying_delete_t);
+  private:
+~S(); // expected-note {{here}}
+  };
+
+  // FIXME: PR47474: GCC accepts this, and it seems somewhat reasonable to
+  // allow, even though [expr.delete]p12 says this is ill-formed.
+  void f() { delete new S; } // expected-error {{calling a private destructor}}
+
+  struct T {
+void operator delete(T *, std::destroying_delete_t);
+  protected:
+virtual ~T(); // expected-note {{here}}
+  };
+
+  struct U : T {
+void operator delete(void *);
+  private:
+~U() override;
+  };
+
+  void g() { delete (T *)new U; } // expected-error {{calling a protected 
destructor}}
+}



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


[PATCH] D91659: Allow enum typedefs to be referenced with the 'enum' specifier under MSVC compat mode

2020-12-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:15752-15754
+  bool AnonymousEnumEligible = getLangOpts().MSVCCompat &&
+   (Kind == TTK_Enum) &&
+   Tag->getDeclName().isEmpty();

shivanshu3 wrote:
> shivanshu3 wrote:
> > rsmith wrote:
> > > In the anonymous union case, we also need to check for qualifiers on the 
> > > typedef type, and more broadly perhaps we should be using 
> > > `getAnonDeclWithTypedefName` here too. Presumably the new case should 
> > > also only apply for `TUK_Reference`.
> > I added a check for TUK_Reference. But I don't fully understand your other 
> > comment about checking the qualifiers on the typedef type. Could you please 
> > explain a little more?
> @rsmith Since my newest iteration removes the restriction for the enum to be 
> anonymous, I'm guessing I can mark this comment as resolved?
Regarding qualifiers:
```
enum A { e };
typedef const A B;
void f() {
enum ::B b = e; // OK?
b = e; // OK?
}
```
MSVC's behavior here is very strange -- they behave exactly as if the `enum` 
keyword were not present. The first commented line above is accepted, and the 
second is rejected because we're assigning to an object of type `const A`.

If we want to be compatible with this kind of thing, then I think we need a 
larger-scale restructuring: `ActOnTag` would need a way to say "no, wait, this 
isn't a tag at all, use this non-tag type instead". I don't know how common 
this kind of code is, but perhaps we could instead reject the first line above 
(because the typedef isn't for *exactly* the enum type).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91659

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


[PATCH] D91980: [OpenMP] Add initial support for `omp [begin/end] assumes`

2020-12-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 312277.
jdoerfert added a comment.

Fixes


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

https://reviews.llvm.org/D91980

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/assumes_codegen.cpp
  clang/test/OpenMP/assumes_include_nvptx.cpp
  clang/test/OpenMP/assumes_messages.c
  clang/test/OpenMP/assumes_print.cpp
  clang/test/OpenMP/assumes_template_print.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -1224,3 +1224,27 @@
 #undef __OMP_REQUIRES_TRAIT
 #undef OMP_REQUIRES_TRAIT
 ///}
+
+
+/// Assumption clauses
+///
+///{
+
+#ifdef OMP_ASSUME_CLAUSE
+#define __OMP_ASSUME_CLAUSE(Identifier, StartsWith, HasDirectiveList, HasExpression) \
+OMP_ASSUME_CLAUSE(Identifier, StartsWith, HasDirectiveList, HasExpression)
+#else
+#define __OMP_ASSUME_CLAUSE(...)
+#endif
+
+__OMP_ASSUME_CLAUSE(llvm::StringLiteral("ext_"), true, false, false)
+__OMP_ASSUME_CLAUSE(llvm::StringLiteral("absent"), false, true, false)
+__OMP_ASSUME_CLAUSE(llvm::StringLiteral("contains"), false, true, false)
+__OMP_ASSUME_CLAUSE(llvm::StringLiteral("holds"), false, false, true)
+__OMP_ASSUME_CLAUSE(llvm::StringLiteral("no_openmp"), false, false, false)
+__OMP_ASSUME_CLAUSE(llvm::StringLiteral("no_openmp_routines"), false, false, false)
+__OMP_ASSUME_CLAUSE(llvm::StringLiteral("no_parallelism"), false, false, false)
+
+#undef __OMP_ASSUME_CLAUSE
+#undef OMP_ASSUME_CLAUSE
+///}
Index: llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
@@ -16,6 +16,7 @@
 
 #include "llvm/ADT/BitmaskEnum.h"
 
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Frontend/OpenMP/OMP.h.inc"
 
 namespace llvm {
@@ -79,6 +80,33 @@
 #define OMP_IDENT_FLAG(Enum, ...) constexpr auto Enum = omp::IdentFlag::Enum;
 #include "llvm/Frontend/OpenMP/OMPKinds.def"
 
+/// Helper to describe assume clauses.
+struct AssumptionClauseMappingInfo {
+  /// The identifier describing the (beginning of the) clause.
+  llvm::StringLiteral Identifier;
+  /// Flag to determine if the identifier is a full name or the start of a name.
+  bool StartsWith;
+  /// Flag to determine if a directive lists follows.
+  bool HasDirectiveList;
+  /// Flag to determine if an expression follows.
+  bool HasExpression;
+};
+
+/// All known assume clauses.
+static constexpr AssumptionClauseMappingInfo AssumptionClauseMappings[] = {
+#define OMP_ASSUME_CLAUSE(Identifier, StartsWith, HasDirectiveList,\
+  HasExpression)   \
+  {Identifier, StartsWith, HasDirectiveList, HasExpression},
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
+};
+
+inline std::string getAllAssumeClauseOptions() {
+  std::string S;
+  for (const AssumptionClauseMappingInfo  : AssumptionClauseMappings)
+S += (S.empty() ? "'" : "', '") + ACMI.Identifier.str();
+  return S + "'";
+}
+
 } // end namespace omp
 
 } // end namespace llvm
Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -1593,6 +1593,9 @@
 VersionedClause
   ];
 }
+def OMP_Assumes : Directive<"assumes"> {}
+def OMP_BeginAssumes : Directive<"begin assumes"> {}
+def OMP_EndAssumes : Directive<"end assumes"> {}
 def OMP_BeginDeclareVariant : Directive<"begin declare variant"> {}
 def OMP_EndDeclareVariant : Directive<"end declare variant"> {}
 def OMP_ParallelWorkshare : Directive<"parallel workshare"> {
Index: clang/test/OpenMP/assumes_template_print.cpp
===
--- /dev/null
+++ clang/test/OpenMP/assumes_template_print.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+// It is unclear if we want to annotate the template 

[PATCH] D93068: [clang-offload-bundler] Add option -allow-missing-bundles

2020-12-16 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
yaxunl marked 2 inline comments as done.
Closed by commit rGb9fb063e63c7: [clang-offload-bundler] Add option 
-allow-missing-bundles (authored by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D93068?vs=311099=312274#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93068

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  clang/test/Driver/openmp-offload.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -43,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -95,6 +96,12 @@
  "instead of actually executing them - for testing purposes.\n"),
 cl::init(false), cl::cat(ClangOffloadBundlerCategory));
 
+static cl::opt
+AllowMissingBundles("allow-missing-bundles",
+cl::desc("Create empty files if bundles are missing "
+ "when unbundling.\n"),
+cl::init(false), cl::cat(ClangOffloadBundlerCategory));
+
 static cl::opt
 BundleAlignment("bundle-align",
 cl::desc("Alignment of bundle for binary files"),
@@ -883,6 +890,25 @@
   FoundHostBundle = true;
   }
 
+  if (!AllowMissingBundles && !Worklist.empty()) {
+std::string ErrMsg = "Can't find bundles for";
+std::set Sorted;
+for (auto  : Worklist)
+  Sorted.insert(E.first());
+unsigned I = 0;
+unsigned Last = Sorted.size() - 1;
+for (auto  : Sorted) {
+  if (I != 0 && Last > 1)
+ErrMsg += ",";
+  ErrMsg += " ";
+  if (I == Last && I != 0)
+ErrMsg += "and ";
+  ErrMsg += E.str();
+  ++I;
+}
+return createStringError(inconvertibleErrorCode(), ErrMsg);
+  }
+
   // If no bundles were found, assume the input file is the host bundle and
   // create empty files for the remaining targets.
   if (Worklist.size() == TargetNames.size()) {
@@ -974,7 +1000,15 @@
   // have exactly one host target.
   unsigned Index = 0u;
   unsigned HostTargetNum = 0u;
+  llvm::DenseSet ParsedTargets;
   for (StringRef Target : TargetNames) {
+if (ParsedTargets.contains(Target)) {
+  reportError(createStringError(errc::invalid_argument,
+"Duplicate targets are not allowed"));
+  return 1;
+}
+ParsedTargets.insert(Target);
+
 StringRef Kind;
 StringRef Triple;
 getOffloadKindAndTriple(Target, Kind, Triple);
Index: clang/test/Driver/openmp-offload.c
===
--- clang/test/Driver/openmp-offload.c
+++ clang/test/Driver/openmp-offload.c
@@ -495,7 +495,7 @@
 // CHK-UBJOBS-SAME: [[INPUT:[^\\/]+\.i]]" "-outputs=
 // CHK-UBJOBS-SAME: [[HOSTPP:[^\\/]+\.i]],
 // CHK-UBJOBS-SAME: [[T1PP:[^\\/]+\.i]],
-// CHK-UBJOBS-SAME: [[T2PP:[^\\/]+\.i]]" "-unbundle"
+// CHK-UBJOBS-SAME: [[T2PP:[^\\/]+\.i]]" "-unbundle" "-allow-missing-bundles"
 // CHK-UBJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" {{.*}}"-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-disable-llvm-passes" {{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" {{.*}}"-o" "
 // CHK-UBJOBS-SAME: [[HOSTBC:[^\\/]+\.bc]]" "-x" "cpp-output" "{{.*}}[[HOSTPP]]"
 // CHK-UBJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" {{.*}}"-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "
@@ -504,7 +504,7 @@
 // CHK-UBJOBS-ST-SAME: [[INPUT:[^\\/]+\.i]]" "-outputs=
 // CHK-UBJOBS-ST-SAME: [[HOSTPP:[^\\/,]+\.i]],
 // CHK-UBJOBS-ST-SAME: [[T1PP:[^\\/,]+\.i]],
-// CHK-UBJOBS-ST-SAME: [[T2PP:[^\\/,]+\.i]]" "-unbundle"
+// CHK-UBJOBS-ST-SAME: [[T2PP:[^\\/,]+\.i]]" "-unbundle" "-allow-missing-bundles"
 // CHK-UBJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" {{.*}}"-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-disable-llvm-passes" {{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" {{.*}}"-o" "
 // CHK-UBJOBS-ST-SAME: [[HOSTBC:[^\\/]+\.bc]]" "-x" "cpp-output" "{{.*}}[[HOSTPP]]"
 // CHK-UBJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" {{.*}}"-S" {{.*}}"-fopenmp" {{.*}}"-o" "
@@ -563,7 +563,7 @@
 // CHK-UBJOBS2-SAME: [[INPUT:[^\\/]+\.o]]" "-outputs=
 // CHK-UBJOBS2-SAME: [[HOSTOBJ:[^\\/]+\.o]],
 // CHK-UBJOBS2-SAME: [[T1OBJ:[^\\/]+\.o]],
-// CHK-UBJOBS2-SAME: [[T2OBJ:[^\\/]+\.o]]" "-unbundle"
+// CHK-UBJOBS2-SAME: [[T2OBJ:[^\\/]+\.o]]" "-unbundle" "-allow-missing-bundles"
 // CHK-UBJOBS2: ld{{(\.exe)?}}" {{.*}}"-o" "
 // CHK-UBJOBS2-SAME: [[T1BIN:[^\\/]+\.out]]" 

[clang] b9fb063 - [clang-offload-bundler] Add option -allow-missing-bundles

2020-12-16 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-12-16T14:52:39-05:00
New Revision: b9fb063e63c7959e8bc9b424bd34b266ca826826

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

LOG: [clang-offload-bundler] Add option -allow-missing-bundles

There are out-of-tree tools using clang-offload-bundler to extract
bundles from bundled files. When a bundle is not in the bundled
file, clang-offload-bundler is expected to emit an error message
and return non-zero value. However currently clang-offload-bundler
silently generates empty file for the missing bundles.

Since OpenMP/HIP toolchains expect the current behavior, an option
-allow-missing-bundles is added to let clang-offload-bundler
create empty file when a bundle is missing when unbundling.
The unbundling job action is updated to use this option by
default.

clang-offload-bundler itself will emit error when a bundle
is missing when unbundling by default.

Changes are also made to check duplicate targets in -targets
option and emit error.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/clang-offload-bundler.c
clang/test/Driver/hip-toolchain-rdc-separate.hip
clang/test/Driver/openmp-offload.c
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1c1224f3990b..6ec6a551fafe 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7392,6 +7392,7 @@ void OffloadBundler::ConstructJobMultipleOutputs(
   }
   CmdArgs.push_back(TCArgs.MakeArgString(UB));
   CmdArgs.push_back("-unbundle");
+  CmdArgs.push_back("-allow-missing-bundles");
 
   // All the inputs are encoded as commands.
   C.addCommand(std::make_unique(

diff  --git a/clang/test/Driver/clang-offload-bundler.c 
b/clang/test/Driver/clang-offload-bundler.c
index 21699e78dda6..b4bab6bbd1e8 100644
--- a/clang/test/Driver/clang-offload-bundler.c
+++ b/clang/test/Driver/clang-offload-bundler.c
@@ -33,6 +33,7 @@
 // CK-HELP: {{.*}}one. The resulting file can also be unbundled into 
diff erent files by
 // CK-HELP: {{.*}}this tool if -unbundle is provided.
 // CK-HELP: {{.*}}USAGE: clang-offload-bundler [options]
+// CK-HELP: {{.*}}-allow-missing-bundles {{.*}}- Create empty files if bundles 
are missing when unbundling
 // CK-HELP: {{.*}}-inputs=  - [,...]
 // CK-HELP: {{.*}}-outputs= - [,...]
 // CK-HELP: {{.*}}-targets= - [-,...]
@@ -88,7 +89,7 @@
 // RUN: not clang-offload-bundler -type=i 
-targets=openmp-powerpc64le-linux,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.i,%t.tgt1,%t.tgt2 -outputs=%t.bundle.i 2>&1 | FileCheck %s 
--check-prefix CK-ERR9A
 // RUN: not clang-offload-bundler -type=i 
-targets=host-%itanium_abi_triple,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu
 -inputs=%t.i,%t.tgt1,%t.tgt2 -outputs=%t.bundle.i 2>&1 | FileCheck %s 
--check-prefix CK-ERR9B
 // CK-ERR9A: error: expecting exactly one host target but got 0
-// CK-ERR9B: error: expecting exactly one host target but got 2
+// CK-ERR9B: error: Duplicate targets are not allowed
 
 //
 // Check text bundle. This is a readable format, so we check for the format we 
expect to find.
@@ -181,17 +182,17 @@
 // RUN: 
diff  %t.tgt2 %t.res.tgt2
 
 // Check if we can unbundle a file with no magic strings.
-// RUN: clang-offload-bundler -type=s 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -outputs=%t.res.s,%t.res.tgt1,%t.res.tgt2 -inputs=%t.s -unbundle
+// RUN: clang-offload-bundler -type=s 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -outputs=%t.res.s,%t.res.tgt1,%t.res.tgt2 -inputs=%t.s -unbundle 
-allow-missing-bundles
 // RUN: 
diff  %t.s %t.res.s
 // RUN: 
diff  %t.empty %t.res.tgt1
 // RUN: 
diff  %t.empty %t.res.tgt2
-// RUN: clang-offload-bundler -type=s 
-targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu
 -outputs=%t.res.tgt1,%t.res.s,%t.res.tgt2 -inputs=%t.s -unbundle
+// RUN: clang-offload-bundler -type=s 
-targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu
 -outputs=%t.res.tgt1,%t.res.s,%t.res.tgt2 -inputs=%t.s -unbundle 
-allow-missing-bundles
 // RUN: 
diff  %t.s %t.res.s
 // RUN: 
diff  %t.empty %t.res.tgt1
 // RUN: 
diff  %t.empty %t.res.tgt2
 
 // Check that bindler prints an error if given host bundle does not exist in 
the fat binary.
-// RUN: not clang-offload-bundler -type=s 
-targets=host-x86_64-xxx-linux-gnu,openmp-powerpc64le-ibm-linux-gnu 
-outputs=%t.res.s,%t.res.tgt1 -inputs=%t.bundle3.s -unbundle 2>&1 | FileCheck 
%s --check-prefix 

[PATCH] D91659: Allow enum typedefs to be referenced with the 'enum' specifier under MSVC compat mode

2020-12-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

@rnk Your thoughts on this would be appreciated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91659

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


[PATCH] D83892: [clang][cli] Port CodeGen option flags to new option parsing system

2020-12-16 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D83892#2458603 , @dexonsmith wrote:

> Maybe it's worth defining another set of derived multiclasses, [...]

Another possibility of course is to make `Bool*Option` work this way (removing 
the ChangedBy, ResetBy, DefaultsToTrue, and DefaultsToFalse helpers).

(Either way, if we do add better support for dynamic defaults, I think the 
names `SetsTo{True,False}` are more clear than my previous example / suggestion 
`{True,False}Flag`.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83892

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


[PATCH] D93402: [clang-tidy] prevent readability-identifier-naming from triggering on implicit VarDecls in coroutines

2020-12-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

In D93402#2458591 , @0x1eaf wrote:

>> Do you need me to commit on your behalf?
>
> Yes, I don't have commit access. The attribution line looks good to me. Thank 
> you! 

I've commit on your behalf in 7685d818ef329cd3f6ef121af1208be409eb59db 
, thank 
you for the patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93402

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


[clang] 7685d81 - Mark implicit coroutine variables as being implicit

2020-12-16 Thread Aaron Ballman via cfe-commits

Author: Emma Blink
Date: 2020-12-16T14:42:07-05:00
New Revision: 7685d818ef329cd3f6ef121af1208be409eb59db

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

LOG: Mark implicit coroutine variables as being implicit

This prevents the clang-tidy readability-identifier-naming check from
triggering on implicit __coro_gro and __promise variables in coroutines.

Added: 

clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/system/coroutines.h

Modified: 
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
clang/lib/Sema/SemaCoroutine.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/system/coroutines.h
 
b/clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/system/coroutines.h
new file mode 100644
index ..b38dac52
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/system/coroutines.h
@@ -0,0 +1,34 @@
+#pragma once
+
+namespace std {
+namespace experimental {
+
+template 
+struct coroutine_traits {
+  using promise_type = typename ret_t::promise_type;
+};
+
+template 
+struct coroutine_handle {
+  static constexpr coroutine_handle from_address(void *addr) noexcept { return 
{}; };
+};
+
+} // namespace experimental
+} // namespace std
+
+struct never_suspend {
+  bool await_ready() noexcept { return false; }
+  template 
+  void await_suspend(coro_t handle) noexcept {}
+  void await_resume() noexcept {}
+};
+
+struct task {
+  struct promise_type {
+task get_return_object() noexcept { return {}; }
+never_suspend initial_suspend() noexcept { return {}; }
+never_suspend final_suspend() noexcept { return {}; }
+void return_void() {}
+void unhandled_exception() {}
+  };
+};

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
index 66b6009d62ae..f66202ecd11b 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
@@ -81,13 +81,14 @@
 // RUN: {key: readability-identifier-naming.LocalPointerPrefix, value: 
'l_'}, \
 // RUN: {key: readability-identifier-naming.LocalConstantPointerCase, 
value: CamelCase}, \
 // RUN: {key: readability-identifier-naming.LocalConstantPointerPrefix, 
value: 'lc_'}, \
-// RUN:   ]}' -- -fno-delayed-template-parsing -Dbad_macro \
+// RUN:   ]}' -- -fno-delayed-template-parsing -Dbad_macro -std=c++17 
-fcoroutines-ts \
 // RUN:   -I%S/Inputs/readability-identifier-naming \
 // RUN:   -isystem %S/Inputs/readability-identifier-naming/system
 
 // clang-format off
 
 #include 
+#include 
 #include "user-header.h"
 // NO warnings or fixes expected from declarations within header files without
 // the -header-filter= option
@@ -287,7 +288,7 @@ class COverriding : public AOverridden {
   // Overriding a badly-named base isn't a new violation.
   void BadBaseMethod() override {}
   // CHECK-FIXES: {{^}}  void v_Bad_Base_Method() override {}
-  
+
   void foo() {
 BadBaseMethod();
 // CHECK-FIXES: {{^}}v_Bad_Base_Method();
@@ -614,3 +615,14 @@ template
 auto GetRes(type_t& Param) -> decltype(Param.res());
 // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for parameter 
'Param'
 // CHECK-FIXES: auto GetRes(type_t& a_param) -> decltype(a_param.res());
+
+// Check implicit declarations in coroutines
+
+struct async_obj {
+public:
+  never_suspend operator co_await() const noexcept;
+};
+
+task ImplicitDeclTest(async_obj _object) {
+  co_await a_object;  // CHECK-MESSAGES-NOT: warning: invalid case style for 
local variable
+}

diff  --git a/clang/lib/Sema/SemaCoroutine.cpp 
b/clang/lib/Sema/SemaCoroutine.cpp
index 76820616fb9d..7a48bfa429e9 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -544,6 +544,7 @@ VarDecl *Sema::buildCoroutinePromise(SourceLocation Loc) {
   auto *VD = VarDecl::Create(Context, FD, FD->getLocation(), FD->getLocation(),
  ().get("__promise"), T,
  Context.getTrivialTypeSourceInfo(T, Loc), 
SC_None);
+  VD->setImplicit();
   CheckVariableDeclarationType(VD);
   if (VD->isInvalidDecl())
 return nullptr;
@@ -1577,6 +1578,7 @@ bool CoroutineStmtBuilder::makeGroDeclAndReturnStmt() {
   S.Context, , FD.getLocation(), FD.getLocation(),
   ().get("__coro_gro"), GroType,
   S.Context.getTrivialTypeSourceInfo(GroType, Loc), SC_None);
+  GroDecl->setImplicit();
 
   S.CheckVariableDeclarationType(GroDecl);
   if (GroDecl->isInvalidDecl())




[PATCH] D90275: [clang][IR] Add support for leaf attribute

2020-12-16 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem added a comment.

> I fixed it in
> https://reviews.llvm.org/D92493
> But that was just to make my test pass.

Ok, thank you! 
I did not realize that typo after the merge, and sorry about that!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90275

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


[PATCH] D93110: [analyzer] Implement a first version of suppressions via attributes

2020-12-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D93110#2448587 , @vsavchenko wrote:

> Right now, I reused existing `suppress` attribute.  However I did it in a 
> rather unconventional manner.  I allowed 0 arguments in one spelling and >1 
> in another, which seems odd.
> I can see a couple other possible solutions here:
>
> - Choose a "keyword" that would be used to suppress all warnings (e.g. 
> "suppress(all)")
> - Introduce two different suppress attributes (maybe even rename existing 
> attribute to be GSLSuppress)

I don't think it's a problem that we use the same semantic attribute but with 
different syntax requirements for the arguments. The semantics for GSL 
suppression and Clang suppression are the same so it makes sense to me to use 
the same semantic attribute so we don't wind up checking `isa(D)` everywhere. However, if it does start to get awkward, I think 
splitting the attributes into two different semantic attributes is preferable 
to using a keyword.

One usability concern I have with adding `[[clang::suppress]]` is that users 
are going to want to use it to suppress all the various kinds of diagnostics 
and not just clang static analyzer warnings. We get away with 
`[[gsl::suppress]]` because that's very specific to the C++ core guidelines, 
but we can't really hand-wave away the problem with `[[clang::suppress]]`. Have 
you explored how this attribute will work with clang frontend diagnostics or 
clang-tidy diagnostics? (This ignores some of the even harder diagnostics like 
ones that percolate back up from the backend, but we should probably keep those 
in mind as well.)




Comment at: clang/include/clang/Basic/Attr.td:2366
   let Args = [VariadicStringArgument<"DiagnosticIdentifiers">];
   let Documentation = [SuppressDocs];
 }

The documentation will need to be updated for this. I have no idea if that may 
be a bit awkward because we're documenting two different suppression mechanisms 
(that do roughly the same thing).



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4567
 static void handleSuppressAttr(Sema , Decl *D, const ParsedAttr ) {
-  if (!checkAttributeAtLeastNumArgs(S, AL, 1))
+  if (AL.isCXX11Attribute() && !checkAttributeAtLeastNumArgs(S, AL, 1))
 return;

The behavior here will be that `[[gsl::suppress]]` in C++11 mode and 
`[[clang::suppress]]` in C++11 mode require at least one argument, while 
`[[clang::supress]]` in C2x mode and `__attribute__((suppress))` in all 
language modes allow any number of arguments (including zero). That doesn't 
seem like what you want. I think you need something more like:
```
// The [[gsl::suppress]] spelling requires at least one argument, but the GNU
// and [[clang::suppress]] spellings do not require any arguments.
if (AL.hasScope() && AL.getScopeName()->isStr("gsl") &&
!checkAttributeAtLeastNumArgs(S, AL, 1))
  return;
```



Comment at: clang/lib/Sema/SemaStmtAttr.cpp:56
 SourceRange Range) {
-  if (A.getNumArgs() < 1) {
+  if (A.isCXX11Attribute() && A.getNumArgs() < 1) {
 S.Diag(A.getLoc(), diag::err_attribute_too_few_arguments) << A << 1;

Same issue here.

(In other news, it looks like this attribute could stand to be updated to be a 
`DeclOrStmtAttr` once D92800 lands -- that's not your problem to solve, more 
just an observation.)



Comment at: clang/lib/Sema/SemaStmtAttr.cpp:69
 // FIXME: Warn if the rule name is unknown. This is tricky because only
-// clang-tidy knows about available rules.
+// clang-tidy and static analyzer know about available rules.
 DiagnosticIdentifiers.push_back(RuleName);





Comment at: clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2885
+
+  if (It != Attrs.end()) {
+return cast(*It);

The coding standard has us elide braces on single-line ifs (same comment 
applies elsewhere).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93110

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


Re: [PATCH] D90275: [clang][IR] Add support for leaf attribute

2020-12-16 Thread Rong Xu via cfe-commits
yes. Also #43 should be #42
I fixed it in
https://reviews.llvm.org/D92493
But that was just to make my test pass.

On Wed, Dec 16, 2020 at 11:35 AM Gulfem Savrun Yeniceri via Phabricator <
revi...@reviews.llvm.org> wrote:

> gulfem added a comment.
>
> > The problem in `llvm/test/Bitcode/attributes.ll` is clear?
>
> Instead of `define void @f70() nocallback`, it should be `define void
> @f69() nocallback`, right?
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D90275/new/
>
> https://reviews.llvm.org/D90275
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83892: [clang][cli] Port CodeGen option flags to new option parsing system

2020-12-16 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D83892#2458049 , @probinson wrote:

> One thing this patch does, is make decisions about default behavior static.  
> Meaning, the option behavior cannot depend on other options; specifically, it 
> can't be based on the triple, which allows target-specific customization.  
> PS4 certainly has cases where our defaults are different from the usual ones, 
> and I'd kind of think that was true for other targets as well.
>
> Sorry I didn't notice this patch before, our CI has just tried to merge it.  
> We've patched it up in our main branch but I'm not sure what the upstream 
> intent is here.

`BoolOption` doesn't support dynamic defaults, but `BoolOptionBase` does. 
Here's an example of how to use it:

  defm legacy_pass_manager : BoolOptionBase<"legacy-pass-manager",
"CodeGenOpts.LegacyPassManager", 
Default<"!static_cast(LLVM_ENABLE_NEW_PASS_MANAGER)">,
FlagDef,
FlagDef,
FlagDefSuffix<[CC1Option], "">, "f">, Group;

For depending on `-triple`, you should be able to do something like:

  defm this_option : BoolOptionBase<...,
  Default<"getDefaultForThisOption(TargetOptions->Triple)",
  ...>

if I understand your use case correctly (it's important to define `this_option` 
after the definition of `triple`).

Maybe it's worth defining another set of derived multiclasses, something like:

  defm legacy_pass_manager : DynamicBoolFOption<"legacy-pass-manager",
"CodeGenOpts.LegacyPassManager", 
Default<"!static_cast(LLVM_ENABLE_NEW_PASS_MANAGER)">,
TrueFlag,
FalseFlag,
BothFlags<[], " pass manager in LLVM">>;

WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83892

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


[PATCH] D90275: [clang][IR] Add support for leaf attribute

2020-12-16 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem added a comment.

> The problem in `llvm/test/Bitcode/attributes.ll` is clear?

Instead of `define void @f70() nocallback`, it should be `define void @f69() 
nocallback`, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90275

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


[PATCH] D93402: [clang-tidy] prevent readability-identifier-naming from triggering on implicit VarDecls in coroutines

2020-12-16 Thread Emma Blink via Phabricator via cfe-commits
0x1eaf added a comment.

> Do you need me to commit on your behalf?

Yes, I don't have commit access. The attribution line looks good to me. Thank 
you! 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93402

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


[PATCH] D93402: [clang-tidy] prevent readability-identifier-naming from triggering on implicit VarDecls in coroutines

2020-12-16 Thread Emma Blink via Phabricator via cfe-commits
0x1eaf updated this revision to Diff 312272.
0x1eaf added a comment.

Updated to address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93402

Files:
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/system/coroutines.h
  clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
  clang/lib/Sema/SemaCoroutine.cpp

Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -544,6 +544,7 @@
   auto *VD = VarDecl::Create(Context, FD, FD->getLocation(), FD->getLocation(),
  ().get("__promise"), T,
  Context.getTrivialTypeSourceInfo(T, Loc), SC_None);
+  VD->setImplicit();
   CheckVariableDeclarationType(VD);
   if (VD->isInvalidDecl())
 return nullptr;
@@ -1577,6 +1578,7 @@
   S.Context, , FD.getLocation(), FD.getLocation(),
   ().get("__coro_gro"), GroType,
   S.Context.getTrivialTypeSourceInfo(GroType, Loc), SC_None);
+  GroDecl->setImplicit();
 
   S.CheckVariableDeclarationType(GroDecl);
   if (GroDecl->isInvalidDecl())
Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
@@ -81,13 +81,14 @@
 // RUN: {key: readability-identifier-naming.LocalPointerPrefix, value: 'l_'}, \
 // RUN: {key: readability-identifier-naming.LocalConstantPointerCase, value: CamelCase}, \
 // RUN: {key: readability-identifier-naming.LocalConstantPointerPrefix, value: 'lc_'}, \
-// RUN:   ]}' -- -fno-delayed-template-parsing -Dbad_macro \
+// RUN:   ]}' -- -fno-delayed-template-parsing -Dbad_macro -std=c++17 -fcoroutines-ts \
 // RUN:   -I%S/Inputs/readability-identifier-naming \
 // RUN:   -isystem %S/Inputs/readability-identifier-naming/system
 
 // clang-format off
 
 #include 
+#include 
 #include "user-header.h"
 // NO warnings or fixes expected from declarations within header files without
 // the -header-filter= option
@@ -287,7 +288,7 @@
   // Overriding a badly-named base isn't a new violation.
   void BadBaseMethod() override {}
   // CHECK-FIXES: {{^}}  void v_Bad_Base_Method() override {}
-  
+
   void foo() {
 BadBaseMethod();
 // CHECK-FIXES: {{^}}v_Bad_Base_Method();
@@ -614,3 +615,14 @@
 auto GetRes(type_t& Param) -> decltype(Param.res());
 // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for parameter 'Param'
 // CHECK-FIXES: auto GetRes(type_t& a_param) -> decltype(a_param.res());
+
+// Check implicit declarations in coroutines
+
+struct async_obj {
+public:
+  never_suspend operator co_await() const noexcept;
+};
+
+task ImplicitDeclTest(async_obj _object) {
+  co_await a_object;  // CHECK-MESSAGES-NOT: warning: invalid case style for local variable
+}
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/system/coroutines.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/system/coroutines.h
@@ -0,0 +1,34 @@
+#pragma once
+
+namespace std {
+namespace experimental {
+
+template 
+struct coroutine_traits {
+  using promise_type = typename ret_t::promise_type;
+};
+
+template 
+struct coroutine_handle {
+  static constexpr coroutine_handle from_address(void *addr) noexcept { return {}; };
+};
+
+} // namespace experimental
+} // namespace std
+
+struct never_suspend {
+  bool await_ready() noexcept { return false; }
+  template 
+  void await_suspend(coro_t handle) noexcept {}
+  void await_resume() noexcept {}
+};
+
+struct task {
+  struct promise_type {
+task get_return_object() noexcept { return {}; }
+never_suspend initial_suspend() noexcept { return {}; }
+never_suspend final_suspend() noexcept { return {}; }
+void return_void() {}
+void unhandled_exception() {}
+  };
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90275: [clang][IR] Add support for leaf attribute

2020-12-16 Thread Rong Xu via Phabricator via cfe-commits
xur added a comment.

This breaks  llvm/test/Bitcode/attributes.ll.
The added test code was obviously wrong.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90275

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


[PATCH] D93258: [amdgpu] Default to code object v3

2020-12-16 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93258

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


[PATCH] D91444: [InstCombine] Preserve !annotation metadata for memory combines.

2020-12-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri accepted this revision.
lebedev.ri added a comment.

In D91444#2458024 , @fhahn wrote:

> In D91444#2394512 , @lebedev.ri 
> wrote:
>
>> What about teaching IRBuilder to deal with it like it deals with debugloc?
>
> Done! Together with D93400  this patch now 
> boils down to requesting !annotation to be preserved for instructions created 
> by IRBuilder.

Yay, now this does look good to me.
Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91444

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


[PATCH] D91444: [InstCombine] Preserve !annotation metadata for memory combines.

2020-12-16 Thread Francis Visoiu Mistrih via Phabricator via cfe-commits
thegameg accepted this revision.
thegameg added a comment.
This revision is now accepted and ready to land.

LGTM, nice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91444

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


[PATCH] D92788: [clangd] NFC: Use SmallVector where possible

2020-12-16 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/Headers.h:139
   // Maps a file's index to that of the files it includes.
-  llvm::DenseMap> IncludeChildren;
+  llvm::DenseMap> IncludeChildren;
 };

arphaman wrote:
> It looks like the change on this line is failing to compile on Ubuntu 16.04 
> with the System GCC. 
> (https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04-next/23655/console).
> 
> Can I reinstate the `llvm::DenseMap>` for 
> now until we drop support for Ubuntu 16.04?
Uh, didn't see that one, I'm sorry to hear that. Yes, sure, feel free to change 
it to make your setup work!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92788

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


[PATCH] D93102: [Clang][Sema] Detect section type conflicts between functions and variables

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

LGTM aside from a minor nit. Thank you for the patch! Do you need me to commit 
on your behalf? If so, are you okay with `Tomas Matheson 
` for patch attribution?




Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3086-3087
 D->addAttr(NewAttr);
+if (isa(D) || isa(D) ||
+isa(D) || isa(D))
+  S.UnifySection(NewAttr->getName(),




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93102

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


[PATCH] D84186: [clang][cli] Convert Analyzer option string based options to new option parsing system

2020-12-16 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h:261-263
   /// The inlining stack depth limit.
-  // Cap the stack depth at 4 calls (5 stack frames, base + 4 calls).
-  unsigned InlineMaxStackDepth = 5;
+  unsigned InlineMaxStackDepth;
 

jansvoboda11 wrote:
> dexonsmith wrote:
> > Hmm, I wonder if this is entirely better. It's not obvious at all, looking 
> > at the code here, whether `InlineMaxStackDepth` can be used without getting 
> > initialized at all.
> > 
> > I agree we should have the default value in two places -- I think removing 
> > assignment to 5 is the right thing to do -- but I'm not sure leaving this 
> > entirely uninitialized is a good thing. WDYT of initializing it to 0?
> I think leaving this uninitialized communicates the fact that it will be 
> initialized somewhere else.
> 
> If I saw `unsigned InlineMacStackDepth = 0;` and then observed it changing to 
> `5` without passing `-analyzer-inline-max-stack-depth=5`, I'd be surprised.
Okay, that's fair.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84186

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


[PATCH] D92600: [ASTImporter] Add support for importing GenericSelectionExpr AST nodes.

2020-12-16 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder updated this revision to Diff 312256.
tmroeder added a comment.

Rebase to the latest head, mostly to force the CI infrastructure to run again 
now that it is said to work again: 
https://github.com/google/llvm-premerge-checks/issues/268#issuecomment-745979134.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92600

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/lib/Analysis/ExprMutationAnalyzer.cpp
  clang/test/ASTMerge/generic-selection-expr/Inputs/generic.c
  clang/test/ASTMerge/generic-selection-expr/Inputs/generic.cpp
  clang/test/ASTMerge/generic-selection-expr/test.c
  clang/test/ASTMerge/generic-selection-expr/test.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/StructuralEquivalenceTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -982,6 +982,11 @@
   EXPECT_TRUE(matches("int* i = __null;", gnuNullExpr()));
 }
 
+TEST_P(ASTMatchersTest, GenericSelectionExpr) {
+  EXPECT_TRUE(matches("void f() { (void)_Generic(1, int: 1, float: 2.0); }",
+  genericSelectionExpr()));
+}
+
 TEST_P(ASTMatchersTest, AtomicExpr) {
   EXPECT_TRUE(matches("void foo() { int *ptr; __atomic_load_n(ptr, 1); }",
   atomicExpr()));
Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -1598,6 +1598,72 @@
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
+TEST_F(StructuralEquivalenceStmtTest, GenericSelectionExprSame) {
+  auto t = makeWrappedStmts("_Generic(0u, unsigned int: 0, float: 1)",
+"_Generic(0u, unsigned int: 0, float: 1)", Lang_C99,
+genericSelectionExpr());
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceStmtTest, GenericSelectionExprSignsDiffer) {
+  auto t = makeWrappedStmts("_Generic(0u, unsigned int: 0, float: 1)",
+"_Generic(0, int: 0, float: 1)", Lang_C99,
+genericSelectionExpr());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceStmtTest, GenericSelectionExprOrderDiffers) {
+  auto t = makeWrappedStmts("_Generic(0u, unsigned int: 0, float: 1)",
+"_Generic(0u, float: 1, unsigned int: 0)", Lang_C99,
+genericSelectionExpr());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceStmtTest, GenericSelectionExprDependentResultSame) {
+  auto t = makeStmts(
+  R"(
+  template 
+  void f() {
+T x;
+(void)_Generic(x, int: 0, float: 1);
+  }
+  void g() { f(); }
+  )",
+  R"(
+  template 
+  void f() {
+T x;
+(void)_Generic(x, int: 0, float: 1);
+  }
+  void g() { f(); }
+  )",
+  Lang_CXX03, genericSelectionExpr());
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceStmtTest,
+   GenericSelectionExprDependentResultOrderDiffers) {
+  auto t = makeStmts(
+  R"(
+  template 
+  void f() {
+T x;
+(void)_Generic(x, float: 1, int: 0);
+  }
+  void g() { f(); }
+  )",
+  R"(
+  template 
+  void f() {
+T x;
+(void)_Generic(x, int: 0, float: 1);
+  }
+  void g() { f(); }
+  )",
+  Lang_CXX03, genericSelectionExpr());
+
+  EXPECT_FALSE(testStructuralMatch(t));
+}
 TEST_F(StructuralEquivalenceStmtTest, IntegerLiteral) {
   auto t = makeWrappedStmts("1", "1", Lang_CXX03, integerLiteral());
   EXPECT_TRUE(testStructuralMatch(t));
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -279,6 +279,15 @@
  functionDecl(hasDescendant(gnuNullExpr(hasType(isInteger());
 }
 
+TEST_P(ImportExpr, ImportGenericSelectionExpr) {
+  MatchVerifier Verifier;
+
+  testImport(
+  "void declToImport() { int x; (void)_Generic(x, int: 0, float: 1); }",
+  Lang_C99, "", Lang_C99, Verifier,
+  functionDecl(hasDescendant(genericSelectionExpr(;
+}
+
 TEST_P(ImportExpr, ImportCXXNullPtrLiteralExpr) {
   MatchVerifier Verifier;
   testImport(
@@ -1087,6 +1096,36 @@
 ToChooseExpr->isConditionDependent());
 }
 

[PATCH] D92788: [clangd] NFC: Use SmallVector where possible

2020-12-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: clang-tools-extra/clangd/Headers.h:139
   // Maps a file's index to that of the files it includes.
-  llvm::DenseMap> IncludeChildren;
+  llvm::DenseMap> IncludeChildren;
 };

It looks like the change on this line is failing to compile on Ubuntu 16.04 
with the System GCC. 
(https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04-next/23655/console).

Can I reinstate the `llvm::DenseMap>` for 
now until we drop support for Ubuntu 16.04?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92788

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


[PATCH] D92039: [-Wcalled-once-parameter] Introduce 'called_once' attribute

2020-12-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D92039#2458042 , @vsavchenko wrote:

> That was a tough choice whether we should do it in the analyzer or not.
> The analyzer check would've been easier in terms of existing infrastructure, 
> path sensitivity, and IPA.  It is also much more lenient in terms of false 
> positives (it is expected that the analyzer can have those).
> However, warnings have much broader audience and we aim for a higher numbers 
> of people to check their code (we've been asked to deliver it for 8 years).  
> And because the analyzer doesn't have cross-translation unit analysis, the 
> problem with inter procedural bugs appears as well.

There have been efforts to add cross-TU support to the static analyzer, so I'm 
less worried about cross-TU inter-procedural bugs over the long term as I would 
expect that situation to be improved.

>> From the test cases you have, it looks like you explicitly allow this code 
>> without diagnosing it, which suggests the attribute is really a property of 
>> the function and not a property of the parameter.
>
> I have to disagree here.  //Semantically// this is a property of a parameter 
> and the fact that we couldn't analyze inter-procedurally is our own problem 
> and implementation detail.

Okay, that's good to know that you think the semantics should follow the 
parameter rather than the function. I agree that the analysis part is our own 
problem, I'm mostly trying to make sure we add this functionality to the 
correct place within the toolchain.

> We don't want to bother users with this.  As far as I understand, the 
> majority of existing warnings are not complete (don't find every bug) and 
> this warning is not different.

I think my concern is somewhat different. If the goal is for the semantics to 
follow the parameter (which I also think is the correct behavior), then I think 
adding this as a frontend analysis is the incorrect place for the check to go 
because someday we're going to want the inter-procedural analysis and that will 
require us to figure out what to do with the frontend bits vs the static 
analyzer bits. If it starts off in the static analyzer, then the later 
improvements to the analysis capabilities don't require the user to change the 
way they interact with the toolchain.

Or do you expect that this analysis is sufficient and you don't expect to ever 
extend it to be inter-procedural?

>> and the user marks the functions that should be exempt from the checking 
>> rather than marking the parameters that should be checked
>
> Essentially, there is a way to prevent function from being analyzed by 
> `-Wcompletion-handler` - annotate it with 
> `__attribute__((swift_async(none)))`.

Ah, that's good to know, thanks!




Comment at: clang/include/clang/Basic/AttrDocs.td:5133-5134
+
+This attribute is useful for API developers who want to double-check if they
+implemented their method correctly.
+

vsavchenko wrote:
> aaron.ballman wrote:
> > Oh, I was thinking this attribute was enabling some optimization 
> > opportunities or doing something more than just acting as a marker to 
> > please check this function's correctness for some properties. This means 
> > that the programmer has to annotate their code and enable the warning flag 
> > in order for either the attribute or the warning flag to have effect, which 
> > feels a bit surprising to me.
> For explicitly marked parameters, it's on by default, so the users can simply 
> annotate their parameters and get their checks.
Ah, yes, there are two diagnostics being used and only one of them is off by 
default. Thank you for clarifying.



Comment at: clang/include/clang/Basic/AttrDocs.td:5098-5102
+* Parameter is not called at all.
+
+* Parameter is called more than once.
+
+* Parameter is not called on one of the execution paths.

vsavchenko wrote:
> aaron.ballman wrote:
> > I think you may have to remove the newlines here to make this a single 
> > bulleted list in Sphinx.
> I checked it, it is one list with newlines: {F14734606}
Oh, good to know, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92039

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


[PATCH] D93402: [clang-tidy] prevent readability-identifier-naming from triggering on implicit VarDecls in coroutines

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

LGTM aside from some small nits, thank you for the fix! Do you need me to 
commit on your behalf? (If so, are you okay with using `Emma Blink 
` for patch attribution?)




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp:619
+
+#pragma mark - Check implicit declarations in coroutines
+





Comment at: clang/lib/Sema/SemaCoroutine.cpp:547
  Context.getTrivialTypeSourceInfo(T, Loc), 
SC_None);
+  VD->setImplicit(true);
   CheckVariableDeclarationType(VD);





Comment at: clang/lib/Sema/SemaCoroutine.cpp:1581
   S.Context.getTrivialTypeSourceInfo(GroType, Loc), SC_None);
+  GroDecl->setImplicit(true);
 




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93402

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


[PATCH] D93350: [Test] Fix undef var in catch-undef-behavior.c

2020-12-16 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93350

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


[PATCH] D93068: [clang-offload-bundler] Add option -allow-missing-bundles

2020-12-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D93068#2457946 , @yaxunl wrote:

> @ABataev Is this patch OK for OpenMP? It is NFC for OpenMP toolchain but 
> affects using clang-offload-bundler as a standalone tool. Thanks.

Yes, I think it is ok.


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

https://reviews.llvm.org/D93068

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


[PATCH] D87146: [analyzer] Implement shared semantics checks for XNU functions in PthreadLockChecker

2020-12-16 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

Hey, folk. Please, look at this revision.
This is the **2nd** revision from the //stack of 3//. Its aim is preparing the 
field for the **3rd** revision (also welcome to review). The **1st** one has 
been closed.


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

https://reviews.llvm.org/D87146

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


[clang] 6eff127 - [DDG] Data Dependence Graph - DOT printer - recommit

2020-12-16 Thread Bardia Mahjour via cfe-commits

Author: Bardia Mahjour
Date: 2020-12-16T12:37:36-05:00
New Revision: 6eff12788ee8d3f85f6e57809e757ca3250813d8

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

LOG: [DDG] Data Dependence Graph - DOT printer - recommit

This is being recommitted to try and address the MSVC complaint.

This patch implements a DDG printer pass that generates a graph in
the DOT description language, providing a more visually appealing
representation of the DDG. Similar to the CFG DOT printer, this
functionality is provided under an option called -dot-ddg and can
be generated in a less verbose mode under -dot-ddg-only option.

Reviewed By: Meinersbur

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

Added: 
llvm/include/llvm/Analysis/DDGPrinter.h
llvm/lib/Analysis/DDGPrinter.cpp

Modified: 
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
llvm/include/llvm/Analysis/CFGPrinter.h
llvm/include/llvm/Analysis/DDG.h
llvm/include/llvm/Support/DOTGraphTraits.h
llvm/include/llvm/Support/GraphWriter.h
llvm/lib/Analysis/CFGPrinter.cpp
llvm/lib/Analysis/CMakeLists.txt
llvm/lib/Analysis/CallPrinter.cpp
llvm/lib/CodeGen/MachineScheduler.cpp
llvm/lib/CodeGen/ScheduleDAGPrinter.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 409741cdb6e4..f285b652c175 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3149,7 +3149,7 @@ struct DOTGraphTraits : public 
DefaultDOTGraphTraits {
   if (Stop(N))
 return true;
 
-  if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc()))
+  if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc(), nullptr))
 break;
   PostCallback(N);
 
@@ -3158,7 +3158,7 @@ struct DOTGraphTraits : public 
DefaultDOTGraphTraits {
 return false;
   }
 
-  static bool isNodeHidden(const ExplodedNode *N) {
+  static bool isNodeHidden(const ExplodedNode *N, const ExplodedGraph *G) {
 return N->isTrivial();
   }
 

diff  --git a/llvm/include/llvm/Analysis/CFGPrinter.h 
b/llvm/include/llvm/Analysis/CFGPrinter.h
index bc6a19f2e2b9..53700798b6b3 100644
--- a/llvm/include/llvm/Analysis/CFGPrinter.h
+++ b/llvm/include/llvm/Analysis/CFGPrinter.h
@@ -295,7 +295,7 @@ struct DOTGraphTraits : public 
DefaultDOTGraphTraits {
 " fillcolor=\"" + Color + "70\"";
 return Attrs;
   }
-  bool isNodeHidden(const BasicBlock *Node);
+  bool isNodeHidden(const BasicBlock *Node, const DOTFuncInfo *CFGInfo);
   void computeHiddenNodes(const Function *F);
 };
 } // End llvm namespace

diff  --git a/llvm/include/llvm/Analysis/DDG.h 
b/llvm/include/llvm/Analysis/DDG.h
index 9e2b7907eaec..8d225c155cd4 100644
--- a/llvm/include/llvm/Analysis/DDG.h
+++ b/llvm/include/llvm/Analysis/DDG.h
@@ -290,6 +290,12 @@ template  class DependenceGraphInfo {
   bool getDependencies(const NodeType , const NodeType ,
DependenceList ) const;
 
+  /// Return a string representing the type of dependence that the dependence
+  /// analysis identified between the two given nodes. This function assumes
+  /// that there is a memory dependence between the given two nodes.
+  const std::string getDependenceString(const NodeType ,
+const NodeType ) const;
+
 protected:
   // Name of the graph.
   std::string Name;
@@ -463,6 +469,26 @@ bool DependenceGraphInfo::getDependencies(
   return !Deps.empty();
 }
 
+template 
+const std::string
+DependenceGraphInfo::getDependenceString(const NodeType ,
+   const NodeType ) const {
+  std::string Str;
+  raw_string_ostream OS(Str);
+  DependenceList Deps;
+  if (!getDependencies(Src, Dst, Deps))
+return OS.str();
+  interleaveComma(Deps, OS, [&](const std::unique_ptr ) {
+D->dump(OS);
+// Remove the extra new-line character printed by the dump
+// method
+if (OS.str().back() == '\n')
+  OS.str().pop_back();
+  });
+
+  return OS.str();
+}
+
 //======//
 // GraphTraits specializations for the DDG
 //======//

diff  --git a/llvm/include/llvm/Analysis/DDGPrinter.h 
b/llvm/include/llvm/Analysis/DDGPrinter.h
new file mode 100644
index ..4477b387fe50
--- /dev/null
+++ b/llvm/include/llvm/Analysis/DDGPrinter.h
@@ -0,0 +1,91 @@
+//===- llvm/Analysis/DDGPrinter.h ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See 

[PATCH] D93102: [Clang][Sema] Detect section type conflicts between functions and variables

2020-12-16 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson marked 3 inline comments as done.
tmatheson added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3048
 D->addAttr(NewAttr);
+if (auto FD = dyn_cast(D))
+  if (auto SA = dyn_cast(NewAttr))

aaron.ballman wrote:
> Does this need to be limited to function declarations? It seems to me that 
> this should also be used on say ObjCMethod declarations or global variables 
> as well, right?
> 
> If so, then `Sema::UnifySection()` may need to be updated as well as it 
> currently accepts a `DeclaratorDecl` but some of these constructs (like 
> `ObjcMethodDecl` and `ObjCPropertyDecl`) are `NamedDecl`s and not declarators.
I've extended this to include Objective-C methods and properties and template 
functions. Gobal variables are handled by 
Sema::CheckCompleteVariableDeclaration.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93102

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


[PATCH] D90159: [DDG] Data Dependence Graph - DOT printer

2020-12-16 Thread Bardia Mahjour via Phabricator via cfe-commits
bmahjour added a comment.

In D90159#2454905 , @bmahjour wrote:

> In D90159#2453805 , @Meinersbur 
> wrote:
>
>> Can I help fixing the Windows build problem?
>
> I think I have a fix (please see the updated patch), but don't have access to 
> a windows machine to verify. Would you be able to try building with MSVC and 
> let me know if it passes?

I'll try to recommit and watch the windows buildbots.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90159

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


[PATCH] D91974: [PowerPC] Rename the vector pair intrinsics and builtins to replace the _mma_ prefix by _vsx_

2020-12-16 Thread Baptiste Saleil via Phabricator via cfe-commits
bsaleil updated this revision to Diff 312238.
bsaleil added a comment.

Rebase and fix comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91974

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-mma.c
  clang/test/CodeGen/builtins-ppc-pair-mma.c
  clang/test/Sema/ppc-mma-types.c
  clang/test/Sema/ppc-pair-mma-types.c
  clang/test/SemaCXX/ppc-mma-types.cpp
  clang/test/SemaCXX/ppc-pair-mma-types.cpp
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
  llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
  llvm/test/CodeGen/PowerPC/dform-pair-load-store.ll
  llvm/test/CodeGen/PowerPC/loop-p10-pair-prepare.ll
  llvm/test/CodeGen/PowerPC/mma-intrinsics.ll
  llvm/test/CodeGen/PowerPC/mma-outer-product.ll
  llvm/test/CodeGen/PowerPC/mma-phi-accs.ll
  llvm/test/CodeGen/PowerPC/more-dq-form-prepare.ll
  llvm/test/CodeGen/PowerPC/paired-vector-intrinsics-without-mma.ll
  llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll

Index: llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll
@@ -0,0 +1,357 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O3 \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr \
+; RUN:   < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O3 \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr -mattr=-mma \
+; RUN:   < %s | FileCheck %s --check-prefix=CHECK-NOMMA
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O3 \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr \
+; RUN:   < %s | FileCheck %s --check-prefix=CHECK-BE
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O3 \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr -mattr=-mma \
+; RUN:   < %s | FileCheck %s --check-prefix=CHECK-BE-NOMMA
+
+; This test also checks that the paired vector intrinsics are available even
+; when MMA is disabled.
+
+; assemble_pair
+declare <256 x i1> @llvm.ppc.vsx.assemble.pair(<16 x i8>, <16 x i8>)
+define void @ass_pair(<256 x i1>* %ptr, <16 x i8> %vc) {
+; CHECK-LABEL: ass_pair:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmr v3, v2
+; CHECK-NEXT:stxv v2, 16(r3)
+; CHECK-NEXT:stxv v3, 0(r3)
+; CHECK-NEXT:blr
+;
+; CHECK-NOMMA-LABEL: ass_pair:
+; CHECK-NOMMA:   # %bb.0: # %entry
+; CHECK-NOMMA-NEXT:vmr v3, v2
+; CHECK-NOMMA-NEXT:stxv v2, 16(r3)
+; CHECK-NOMMA-NEXT:stxv v3, 0(r3)
+; CHECK-NOMMA-NEXT:blr
+;
+; CHECK-BE-LABEL: ass_pair:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:vmr v3, v2
+; CHECK-BE-NEXT:stxv v2, 16(r3)
+; CHECK-BE-NEXT:stxv v2, 0(r3)
+; CHECK-BE-NEXT:blr
+;
+; CHECK-BE-NOMMA-LABEL: ass_pair:
+; CHECK-BE-NOMMA:   # %bb.0: # %entry
+; CHECK-BE-NOMMA-NEXT:vmr v3, v2
+; CHECK-BE-NOMMA-NEXT:stxv v2, 16(r3)
+; CHECK-BE-NOMMA-NEXT:stxv v2, 0(r3)
+; CHECK-BE-NOMMA-NEXT:blr
+entry:
+  %0 = tail call <256 x i1> @llvm.ppc.vsx.assemble.pair(<16 x i8> %vc, <16 x i8> %vc)
+  store <256 x i1> %0, <256 x i1>* %ptr, align 32
+  ret void
+}
+
+; disassemble_pair
+declare { <16 x i8>, <16 x i8> } @llvm.ppc.vsx.disassemble.pair(<256 x i1>)
+define void @disass_pair(<256 x i1>* %ptr1, <16 x i8>* %ptr2, <16 x i8>* %ptr3) {
+; CHECK-LABEL: disass_pair:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:lxv vs1, 0(r3)
+; CHECK-NEXT:lxv vs0, 16(r3)
+; CHECK-NEXT:stxv vs1, 0(r4)
+; CHECK-NEXT:stxv vs0, 0(r5)
+; CHECK-NEXT:blr
+;
+; CHECK-NOMMA-LABEL: disass_pair:
+; CHECK-NOMMA:   # %bb.0: # %entry
+; CHECK-NOMMA-NEXT:lxv vs1, 0(r3)
+; CHECK-NOMMA-NEXT:lxv vs0, 16(r3)
+; CHECK-NOMMA-NEXT:stxv vs1, 0(r4)
+; CHECK-NOMMA-NEXT:stxv vs0, 0(r5)
+; CHECK-NOMMA-NEXT:blr
+;
+; CHECK-BE-LABEL: disass_pair:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:lxv vs1, 16(r3)
+; CHECK-BE-NEXT:lxv vs0, 0(r3)
+; CHECK-BE-NEXT:stxv vs0, 0(r4)
+; CHECK-BE-NEXT:stxv vs1, 0(r5)
+; CHECK-BE-NEXT:blr
+;
+; CHECK-BE-NOMMA-LABEL: disass_pair:
+; CHECK-BE-NOMMA:   # %bb.0: # %entry
+; CHECK-BE-NOMMA-NEXT:lxv vs1, 16(r3)
+; CHECK-BE-NOMMA-NEXT:lxv vs0, 0(r3)
+; CHECK-BE-NOMMA-NEXT:stxv vs0, 0(r4)
+; CHECK-BE-NOMMA-NEXT:stxv vs1, 0(r5)
+; CHECK-BE-NOMMA-NEXT:blr
+entry:
+  %0 = load <256 x i1>, <256 x i1>* %ptr1, align 32
+  %1 = tail call { <16 x i8>, <16 x i8> } @llvm.ppc.vsx.disassemble.pair(<256 x i1> %0)
+  %2 = extractvalue { <16 x i8>, <16 x i8> } 

[PATCH] D93258: [amdgpu] Default to code object v3

2020-12-16 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 312236.
JonChesterfield added a comment.

- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93258

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/hip-code-object-version.hip
  llvm/docs/AMDGPUUsage.rst


Index: llvm/docs/AMDGPUUsage.rst
===
--- llvm/docs/AMDGPUUsage.rst
+++ llvm/docs/AMDGPUUsage.rst
@@ -911,12 +911,12 @@
 
   * ``ELFABIVERSION_AMDGPU_HSA_V3`` is used to specify the version of AMD HSA
 runtime ABI for code object V3. Specify using the Clang option
-``-mcode-object-version=3``.
+``-mcode-object-version=3``. This is the default code object
+version if not specified.
 
   * ``ELFABIVERSION_AMDGPU_HSA_V4`` is used to specify the version of AMD HSA
 runtime ABI for code object V4. Specify using the Clang option
-``-mcode-object-version=4``. This is the default code object
-version if not specified.
+``-mcode-object-version=4``.
 
   * ``ELFABIVERSION_AMDGPU_PAL`` is used to specify the version of AMD PAL
 runtime ABI.
@@ -2871,10 +2871,6 @@
 Code Object V3 Metadata
 +++
 
-.. warning::
-  Code object V3 is not the default code object version emitted by this version
-  of LLVM.
-
 Code object V3 to V4 metadata is specified by the ``NT_AMDGPU_METADATA`` note
 record (see :ref:`amdgpu-note-records-v3-v4`).
 
@@ -3279,6 +3275,10 @@
 Code Object V4 Metadata
 +++
 
+.. warning::
+  Code object V4 is not the default code object version emitted by this version
+  of LLVM.
+
 Code object V4 metadata is the same as
 :ref:`amdgpu-amdhsa-code-object-metadata-v3` with the changes and additions
 defined in table :ref:`amdgpu-amdhsa-code-object-metadata-map-table-v3`.
Index: clang/test/Driver/hip-code-object-version.hip
===
--- clang/test/Driver/hip-code-object-version.hip
+++ clang/test/Driver/hip-code-object-version.hip
@@ -53,7 +53,7 @@
 // RUN:   --offload-arch=gfx906 -nogpulib \
 // RUN:   %s 2>&1 | FileCheck -check-prefix=VD %s
 
-// VD: "-mllvm" "--amdhsa-code-object-version=4"
+// VD: "-mllvm" "--amdhsa-code-object-version=3"
 // VD: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
 
 // Check invalid code object version option.
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1549,7 +1549,7 @@
 const Driver , const llvm::opt::ArgList , bool Diagnose) {
   const unsigned MinCodeObjVer = 2;
   const unsigned MaxCodeObjVer = 4;
-  unsigned CodeObjVer = 4;
+  unsigned CodeObjVer = 3;
 
   // Emit warnings for legacy options even if they are overridden.
   if (Diagnose) {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2909,7 +2909,7 @@
  HelpText<"Execution model (WebAssembly only)">;
 
 def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, 
Group,
-  HelpText<"Specify code object ABI version. Defaults to 4. (AMDGPU only)">,
+  HelpText<"Specify code object ABI version. Defaults to 3. (AMDGPU only)">,
   MetaVarName<"">, Values<"2,3,4">;
 
 def mcode_object_v3_legacy : Flag<["-"], "mcode-object-v3">, Group,


Index: llvm/docs/AMDGPUUsage.rst
===
--- llvm/docs/AMDGPUUsage.rst
+++ llvm/docs/AMDGPUUsage.rst
@@ -911,12 +911,12 @@
 
   * ``ELFABIVERSION_AMDGPU_HSA_V3`` is used to specify the version of AMD HSA
 runtime ABI for code object V3. Specify using the Clang option
-``-mcode-object-version=3``.
+``-mcode-object-version=3``. This is the default code object
+version if not specified.
 
   * ``ELFABIVERSION_AMDGPU_HSA_V4`` is used to specify the version of AMD HSA
 runtime ABI for code object V4. Specify using the Clang option
-``-mcode-object-version=4``. This is the default code object
-version if not specified.
+``-mcode-object-version=4``.
 
   * ``ELFABIVERSION_AMDGPU_PAL`` is used to specify the version of AMD PAL
 runtime ABI.
@@ -2871,10 +2871,6 @@
 Code Object V3 Metadata
 +++
 
-.. warning::
-  Code object V3 is not the default code object version emitted by this version
-  of LLVM.
-
 Code object V3 to V4 metadata is specified by the ``NT_AMDGPU_METADATA`` note
 record (see :ref:`amdgpu-note-records-v3-v4`).
 
@@ -3279,6 +3275,10 @@
 Code Object V4 Metadata
 +++
 
+.. warning::
+  Code object V4 is not the default code object version emitted by this version
+  of LLVM.
+
 Code object V4 

[PATCH] D93102: [Clang][Sema] Detect section type conflicts between functions and variables

2020-12-16 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson updated this revision to Diff 312232.
tmatheson added a comment.
Herald added a subscriber: jdoerfert.

Extended to Objective-C methods and properties.
Added suggested C tests, C++ template function test and Objective-C tests.
I had to removed PSF_Implicit flag so that cases where the function was 
declared before the global variable were caught.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93102

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/attr-section.c
  clang/test/SemaCXX/attr-section.cpp
  clang/test/SemaObjC/method-attributes.m

Index: clang/test/SemaObjC/method-attributes.m
===
--- clang/test/SemaObjC/method-attributes.m
+++ clang/test/SemaObjC/method-attributes.m
@@ -99,3 +99,18 @@
 
 + (void) CMethod : (id) Obj __attribute__((section("__TEXT,fee")));
 @end
+
+// Section type conflicts between methods/properties and global variables
+const int global1 __attribute__((section("seg1,sec1"))) = 10; // expected-note {{declared here}} expected-note {{declared here}} expected-note {{declared here}}
+int global2 __attribute__((section("seg2,sec2"))) = 10;   // expected-note {{declared here}} expected-note {{declared here}} expected-note {{declared here}}
+
+@interface section_conflicts : NSObject
+@property int p1 __attribute__((section("seg1,sec1"))); // expected-error {{'p1' causes a section type conflict with 'global1'}}
+@property int p2 __attribute__((section("seg2,sec2"))); // expected-error {{'p2' causes a section type conflict with 'global2'}}
+
+- (void)imethod1 __attribute__((section("seg1,sec1"))); // expected-error {{'imethod1' causes a section type conflict with 'global1'}}
+- (void)imethod2 __attribute__((section("seg2,sec2"))); // expected-error {{'imethod2' causes a section type conflict with 'global2'}}
+
++ (void)cmethod1:(id)Obj __attribute__((section("seg1,sec1"))); // expected-error {{'cmethod1:' causes a section type conflict with 'global1'}}
++ (void)cmethod2:(id)Obj __attribute__((section("seg2,sec2"))); // expected-error {{'cmethod2:' causes a section type conflict with 'global2'}}
+@end
Index: clang/test/SemaCXX/attr-section.cpp
===
--- clang/test/SemaCXX/attr-section.cpp
+++ clang/test/SemaCXX/attr-section.cpp
@@ -42,3 +42,9 @@
   __attribute__((section("baz"))) // expected-warning {{section does not match}}
   void C::f() {}
 }
+
+// Check for section type conflicts between global variables and function templates
+template  __attribute__((section("template_fn1"))) void template_fn1() {} // expected-note {{declared here}}
+const int const_global_var __attribute__((section("template_fn1"))) = 42;   // expected-error {{'const_global_var' causes a section type conflict with 'template_fn1'}}
+int mut_global_var __attribute__((section("template_fn2"))) = 42;   // expected-note {{declared here}}
+template  __attribute__((section("template_fn2"))) void template_fn2() {} // expected-error {{'template_fn2' causes a section type conflict with 'mut_global_var'}}
Index: clang/test/Sema/attr-section.c
===
--- clang/test/Sema/attr-section.c
+++ clang/test/Sema/attr-section.c
@@ -26,9 +26,27 @@
 
 // Not a warning.
 int c;
-int c __attribute__((section("foo,zed")));
+int c __attribute__((section("seg1,sec1")));
 
 // Also OK.
 struct r_debug {};
 extern struct r_debug _r_debug;
 struct r_debug _r_debug __attribute__((nocommon, section(".r_debug,bar")));
+
+// Section type conflicts between functions and variables
+void test3(void) __attribute__((section("seg3,sec3"))); // expected-note {{declared here}}
+void test3(void) {}
+const int const_global_var __attribute__((section("seg3,sec3"))) = 10; // expected-error {{'const_global_var' causes a section type conflict with 'test3'}}
+
+void test4(void) __attribute__((section("seg4,sec4"))); // expected-note {{declared here}}
+void test4(void) {}
+int mut_global_var __attribute__((section("seg4,sec4"))) = 10; // expected-error {{'mut_global_var' causes a section type conflict with 'test4'}}
+
+const int global_seg5sec5 __attribute__((section("seg5,sec5"))) = 10; // expected-note {{declared here}}
+void test5(void) __attribute__((section("seg5,sec5")));   // expected-error {{'test5' causes a section type conflict with 'global_seg5sec5'}}
+void test5(void) {}
+
+void test6(void);
+const int global_seg6sec6 __attribute__((section("seg6,sec6"))) = 10; // expected-note {{declared here}}
+void test6(void) __attribute__((section("seg6,sec6")));   // expected-error {{'test6' causes a section type conflict with 'global_seg6sec6'}}
+void test6(void) {}
Index: clang/lib/Sema/SemaDeclAttr.cpp

[PATCH] D93220: [clangd] Add error handling (elog) in code completion.

2020-12-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:193
+} else {
+  elog("Code completion header path manipulation failed {0}",
+   HeaderFile.takeError());

adamcz wrote:
> sammccall wrote:
> > I think this is too noisy.
> > 
> > We can hit this in "normal" cases of certain projects.
> > For better or worse, we don't currently filter out index results where we 
> > know the responsible header and can't include it (because it's not under 
> > any include path entry). In these cases toHeaderFile() returns an error.
> > 
> > Since this can happen in the normal case for *each* completion candidate 
> > (default 100), and completion requests are very frequent, this could 
> > dominate log output in affected projects.
> > 
> > It *might* be OK at vlog? I get the desire to not silence errors here. I 
> > think the question is what are the error cases we're *trying* to call out 
> > loudly. Maybe we can separate out the "shouldn't happen" vs the "fairly 
> > expected" cases.
> > (Even then there's the prospect that this is either going to not fire or 
> > fire dozens of times, which is a little sad)
> Originally I didn't even log here. We do this expansion at other places and 
> they may log already, I don't think it's critical to log here. Kadir pointed 
> out error needs to be handled or it will assert()-fail (that one place 
> returns Expected rather than Optional, I missed that), which is the 
> motivation for this change.
> 
> I made it vlog, but if you think it's too spammy I can remove it and just 
> ignore the error (by this time explicitly, so it doesn't crash). I don't 
> think we'll see these errors often - this only happens when we failed to 
> parse the URI or recognize the scheme, which basically can only happen with 
> remote index and some kind of version skew or corrupt data, so I'm fine with 
> vlog() I think.
Oh wow, I totally missed that the Expected was unhandled before!

Yeah let's go with vlog.
(If you like, downgrading the log() to vlog() for the callsite in 
CodeComplete.cpp seems like a good idea)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93220

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


[PATCH] D93398: [NFC] Use regex for code object version in hip tests

2020-12-16 Thread Jon Chesterfield 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 rGc0619d3b21cd: [NFC] Use regex for code object version in hip 
tests (authored by JonChesterfield).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93398

Files:
  clang/test/Driver/hip-autolink.hip
  clang/test/Driver/hip-code-object-version.hip
  clang/test/Driver/hip-device-compile.hip
  clang/test/Driver/hip-host-cpu-features.hip
  clang/test/Driver/hip-rdc-device-only.hip
  clang/test/Driver/hip-target-id.hip
  clang/test/Driver/hip-toolchain-mllvm.hip
  clang/test/Driver/hip-toolchain-no-rdc.hip
  clang/test/Driver/hip-toolchain-opt.hip
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  clang/test/Driver/hip-toolchain-rdc-static-lib.hip
  clang/test/Driver/hip-toolchain-rdc.hip

Index: clang/test/Driver/hip-toolchain-rdc.hip
===
--- clang/test/Driver/hip-toolchain-rdc.hip
+++ clang/test/Driver/hip-toolchain-rdc.hip
@@ -32,7 +32,7 @@
 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
 
 // generate image for device side path on gfx803
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -43,7 +43,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC1:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
@@ -62,7 +62,7 @@
 // CHECK-SAME: "-o" "[[IMG_DEV1:.*.out]]" [[A_BC1]] [[B_BC1]]
 
 // generate image for device side path on gfx900
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -72,7 +72,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC2:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
Index: clang/test/Driver/hip-toolchain-rdc-static-lib.hip
===
--- clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -26,7 +26,7 @@
 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
 
 // generate image for device side path on gfx803
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -35,7 +35,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC1:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
@@ -52,7 +52,7 @@
 // CHECK-SAME: "-o" "[[IMG_DEV1:.*out]]" [[A_BC1]] [[B_BC1]]
 
 // generate image for device side path on gfx900
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -61,7 +61,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC2:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // 

[PATCH] D93393: [clangd] Ignore the static index refs from the dynamic index files.

2020-12-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

TL;DR: Cool! I think we should complicate the signature of `hasFile()` a bit to 
avoid calling SwapIndex::snapshot() for each file. There's also some quadratic 
behavior due to calling index ops from MergeIndex when children are 
MergeIndexes, but N is small and I think we can solve it later.

---

I like the simplicity/elegance of this solution, and the fact that it avoids 
the scaling pitfall of trying to return a list of all the indexed files.

I am concerned about performance though. At a high level, we try to make index 
operations fairly coarse/batched and only do a handful of them. This was 
originally to allow these operations to be RPCs, but of course this assumption 
gets baked in in other ways too. Introducing a fine-grained operation like this 
causes some of the assumptions to be violated.

Concretely, SwapIndex (and ProjectAwareIndex) take a lock to obtain the index 
snapshot to use, and so here we do that for each call to `hasFile()`. Most 
indexes are wrapped in SwapIndex for either lazy-loading or dynamic updating.

And we hammer it reasonably hard here, MergeIndex::refs() will call it in a 
loop for ~100 times, and because there are multiple MergeIndexes in the index 
stack, we end up with duplication: the first index never gets hasFile(), the 
second gets it 100 times, the third 200 times, the fourth 300 times. (Currently 
we have at least 4 indexes in the stack).

Taking 600 locks to call refs() seems... less than ideal. For now they'll 
probably be uncontended as we only call refs() for interactive actions 
(find-references and rename), but fundamentally this applies to all requests, 
not just refs, so I'm not sure this will be true in the future (a fast 
pseudoparser index will want to consult the previous index to resolve symbols).

This all seems related to the idea that `hasFile()` isn't implemented for 
RemoteIndex - it's a pragmatic shortcut, but in principle it'd be nice to be 
able to implement it, and there's some minimum per-RPC overhead.

---

So, can we do anything about all this?

Locking once for each ref: fundamentally we want to lock once to get the 
snapshot, then query the snapshot for each file. This changing hasFile to 
return an oracle that can be cheaply queried, e.g. a signature like 
`unique_function SymbolIndex::indexedFiles()`.

The quadratic nature of calling any index ops in MergedIndex: I guess probably 
not without flattening our binary-tree/linked-list of MergedIndex into an N-way 
merge. Back in the day, we basically had one static index which was huge, and 
one dynamic index which was tiny, and the no-copy aspect of MergedIndex was 
appealing (and it was easy to implement!). But we're probably not coming out 
ahead anymore vs simply committing to copy everything once. The N-way merge 
would have other advantages too: we could query large/slow indexes in parallel 
to improve latency.

Implementing a pseudo-batch form of hasFiles as an RPC for remote-index: we'd 
need to give up on getting answers for files one-by-one. That would be OK for 
an N-way merge (since we'd fetch all results before merging, we could build a 
list). But servers typically index *everything* under a certain directory, so 
fetching the list of directories and evaluating per-file queries client-side is 
a cheap and reasonable alternative (that's more accurate than `return false`!)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93393

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


[clang] c0619d3 - [NFC] Use regex for code object version in hip tests

2020-12-16 Thread Jon Chesterfield via cfe-commits

Author: Jon Chesterfield
Date: 2020-12-16T17:00:19Z
New Revision: c0619d3b21cd420b9faf15f14db0816787c44ded

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

LOG: [NFC] Use regex for code object version in hip tests

[NFC] Use regex for code object version in hip tests

Extracted from D93258. Makes tests robust to changes in default
code object version.

Reviewed By: t-tye

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

Added: 


Modified: 
clang/test/Driver/hip-autolink.hip
clang/test/Driver/hip-code-object-version.hip
clang/test/Driver/hip-device-compile.hip
clang/test/Driver/hip-host-cpu-features.hip
clang/test/Driver/hip-rdc-device-only.hip
clang/test/Driver/hip-target-id.hip
clang/test/Driver/hip-toolchain-mllvm.hip
clang/test/Driver/hip-toolchain-no-rdc.hip
clang/test/Driver/hip-toolchain-opt.hip
clang/test/Driver/hip-toolchain-rdc-separate.hip
clang/test/Driver/hip-toolchain-rdc-static-lib.hip
clang/test/Driver/hip-toolchain-rdc.hip

Removed: 




diff  --git a/clang/test/Driver/hip-autolink.hip 
b/clang/test/Driver/hip-autolink.hip
index 073c6c4d244a6..5f9311d7ba734 100644
--- a/clang/test/Driver/hip-autolink.hip
+++ b/clang/test/Driver/hip-autolink.hip
@@ -7,7 +7,7 @@
 // RUN: %clang --target=i386-pc-windows-msvc --cuda-gpu-arch=gfx906 -nogpulib \
 // RUN:   --cuda-host-only %s -### 2>&1 | FileCheck --check-prefix=HOST %s
 
-// DEV: "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" 
"amdgcn-amd-amdhsa"
+// DEV: "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" 
"amdgcn-amd-amdhsa"
 // DEV-SAME: "-fno-autolink"
 
 // HOST: "-cc1" "-triple" "i386-pc-windows-msvc{{.*}}"

diff  --git a/clang/test/Driver/hip-code-object-version.hip 
b/clang/test/Driver/hip-code-object-version.hip
index 26ad6f8710cc2..51d9004b0cbf5 100644
--- a/clang/test/Driver/hip-code-object-version.hip
+++ b/clang/test/Driver/hip-code-object-version.hip
@@ -44,12 +44,17 @@
 // RUN:   --offload-arch=gfx906 -nogpulib \
 // RUN:   %s 2>&1 | FileCheck -check-prefix=V4 %s
 
+// V4: "-mllvm" "--amdhsa-code-object-version=4"
+// V4: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
+
+// Check bundle ID for code object version default
+
 // RUN: %clang -### -target x86_64-linux-gnu \
 // RUN:   --offload-arch=gfx906 -nogpulib \
-// RUN:   %s 2>&1 | FileCheck -check-prefix=V4 %s
+// RUN:   %s 2>&1 | FileCheck -check-prefix=VD %s
 
-// V4: "-mllvm" "--amdhsa-code-object-version=4"
-// V4: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
+// VD: "-mllvm" "--amdhsa-code-object-version=4"
+// VD: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
 
 // Check invalid code object version option.
 

diff  --git a/clang/test/Driver/hip-device-compile.hip 
b/clang/test/Driver/hip-device-compile.hip
index 5fbcbc97bd805..c460ff7e8c67d 100644
--- a/clang/test/Driver/hip-device-compile.hip
+++ b/clang/test/Driver/hip-device-compile.hip
@@ -26,7 +26,7 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK,ASM %s
 
-// CHECK: {{".*clang.*"}} "-cc1" "-mllvm" "--amdhsa-code-object-version=4" 
"-triple" "amdgcn-amd-amdhsa"
+// CHECK: {{".*clang.*"}} "-cc1" "-mllvm" 
"--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // BC-SAME: "-emit-llvm-bc"
 // LL-SAME: "-emit-llvm"

diff  --git a/clang/test/Driver/hip-host-cpu-features.hip 
b/clang/test/Driver/hip-host-cpu-features.hip
index 235f0f1f22c24..8addfb11dc0b6 100644
--- a/clang/test/Driver/hip-host-cpu-features.hip
+++ b/clang/test/Driver/hip-host-cpu-features.hip
@@ -6,14 +6,14 @@
 // RUN: %clang -### -c -target x86_64-linux-gnu -msse3 --cuda-gpu-arch=gfx803 
-nogpulib %s 2>&1 | FileCheck %s -check-prefix=HOSTSSE3
 // RUN: %clang -### -c -target x86_64-linux-gnu --gpu-use-aux-triple-only 
-march=znver2 --cuda-gpu-arch=gfx803 -nogpulib %s 2>&1 | FileCheck %s 
-check-prefix=NOHOSTCPU
 
-// HOSTCPU: "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" 
"amdgcn-amd-amdhsa"
+// HOSTCPU: "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" 
"-triple" "amdgcn-amd-amdhsa"
 // HOSTCPU-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // HOSTCPU-SAME: "-aux-target-cpu" "znver2"
 
-// HOSTSSE3: "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" 
"amdgcn-amd-amdhsa"
+// HOSTSSE3: "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" 
"-triple" "amdgcn-amd-amdhsa"
 // HOSTSSE3-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // HOSTSSE3-SAME: "-aux-target-feature" "+sse3"
 
-// NOHOSTCPU: "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" 
"amdgcn-amd-amdhsa"
+// NOHOSTCPU: "-cc1" "-mllvm" 

[PATCH] D93398: [NFC] Use regex for code object version in hip tests

2020-12-16 Thread Tony Tye via Phabricator via cfe-commits
t-tye accepted this revision.
t-tye added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93398

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


[PATCH] D93031: Enable fexec-charset option

2020-12-16 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added inline comments.



Comment at: clang/test/CodeGen/systemz-charset.c:4
+
+char *UpperCaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+// CHECK: 
c"\C1\C2\C3\C4\C5\C6\C7\C8\C9\D1\D2\D3\D4\D5\D6\D7\D8\D9\E2\E3\E4\E5\E6\E7\E8\E9\00"

`const char *` please :)



Comment at: clang/test/CodeGen/systemz-charset.c:24
+//CHECK: c"abc\00"
+
+char singleChar = 'a';

Add validation of UCNs.  Something like:
  const char *UcnCharacters = "\u00E2\u00AC\U00DF";
  // CHECK: c"\42\B0\59\00"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

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


[PATCH] D91944: OpenMP 5.0 metadirective

2020-12-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D91944#2457744 , @dreachem wrote:

> In D91944#2414364 , @jdoerfert wrote:
>
>> This looks close to an OpenMP 5.0 implementation. I left comments inlined.
>>
>> We need tests that show how non-selected alternatives *do not* impact the 
>> program. As an example, a template instantiation inside of a non-selected 
>> alternative is not actually performed.
>>
>> We also need test with ill-formed metadirectives.
>
> @jdoerfert I'm still trying to understand this thing regarding template 
> instantiations.

The problem is this patch can only resolve to a single directive during 
parsing. Take

  template
  void foo() {
#pragma omp metadirective when(user={condition(b)}) ...
  }

which is not resolvable at parsing time but it is a valid OpenMP 5.0 use of the 
metadirective
that needs to resolve at compile time.

> The spec says that a directive variant associated with a when clause can only 
> affect the program if it is a dynamic replacement candidate. I had assumed 
> this is referring to the runtime behavior of the program, and not (for 
> instance) whether a compiler error is emitted due to a failing static assert.

I always assume(d) that static_assert is something "affecting the program". It 
doesn't matter though because if you instantiate all the clauses eagerly you 
change things for the runtime as well, e.g., you can cause different template 
instances to be selected later on depending on earlier instantiations. So it's 
not "just" static_assert.

> Also, in order to determine what are the dynamic replacement candidates, and 
> their order, all specified score expressions would need to be evaluated.  
> Then, you'd need to evaluate the static context selectors, in decreasing 
> order of their score, to find which one is the last dynamic replacement 
> candidate. So I think template instantiations could be possible for those 
> expressions, even if the corresponding variants aren't selected?

Yes, we will always evaluate selectors and scores. The key is that we won't 
evaluate the directive variant, which is neither a selector nor a score.

I hope this makes sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D92955: [openmp] Remove clause from OMPKinds.def and use OMP.td info

2020-12-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.

LGTM still


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92955

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


[PATCH] D93356: [libomptarget][amdgpu] Call into deviceRTL instead of ockl

2020-12-16 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield planned changes to this revision.
JonChesterfield added a comment.

There's a codegen test that checks for __ockl_get_local_size. Testing a change 
to that test out of tree now, probably need to update said test before landing 
this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93356

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


[PATCH] D93402: [clang-tidy] prevent readability-identifier-naming from triggering on implicit VarDecls in coroutines

2020-12-16 Thread Emma Blink via Phabricator via cfe-commits
0x1eaf created this revision.
0x1eaf added reviewers: alexfh, njames93, aaron.ballman.
0x1eaf added projects: clang, clang-tools-extra.
Herald added subscribers: lxfind, modocache, xazax.hun.
0x1eaf requested review of this revision.
Herald added a subscriber: cfe-commits.

We have an internal bug report about readability-identifier-naming
warnings on implicit `__coro_gro` and `__promise` variables
in coroutines.

Turns out they haven't been marked as implicit in SemaCoroutine.
This diff resolves that and adds a couroutine test for the check.

Tested with:

> cd build/Debug/bin
> ./llvm-lit -sv --param build_mode=Debug \

  ../../tools/clang/tools/extra/test \
  --filter readability-identifier-naming.cpp


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93402

Files:
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/system/coroutines.h
  clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
  clang/lib/Sema/SemaCoroutine.cpp

Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -544,6 +544,7 @@
   auto *VD = VarDecl::Create(Context, FD, FD->getLocation(), FD->getLocation(),
  ().get("__promise"), T,
  Context.getTrivialTypeSourceInfo(T, Loc), SC_None);
+  VD->setImplicit(true);
   CheckVariableDeclarationType(VD);
   if (VD->isInvalidDecl())
 return nullptr;
@@ -1577,6 +1578,7 @@
   S.Context, , FD.getLocation(), FD.getLocation(),
   ().get("__coro_gro"), GroType,
   S.Context.getTrivialTypeSourceInfo(GroType, Loc), SC_None);
+  GroDecl->setImplicit(true);
 
   S.CheckVariableDeclarationType(GroDecl);
   if (GroDecl->isInvalidDecl())
Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
@@ -81,13 +81,14 @@
 // RUN: {key: readability-identifier-naming.LocalPointerPrefix, value: 'l_'}, \
 // RUN: {key: readability-identifier-naming.LocalConstantPointerCase, value: CamelCase}, \
 // RUN: {key: readability-identifier-naming.LocalConstantPointerPrefix, value: 'lc_'}, \
-// RUN:   ]}' -- -fno-delayed-template-parsing -Dbad_macro \
+// RUN:   ]}' -- -fno-delayed-template-parsing -Dbad_macro -std=c++17 -fcoroutines-ts \
 // RUN:   -I%S/Inputs/readability-identifier-naming \
 // RUN:   -isystem %S/Inputs/readability-identifier-naming/system
 
 // clang-format off
 
 #include 
+#include 
 #include "user-header.h"
 // NO warnings or fixes expected from declarations within header files without
 // the -header-filter= option
@@ -287,7 +288,7 @@
   // Overriding a badly-named base isn't a new violation.
   void BadBaseMethod() override {}
   // CHECK-FIXES: {{^}}  void v_Bad_Base_Method() override {}
-  
+
   void foo() {
 BadBaseMethod();
 // CHECK-FIXES: {{^}}v_Bad_Base_Method();
@@ -614,3 +615,14 @@
 auto GetRes(type_t& Param) -> decltype(Param.res());
 // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for parameter 'Param'
 // CHECK-FIXES: auto GetRes(type_t& a_param) -> decltype(a_param.res());
+
+#pragma mark - Check implicit declarations in coroutines
+
+struct async_obj {
+public:
+  never_suspend operator co_await() const noexcept;
+};
+
+task ImplicitDeclTest(async_obj _object) {
+  co_await a_object;  // CHECK-MESSAGES-NOT: warning: invalid case style for local variable
+}
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/system/coroutines.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/system/coroutines.h
@@ -0,0 +1,34 @@
+#pragma once
+
+namespace std {
+namespace experimental {
+
+template 
+struct coroutine_traits {
+  using promise_type = typename ret_t::promise_type;
+};
+
+template 
+struct coroutine_handle {
+  static constexpr coroutine_handle from_address(void *addr) noexcept { return {}; };
+};
+
+} // namespace experimental
+} // namespace std
+
+struct never_suspend {
+  bool await_ready() noexcept { return false; }
+  template 
+  void await_suspend(coro_t handle) noexcept {}
+  void await_resume() noexcept {}
+};
+
+struct task {
+  struct promise_type {
+task get_return_object() noexcept { return {}; }
+never_suspend initial_suspend() noexcept { return {}; }
+never_suspend final_suspend() noexcept { return {}; }
+void return_void() {}
+void unhandled_exception() {}
+  };
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93031: Enable fexec-charset option

2020-12-16 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added inline comments.



Comment at: clang/include/clang/Driver/Options.td:3583-3584
 
+def fexec_charset : Separate<["-"], "fexec-charset">, 
MetaVarName<"">,
+  HelpText<"Set the execution  for string and character literals">;
 def target_cpu : Separate<["-"], "target-cpu">,

abhina.sreeskantharajan wrote:
> tahonermann wrote:
> > How about substituting "character set", "character encoding", or "charset" 
> > for "codepage"?
> > 
> > This doesn't state what names are recognized.  The ones provided by the 
> > system iconv() implementation (as is the case for gcc)?  Or all names and 
> > aliases specified by the [[ 
> > https://www.iana.org/assignments/character-sets/character-sets.xhtml | IANA 
> > character set registry ]]?
> > 
> > The set of recognized names can be a superset of the names that are 
> > actually supported.
> I've updated the description from codepage to charset.
> 
> It's hard to specify what charsets are supported because iconv library 
> differs between targets, so the list will not be the same on every platform.
Being dependent on the host iconv library seems fine by me; that is the case 
for gcc today.  I suggest making that explicit here:
  def fexec_charset : Separate<["-"], "fexec-charset">, 
MetaVarName<"">,
HelpText<"Set the execution  for string and character literals.  
Supported character encodings include XXX and those supported by the host iconv 
library.">;



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5969-5977
+  // Pass all -fexec-charset options to cc1.
+  std::vector vList =
+  Args.getAllArgValues(options::OPT_fexec_charset_EQ);
+  // Set the default fexec-charset as the system charset.
+  CmdArgs.push_back("-fexec-charset");
+  CmdArgs.push_back(Args.MakeArgString(Triple.getSystemCharset()));
+  for (auto it = vList.begin(), ie = vList.end(); it != ie; ++it) {

abhina.sreeskantharajan wrote:
> tahonermann wrote:
> > I think it would be preferable to diagnose an unrecognized character 
> > encoding name here if possible.  The current changes will result in an 
> > unrecognized name (as opposed to one that is unsupported for the target) 
> > being diagnosed for each compiler instance.
> Since we do not know what charsets are supported by the iconv library on the 
> target platform, we don't know what charsets are actually invalid until we 
> try creating a CharSetConverter.
Understood, but what would be the harm in performing a lookup (constructing a 
`CharSetConverter`) here?



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3573
+StringRef Value = ExecCharset->getValue();
+Opts.ExecCharset = (std::string)Value;
+  }

abhina.sreeskantharajan wrote:
> tahonermann wrote:
> > I wouldn't expect the cast to `std::string` to be needed here.
> Without that cast, I get the following build error:
> ```
>  error: no viable overloaded '='
> ```
Ok, rather than a cast, I suggest:
  Opts.ExecCharset = Value.str();



Comment at: clang/lib/Lex/LiteralSupport.cpp:1322-1323
+  TranslationState = translationState;
+  if (Kind == tok::wide_string_literal)
+TranslationState = TranslateToSystemCharset;
+  else if (isUTFLiteral(Kind))

Converting wide character literals to the system encoding doesn't seem right to 
me.  For z/OS, this should presumably convert to the wide EBCDIC encoding, but 
for all other supported platforms, the wide execution character set is either 
UTF-16 or UTF-32 depending on the size of `wchar_t` (which may be influenced by 
the `-fshort-wchar` option).



Comment at: clang/lib/Lex/LiteralSupport.cpp:1593-1597
+  ConversionState State = TranslationState;
+  if (Kind == tok::wide_string_literal)
+State = TranslateToSystemCharset;
+  else if (isUTFLiteral(Kind))
+State = NoTranslation;

The stored `TranslationState` should not be completely ignored for wide and UTF 
string literals.  The standard permits things like the following.
  #pragma rigoot L"bozit"
  #pragma rigoot u"bozit"
  _Pragma(L"rigoot bozit")
  _Pragma(u8"rigoot bozit")
For at least the `_Pragma(L"...")` case, the C++ standard [[ 
http://eel.is/c++draft/cpp.pragma.op | states ]] the `L` is ignored, but it 
doesn't say anything about other encoding prefixes.



Comment at: clang/lib/Lex/LiteralSupport.cpp:1594-1595
+  ConversionState State = TranslationState;
+  if (Kind == tok::wide_string_literal)
+State = TranslateToSystemCharset;
+  else if (isUTFLiteral(Kind))

Converting wide string literals to the system encoding doesn't seem right to 
me.  For z/OS, this should presumably convert to the wide EBCDIC encoding, but 
for all other supported platforms, the wide execution character set is either 
UTF-16 or UTF-32 depending on the size of `wchar_t` (which may be influenced by 
the `-fshort-wchar` option).


Repository:
  rG LLVM Github Monorepo


[PATCH] D93401: [flang][driver] Add support for `-D`, `-U`

2020-12-16 Thread Faris via Phabricator via cfe-commits
FarisRehman created this revision.
Herald added a reviewer: sscalpone.
Herald added a subscriber: dang.
FarisRehman requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add support for options -D and -U in the Flang driver along with a regression 
test for them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93401

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInstance.h
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/macro.f90

Index: flang/test/Flang-Driver/macro.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/macro.f90
@@ -0,0 +1,49 @@
+! Ensure arguments -D and -U work as expected.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -E %s  2>&1 | FileCheck %s --check-prefix=UNDEFINED
+! RUN: %flang-new -E -DNEW %s  2>&1 | FileCheck %s --check-prefix=DEFINED
+! RUN: %flang-new -E -DNEW -UNEW %s  2>&1 | FileCheck %s --check-prefix=UNDEFINED
+
+!-
+!   FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang-new -fc1 -E %s  2>&1 | FileCheck %s --check-prefix=UNDEFINED
+! RUN: %flang-new -fc1 -E -DNEW %s  2>&1 | FileCheck %s --check-prefix=DEFINED
+! RUN: %flang-new -fc1 -E -DNEW -UNEW %s  2>&1 | FileCheck %s --check-prefix=UNDEFINED
+
+
+!
+! EXPECTED OUTPUT FOR MACRO 'NEW' UNDEFINED
+!
+! flang-new -E %s
+! flang-new -E -DNEW -UNEW %s
+! UNDEFINED:program b
+! UNDEFINED-NOT:program a
+! UNDEFINED-NEXT:x = 1
+! UNDEFINED-NEXT:write(*,*) x
+! UNDEFINED-NEXT:end
+
+!
+! EXPECTED OUTPUT FOR MACRO 'NEW' DEFINED
+!
+! flang-new -E -DNEW %s
+! DEFINED:program a
+! DEFINED-NOT:program b
+! DEFINED-NEXT:x = 1
+! DEFINED-NEXT:write(*,*) x
+! DEFINED-NEXT:end
+
+! Macro.F:
+#ifdef NEW
+program A
+#else
+program B
+#endif
+  x = 1
+  write(*,*) x
+end
\ No newline at end of file
Index: flang/test/Flang-Driver/driver-help.f90
===
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -19,11 +19,13 @@
 ! HELP-EMPTY:
 ! HELP-NEXT:OPTIONS:
 ! HELP-NEXT: -###   Print (but do not run) the commands to run for this compilation
+! HELP-NEXT: -D = Define  to  (or 1 if  omitted)
 ! HELP-NEXT: -E Only run the preprocessor
 ! HELP-NEXT: -fcolor-diagnosticsEnable colors in diagnostics
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
 ! HELP-NEXT: -help  Display available options
 ! HELP-NEXT: -o   Write output to 
+! HELP-NEXT: -U  Undefine macro 
 ! HELP-NEXT: --version  Print version information
 
 !-
@@ -32,10 +34,12 @@
 ! HELP-FC1:USAGE: flang-new
 ! HELP-FC1-EMPTY:
 ! HELP-FC1-NEXT:OPTIONS:
-! HELP-FC1-NEXT: -EOnly run the preprocessor
-! HELP-FC1-NEXT: -help Display available options
-! HELP-FC1-NEXT: -o  Write output to 
-! HELP-FC1-NEXT: --version Print version information
+! HELP-FC1-NEXT: -D = Define  to  (or 1 if  omitted)
+! HELP-FC1-NEXT: -E Only run the preprocessor
+! HELP-FC1-NEXT: -help  Display available options
+! HELP-FC1-NEXT: -o   Write output to 
+! HELP-FC1-NEXT: -U  Undefine macro 
+! HELP-FC1-NEXT: --version  Print version information
 
 !---
 ! EXPECTED ERROR
Index: flang/test/Flang-Driver/driver-help-hidden.f90
===
--- flang/test/Flang-Driver/driver-help-hidden.f90
+++ flang/test/Flang-Driver/driver-help-hidden.f90
@@ -19,12 +19,14 @@
 ! CHECK-EMPTY:
 ! CHECK-NEXT:OPTIONS:
 ! CHECK-NEXT: -###  Print (but do not run) the commands to run for this compilation
+! CHECK-NEXT: -D = Define  to  (or 1 if  omitted)
 ! CHECK-NEXT: -EOnly run the preprocessor
 ! CHECK-NEXT: -fcolor-diagnosticsEnable colors in diagnostics
 ! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
 ! CHECK-NEXT: -help Display available options
 ! CHECK-NEXT: -o  Write output to 
 ! CHECK-NEXT: -test-io  Run the InputOuputTest action. Use for development and testing only.
+! CHECK-NEXT: -U  Undefine macro 
 ! CHECK-NEXT: --version Print version 

[PATCH] D93398: [NFC] Use regex for code object version in hip tests

2020-12-16 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/test/Driver/hip-code-object-version.hip:56
 
-// V4: "-mllvm" "--amdhsa-code-object-version=4"
-// V4: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
+// VD: "-mllvm" "--amdhsa-code-object-version=4"
+// VD: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"

t-tye wrote:
> t-tye wrote:
> > If the upstream default is being changed to 3 does this need to also be 3?
> I can also help getting this landed in to internal branches.
Thanks. And yeah, it'll be changed to =3 as part of D93258. Until then, test 
needs to match the clang front end.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93398

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


[PATCH] D83892: [clang][cli] Port CodeGen option flags to new option parsing system

2020-12-16 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

One thing this patch does, is make decisions about default behavior static.  
Meaning, the option behavior cannot depend on other options; specifically, it 
can't be based on the triple, which allows target-specific customization.  PS4 
certainly has cases where our defaults are different from the usual ones, and 
I'd kind of think that was true for other targets as well.

Sorry I didn't notice this patch before, our CI has just tried to merge it.  
We've patched it up in our main branch but I'm not sure what the upstream 
intent is here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83892

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


[PATCH] D92039: [-Wcalled-once-parameter] Introduce 'called_once' attribute

2020-12-16 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D92039#2457867 , @aaron.ballman 
wrote:

> Is the attribute considered to be a property of the parameter or a property 
> of the function the parameter is declared in? e.g.,
>
>   void someOtherFunc(void (^cb)(void)) {
> if (something())
>   cb();
>   }
>   
>   void barWithCallback(void (^callback)(void) __attribute__((called_once))) {
> someOtherFunc(callback);
>   }
>
> Should code like that also diagnose given that `callback` is not called on 
> every code path? From the test cases you have, it looks like you explicitly 
> allow this code without diagnosing it, which suggests the attribute is really 
> a property of the function and not a property of the parameter. This in turn 
> makes me wonder whether a better design is for `-Wcompletion-handler` to 
> diagnose any function with a completion handler-like parameter if the 
> parameter is not called exactly once within the function, and the user marks 
> the functions that should be exempt from the checking rather than marking the 
> parameters that should be checked (or does this have too many false positives 
> in practice)? Alternatively, should the check be implemented as a clang 
> static analyzer check that tracks an annotated parameter across the 
> inter-procedural CFG and diagnoses such code?



> should the check be implemented as a clang static analyzer check that tracks 
> an annotated parameter across the inter-procedural CFG and diagnoses such 
> code?

That was a tough choice whether we should do it in the analyzer or not.
The analyzer check would've been easier in terms of existing infrastructure, 
path sensitivity, and IPA.  It is also much more lenient in terms of false 
positives (it is expected that the analyzer can have those).
However, warnings have much broader audience and we aim for a higher numbers of 
people to check their code (we've been asked to deliver it for 8 years).  And 
because the analyzer doesn't have cross-translation unit analysis, the problem 
with inter procedural bugs appears as well.

> From the test cases you have, it looks like you explicitly allow this code 
> without diagnosing it, which suggests the attribute is really a property of 
> the function and not a property of the parameter.

I have to disagree here.  //Semantically// this is a property of a parameter 
and the fact that we couldn't analyze inter-procedurally is our own problem and 
implementation detail.  We don't want to bother users with this.  As far as I 
understand, the majority of existing warnings are not complete (don't find 
every bug) and this warning is not different.

> and the user marks the functions that should be exempt from the checking 
> rather than marking the parameters that should be checked

Essentially, there is a way to prevent function from being analyzed by 
`-Wcompletion-handler` - annotate it with `__attribute__((swift_async(none)))`.




Comment at: clang/include/clang/Basic/AttrDocs.td:5133-5134
+
+This attribute is useful for API developers who want to double-check if they
+implemented their method correctly.
+

aaron.ballman wrote:
> Oh, I was thinking this attribute was enabling some optimization 
> opportunities or doing something more than just acting as a marker to please 
> check this function's correctness for some properties. This means that the 
> programmer has to annotate their code and enable the warning flag in order 
> for either the attribute or the warning flag to have effect, which feels a 
> bit surprising to me.
For explicitly marked parameters, it's on by default, so the users can simply 
annotate their parameters and get their checks.



Comment at: clang/include/clang/Basic/AttrDocs.td:5098-5102
+* Parameter is not called at all.
+
+* Parameter is called more than once.
+
+* Parameter is not called on one of the execution paths.

aaron.ballman wrote:
> I think you may have to remove the newlines here to make this a single 
> bulleted list in Sphinx.
I checked it, it is one list with newlines: {F14734606}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92039

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


[PATCH] D93398: [NFC] Use regex for code object version in hip tests

2020-12-16 Thread Tony Tye via Phabricator via cfe-commits
t-tye added inline comments.



Comment at: clang/test/Driver/hip-code-object-version.hip:56
 
-// V4: "-mllvm" "--amdhsa-code-object-version=4"
-// V4: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
+// VD: "-mllvm" "--amdhsa-code-object-version=4"
+// VD: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"

t-tye wrote:
> If the upstream default is being changed to 3 does this need to also be 3?
I can also help getting this landed in to internal branches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93398

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


[PATCH] D91444: [InstCombine] Preserve !annotation metadata for memory combines.

2020-12-16 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 312216.
fhahn added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In D91444#2394512 , @lebedev.ri wrote:

> What about teaching IRBuilder to deal with it like it deals with debugloc?

Done! Together with D93400  this patch now 
boils down to requesting !annotation to be preserved for instructions created 
by IRBuilder.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91444

Files:
  clang/test/CodeGenCXX/auto-var-init.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/annotations.ll

Index: llvm/test/Transforms/InstCombine/annotations.ll
===
--- llvm/test/Transforms/InstCombine/annotations.ll
+++ llvm/test/Transforms/InstCombine/annotations.ll
@@ -48,8 +48,8 @@
 
 define void @copy_1_byte(i8* %d, i8* %s) {
 ; CHECK-LABEL: define {{.+}} @copy_1_byte({{.+}}
-; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1
-; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1, !annotation [[ANN]]
+; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call void @llvm.memcpy.p0i8.p0i8.i32(i8* %d, i8* %s, i32 1, i1 false), !annotation !0
@@ -60,8 +60,8 @@
 
 define void @libcallcopy_1_byte(i8* %d, i8* %s) {
 ; CHECK-LABEL: define {{.+}} @libcallcopy_1_byte({{.+}}
-; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1
-; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1, !annotation [[ANN]]
+; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call i8* @memcpy(i8* %d, i8* %s, i64 1), !annotation !0
@@ -72,8 +72,8 @@
 
 define void @libcallcopy_1_byte_chk(i8* %d, i8* %s) {
 ; CHECK-LABEL: define {{.+}} @libcallcopy_1_byte_chk({{.+}}
-; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1
-; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1, !annotation [[ANN]]
+; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call i8* @__memcpy_chk(i8* %d, i8* %s, i64 1, i64 1), !annotation !0
@@ -84,8 +84,8 @@
 
 define void @move_1_byte(i8* %d, i8* %s) {
 ; CHECK-LABEL: define {{.+}} @move_1_byte({{.+}}
-; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1
-; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1, !annotation [[ANN]]
+; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call void @llvm.memmove.p0i8.p0i8.i32(i8* %d, i8* %s, i32 1, i1 false), !annotation !0
@@ -96,8 +96,8 @@
 
 define void @libcallmove_1_byte(i8* %d, i8* %s) {
 ; CHECK-LABEL: define {{.+}} @libcallmove_1_byte({{.+}}
-; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1
-; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1, !annotation [[ANN]]
+; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call i8* @memmove(i8* %d, i8* %s, i64 1), !annotation !0
@@ -108,8 +108,8 @@
 
 define void @libcallmove_1_byte_chk(i8* %d, i8* %s) {
 ; CHECK-LABEL: define {{.+}} @libcallmove_1_byte_chk({{.+}}
-; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1
-; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1, !annotation [[ANN]]
+; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call i8* @__memmove_chk(i8* %d, i8* %s, i64 1, i64 1), !annotation !0
@@ -120,7 +120,7 @@
 
 define void @set_1_byte(i8* %d) {
 ; CHECK-LABEL: define {{.+}} @set_1_byte({{.+}}
-; CHECK-NEXT:store i8 1, i8* [[D:%.*]], align 1
+; CHECK-NEXT:store i8 1, i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call void @llvm.memset.p0i8.i32(i8* %d, i8 1, i32 1, i1 false), !annotation !0
@@ -131,7 +131,7 @@
 
 define void @libcall_set_1_byte(i8* %d) {
 ; CHECK-LABEL: define {{.+}} @libcall_set_1_byte({{.+}}
-; CHECK-NEXT:store i8 1, i8* [[D:%.*]], align 1
+; CHECK-NEXT:store i8 1, i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call i8* @memset(i8* %d, i32 1, i64 1), !annotation !0
@@ -142,7 +142,7 @@
 
 define void @libcall_set_1_byte_chk(i8* %d) {
 ; CHECK-LABEL: define {{.+}} @libcall_set_1_byte_chk({{.+}}
-; CHECK-NEXT:store i8 1, i8* [[D:%.*]], align 1
+; 

[PATCH] D93398: [NFC] Use regex for code object version in hip tests

2020-12-16 Thread Tony Tye via Phabricator via cfe-commits
t-tye added inline comments.



Comment at: clang/test/Driver/hip-code-object-version.hip:56
 
-// V4: "-mllvm" "--amdhsa-code-object-version=4"
-// V4: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
+// VD: "-mllvm" "--amdhsa-code-object-version=4"
+// VD: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"

If the upstream default is being changed to 3 does this need to also be 3?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93398

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


[PATCH] D93258: [amdgpu] Default to code object v3

2020-12-16 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D93258#2457905 , @yaxunl wrote:

> Thanks for fixing the lit tests. Using regex is the right choice.
>
> Do we have a plan about how to merge this to amd-stg-open? Will it cause 
> ePSDB to fail? Do you have a follow up patch to make amd-stg-open happy?
>
> Thanks.

Extracted as D93398 . Suggest we land that, 
then it flows into gerrit (where it won't break anything), and rebase this 
patch to reduce the noise.

This will need to be merged carefully into amd-stg-open if the intent is to 
continue using v4 as the default on the internal branch. No follow up patch 
necessary, the trick would be to not land this.

Note that none of this would be necessary if trunk clang hadn't been 
prematurely updated to default to a code object version that llvm trunk doesn't 
use.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93258

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


[PATCH] D93398: [NFC] Use regex for code object version in hip tests

2020-12-16 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield created this revision.
JonChesterfield added a reviewer: yaxunl.
JonChesterfield requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

[NFC] Use regex for code object version in hip tests

Extracted from D93258 . Makes tests robust to 
changes in default
code object version.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93398

Files:
  clang/test/Driver/hip-autolink.hip
  clang/test/Driver/hip-code-object-version.hip
  clang/test/Driver/hip-device-compile.hip
  clang/test/Driver/hip-host-cpu-features.hip
  clang/test/Driver/hip-rdc-device-only.hip
  clang/test/Driver/hip-target-id.hip
  clang/test/Driver/hip-toolchain-mllvm.hip
  clang/test/Driver/hip-toolchain-no-rdc.hip
  clang/test/Driver/hip-toolchain-opt.hip
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  clang/test/Driver/hip-toolchain-rdc-static-lib.hip
  clang/test/Driver/hip-toolchain-rdc.hip

Index: clang/test/Driver/hip-toolchain-rdc.hip
===
--- clang/test/Driver/hip-toolchain-rdc.hip
+++ clang/test/Driver/hip-toolchain-rdc.hip
@@ -32,7 +32,7 @@
 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
 
 // generate image for device side path on gfx803
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -43,7 +43,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC1:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
@@ -62,7 +62,7 @@
 // CHECK-SAME: "-o" "[[IMG_DEV1:.*.out]]" [[A_BC1]] [[B_BC1]]
 
 // generate image for device side path on gfx900
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -72,7 +72,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC2:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
Index: clang/test/Driver/hip-toolchain-rdc-static-lib.hip
===
--- clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -26,7 +26,7 @@
 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
 
 // generate image for device side path on gfx803
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -35,7 +35,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC1:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
@@ -52,7 +52,7 @@
 // CHECK-SAME: "-o" "[[IMG_DEV1:.*out]]" [[A_BC1]] [[B_BC1]]
 
 // generate image for device side path on gfx900
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -61,7 +61,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC2:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
 // 

  1   2   >