[PATCH] D141757: [clangd] allow extracting to variable for complete lambda expressions

2023-01-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

branch cut is upon us, so it'd be great if you can land this soon (or let us 
know if you don't have commit access)




Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:158
   if (isa(Stmt))
-return !isa(Stmt);
+return !(isa(Stmt) &&
+ InsertionPoint->Selected != SelectionTree::Complete);

nit: can we re-write this as: `!isa(Stmt) || 
InsertionPoint->Selected == SelectionTree::Complete` ?



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:81
 
+- The extract variable tweak gained support for extracting complete lambda 
expressions to a variable.
+

nridge wrote:
> Maybe add a "Code Actions" section for this?
+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141757

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


[PATCH] D142092: [include-mapping] Allow multiple headers for the same symbol. Choose the first header of available ones.

2023-01-23 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D142092#4068792 , @VitaNuo wrote:

> Added the re-generated symbol maps to this patch as per @hokein's request.

Sorry for not being cleared. My suggestion was to generate the maps on the old 
data (2018-10-28), the reason is that we can see the diffs caused by the change 
of the python script, it would make the review easier. We plan to update the 
symbol mappings to latest version, I think we should do it in a followup patch.




Comment at: clang/tools/include-mapping/gen_std.py:17
 Caveats and FIXMEs:
-  - only symbols directly in "std" namespace are added, we should also add 
std's
-subnamespace symbols (e.g. chrono).
-  - symbols with multiple variants or defined in multiple headers aren't added,
-e.g. std::move, std::swap
+  - symbols with multiple variants aren't added, e.g., std::move, std::swap
 

nit: `std::swap` doesn't have variants, it is provided by multiple headers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

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


[clang] 8f15c4c - [clang][Interp][NFC] Add Record::getDestructor()

2023-01-23 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-01-23T10:19:34+01:00
New Revision: 8f15c4c2a0fb61469060f9cf85b0b5adee8e0275

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

LOG: [clang][Interp][NFC] Add Record::getDestructor()

Unused for now but will be used in later commits.

Added: 


Modified: 
clang/lib/AST/Interp/Record.h

Removed: 




diff  --git a/clang/lib/AST/Interp/Record.h b/clang/lib/AST/Interp/Record.h
index f638ae90a1c4..1742cb1cc4ee 100644
--- a/clang/lib/AST/Interp/Record.h
+++ b/clang/lib/AST/Interp/Record.h
@@ -13,8 +13,9 @@
 #ifndef LLVM_CLANG_AST_INTERP_RECORD_H
 #define LLVM_CLANG_AST_INTERP_RECORD_H
 
-#include "clang/AST/Decl.h"
 #include "Descriptor.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
 
 namespace clang {
 namespace interp {
@@ -62,6 +63,12 @@ class Record final {
   const Base *getBase(const RecordDecl *FD) const;
   /// Returns a virtual base descriptor.
   const Base *getVirtualBase(const RecordDecl *RD) const;
+  // Returns the destructor of the record, if any.
+  const CXXDestructorDecl *getDestructor() const {
+if (const auto *CXXDecl = dyn_cast(Decl))
+  return CXXDecl->getDestructor();
+return nullptr;
+  }
 
   using const_field_iter = FieldList::const_iterator;
   llvm::iterator_range fields() const {



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


[clang] 284bd95 - [clang][Interp][NFC] Remove unused using alias

2023-01-23 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-01-23T10:19:34+01:00
New Revision: 284bd95e80fc7674040f62b8c09ea06a54bd51b9

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

LOG: [clang][Interp][NFC] Remove unused using alias

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 4bab2897b03b3..8bedf6898bb5c 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -20,7 +20,6 @@ using namespace clang;
 using namespace clang::interp;
 
 using APSInt = llvm::APSInt;
-template  using Expected = llvm::Expected;
 
 namespace clang {
 namespace interp {



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


[PATCH] D141826: [WIP][clang][TemplateBase] Add IsDefaulted bit to TemplateArgument

2023-01-23 Thread Michael Buch via Phabricator via cfe-commits
Michael137 updated this revision to Diff 491251.
Michael137 added a comment.

- `setIsDefaulted` when constructing `ClassTemplateSpecializationDecl`s
- Propagate `IsDefaulted` on serialization


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141826

Files:
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/TemplateBase.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/unittests/AST/DeclTest.cpp

Index: clang/unittests/AST/DeclTest.cpp
===
--- clang/unittests/AST/DeclTest.cpp
+++ clang/unittests/AST/DeclTest.cpp
@@ -490,3 +490,34 @@
   ASSERT_TRUE(AlignedArrayDelete->getOwningModule());
   EXPECT_TRUE(AlignedArrayDelete->getOwningModule()->isGlobalModule());
 }
+
+TEST(Decl, TemplateParameterListWithCallback) {
+  llvm::Annotations Code(R"cpp(
+template
+struct Alloc {};
+
+template >
+struct Foo {
+};
+
+Foo> X;
+  )cpp");
+
+  auto AST =
+  tooling::buildASTFromCodeWithArgs(Code.code(), /*Args=*/{"-std=c++20"});
+  ASTContext &Ctx = AST->getASTContext();
+
+  auto const *CTSD = selectFirst(
+  "id",
+  match(classTemplateSpecializationDecl(hasName("Foo")).bind("id"), Ctx));
+  ASSERT_NE(CTSD, nullptr);
+  auto const &ArgList = CTSD->getTemplateArgs();
+
+  EXPECT_FALSE(ArgList.get(0).getIsDefaulted());
+  EXPECT_FALSE(ArgList.get(1).getIsDefaulted());
+  EXPECT_TRUE(ArgList.get(2).getIsDefaulted());
+  EXPECT_TRUE(ArgList.get(3).getIsDefaulted());
+}
Index: clang/lib/AST/TemplateBase.cpp
===
--- clang/lib/AST/TemplateBase.cpp
+++ clang/lib/AST/TemplateBase.cpp
@@ -161,8 +161,9 @@
 //===--===//
 
 TemplateArgument::TemplateArgument(ASTContext &Ctx, const llvm::APSInt &Value,
-   QualType Type) {
+   QualType Type, bool IsDefaulted) {
   Integer.Kind = Integral;
+  Integer.IsDefaulted = IsDefaulted;
   // Copy the APSInt value into our decomposed form.
   Integer.BitWidth = Value.getBitWidth();
   Integer.IsUnsigned = Value.isUnsigned();
Index: clang/lib/AST/DeclTemplate.cpp
===
--- clang/lib/AST/DeclTemplate.cpp
+++ clang/lib/AST/DeclTemplate.cpp
@@ -903,22 +903,42 @@
   FD, Template, TSK, TemplateArgs, ArgsAsWritten, POI, MSInfo);
 }
 
+/// Creates a copy of the 'TemplateArgument's in 'Args'.
+/// If a 'TemplateArgument' corresponds to a default template
+/// parameter this function will mark it as such.
+static TemplateArgumentList *
+CreateCopyWithDefaultedArgs(ASTContext &Ctx,
+TemplateParameterList const *Params,
+ArrayRef Args) {
+  int i = 0;
+  auto MutArgs = Args.copy(Ctx);
+  for (auto &Arg : MutArgs) {
+if (clang::isSubstitutedDefaultArgument(Ctx, Arg, Params->getParam(i), Args,
+Params->getDepth())) {
+  Arg.setIsDefaulted(true);
+}
+++i;
+  }
+
+  return TemplateArgumentList::CreateCopy(Ctx, MutArgs);
+}
+
 //===--===//
 // ClassTemplateSpecializationDecl Implementation
 //===--===//
 
-ClassTemplateSpecializationDecl::
-ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK, TagKind TK,
-DeclContext *DC, SourceLocation StartLoc,
-SourceLocation IdLoc,
-ClassTemplateDecl *SpecializedTemplate,
-ArrayRef Args,
-ClassTemplateSpecializationDecl *PrevDecl)
+ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl(
+ASTContext &Context, Kind DK, TagKind TK, DeclContext *DC,
+SourceLocation StartLoc, SourceLocation IdLoc,
+ClassTemplateDecl *SpecializedTemplate, ArrayRef Args,
+ClassTemplateSpecializationDecl *PrevDecl)
 : CXXRecordDecl(DK, TK, Context, DC, StartLoc, IdLoc,
 SpecializedTemplate->getIdentifier(), PrevDecl),
-SpecializedTemplate(SpecializedTemplate),
-TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args)),
-SpecializationKind(TSK_Undeclared) {
+  SpecializedTemplate(SpecializedTemplate),
+  SpecializationKind(TSK_Undeclared) {
+
+  TemplateArgs = CreateCopyWithDefaultedArgs(
+  Context, SpecializedTemplate->getTemplateParameters(), Args);
 }
 
 ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl(ASTContext &C,
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTConte

[PATCH] D141827: [WIP][clang][TypePrinter] Test TemplateArgument::IsDefaulted when omitting default arguments

2023-01-23 Thread Michael Buch via Phabricator via cfe-commits
Michael137 updated this revision to Diff 491254.
Michael137 added a comment.

- Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141827

Files:
  clang/lib/AST/TypePrinter.cpp


Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -2086,14 +2086,10 @@
   if (TPL && Policy.SuppressDefaultTemplateArgs &&
   !Policy.PrintCanonicalTypes && !Args.empty() && !IsPack &&
   Args.size() <= TPL->size()) {
-ASTContext &Ctx = TPL->getParam(0)->getASTContext();
 llvm::SmallVector OrigArgs;
 for (const TA &A : Args)
   OrigArgs.push_back(getArgument(A));
-while (!Args.empty() &&
-   isSubstitutedDefaultArgument(Ctx, getArgument(Args.back()),
-TPL->getParam(Args.size() - 1),
-OrigArgs, TPL->getDepth()))
+while (!Args.empty() && getArgument(Args.back()).getIsDefaulted())
   Args = Args.drop_back();
   }
 


Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -2086,14 +2086,10 @@
   if (TPL && Policy.SuppressDefaultTemplateArgs &&
   !Policy.PrintCanonicalTypes && !Args.empty() && !IsPack &&
   Args.size() <= TPL->size()) {
-ASTContext &Ctx = TPL->getParam(0)->getASTContext();
 llvm::SmallVector OrigArgs;
 for (const TA &A : Args)
   OrigArgs.push_back(getArgument(A));
-while (!Args.empty() &&
-   isSubstitutedDefaultArgument(Ctx, getArgument(Args.back()),
-TPL->getParam(Args.size() - 1),
-OrigArgs, TPL->getDepth()))
+while (!Args.empty() && getArgument(Args.back()).getIsDefaulted())
   Args = Args.drop_back();
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142333: [clang][DebugInfo] Check TemplateArgument::IsDefaulted

2023-01-23 Thread Michael Buch via Phabricator via cfe-commits
Michael137 created this revision.
Michael137 added reviewers: dblaikie, aprantl.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Since `ClassTemplateSpecializationDecl`s now set the
`TemplateArgument::IsDefaulted` bit, there's no need
to derive it here.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142333

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2010,15 +2010,10 @@
   for (unsigned i = 0, e = Args.Args.size(); i != e; ++i) {
 const TemplateArgument &TA = Args.Args[i];
 StringRef Name;
-bool defaultParameter = false;
-if (Args.TList) {
+bool defaultParameter = TA.getIsDefaulted();
+if (Args.TList)
   Name = Args.TList->getParam(i)->getName();
 
-  NamedDecl const *ND = Args.TList->getParam(i);
-  defaultParameter = clang::isSubstitutedDefaultArgument(
-  CGM.getContext(), TA, ND, Args.Args, Args.TList->getDepth());
-}
-
 switch (TA.getKind()) {
 case TemplateArgument::Type: {
   llvm::DIType *TTy = getOrCreateType(TA.getAsType(), Unit);


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2010,15 +2010,10 @@
   for (unsigned i = 0, e = Args.Args.size(); i != e; ++i) {
 const TemplateArgument &TA = Args.Args[i];
 StringRef Name;
-bool defaultParameter = false;
-if (Args.TList) {
+bool defaultParameter = TA.getIsDefaulted();
+if (Args.TList)
   Name = Args.TList->getParam(i)->getName();
 
-  NamedDecl const *ND = Args.TList->getParam(i);
-  defaultParameter = clang::isSubstitutedDefaultArgument(
-  CGM.getContext(), TA, ND, Args.Args, Args.TList->getDepth());
-}
-
 switch (TA.getKind()) {
 case TemplateArgument::Type: {
   llvm::DIType *TTy = getOrCreateType(TA.getAsType(), Unit);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d54ae90 - [clang][Interp][NFC] Rename InlineDescptor::IsMutable to IsFieldMutable

2023-01-23 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-01-23T10:32:51+01:00
New Revision: d54ae905d13ed56ab8f4ce0147eb92801684f0f3

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

LOG: [clang][Interp][NFC] Rename InlineDescptor::IsMutable to IsFieldMutable

Added: 


Modified: 
clang/lib/AST/Interp/Descriptor.cpp
clang/lib/AST/Interp/Descriptor.h
clang/lib/AST/Interp/EvalEmitter.cpp
clang/lib/AST/Interp/InterpFrame.cpp
clang/lib/AST/Interp/Pointer.h

Removed: 




diff  --git a/clang/lib/AST/Interp/Descriptor.cpp 
b/clang/lib/AST/Interp/Descriptor.cpp
index 70294af7dea7..04bc8681dd6e 100644
--- a/clang/lib/AST/Interp/Descriptor.cpp
+++ b/clang/lib/AST/Interp/Descriptor.cpp
@@ -78,9 +78,10 @@ static void ctorArrayDesc(Block *B, char *Ptr, bool IsConst, 
bool IsMutable,
 Desc->IsBase = false;
 Desc->IsActive = IsActive;
 Desc->IsConst = IsConst || D->IsConst;
-Desc->IsMutable = IsMutable || D->IsMutable;
+Desc->IsFieldMutable = IsMutable || D->IsMutable;
 if (auto Fn = D->ElemDesc->CtorFn)
-  Fn(B, ElemLoc, Desc->IsConst, Desc->IsMutable, IsActive, D->ElemDesc);
+  Fn(B, ElemLoc, Desc->IsConst, Desc->IsFieldMutable, IsActive,
+ D->ElemDesc);
   }
 }
 
@@ -131,9 +132,10 @@ static void ctorRecord(Block *B, char *Ptr, bool IsConst, 
bool IsMutable,
 Desc->IsBase = IsBase;
 Desc->IsActive = IsActive && !IsUnion;
 Desc->IsConst = IsConst || F->IsConst;
-Desc->IsMutable = IsMutable || F->IsMutable;
+Desc->IsFieldMutable = IsMutable || F->IsMutable;
 if (auto Fn = F->CtorFn)
-  Fn(B, Ptr + SubOff, Desc->IsConst, Desc->IsMutable, Desc->IsActive, F);
+  Fn(B, Ptr + SubOff, Desc->IsConst, Desc->IsFieldMutable, Desc->IsActive,
+ F);
   };
   for (const auto &B : D->ElemRecord->bases())
 CtorSub(B.Offset, B.Desc, /*isBase=*/true);

diff  --git a/clang/lib/AST/Interp/Descriptor.h 
b/clang/lib/AST/Interp/Descriptor.h
index 730d66b0cb64..6ef4fc2f4c9b 100644
--- a/clang/lib/AST/Interp/Descriptor.h
+++ b/clang/lib/AST/Interp/Descriptor.h
@@ -70,7 +70,7 @@ struct InlineDescriptor {
   /// Flag indicating if the field is the active member of a union.
   unsigned IsActive : 1;
   /// Flag indicating if the field is mutable (if in a record).
-  unsigned IsMutable : 1; // TODO: Rename to IsFieldMutable.
+  unsigned IsFieldMutable : 1;
 
   Descriptor *Desc;
 };

diff  --git a/clang/lib/AST/Interp/EvalEmitter.cpp 
b/clang/lib/AST/Interp/EvalEmitter.cpp
index 3c1d48f09f9b..72fd3b45254b 100644
--- a/clang/lib/AST/Interp/EvalEmitter.cpp
+++ b/clang/lib/AST/Interp/EvalEmitter.cpp
@@ -61,7 +61,7 @@ Scope::Local EvalEmitter::createLocal(Descriptor *D) {
   Desc.Offset = sizeof(InlineDescriptor);
   Desc.IsActive = true;
   Desc.IsBase = false;
-  Desc.IsMutable = false;
+  Desc.IsFieldMutable = false;
   Desc.IsConst = false;
   Desc.IsInitialized = false;
 

diff  --git a/clang/lib/AST/Interp/InterpFrame.cpp 
b/clang/lib/AST/Interp/InterpFrame.cpp
index 30068e12aa9d..40644c538c6a 100644
--- a/clang/lib/AST/Interp/InterpFrame.cpp
+++ b/clang/lib/AST/Interp/InterpFrame.cpp
@@ -42,7 +42,7 @@ InterpFrame::InterpFrame(InterpState &S, const Function *Func,
   ID->IsActive = true;
   ID->Offset = sizeof(InlineDescriptor);
   ID->IsBase = false;
-  ID->IsMutable = false;
+  ID->IsFieldMutable = false;
   ID->IsConst = false;
   ID->IsInitialized = false;
 }

diff  --git a/clang/lib/AST/Interp/Pointer.h b/clang/lib/AST/Interp/Pointer.h
index ce113a54e122..1462d01c2412 100644
--- a/clang/lib/AST/Interp/Pointer.h
+++ b/clang/lib/AST/Interp/Pointer.h
@@ -260,7 +260,9 @@ class Pointer {
   bool isStaticTemporary() const { return isStatic() && isTemporary(); }
 
   /// Checks if the field is mutable.
-  bool isMutable() const { return Base != 0 && getInlineDesc()->IsMutable; }
+  bool isMutable() const {
+return Base != 0 && getInlineDesc()->IsFieldMutable;
+  }
   /// Checks if an object was initialized.
   bool isInitialized() const;
   /// Checks if the object is active.



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


[PATCH] D142268: [clang][DebugInfo] Don't canonicalize names in template argument list for alias templates

2023-01-23 Thread Michael Buch 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 rGbee8860525ac: [clang][DebugInfo] Don't canonicalize 
names in template argument list for alias… (authored by Michael137).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142268

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-alias.cpp


Index: clang/test/CodeGenCXX/debug-info-alias.cpp
===
--- clang/test/CodeGenCXX/debug-info-alias.cpp
+++ clang/test/CodeGenCXX/debug-info-alias.cpp
@@ -3,6 +3,11 @@
 template
 struct foo {
 };
+
+template
+struct baz {
+};
+
 namespace x {
 // splitting these over multiple lines to make sure the right token is used for
 // the location
@@ -18,6 +23,9 @@
 // CHECK: !DIGlobalVariable(name: "bf",{{.*}} type: [[BFLOAT:![0-9]+]]
 // CHECK: [[BFLOAT]] = !DIDerivedType(tag: DW_TAG_typedef, name: "bar"
 x::bar bf;
+// CHECK: !DIGlobalVariable(name: "bz",{{.*}} type: [[BBAZ:![0-9]+]]
+// CHECK: [[BBAZ]] = !DIDerivedType(tag: DW_TAG_typedef, name: "bar >"
+x::bar> bz;
 
 using
 // CHECK: !DIGlobalVariable(name: "n",{{.*}} type: [[NARF:![0-9]+]]
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1288,9 +1288,21 @@
 
   SmallString<128> NS;
   llvm::raw_svector_ostream OS(NS);
-  Ty->getTemplateName().print(OS, getPrintingPolicy(),
-  TemplateName::Qualified::None);
-  printTemplateArgumentList(OS, Ty->template_arguments(), getPrintingPolicy());
+
+  auto PP = getPrintingPolicy();
+  Ty->getTemplateName().print(OS, PP, TemplateName::Qualified::None);
+
+  // Disable PrintCanonicalTypes here because we want
+  // the DW_AT_name to benefit from the TypePrinter's ability
+  // to skip defaulted template arguments.
+  //
+  // FIXME: Once -gsimple-template-names is enabled by default
+  // and we attach template parameters to alias template DIEs
+  // we don't need to worry about customizing the PrintingPolicy
+  // here anymore.
+  PP.PrintCanonicalTypes = false;
+  printTemplateArgumentList(OS, Ty->template_arguments(), PP,
+TD->getTemplateParameters());
 
   SourceLocation Loc = AliasDecl->getLocation();
   return DBuilder.createTypedef(Src, OS.str(), getOrCreateFile(Loc),


Index: clang/test/CodeGenCXX/debug-info-alias.cpp
===
--- clang/test/CodeGenCXX/debug-info-alias.cpp
+++ clang/test/CodeGenCXX/debug-info-alias.cpp
@@ -3,6 +3,11 @@
 template
 struct foo {
 };
+
+template
+struct baz {
+};
+
 namespace x {
 // splitting these over multiple lines to make sure the right token is used for
 // the location
@@ -18,6 +23,9 @@
 // CHECK: !DIGlobalVariable(name: "bf",{{.*}} type: [[BFLOAT:![0-9]+]]
 // CHECK: [[BFLOAT]] = !DIDerivedType(tag: DW_TAG_typedef, name: "bar"
 x::bar bf;
+// CHECK: !DIGlobalVariable(name: "bz",{{.*}} type: [[BBAZ:![0-9]+]]
+// CHECK: [[BBAZ]] = !DIDerivedType(tag: DW_TAG_typedef, name: "bar >"
+x::bar> bz;
 
 using
 // CHECK: !DIGlobalVariable(name: "n",{{.*}} type: [[NARF:![0-9]+]]
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1288,9 +1288,21 @@
 
   SmallString<128> NS;
   llvm::raw_svector_ostream OS(NS);
-  Ty->getTemplateName().print(OS, getPrintingPolicy(),
-  TemplateName::Qualified::None);
-  printTemplateArgumentList(OS, Ty->template_arguments(), getPrintingPolicy());
+
+  auto PP = getPrintingPolicy();
+  Ty->getTemplateName().print(OS, PP, TemplateName::Qualified::None);
+
+  // Disable PrintCanonicalTypes here because we want
+  // the DW_AT_name to benefit from the TypePrinter's ability
+  // to skip defaulted template arguments.
+  //
+  // FIXME: Once -gsimple-template-names is enabled by default
+  // and we attach template parameters to alias template DIEs
+  // we don't need to worry about customizing the PrintingPolicy
+  // here anymore.
+  PP.PrintCanonicalTypes = false;
+  printTemplateArgumentList(OS, Ty->template_arguments(), PP,
+TD->getTemplateParameters());
 
   SourceLocation Loc = AliasDecl->getLocation();
   return DBuilder.createTypedef(Src, OS.str(), getOrCreateFile(Loc),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141826: [WIP][clang][TemplateBase] Add IsDefaulted bit to TemplateArgument

2023-01-23 Thread Michael Buch via Phabricator via cfe-commits
Michael137 added a comment.

In D141826#4059088 , @erichkeane 
wrote:

> In D141826#4059073 , @Michael137 
> wrote:
>
>> In D141826#4058866 , @erichkeane 
>> wrote:
>>
>>> This seems innocuous enough/easy enough to use.  I'd like a comment on the 
>>> functions at least and types in TemplateBase.h to specify that this is for 
>>> printing-policy only?  Alternatively (and perhaps MUCH more appreciated) 
>>> would be to make sure we mark the defaulted during AST generation as well.
>>
>> I'll have a look at doing that
>>
>> Are you suggesting we do the substitution check that the TypePrinter 
>> currently does when constructing the specialisation decls? So the 
>> TypePrinter simply needs to check the `TemplateArgument::getIsDefaulted`? I 
>> like the sound of that.
>>
>> Unfortunately we'd still need the `setIsDefaulted` because of the DWARF 
>> limitation in LLDB
>
> Yes, thats my thought.  Of course we'd still need the 'setIsDefaulted', but 
> at least it would be something that coudl be generally useful.

So I've been having a go at this. The latest diff sets the bit when creating 
`ClassTemplateSpecializationDecl`s. However, we end up having to copy the 
`ArrayRef` twice (because of the current assumptions that a 
`TemplateArgumentList` is immutable, which seems like a nice property to 
maintain). But the double copy does seem iffy.

I also had to add the flag to the `TemplateArgument` tablegen description to 
support deserialized `ClassTemplateSpecializationDecl`.

I've been playing around with setting the flag at construction of 
`TemplateArgument`s instead. Not sure how much cleaner that's going to be 
because so far I've not found a good single point of entry (been looking at 
CheckTemplateArgumentList 

 in `SemaTemplate`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141826

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


[PATCH] D142334: [Clang[NFC] Fix bitmask for NullabilityPayload in Types.h

2023-01-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta created this revision.
xgupta added reviewers: aaron.ballman, usaxena95.
Herald added a project: All.
xgupta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Found by PVS-Studio - https://pvs-studio.com/en/blog/posts/cpp/1003/, N37.

The code you is using the bit mask NullabilityKindMask which is 0x3 
(0011 in binary) to clear the bits in the NullabilityPayload variable.
Since NullabilityPayload is a 64-bit variable and NullabilityKindMask is 
only a 8-bit variable(0x3), it will only affect the last 8 bits of the 
variable. The higher 56 bits will remain unchanged.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142334

Files:
  clang/include/clang/APINotes/Types.h


Index: clang/include/clang/APINotes/Types.h
===
--- clang/include/clang/APINotes/Types.h
+++ clang/include/clang/APINotes/Types.h
@@ -532,7 +532,7 @@
 
 // Mask the bits.
 NullabilityPayload &=
-~(NullabilityKindMask << (index * NullabilityKindSize));
+~(static_castNullabilityKindMask << (index * 
NullabilityKindSize));
 
 // Set the value.
 unsigned kindValue = (static_cast(kind))


Index: clang/include/clang/APINotes/Types.h
===
--- clang/include/clang/APINotes/Types.h
+++ clang/include/clang/APINotes/Types.h
@@ -532,7 +532,7 @@
 
 // Mask the bits.
 NullabilityPayload &=
-~(NullabilityKindMask << (index * NullabilityKindSize));
+~(static_castNullabilityKindMask << (index * NullabilityKindSize));
 
 // Set the value.
 unsigned kindValue = (static_cast(kind))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142268: [clang][DebugInfo] Don't canonicalize names in template argument list for alias templates

2023-01-23 Thread Michael Buch via Phabricator via cfe-commits
Michael137 added a comment.

In D142268#4072358 , @dblaikie wrote:

> So @Michael137 and I talked about this offline, and a few extra details:
>
> - Generally it's important that types have identical names. Templates try to 
> do this, but get it wrong in a bunch of ways (& certainly between GCC and 
> Clang we get it different in a bunch of ways too) which are all 
> problematic/could cause a debugger to not correctly identify two types in 
> distinct CUs as being actually the same type.
>   - That's why we usually use the full name of a template, to ensure it's 
> identical between instantiations in different CUs
> - Because compilers don't all produce character-for-character identical 
> names, debuggers mostly have to throw away the "<.*>" and recanonicalize from 
> the `DW_TAG_template_*_parameter`s anyway..
> - But none of that matters, because alias templates aren't strong aliases - 
> they aren't part of the type system, they're just a name that code can use
> - As mentioned, GCC currently only uses the base name, no template parameters 
> - which isn't super helpful (since you'd then end up with a bunch of 
> different alias template instantiations all with the same name).
> - Clang produces the alias template with the template parameters in the 
> `DW_AT_name`, but without any `DW_TAG_template_*_parameter` DIEs, which means 
> we can't apply Simple Template Names here, currently - though might be a nice 
> thing to do at somepoint.
>
> But for now, since the name doesn't actually have to be 
> deconstruct/canonicalize the template parameters - we can just pick whatever 
> name is nice for the user, really.
>
> So, I think this is an OK change to make for now - though probably the nicer 
> thing, long-term, would be to add the template parameter DIEs, and under 
> `-gsimple-template-names` remove the template parameters from the 
> `DW_AT_name` (& maybe eventually turn that on by default/migrate to 
> `-gsimple-template-names`) but for now/when using 
> non`-gsimple-template-names`, this seems OK, if a bit weird/inconsistent, but 
> for good reasons because the alias template isn't part of the type system. 
> (thanks for including the FIXME there)

Thanks for the extensive summary!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142268

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


[PATCH] D142333: [clang][DebugInfo] Check TemplateArgument::IsDefaulted

2023-01-23 Thread Michael Buch via Phabricator via cfe-commits
Michael137 updated this revision to Diff 491257.
Michael137 added a comment.

- Make variable `const`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142333

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2010,15 +2010,10 @@
   for (unsigned i = 0, e = Args.Args.size(); i != e; ++i) {
 const TemplateArgument &TA = Args.Args[i];
 StringRef Name;
-bool defaultParameter = false;
-if (Args.TList) {
+const bool defaultParameter = TA.getIsDefaulted();
+if (Args.TList)
   Name = Args.TList->getParam(i)->getName();
 
-  NamedDecl const *ND = Args.TList->getParam(i);
-  defaultParameter = clang::isSubstitutedDefaultArgument(
-  CGM.getContext(), TA, ND, Args.Args, Args.TList->getDepth());
-}
-
 switch (TA.getKind()) {
 case TemplateArgument::Type: {
   llvm::DIType *TTy = getOrCreateType(TA.getAsType(), Unit);


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2010,15 +2010,10 @@
   for (unsigned i = 0, e = Args.Args.size(); i != e; ++i) {
 const TemplateArgument &TA = Args.Args[i];
 StringRef Name;
-bool defaultParameter = false;
-if (Args.TList) {
+const bool defaultParameter = TA.getIsDefaulted();
+if (Args.TList)
   Name = Args.TList->getParam(i)->getName();
 
-  NamedDecl const *ND = Args.TList->getParam(i);
-  defaultParameter = clang::isSubstitutedDefaultArgument(
-  CGM.getContext(), TA, ND, Args.Args, Args.TList->getDepth());
-}
-
 switch (TA.getKind()) {
 case TemplateArgument::Type: {
   llvm::DIType *TTy = getOrCreateType(TA.getAsType(), Unit);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142092: [include-mapping] Allow multiple headers for the same symbol. Choose the first header of available ones.

2023-01-23 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo added a comment.

Oh I misunderstood your comment regarding which maps need to be regenerated as 
part of this patch. Regenerated the 2018 ones now. As expected, there are only 
added symbols now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

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


[PATCH] D142144: [RISCV][Driver] Add -rvv-vector-bits= option similar to -sve-vector-bits=

2023-01-23 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck added inline comments.



Comment at: clang/include/clang/Driver/Options.td:3587
+  HelpText<"Specify the size in bits of an RVV vector register. Defaults to 
the"
+   " vector length agnostic value of \"scalable\". Also accepts 
\"zvl\""
+   " to use the value implied by -march/-mcpu. (RISC-V only)">;

Same question as below with the value `"scalable"`. Should we excise it for now?



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2150
+  Args.MakeArgString("-mvscale-min=" + llvm::Twine(VScaleMin)));
+} else if (!Val.equals("scalable")) {
+  // Handle the unsupported values passed to mrvv-vector-bits.

Is this check right? I don't see mention of "scalable" in the commit 
description. Should this be a plain `else`?



Comment at: clang/test/Driver/riscv-rvv-vector-bits.c:2
+// 
-
+// Tests for the -msve-vector-bits flag
+// 
-

Need to adjust this comment



Comment at: clang/test/Driver/riscv-rvv-vector-bits.c:16
+// RUN: %clang -c %s -### -target riscv64-linux-gnu -march=rv64gc_zve64x \
+// RUN:  -mrvv-vector-bits=scalable 2>&1 | FileCheck 
--check-prefix=CHECK-SCALABLE %s
+

Another use of `"scalable"` which I'm not sure about.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142144

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


[PATCH] D142092: [include-mapping] Allow multiple headers for the same symbol. Choose the first header of available ones.

2023-01-23 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 491260.
VitaNuo marked an inline comment as done.
VitaNuo added a comment.

Address review comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

Files:
  clang/include/clang/Tooling/Inclusions/CSymbolMap.inc
  clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc
  clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
  clang/tools/include-mapping/cppreference_parser.py
  clang/tools/include-mapping/gen_std.py

Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -14,10 +14,7 @@
 The generated files are located in clang/include/Tooling/Inclusions.
 
 Caveats and FIXMEs:
-  - only symbols directly in "std" namespace are added, we should also add std's
-subnamespace symbols (e.g. chrono).
-  - symbols with multiple variants or defined in multiple headers aren't added,
-e.g. std::move, std::swap
+  - symbols with multiple variants aren't added, e.g., std::move
 
 Usage:
   1. Install BeautifulSoup dependency, see instruction:
@@ -110,17 +107,12 @@
 os.stat(index_page_path).st_mtime).strftime('%Y-%m-%d')
   print(CODE_PREFIX % (args.symbols.upper(), cppreference_modified_date))
   for symbol in symbols:
-if len(symbol.headers) == 1:
-  # SYMBOL(unqualified_name, namespace, header)
-  print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
-symbol.headers[0]))
-elif len(symbol.headers) == 0:
+if len(symbol.headers) == 0:
   sys.stderr.write("No header found for symbol %s\n" % symbol.name)
 else:
-  # FIXME: support symbols with multiple headers (e.g. std::move).
-  sys.stderr.write("Ambiguous header for symbol %s: %s\n" % (
-  symbol.name, ', '.join(symbol.headers)))
-
-
+  for header in symbol.headers:
+# SYMBOL(unqualified_name, namespace, header)
+print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
+  header))
 if __name__ == '__main__':
   main()
Index: clang/tools/include-mapping/cppreference_parser.py
===
--- clang/tools/include-mapping/cppreference_parser.py
+++ clang/tools/include-mapping/cppreference_parser.py
@@ -118,7 +118,7 @@
 return _ParseSymbolPage(f.read(), name)
 
 
-def _GetSymbols(pool, root_dir, index_page_name, namespace, variants_to_accept):
+def _GetSymbols(pool, root_dir, index_page_name, namespace):
   """Get all symbols listed in the index page. All symbols should be in the
   given namespace.
 
@@ -137,9 +137,7 @@
 for symbol_name, symbol_page_path, variant in _ParseIndexPage(f.read()):
   # Variant symbols (e.g. the std::locale version of isalpha) add ambiguity.
   # FIXME: use these as a fallback rather than ignoring entirely.
-  variants_for_symbol = variants_to_accept.get(
-  (namespace or "") + symbol_name, ())
-  if variant and variant not in variants_for_symbol:
+  if variant:
 continue
   path = os.path.join(root_dir, symbol_page_path)
   if os.path.isfile(path):
@@ -166,13 +164,6 @@
   Args:
 parse_pages: a list of tuples (page_root_dir, index_page_name, namespace)
   """
-  # By default we prefer the non-variant versions, as they're more common. But
-  # there are some symbols, whose variant is more common. This list describes
-  # those symbols.
-  variants_to_accept = {
-  # std::remove<> has variant algorithm.
-  "std::remove": ("algorithm"),
-  }
   symbols = []
   # Run many workers to process individual symbol pages under the symbol index.
   # Don't allow workers to capture Ctrl-C.
@@ -180,8 +171,7 @@
   initializer=lambda: signal.signal(signal.SIGINT, signal.SIG_IGN))
   try:
 for root_dir, page_name, namespace in parse_pages:
-  symbols.extend(_GetSymbols(pool, root_dir, page_name, namespace,
- variants_to_accept))
+  symbols.extend(_GetSymbols(pool, root_dir, page_name, namespace))
   finally:
 pool.terminate()
 pool.join()
Index: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
===
--- clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -8,6 +8,7 @@
 
 #include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "clang/AST/Decl.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 
@@ -16,8 +17,9 @@
 namespace stdlib {
 
 static llvm::StringRef *HeaderNames;
-static std::pair *SymbolNames;
-static unsigned *SymbolHeaderIDs;
+static llvm::DenseMap>
+*SymbolNames;
+static llvm::SmallVector *SymbolHeaderIDs;
 static llvm::DenseMap *HeaderIDs;
 // Maps s

[clang] bee8860 - [clang][DebugInfo] Don't canonicalize names in template argument list for alias templates

2023-01-23 Thread Michael Buch via cfe-commits

Author: Michael Buch
Date: 2023-01-23T09:43:17Z
New Revision: bee8860525acbfe33f5b32870ad5e13de07fa6ff

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

LOG: [clang][DebugInfo] Don't canonicalize names in template argument list for 
alias templates

**Summary**

This patch customizes the `CGDebugInfo` printing policy to stop canonicalizing
the template arugment list in `DW_AT_name` for alias templates. The motivation 
for
this is that we want to be able to use the `TypePrinter`s support for
omitting defaulted template arguments when emitting `DW_AT_name`.

For reference, GCC currently completely omits the template arguments
when emitting alias template DIEs.

**Testing**

* Added unit-test

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

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-alias.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index b8e16918075e4..3bde43cc1db36 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1288,9 +1288,21 @@ llvm::DIType *CGDebugInfo::CreateType(const 
TemplateSpecializationType *Ty,
 
   SmallString<128> NS;
   llvm::raw_svector_ostream OS(NS);
-  Ty->getTemplateName().print(OS, getPrintingPolicy(),
-  TemplateName::Qualified::None);
-  printTemplateArgumentList(OS, Ty->template_arguments(), getPrintingPolicy());
+
+  auto PP = getPrintingPolicy();
+  Ty->getTemplateName().print(OS, PP, TemplateName::Qualified::None);
+
+  // Disable PrintCanonicalTypes here because we want
+  // the DW_AT_name to benefit from the TypePrinter's ability
+  // to skip defaulted template arguments.
+  //
+  // FIXME: Once -gsimple-template-names is enabled by default
+  // and we attach template parameters to alias template DIEs
+  // we don't need to worry about customizing the PrintingPolicy
+  // here anymore.
+  PP.PrintCanonicalTypes = false;
+  printTemplateArgumentList(OS, Ty->template_arguments(), PP,
+TD->getTemplateParameters());
 
   SourceLocation Loc = AliasDecl->getLocation();
   return DBuilder.createTypedef(Src, OS.str(), getOrCreateFile(Loc),

diff  --git a/clang/test/CodeGenCXX/debug-info-alias.cpp 
b/clang/test/CodeGenCXX/debug-info-alias.cpp
index 8c3f8447de691..3d3f87ed1f6fa 100644
--- a/clang/test/CodeGenCXX/debug-info-alias.cpp
+++ b/clang/test/CodeGenCXX/debug-info-alias.cpp
@@ -3,6 +3,11 @@
 template
 struct foo {
 };
+
+template
+struct baz {
+};
+
 namespace x {
 // splitting these over multiple lines to make sure the right token is used for
 // the location
@@ -18,6 +23,9 @@ x::bar bi;
 // CHECK: !DIGlobalVariable(name: "bf",{{.*}} type: [[BFLOAT:![0-9]+]]
 // CHECK: [[BFLOAT]] = !DIDerivedType(tag: DW_TAG_typedef, name: "bar"
 x::bar bf;
+// CHECK: !DIGlobalVariable(name: "bz",{{.*}} type: [[BBAZ:![0-9]+]]
+// CHECK: [[BBAZ]] = !DIDerivedType(tag: DW_TAG_typedef, name: "bar >"
+x::bar> bz;
 
 using
 // CHECK: !DIGlobalVariable(name: "n",{{.*}} type: [[NARF:![0-9]+]]



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


[PATCH] D141826: [WIP][clang][TemplateBase] Add IsDefaulted bit to TemplateArgument

2023-01-23 Thread Michael Buch via Phabricator via cfe-commits
Michael137 updated this revision to Diff 491265.
Michael137 added a comment.

- Rename test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141826

Files:
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/TemplateBase.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/unittests/AST/DeclTest.cpp

Index: clang/unittests/AST/DeclTest.cpp
===
--- clang/unittests/AST/DeclTest.cpp
+++ clang/unittests/AST/DeclTest.cpp
@@ -490,3 +490,34 @@
   ASSERT_TRUE(AlignedArrayDelete->getOwningModule());
   EXPECT_TRUE(AlignedArrayDelete->getOwningModule()->isGlobalModule());
 }
+
+TEST(Decl, TemplateArgumentDefaulted) {
+  llvm::Annotations Code(R"cpp(
+template
+struct Alloc {};
+
+template >
+struct Foo {
+};
+
+Foo> X;
+  )cpp");
+
+  auto AST =
+  tooling::buildASTFromCodeWithArgs(Code.code(), /*Args=*/{"-std=c++20"});
+  ASTContext &Ctx = AST->getASTContext();
+
+  auto const *CTSD = selectFirst(
+  "id",
+  match(classTemplateSpecializationDecl(hasName("Foo")).bind("id"), Ctx));
+  ASSERT_NE(CTSD, nullptr);
+  auto const &ArgList = CTSD->getTemplateArgs();
+
+  EXPECT_FALSE(ArgList.get(0).getIsDefaulted());
+  EXPECT_FALSE(ArgList.get(1).getIsDefaulted());
+  EXPECT_TRUE(ArgList.get(2).getIsDefaulted());
+  EXPECT_TRUE(ArgList.get(3).getIsDefaulted());
+}
Index: clang/lib/AST/TemplateBase.cpp
===
--- clang/lib/AST/TemplateBase.cpp
+++ clang/lib/AST/TemplateBase.cpp
@@ -161,8 +161,9 @@
 //===--===//
 
 TemplateArgument::TemplateArgument(ASTContext &Ctx, const llvm::APSInt &Value,
-   QualType Type) {
+   QualType Type, bool IsDefaulted) {
   Integer.Kind = Integral;
+  Integer.IsDefaulted = IsDefaulted;
   // Copy the APSInt value into our decomposed form.
   Integer.BitWidth = Value.getBitWidth();
   Integer.IsUnsigned = Value.isUnsigned();
Index: clang/lib/AST/DeclTemplate.cpp
===
--- clang/lib/AST/DeclTemplate.cpp
+++ clang/lib/AST/DeclTemplate.cpp
@@ -903,22 +903,42 @@
   FD, Template, TSK, TemplateArgs, ArgsAsWritten, POI, MSInfo);
 }
 
+/// Creates a copy of the 'TemplateArgument's in 'Args'.
+/// If a 'TemplateArgument' corresponds to a default template
+/// parameter this function will mark it as such.
+static TemplateArgumentList *
+CreateCopyWithDefaultedArgs(ASTContext &Ctx,
+TemplateParameterList const *Params,
+ArrayRef Args) {
+  int i = 0;
+  auto MutArgs = Args.copy(Ctx);
+  for (auto &Arg : MutArgs) {
+if (clang::isSubstitutedDefaultArgument(Ctx, Arg, Params->getParam(i), Args,
+Params->getDepth())) {
+  Arg.setIsDefaulted(true);
+}
+++i;
+  }
+
+  return TemplateArgumentList::CreateCopy(Ctx, MutArgs);
+}
+
 //===--===//
 // ClassTemplateSpecializationDecl Implementation
 //===--===//
 
-ClassTemplateSpecializationDecl::
-ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK, TagKind TK,
-DeclContext *DC, SourceLocation StartLoc,
-SourceLocation IdLoc,
-ClassTemplateDecl *SpecializedTemplate,
-ArrayRef Args,
-ClassTemplateSpecializationDecl *PrevDecl)
+ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl(
+ASTContext &Context, Kind DK, TagKind TK, DeclContext *DC,
+SourceLocation StartLoc, SourceLocation IdLoc,
+ClassTemplateDecl *SpecializedTemplate, ArrayRef Args,
+ClassTemplateSpecializationDecl *PrevDecl)
 : CXXRecordDecl(DK, TK, Context, DC, StartLoc, IdLoc,
 SpecializedTemplate->getIdentifier(), PrevDecl),
-SpecializedTemplate(SpecializedTemplate),
-TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args)),
-SpecializationKind(TSK_Undeclared) {
+  SpecializedTemplate(SpecializedTemplate),
+  SpecializationKind(TSK_Undeclared) {
+
+  TemplateArgs = CreateCopyWithDefaultedArgs(
+  Context, SpecializedTemplate->getTemplateParameters(), Args);
 }
 
 ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl(ASTContext &C,
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -6739,26 +6739,29 @@
 
 case TemplateArgument::Declaration: {
   auto *D = cast(Arg.getAsDe

[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-23 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk added a comment.

In D141581#4071617 , @thesamesam 
wrote:

> This is currently holding back further testing on our end which is concerning 
> me a bit, especially as we approach the branch point. Could you revert this 
> please if a fix isn't imminent? Thank you!

@thesamesam what do you mean with "revert"? Just by looking at this 
differential I cannot see that this patch has landed. Has it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D140972: [flang] Add -fstack-arrays flag

2023-01-23 Thread Tom Eccles via Phabricator via cfe-commits
tblah updated this revision to Diff 491267.
tblah added a comment.

- Rename option macro to make it clear that it doesn't do marshalling


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140972

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/docs/FlangDriver.md
  flang/include/flang/Frontend/CodeGenOptions.def
  flang/include/flang/Tools/CLOptions.inc
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/fast_math.f90
  flang/test/Transforms/stack-arrays.f90

Index: flang/test/Transforms/stack-arrays.f90
===
--- flang/test/Transforms/stack-arrays.f90
+++ flang/test/Transforms/stack-arrays.f90
@@ -1,5 +1,10 @@
 ! RUN: %flang_fc1 -emit-fir %s -o - | fir-opt --array-value-copy | fir-opt --stack-arrays | FileCheck %s
 
+! In order to verify the whole MLIR pipeline, make the driver generate LLVM IR.
+! This is only to check that -fstack-arrays enables the stack-arrays pass so
+! only check the first example
+! RUN: %flang_fc1 -emit-llvm -o - -fstack-arrays %s | FileCheck --check-prefix=LLVM-IR %s
+
 ! check simple array value copy case
 subroutine array_value_copy_simple(arr)
   integer, intent(inout) :: arr(4)
@@ -14,6 +19,15 @@
 ! CHECK: return
 ! CHECK-NEXT: }
 
+! LLVM-IR: array_value_copy_simple
+! LLVM-IR-NOT: malloc
+! LLVM-IR-NOT: free
+! LLVM-IR: alloca [4 x i32]
+! LLVM-IR-NOT: malloc
+! LLVM-IR-NOT: free
+! LLVM-IR: ret void
+! LLVM-IR-NEXT: }
+
 ! check complex array value copy case
 module stuff
   type DerivedWithAllocatable
Index: flang/test/Driver/fast_math.f90
===
--- flang/test/Driver/fast_math.f90
+++ flang/test/Driver/fast_math.f90
@@ -1,25 +1,35 @@
 ! Test for correct forwarding of fast-math flags from the compiler driver to the
 ! frontend driver
 
-! -Ofast => -ffast-math -O3
+! -Ofast => -ffast-math -O3 -fstack-arrays
 ! RUN: %flang -Ofast -fsyntax-only -### %s -o %t 2>&1 \
 ! RUN: | FileCheck --check-prefix=CHECK-OFAST %s
 ! CHECK-OFAST: -fc1
 ! CHECK-OFAST-SAME: -ffast-math
+! CHECK-OFAST-SAME: -fstack-arrays
 ! CHECK-OFAST-SAME: -O3
 
-! TODO: update once -fstack-arays is added
-! RUN: %flang -fstack-arrays -fsyntax-only %s -o %t 2>&1 \
+! RUN: %flang -fstack-arrays -fsyntax-only -### %s -o %t 2>&1 \
 ! RUN: | FileCheck --check-prefix=CHECK-STACK-ARRAYS %s
-! CHECK-STACK-ARRAYS: warning: argument unused during compilation: '-fstack-arrays'
+! CHECK-STACK-ARRAYS: -fc1
+! CHECK-STACK-ARRAYS-SAME: -fstack-arrays
 
-! -Ofast -fno-fast-math => -O3
+! -Ofast -fno-fast-math => -O3 -fstack-arrays
 ! RUN: %flang -Ofast -fno-fast-math -fsyntax-only -### %s -o %t 2>&1 \
 ! RUN: | FileCheck --check-prefix=CHECK-OFAST-NO-FAST %s
 ! CHECK-OFAST-NO-FAST: -fc1
 ! CHECK-OFAST-NO-FAST-NOT: -ffast-math
+! CHECK-OFAST-NO-FAST-SAME: -fstack-arrays
 ! CHECK-OFAST-NO-FAST-SAME: -O3
 
+! -Ofast -fno-stack-arrays -> -O3 -ffast-math
+! RUN: %flang -Ofast -fno-stack-arrays -fsyntax-only -### %s -o %t 2>&1 \
+! RUN: | FileCheck --check-prefix=CHECK-OFAST-NO-SA %s
+! CHECK-OFAST-NO-SA: -fc1
+! CHECK-OFAST-NO-SA-SAME: -ffast-math
+! CHECK-OFAST-NO-SA-NOT: -fstack-arrays
+! CHECK-OFAST-NO-SA-SAME: -O3
+
 ! -ffast-math => -ffast-math
 ! RUN: %flang -ffast-math -fsyntax-only -### %s -o %t 2>&1 \
 ! RUN: | FileCheck --check-prefix=CHECK-FFAST %s
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -45,10 +45,12 @@
 ! HELP-NEXT: -fno-color-diagnostics  Disable colors in diagnostics
 ! HELP-NEXT: -fno-integrated-as  Disable the integrated assembler
 ! HELP-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
+! HELP-NEXT: -fno-stack-arrays  Allocate array temporaries on the heap (default)
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
 ! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! HELP-NEXT: -freciprocal-math  Allow division operations to be reassociated
+! HELP-NEXT: -fstack-arrays Attempt to allocate array temporaries on the stack, no matter their size
 ! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-NEXT: -help  Display available options
@@ -130,10 +132,12 @@
 ! HELP-FC1-NEXT: -fno-debug-pass-manager Disables debug printing for the new pass manager
 ! HELP-FC1-NEXT: -fno-reformat  Dump the cooked character stream in -E 

[PATCH] D142338: [Clang][NFC] Remove a redundancy check in Sema::adjustMemberFunctionCC

2023-01-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta created this revision.
Herald added a project: All.
xgupta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If the current calling convection CurCC is not equal to Target calling 
convection ToCC and current calling convention (CurCC) is equal to the 
default calling convention (DefaultCC), that means DefaultCC can not be 
equal to ToCC so the right part of the expression DefaultCC == ToCC is 
not needed.

revelant code -

  if (CurCC == ToCC)
return;
  if (CurCC != DefaultCC || DefaultCC == ToCC)
return;

Found by PVS-Studio - https://pvs-studio.com/en/blog/posts/cpp/1003/, N41.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142338

Files:
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7960,7 +7960,7 @@
 CallingConv DefaultCC =
 Context.getDefaultCallingConvention(IsVariadic, IsStatic);
 
-if (CurCC != DefaultCC || DefaultCC == ToCC)
+if (CurCC != DefaultCC)
   return;
 
 if (hasExplicitCallingConv(T))


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7960,7 +7960,7 @@
 CallingConv DefaultCC =
 Context.getDefaultCallingConvention(IsVariadic, IsStatic);
 
-if (CurCC != DefaultCC || DefaultCC == ToCC)
+if (CurCC != DefaultCC)
   return;
 
 if (hasExplicitCallingConv(T))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139326: [clang] Add test for CWG952

2023-01-23 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill added inline comments.



Comment at: clang/test/CXX/drs/dr9xx.cpp:76
+namespace dr952 { // dr952: yes
+struct A {
+  typedef int I; // #dr952-typedef-decl

aaron.ballman wrote:
> I wouldn't mind another test case:
> ```
> struct A {
> protected:
>   static int x;
> };
> struct B : A {
>   friend int get(B) { return x; }
> };
> ```
> this was something Richard had pointed out needs to still work as part of the 
> reflector discussions of this issue.
Sorry, it seems I missed your comment when I landed the patch. Would it be fine 
to add this test as NFC patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139326

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


[clang] ddbe140 - Add clang_CXXMethod_isExplicit to libclang

2023-01-23 Thread Luca Di Sera via cfe-commits

Author: Luca Di Sera
Date: 2023-01-23T11:30:38+01:00
New Revision: ddbe14084da7f31d4b4b53e13d9f868d759f3673

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

LOG: Add clang_CXXMethod_isExplicit to libclang

The new method is a wrapper of `CXXConstructorDecl::isExplicit` and
`CXXConversionDecl::isExplicit`, allowing the user to recognize whether
the declaration pointed to by a cursor was marked with the explicit
specifier.

An export for the function, together with its documentation, was added
to "clang/include/clang-c/Index.h" with an implementation provided in
"clang/tools/libclang/CIndex.cpp".

The implementation is based on similar `clang_CXXMethod`
implementations, returning a falsy unsigned value when the cursor is not
a declaration, is not a declaration for a constructor or conversion
function or is not a relevant declaration that was marked with the
`explicit` specifier.

The new symbol was added to "clang/tools/libclang/libclang.map" to be
exported, under the LLVM16 tag.

"clang/tools/c-index-test/c-index-test.c" was modified to print a
specific tag, "(explicit)", for cursors that are recognized by
`clang_CXXMethod_isExplicit`.

Two new regression files, "explicit-constructor.cpp" and
"explicit-conversion-function.cpp", were added to "clang/test/Index", to
ensure that the behavior of the new function is correct for constructors
and conversion functions, respectively.

The "get-cursor.cpp", "index-file.cpp" and
"recursive-cxx-member-calls.cpp" regression files in "clang/test/Index"
were updated as they were affected by the new "(explicit)" tag.

A binding for the new function was added to libclang's python's
bindings, in "clang/bindings/python/clang/cindex.py", as the
"is_explicit_method" method under `Cursor`.

An accompanying test was added to
"clang/bindings/python/tests/cindex/test_cursor.py", mimicking the
regression tests for the C side.

The current release note for Clang, "clang/docs/ReleaseNotes.rst" was
modified to report the new addition under the "libclang" section.

Reviewed By: aaron.ballman

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

Added: 
clang/test/Index/explicit-constructor.cpp
clang/test/Index/explicit-conversion-function.cpp

Modified: 
clang/bindings/python/clang/cindex.py
clang/bindings/python/tests/cindex/test_cursor.py
clang/docs/ReleaseNotes.rst
clang/include/clang-c/Index.h
clang/test/Index/get-cursor.cpp
clang/test/Index/index-file.cpp
clang/test/Index/recursive-cxx-member-calls.cpp
clang/tools/c-index-test/c-index-test.c
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/libclang.map

Removed: 




diff  --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index 2e32ce2ba6d06..217873f2d3aaf 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -1529,6 +1529,51 @@ class Bar {
 """
 return conf.lib.clang_CXXMethod_isMoveAssignmentOperator(self)
 
+def is_explicit_method(self):
+"""Determines if a C++ constructor or conversion function is
+explicit, returning 1 if such is the case and 0 otherwise.
+
+Constructors or conversion functions are declared explicit through
+the use of the explicit specifier.
+
+For example, the following constructor and conversion function are
+not explicit as they lack the explicit specifier:
+
+class Foo {
+Foo();
+operator int();
+};
+
+While the following constructor and conversion function are
+explicit as they are declared with the explicit specifier.
+
+class Foo {
+explicit Foo();
+explicit operator int();
+};
+
+This method will return 0 when given a cursor pointing to one of
+the former declarations and it will return 1 for a cursor pointing
+to the latter declarations.
+
+The explicit specifier allows the user to specify a
+conditional compile-time expression whose value decides
+whether the marked element is explicit or not.
+
+For example:
+
+constexpr bool foo(int i) { return 1 % 2 == 0; }
+
+class Foo {
+ explicit(foo(1)) Foo();
+ explicit(foo(2)) operator int();
+}
+
+This method will return 0 for the constructor and 1 for
+the conversion function.
+"""
+return conf.lib.clang_CXXMethod_isExplicit(self)
+
 def is_mutable_field(self):
 """Returns True if the cursor refers to a C++ field that is declared
 'mutable'.
@@ -3494,6 +3539,10 @@ def cursor(self):
[Cursor],
bool),
 
+  ("clang_CXXMethod_isExp

[PATCH] D140756: Add clang_CXXMethod_isExplicit to libclang

2023-01-23 Thread Luca Di sera 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 rGddbe14084da7: Add clang_CXXMethod_isExplicit to libclang 
(authored by diseraluca).

Changed prior to commit:
  https://reviews.llvm.org/D140756?vs=485598&id=491269#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140756

Files:
  clang/bindings/python/clang/cindex.py
  clang/bindings/python/tests/cindex/test_cursor.py
  clang/docs/ReleaseNotes.rst
  clang/include/clang-c/Index.h
  clang/test/Index/explicit-constructor.cpp
  clang/test/Index/explicit-conversion-function.cpp
  clang/test/Index/get-cursor.cpp
  clang/test/Index/index-file.cpp
  clang/test/Index/recursive-cxx-member-calls.cpp
  clang/tools/c-index-test/c-index-test.c
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/libclang.map

Index: clang/tools/libclang/libclang.map
===
--- clang/tools/libclang/libclang.map
+++ clang/tools/libclang/libclang.map
@@ -416,6 +416,7 @@
 clang_disposeAPISet;
 clang_getSymbolGraphForCursor;
 clang_getSymbolGraphForUSR;
+clang_CXXMethod_isExplicit;
 };
 
 # Example of how to add a new symbol version entry.  If you do add a new symbol
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -8947,6 +8947,25 @@
   return (Method && Method->isMoveAssignmentOperator()) ? 1 : 0;
 }
 
+unsigned clang_CXXMethod_isExplicit(CXCursor C) {
+  if (!clang_isDeclaration(C.kind))
+return 0;
+
+  const Decl *D = cxcursor::getCursorDecl(C);
+  const FunctionDecl *FD = D->getAsFunction();
+
+  if (!FD)
+return 0;
+
+  if (const auto *Ctor = dyn_cast(FD))
+return Ctor->isExplicit();
+
+  if (const auto *Conv = dyn_cast(FD))
+return Conv->isExplicit();
+
+  return 0;
+}
+
 unsigned clang_CXXRecord_isAbstract(CXCursor C) {
   if (!clang_isDeclaration(C.kind))
 return 0;
Index: clang/tools/c-index-test/c-index-test.c
===
--- clang/tools/c-index-test/c-index-test.c
+++ clang/tools/c-index-test/c-index-test.c
@@ -916,6 +916,8 @@
   printf(" (copy-assignment operator)");
 if (clang_CXXMethod_isMoveAssignmentOperator(Cursor))
   printf(" (move-assignment operator)");
+if (clang_CXXMethod_isExplicit(Cursor))
+  printf(" (explicit)");
 if (clang_CXXRecord_isAbstract(Cursor))
   printf(" (abstract)");
 if (clang_EnumDecl_isScoped(Cursor))
Index: clang/test/Index/recursive-cxx-member-calls.cpp
===
--- clang/test/Index/recursive-cxx-member-calls.cpp
+++ clang/test/Index/recursive-cxx-member-calls.cpp
@@ -824,7 +824,7 @@
 // CHECK-tokens: Keyword: "public" [86:1 - 86:7] CXXAccessSpecifier=:86:1 (Definition)
 // CHECK-tokens: Punctuation: ":" [86:7 - 86:8] CXXAccessSpecifier=:86:1 (Definition)
 // CHECK-tokens: Keyword: "explicit" [87:3 - 87:11] CXXConstructor=StringSwitch:87:12 (Definition)
-// CHECK-tokens: Identifier: "StringSwitch" [87:12 - 87:24] CXXConstructor=StringSwitch:87:12 (Definition)
+// CHECK-tokens: Identifier: "StringSwitch" [87:12 - 87:24] CXXConstructor=StringSwitch:87:12 (Definition) (explicit)
 // CHECK-tokens: Punctuation: "(" [87:24 - 87:25] CXXConstructor=StringSwitch:87:12 (Definition)
 // CHECK-tokens: Identifier: "StringRef" [87:25 - 87:34] TypeRef=class llvm::StringRef:38:7
 // CHECK-tokens: Identifier: "Str" [87:35 - 87:38] ParmDecl=Str:87:35 (Definition)
@@ -1839,7 +1839,7 @@
 // CHECK: 84:3: TypeRef=class llvm::StringRef:38:7 Extent=[84:3 - 84:12]
 // CHECK: 85:12: FieldDecl=Result:85:12 (Definition) Extent=[85:3 - 85:18]
 // CHECK: 86:1: CXXAccessSpecifier=:86:1 (Definition) Extent=[86:1 - 86:8]
-// CHECK: 87:12: CXXConstructor=StringSwitch:87:12 (Definition) Extent=[87:3 - 87:64]
+// CHECK: 87:12: CXXConstructor=StringSwitch:87:12 (Definition) (explicit) Extent=[87:3 - 87:64]
 // CHECK: 87:35: ParmDecl=Str:87:35 (Definition) Extent=[87:25 - 87:38]
 // CHECK: 87:25: TypeRef=class llvm::StringRef:38:7 Extent=[87:25 - 87:34]
 // CHECK: 87:42: MemberRef=Str:84:13 Extent=[87:42 - 87:45]
Index: clang/test/Index/index-file.cpp
===
--- clang/test/Index/index-file.cpp
+++ clang/test/Index/index-file.cpp
@@ -53,4 +53,4 @@
 // CHECK: [indexDeclaration]: kind: constructor | name: B | {{.*}} | loc: 33:12
 // CHECK: [indexDeclaration]: kind: constructor | name: B | {{.*}} (copy constructor) (converting constructor) | loc: 34:3
 // CHECK: [indexDeclaration]: kind: constructor | name: B | {{.*}} (move constructor) (converting constructor) | loc: 35:3
-// CHECK: [indexDeclaration]: kind: constructor | name: C | {{.*}} (copy constructor) | loc: 39:12

[clang] 6469281 - [clang][Interp][NFC] Remove InitFn code

2023-01-23 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-01-23T12:19:36+01:00
New Revision: 6469281100e654f690af8d5bcf0123e4105cafbe

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

LOG: [clang][Interp][NFC] Remove InitFn code

This is unused.

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/ByteCodeExprGen.h

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 8bedf6898bb5..615dbdefefbe 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -41,45 +41,19 @@ template  class DeclScope final : public 
LocalScope {
 /// Scope used to handle initialization methods.
 template  class OptionScope {
 public:
-  using InitFnRef = typename ByteCodeExprGen::InitFnRef;
-  using ChainedInitFnRef = std::function;
-
   /// Root constructor, compiling or discarding primitives.
   OptionScope(ByteCodeExprGen *Ctx, bool NewDiscardResult)
-  : Ctx(Ctx), OldDiscardResult(Ctx->DiscardResult),
-OldInitFn(std::move(Ctx->InitFn)) {
+  : Ctx(Ctx), OldDiscardResult(Ctx->DiscardResult) {
 Ctx->DiscardResult = NewDiscardResult;
-Ctx->InitFn = std::optional{};
-  }
-
-  /// Root constructor, setting up compilation state.
-  OptionScope(ByteCodeExprGen *Ctx, InitFnRef NewInitFn)
-  : Ctx(Ctx), OldDiscardResult(Ctx->DiscardResult),
-OldInitFn(std::move(Ctx->InitFn)) {
-Ctx->DiscardResult = true;
-Ctx->InitFn = NewInitFn;
   }
 
-  /// Extends the chain of initialisation pointers.
-  OptionScope(ByteCodeExprGen *Ctx, ChainedInitFnRef NewInitFn)
-  : Ctx(Ctx), OldDiscardResult(Ctx->DiscardResult),
-OldInitFn(std::move(Ctx->InitFn)) {
-assert(OldInitFn && "missing initializer");
-Ctx->InitFn = [this, NewInitFn] { return NewInitFn(*OldInitFn); };
-  }
-
-  ~OptionScope() {
-Ctx->DiscardResult = OldDiscardResult;
-Ctx->InitFn = std::move(OldInitFn);
-  }
+  ~OptionScope() { Ctx->DiscardResult = OldDiscardResult; }
 
 private:
   /// Parent context.
   ByteCodeExprGen *Ctx;
   /// Old discard flag to restore.
   bool OldDiscardResult;
-  /// Old pointer emitter to restore.
-  std::optional OldInitFn;
 };
 
 } // namespace interp

diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.h 
b/clang/lib/AST/Interp/ByteCodeExprGen.h
index 89782bd87c32..c7fcc59e5a60 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -44,9 +44,6 @@ class ByteCodeExprGen : public 
ConstStmtVisitor, bool>,
   using LabelTy = typename Emitter::LabelTy;
   using AddrTy = typename Emitter::AddrTy;
 
-  // Reference to a function generating the pointer of an initialized object.s
-  using InitFnRef = std::function;
-
   /// Current compilation context.
   Context &Ctx;
   /// Program to link to.
@@ -221,12 +218,6 @@ class ByteCodeExprGen : public 
ConstStmtVisitor, bool>,
   /// Emits an integer constant.
   template  bool emitConst(T Value, const Expr *E);
 
-  /// Emits the initialized pointer.
-  bool emitInitFn() {
-assert(InitFn && "missing initializer");
-return (*InitFn)();
-  }
-
   /// Returns the CXXRecordDecl for the type of the given expression,
   /// or nullptr if no such decl exists.
   const CXXRecordDecl *getRecordDecl(const Expr *E) const {
@@ -257,9 +248,6 @@ class ByteCodeExprGen : public 
ConstStmtVisitor, bool>,
 
   /// Flag indicating if return value is to be discarded.
   bool DiscardResult = false;
-
-  /// Expression being initialized.
-  std::optional InitFn = {};
 };
 
 extern template class ByteCodeExprGen;



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


[PATCH] D142346: [docs] Add release notes for news in 16.x done by me, or otherwise relating to MinGW targets

2023-01-23 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: efriedma, aaron.ballman, alvinhochun, mati865.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a reviewer: MaskRay.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: openmp-commits, sstefan1.
Herald added projects: clang, OpenMP, LLVM.

These are cases where we've missed to add release notes when the features
were developed.

Posting this mostly as a headsup if people want to comment - I intend on
landing this before the branch is created tomorrow in any case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142346

Files:
  clang/docs/ReleaseNotes.rst
  lld/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst
  openmp/docs/ReleaseNotes.rst

Index: openmp/docs/ReleaseNotes.rst
===
--- openmp/docs/ReleaseNotes.rst
+++ openmp/docs/ReleaseNotes.rst
@@ -19,3 +19,8 @@
 
 Non-comprehensive list of changes in this release
 =
+
+* Support for building the OpenMP runtime for Windows on AArch64 and ARM
+  with MinGW based toolchains.
+
+* Made the OpenMP runtime tests run successfully on Windows.
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -214,6 +214,25 @@
   an affinity mask issue.
   (`D138747 `_)
 
+* When building LLVM and related tools for Windows with Clang in MinGW mode,
+  hidden symbol visiblity is now used to reduce the number of exports in
+  builds with dylibs (``LLVM_BUILD_LLVM_DYLIB`` or ``LLVM_LINK_LLVM_DYLIB``),
+  making such builds more manageable without running into the limit of
+  number of exported symbols.
+
+* AArch64 SEH unwind info generation bugs have been fixed; there were minor
+  cases of mismatches between the generated unwind info and actual
+  prologues/epilogues earlier in some cases.
+
+* AArch64 SEH unwind info is now generated correctly for the AArch64
+  security features BTI (Branch Target Identification) and PAC (Pointer
+  Authentication Code). In particular, using PAC with older versions of LLVM
+  would generate code that would fail to unwind at runtime, if the host
+  actually would use the pointer authentication feature.
+
+* Fixed stack alignment on Windows on AArch64, for stack frames with a
+  large enough allocation that requires stack probing.
+
 Changes to the X86 Backend
 --
 
@@ -300,11 +319,20 @@
 * ``llvm-objdump`` now uses ``--print-imm-hex`` by default, which brings its
   default behavior closer in line with ``objdump``.
 
+* ``llvm-objcopy`` no longer writes corrupt addresses to empty sections if
+  the input file had a nonzero address to an empty section.
+
 Changes to LLDB
 -
 
 * Initial support for debugging Linux LoongArch 64-bit binaries.
 
+* Improvements in COFF symbol handling; previously a DLL (without any other
+  debug info) would only use the DLL's exported symbols, while it now also
+  uses the full list of internal symbols, if available.
+
+* Avoiding duplicate DLLs in the runtime list of loaded modules on Windows.
+
 Changes to Sanitizers
 -
 
@@ -321,6 +349,12 @@
   would now be ``UNSUPPORTED: target=arm{{.*}}`` and ``XFAIL: windows``
   would now be ``XFAIL: target={{.*}}-windows{{.*}}``.
 
+* When cross compiling LLVM (or building with ``LLVM_OPTIMIZED_TABLEGEN``),
+  it is now possible to point the build to prebuilt versions of all the
+  host tools with one CMake variable, ``LLVM_NATIVE_TOOL_DIR``, instead of
+  having to point out each individual tool with variables such as
+  ``LLVM_TABLEGEN``, ``CLANG_TABLEGEN``, ``LLDB_TABLEGEN`` etc.
+
 External Open Source Projects Using LLVM 15
 ===
 
Index: lld/docs/ReleaseNotes.rst
===
--- lld/docs/ReleaseNotes.rst
+++ lld/docs/ReleaseNotes.rst
@@ -57,6 +57,8 @@
 * Improvements to the PCH.OBJ files handling. Now LLD behaves the same as MSVC
   link.exe when merging PCH.OBJ files that don't have the same signature.
   (`D136762 `_)
+* Changed the OrdinalBase for DLLs from 0 to 1, matching the output from
+  both MS link.exe and GNU ld. (`D134140 `_)
 
 MinGW Improvements
 --
@@ -71,6 +73,14 @@
   the load config directory and be filled with the required symbols.
   (`D132808 `_)
 
+* Pick up libraries named ``.lib`` when linked with ``-l``, even
+  if ``-static`` has been specified. This fixes conformance to what
+  GNU ld dpes. (`D135651 `_)
+
+* Unwinding in Rust code on i386 in MinGW builds has been fixed, by avoiding
+  to leave out

[PATCH] D142347: [NFC][Clang] Move DebugOptions to llvm/Frontend for reuse in Flang

2023-01-23 Thread Kiran Chandramohan via Phabricator via cfe-commits
kiranchandramohan created this revision.
Herald added a subscriber: sunshaoce.
Herald added a project: All.
kiranchandramohan requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142347

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DebugInfoOptions.h
  clang/include/clang/Driver/ToolChain.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.h
  clang/lib/Driver/ToolChains/HIPSPV.cpp
  clang/lib/Driver/ToolChains/HIPSPV.h
  clang/lib/Driver/ToolChains/MSVC.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  clang/tools/clang-import-test/clang-import-test.cpp
  llvm/include/llvm/Frontend/Debug/Options.h

Index: llvm/include/llvm/Frontend/Debug/Options.h
===
--- llvm/include/llvm/Frontend/Debug/Options.h
+++ llvm/include/llvm/Frontend/Debug/Options.h
@@ -6,10 +6,10 @@
 //
 //===--===//
 
-#ifndef LLVM_CLANG_BASIC_DEBUGINFOOPTIONS_H
-#define LLVM_CLANG_BASIC_DEBUGINFOOPTIONS_H
+#ifndef LLVM_FRONTEND_DEBUG_OPTIONS_H
+#define LLVM_FRONTEND_DEBUG_OPTIONS_H
 
-namespace clang {
+namespace llvm {
 namespace codegenoptions {
 
 enum DebugInfoFormat {
@@ -54,13 +54,9 @@
   UnusedTypeInfo,
 };
 
-enum class DebugTemplateNamesKind {
-  Full,
-  Simple,
-  Mangled
-};
+enum class DebugTemplateNamesKind { Full, Simple, Mangled };
 
 } // end namespace codegenoptions
-} // end namespace clang
+} // end namespace llvm
 
 #endif
Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -200,7 +200,7 @@
   Inv->getLangOpts()->CXXExceptions = true;
   // Needed for testing dynamic_cast.
   Inv->getLangOpts()->RTTI = true;
-  Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo);
+  Inv->getCodeGenOpts().setDebugInfo(llvm::codegenoptions::FullDebugInfo);
   Inv->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();
 
   Ins->setInvocation(std::move(Inv));
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -165,10 +165,11 @@
   if (std::unique_ptr OS =
   CI.createDefaultOutputFile(false, InFile, "cpp")) {
 if (CI.getLangOpts().ObjCRuntime.isNonFragile())
-  return CreateModernObjCRewriter(
-  std::string(InFile), std::move(OS), CI.getDiagnostics(),
-  CI.getLangOpts(), CI.getDiagnosticOpts().NoRewriteMacros,
-  (CI.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo));
+  return CreateModernObjCRewriter(std::string(InFile), std::move(OS),
+  CI.getDiagnostics(), CI.getLangOpts(),
+  CI.getDiagnosticOpts().NoRewriteMacros,
+  (CI.getCodeGenOpts().getDebugInfo() !=
+   llvm::codegenoptions::NoDebugInfo));
 return CreateObjCRewriter(std::string(InFile), std::move(OS),
   CI.getDiagnostics(), CI.getLangOpts(),
   CI.getDiagnosticOpts().NoRewriteMacros);
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -12,7 +12,6 @@
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/CommentOptions.h"
-#include "clang/Basic/DebugInfoOptions.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticDriver.h"
 #include "clang/Basic/DiagnosticOptions.h"
@@ -60,6 +59,7 @@
 #include "llvm/ADT/Triple.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Config/llvm-config.h"
+#include "llvm/Frontend/Debug/Options.h"
 #include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/Linker/Linker.h"
 #include "llvm/MC/MCTargetOptions.h"
@@ -1366,28 +1366,28 @@
 
   std::optional DebugInfoVal;
   switch (Opts.DebugInfo) {
-  case codegenoptions::DebugLineTablesOnly:
+  case llvm::codegenoptions::DebugLineTablesOnly:
 DebugInfoVal = "line-tables-only";
 break;
-  case codegenoptions::Deb

[PATCH] D139921: [include-cleaner] Ranking of providers based on hints

2023-01-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 491286.
kadircet marked 23 inline comments as done.
kadircet added a comment.

- Address comments & rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139921

Files:
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
  clang-tools-extra/include-cleaner/lib/Analysis.cpp
  clang-tools-extra/include-cleaner/lib/AnalysisInternal.h
  clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
  clang-tools-extra/include-cleaner/lib/HTMLReport.cpp
  clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp
  clang-tools-extra/include-cleaner/lib/Types.cpp
  clang-tools-extra/include-cleaner/lib/TypesInternal.h
  clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
  clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
  clang-tools-extra/include-cleaner/unittests/LocateSymbolTest.cpp

Index: clang-tools-extra/include-cleaner/unittests/LocateSymbolTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/LocateSymbolTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/LocateSymbolTest.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 #include "AnalysisInternal.h"
+#include "TypesInternal.h"
 #include "clang-include-cleaner/Types.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
@@ -20,6 +21,7 @@
 #include "gtest/gtest.h"
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -27,8 +29,11 @@
 
 namespace clang::include_cleaner {
 namespace {
+using testing::Each;
 using testing::ElementsAre;
 using testing::ElementsAreArray;
+using testing::Eq;
+using testing::Field;
 using testing::Pair;
 using testing::UnorderedElementsAre;
 
@@ -55,6 +60,10 @@
   llvm::StringRef NameToFind;
   const NamedDecl *Out = nullptr;
   bool VisitNamedDecl(const NamedDecl *ND) {
+// Skip the templated decls, as they have the same name and matches in
+// this file care about the outer template name.
+if (auto *TD = ND->getDescribedTemplate())
+  ND = TD;
 if (ND->getName() == NameToFind) {
   EXPECT_TRUE(Out == nullptr || Out == ND->getCanonicalDecl())
   << "Found multiple matches for " << NameToFind;
@@ -125,5 +134,57 @@
   ElementsAreArray(Test.points()));
 }
 
+MATCHER_P2(HintedSymbol, Symbol, Hint, "") {
+  return std::tie(arg.Hint, arg) == std::tie(Hint, Symbol);
+}
+TEST(LocateSymbol, CompleteSymbolHint) {
+  {
+// stdlib symbols are always complete.
+LocateExample Test("namespace std { struct vector; }");
+EXPECT_THAT(locateSymbol(Test.findDecl("vector")),
+ElementsAre(HintedSymbol(
+*tooling::stdlib::Symbol::named("std::", "vector"),
+Hints::CompleteSymbol)));
+  }
+  {
+// macros are always complete.
+LocateExample Test("#define ^FOO");
+EXPECT_THAT(locateSymbol(Test.findMacro("FOO")),
+ElementsAre(HintedSymbol(Test.points().front(),
+ Hints::CompleteSymbol)));
+  }
+  {
+// Completeness is only absent in cases that matters.
+const llvm::StringLiteral Cases[] = {
+"struct ^foo; struct ^foo {};",
+"template  struct ^foo; template  struct ^foo {};",
+"template  void ^foo(); template  void ^foo() {};",
+};
+for (auto &Case : Cases) {
+  SCOPED_TRACE(Case);
+  LocateExample Test(Case);
+  EXPECT_THAT(locateSymbol(Test.findDecl("foo")),
+  ElementsAre(HintedSymbol(Test.points().front(), Hints::None),
+  HintedSymbol(Test.points().back(),
+   Hints::CompleteSymbol)));
+}
+  }
+  {
+// All declarations should be marked as complete in cases that a definition
+// is not usually needed.
+const llvm::StringLiteral Cases[] = {
+"void foo(); void foo() {}",
+"extern int foo; int foo;",
+};
+for (auto &Case : Cases) {
+  SCOPED_TRACE(Case);
+  LocateExample Test(Case);
+  EXPECT_THAT(locateSymbol(Test.findDecl("foo")),
+  Each(Field(&Hinted::Hint,
+ Eq(Hints::CompleteSymbol;
+}
+  }
+}
+
 } // namespace
 } // namespace clang::include_cleaner
Index: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
@@ -7,7 +7,7 @@
 //===--===//
 
 #include "AnalysisInternal.h"
-#include "clang-include-cleaner/Analysis.h"
+#include "TypesInternal.h"
 #include "clang-include-cleaner/Record.h"
 #include "clang-include

[PATCH] D139921: [include-cleaner] Ranking of providers based on hints

2023-01-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: 
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h:133
+
+  Header(std::in_place_t, decltype(Storage) Sentinel)
+  : Storage(std::move(Sentinel)) {}

sammccall wrote:
> this is a bit confusing... kind of the opposite of what `std::in_place` means?
> (All of the other constructors build the state in-place in some sense, but 
> this one doesn't)
> 
> Maybe just a private `struct Sentinel{};` instead of in_place_t?
> 
> Symbol does this without any sentinel at all, if that's causing ambiguity 
> then it might be worth fixing both to be the same.
without a disambiguation tag we get an ambigious conversion when we have a 
constructor call that looks like `Header("foo.h")` (whether to use 
Header(StringRef) or Header(variant), not sure if it's fine for an 
"inaccessible" constructor to participate in overload resolution, nor how 
variant can be viable here despite needing a double implicit conversion from 
stringref to variant)

This didn't bite us with Symbol yet because constructor takes a `Decl&` but 
variant stores a `Decl*`, and for Macro case we always explicitly initialized 
with spelling of `Macro`.

You're right about usage of inplace_t though, I was confused. using a sentinel 
tag instead.



Comment at: clang-tools-extra/include-cleaner/lib/Types.cpp:114
+  case Header::Physical:
+return physical() < RHS.physical();
+  case Header::Standard:

sammccall wrote:
> I think comparing pointers is going to give inconsistent results, and would 
> suggest comparing Name (without trying to normalize, just for at least 
> reproducibility across identical runs)
i was rather worried about correctness of a name based match, e.g. we can have 
the same FileEntry pointers for `foo.h` and `bar/foo.h` but i guess it's OK to 
assume that a FileManager won't be accessed in the middle of a comparison 
sequence.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139921

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


[PATCH] D142014: [clangd] fix wrong CalleeArgInfo in the hover

2023-01-23 Thread Vincent Hong via Phabricator via cfe-commits
v1nh1shungry updated this revision to Diff 491287.
v1nh1shungry added a comment.

land comment's suggestions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142014

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

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -934,6 +934,23 @@
  HI.CalleeArgInfo->Type = "const int &";
  HI.CallPassType = HoverInfo::PassType{PassMode::ConstRef, false};
}},
+  {
+  R"cpp(
+int add(int lhs, int rhs);
+int main() {
+  add(1 [[^+]] 2, 3);
+}
+)cpp",
+  [](HoverInfo &HI) {
+HI.Name = "expression";
+HI.Kind = index::SymbolKind::Unknown;
+HI.Type = "int";
+HI.Value = "3";
+HI.CalleeArgInfo.emplace();
+HI.CalleeArgInfo->Name = "lhs";
+HI.CalleeArgInfo->Type = "int";
+HI.CallPassType = HoverInfo::PassType{PassMode::Value, false};
+  }},
   {// Extra info for method call.
R"cpp(
   class C {
@@ -1673,8 +1690,8 @@
   }},
   {
   R"cpp(// Function definition via using declaration
-namespace ns { 
-  void foo(); 
+namespace ns {
+  void foo();
 }
 int main() {
   using ns::foo;
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -952,6 +952,15 @@
   }
 }
 
+HoverInfo::PassType::PassMode getPassMode(QualType ParmType) {
+  if (ParmType->isReferenceType()) {
+if (ParmType->getPointeeType().isConstQualified())
+  return HoverInfo::PassType::ConstRef;
+return HoverInfo::PassType::Ref;
+  }
+  return HoverInfo::PassType::Value;
+}
+
 // If N is passed as argument to a function, fill HI.CalleeArgInfo with
 // information about that argument.
 void maybeAddCalleeArgInfo(const SelectionTree::Node *N, HoverInfo &HI,
@@ -972,14 +981,18 @@
   if (!FD || FD->isOverloadedOperator() || FD->isVariadic())
 return;
 
+  HoverInfo::PassType PassType;
+
   // Find argument index for N.
   for (unsigned I = 0; I < CE->getNumArgs() && I < FD->getNumParams(); ++I) {
 if (CE->getArg(I) != OuterNode.ASTNode.get())
   continue;
 
 // Extract matching argument from function declaration.
-if (const ParmVarDecl *PVD = FD->getParamDecl(I))
+if (const ParmVarDecl *PVD = FD->getParamDecl(I)) {
   HI.CalleeArgInfo.emplace(toHoverInfoParam(PVD, PP));
+  PassType.PassBy = getPassMode(PVD->getType());
+}
 break;
   }
   if (!HI.CalleeArgInfo)
@@ -988,16 +1001,6 @@
   // If we found a matching argument, also figure out if it's a
   // [const-]reference. For this we need to walk up the AST from the arg itself
   // to CallExpr and check all implicit casts, constructor calls, etc.
-  HoverInfo::PassType PassType;
-  if (const auto *E = N->ASTNode.get()) {
-if (E->getType().isConstQualified())
-  PassType.PassBy = HoverInfo::PassType::ConstRef;
-
-// No implicit node, literal passed by value
-if (isLiteral(E) && N->Parent == OuterNode.Parent)
-  PassType.PassBy = HoverInfo::PassType::Value;
-  }
-
   for (auto *CastNode = N->Parent;
CastNode != OuterNode.Parent && !PassType.Converted;
CastNode = CastNode->Parent) {
@@ -1006,22 +1009,13 @@
   case CK_NoOp:
   case CK_DerivedToBase:
   case CK_UncheckedDerivedToBase:
-// If it was a reference before, it's still a reference.
-if (PassType.PassBy != HoverInfo::PassType::Value)
-  PassType.PassBy = ImplicitCast->getType().isConstQualified()
-? HoverInfo::PassType::ConstRef
-: HoverInfo::PassType::Ref;
-break;
   case CK_LValueToRValue:
   case CK_ArrayToPointerDecay:
   case CK_FunctionToPointerDecay:
   case CK_NullToPointer:
   case CK_NullToMemberPointer:
-// No longer a reference, but we do not show this as type conversion.
-PassType.PassBy = HoverInfo::PassType::Value;
 break;
   default:
-PassType.PassBy = HoverInfo::PassType::Value;
 PassType.Converted = true;
 break;
   }
@@ -1029,16 +1023,17 @@
CastNode->ASTNode.get()) {
   // We want to be smart about copy constructors. They should not show up as
   // type conversion, but instead as passing by value.
-  if (CtorCall->getConstructor()->isCopyConstructor())
+  const CXXConstructorDecl *CD = CtorCall->getConstructor();
+  if (CD->isCopyConstructor()) {
   

[PATCH] D142014: [clangd] fix wrong CalleeArgInfo in the hover

2023-01-23 Thread Vincent Hong via Phabricator via cfe-commits
v1nh1shungry marked 2 inline comments as done.
v1nh1shungry added a comment.

Thanks for the review! @nridge


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142014

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


[clang] ebbeb16 - [clang] Fix the location of UsingTypeLoc.

2023-01-23 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-01-23T12:51:21+01:00
New Revision: ebbeb164c25a40cb6ba9c6b18dce5dcd06c0bb07

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

LOG: [clang] Fix the location of UsingTypeLoc.

It is revealed by the https://reviews.llvm.org/D141280.

```
namespace ns { class Foo {}; }
using ns::Foo;

// Before the fix, the Location of UsingTypeLoc Foo points to the
token "class", slection on ^Foo will result in the VarDecl abc.
class Foo abc;

```

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/SelectionTests.cpp
clang/lib/Sema/SemaType.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/SelectionTests.cpp 
b/clang-tools-extra/clangd/unittests/SelectionTests.cpp
index d7ea34c3c7054..4e5c3774c1655 100644
--- a/clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -520,6 +520,13 @@ TEST(SelectionTest, CommonAncestor) {
   )cpp",
"TypedefTypeLoc"},
 
+  {R"cpp(
+namespace ns { class Foo {}; }
+using ns::Foo;
+class [[^Foo]] foo;
+  )cpp",
+   "UsingTypeLoc"},
+
   // lambda captured var-decl
   {R"cpp(
 void test(int bar) {

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index e124db71af18b..16986f6f0d0e5 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -6256,6 +6256,9 @@ namespace {
 void VisitTagTypeLoc(TagTypeLoc TL) {
   TL.setNameLoc(DS.getTypeSpecTypeNameLoc());
 }
+void VisitUsingTypeLoc(UsingTypeLoc TL) {
+  TL.setNameLoc(DS.getTypeSpecTypeNameLoc());
+}
 void VisitAtomicTypeLoc(AtomicTypeLoc TL) {
   // An AtomicTypeLoc can come from either an _Atomic(...) type specifier
   // or an _Atomic qualifier.



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


[PATCH] D142125: [clang] Fix the location of UsingTypeLoc.

2023-01-23 Thread Haojian Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGebbeb164c25a: [clang] Fix the location of UsingTypeLoc. 
(authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142125

Files:
  clang-tools-extra/clangd/unittests/SelectionTests.cpp
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -6256,6 +6256,9 @@
 void VisitTagTypeLoc(TagTypeLoc TL) {
   TL.setNameLoc(DS.getTypeSpecTypeNameLoc());
 }
+void VisitUsingTypeLoc(UsingTypeLoc TL) {
+  TL.setNameLoc(DS.getTypeSpecTypeNameLoc());
+}
 void VisitAtomicTypeLoc(AtomicTypeLoc TL) {
   // An AtomicTypeLoc can come from either an _Atomic(...) type specifier
   // or an _Atomic qualifier.
Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -520,6 +520,13 @@
   )cpp",
"TypedefTypeLoc"},
 
+  {R"cpp(
+namespace ns { class Foo {}; }
+using ns::Foo;
+class [[^Foo]] foo;
+  )cpp",
+   "UsingTypeLoc"},
+
   // lambda captured var-decl
   {R"cpp(
 void test(int bar) {


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -6256,6 +6256,9 @@
 void VisitTagTypeLoc(TagTypeLoc TL) {
   TL.setNameLoc(DS.getTypeSpecTypeNameLoc());
 }
+void VisitUsingTypeLoc(UsingTypeLoc TL) {
+  TL.setNameLoc(DS.getTypeSpecTypeNameLoc());
+}
 void VisitAtomicTypeLoc(AtomicTypeLoc TL) {
   // An AtomicTypeLoc can come from either an _Atomic(...) type specifier
   // or an _Atomic qualifier.
Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -520,6 +520,13 @@
   )cpp",
"TypedefTypeLoc"},
 
+  {R"cpp(
+namespace ns { class Foo {}; }
+using ns::Foo;
+class [[^Foo]] foo;
+  )cpp",
+   "UsingTypeLoc"},
+
   // lambda captured var-decl
   {R"cpp(
 void test(int bar) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1af7164 - Revert "Add clang_CXXMethod_isExplicit to libclang"

2023-01-23 Thread Luca Di Sera via cfe-commits

Author: Luca Di Sera
Date: 2023-01-23T12:55:34+01:00
New Revision: 1af716499d6bc29afd9ff2903200890df774859f

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

LOG: Revert "Add clang_CXXMethod_isExplicit to libclang"

This is currently failing the build due to some test errors.

This reverts commit ddbe14084da7f31d4b4b53e13d9f868d759f3673.

Added: 


Modified: 
clang/bindings/python/clang/cindex.py
clang/bindings/python/tests/cindex/test_cursor.py
clang/docs/ReleaseNotes.rst
clang/include/clang-c/Index.h
clang/test/Index/get-cursor.cpp
clang/test/Index/index-file.cpp
clang/test/Index/recursive-cxx-member-calls.cpp
clang/tools/c-index-test/c-index-test.c
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/libclang.map

Removed: 
clang/test/Index/explicit-constructor.cpp
clang/test/Index/explicit-conversion-function.cpp



diff  --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index 217873f2d3aaf..2e32ce2ba6d06 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -1529,51 +1529,6 @@ class Bar {
 """
 return conf.lib.clang_CXXMethod_isMoveAssignmentOperator(self)
 
-def is_explicit_method(self):
-"""Determines if a C++ constructor or conversion function is
-explicit, returning 1 if such is the case and 0 otherwise.
-
-Constructors or conversion functions are declared explicit through
-the use of the explicit specifier.
-
-For example, the following constructor and conversion function are
-not explicit as they lack the explicit specifier:
-
-class Foo {
-Foo();
-operator int();
-};
-
-While the following constructor and conversion function are
-explicit as they are declared with the explicit specifier.
-
-class Foo {
-explicit Foo();
-explicit operator int();
-};
-
-This method will return 0 when given a cursor pointing to one of
-the former declarations and it will return 1 for a cursor pointing
-to the latter declarations.
-
-The explicit specifier allows the user to specify a
-conditional compile-time expression whose value decides
-whether the marked element is explicit or not.
-
-For example:
-
-constexpr bool foo(int i) { return 1 % 2 == 0; }
-
-class Foo {
- explicit(foo(1)) Foo();
- explicit(foo(2)) operator int();
-}
-
-This method will return 0 for the constructor and 1 for
-the conversion function.
-"""
-return conf.lib.clang_CXXMethod_isExplicit(self)
-
 def is_mutable_field(self):
 """Returns True if the cursor refers to a C++ field that is declared
 'mutable'.
@@ -3539,10 +3494,6 @@ def cursor(self):
[Cursor],
bool),
 
-  ("clang_CXXMethod_isExplicit",
-   [Cursor],
-   bool),
-
   ("clang_CXXMethod_isPureVirtual",
[Cursor],
bool),

diff  --git a/clang/bindings/python/tests/cindex/test_cursor.py 
b/clang/bindings/python/tests/cindex/test_cursor.py
index 74f7445cbc3ef..198352080c69f 100644
--- a/clang/bindings/python/tests/cindex/test_cursor.py
+++ b/clang/bindings/python/tests/cindex/test_cursor.py
@@ -277,57 +277,6 @@ class Bar {
 for cursor in non_move_assignment_operators_cursors
 ]))
 
-def test_is_explicit_method(self):
-"""Ensure Cursor.is_explicit_method works."""
-source_with_explicit_methods = """
-struct Foo {
-   // Those are explicit
-   explicit Foo(double);
-   explicit(true) Foo(char);
-   explicit operator double();
-   explicit(true) operator char();
-};
-"""
-source_without_explicit_methods = """
-struct Foo {
-// Those are not explicit
-Foo(int);
-explicit(false) Foo(float);
-operator int();
-explicit(false) operator float();
-};
-"""
-tu_with_explicit_methods = get_tu(
-source_with_explicit_methods, lang="cpp"
-)
-tu_without_explicit_methods = get_tu(
-source_without_explicit_methods, lang="cpp"
-)
-
-explicit_methods_cursors = [
-*get_cursors(tu_with_explicit_methods, "Foo")[1:],
-get_cursor(tu_with_explicit_methods, "operator double"),
-get_cursor(tu_with_explicit_methods, "operator char"),
-]
-
-non_explicit_methods_cursors = [
-*get_cursors(tu_without_explicit_methods, "Foo")[1:],
-get_cursor(tu_without_explicit_me

[PATCH] D142092: [include-mapping] Allow multiple headers for the same symbol. Choose the first header of available ones.

2023-01-23 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 491258.
VitaNuo added a comment.

Update the 20181028 archive maps.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

Files:
  clang/include/clang/Tooling/Inclusions/CSymbolMap.inc
  clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc
  clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
  clang/tools/include-mapping/cppreference_parser.py
  clang/tools/include-mapping/gen_std.py

Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -14,10 +14,7 @@
 The generated files are located in clang/include/Tooling/Inclusions.
 
 Caveats and FIXMEs:
-  - only symbols directly in "std" namespace are added, we should also add std's
-subnamespace symbols (e.g. chrono).
-  - symbols with multiple variants or defined in multiple headers aren't added,
-e.g. std::move, std::swap
+  - symbols with multiple variants aren't added, e.g., std::move, std::swap
 
 Usage:
   1. Install BeautifulSoup dependency, see instruction:
@@ -110,17 +107,12 @@
 os.stat(index_page_path).st_mtime).strftime('%Y-%m-%d')
   print(CODE_PREFIX % (args.symbols.upper(), cppreference_modified_date))
   for symbol in symbols:
-if len(symbol.headers) == 1:
-  # SYMBOL(unqualified_name, namespace, header)
-  print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
-symbol.headers[0]))
-elif len(symbol.headers) == 0:
+if len(symbol.headers) == 0:
   sys.stderr.write("No header found for symbol %s\n" % symbol.name)
 else:
-  # FIXME: support symbols with multiple headers (e.g. std::move).
-  sys.stderr.write("Ambiguous header for symbol %s: %s\n" % (
-  symbol.name, ', '.join(symbol.headers)))
-
-
+  for header in symbol.headers:
+# SYMBOL(unqualified_name, namespace, header)
+print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
+  header))
 if __name__ == '__main__':
   main()
Index: clang/tools/include-mapping/cppreference_parser.py
===
--- clang/tools/include-mapping/cppreference_parser.py
+++ clang/tools/include-mapping/cppreference_parser.py
@@ -118,7 +118,7 @@
 return _ParseSymbolPage(f.read(), name)
 
 
-def _GetSymbols(pool, root_dir, index_page_name, namespace, variants_to_accept):
+def _GetSymbols(pool, root_dir, index_page_name, namespace):
   """Get all symbols listed in the index page. All symbols should be in the
   given namespace.
 
@@ -137,9 +137,7 @@
 for symbol_name, symbol_page_path, variant in _ParseIndexPage(f.read()):
   # Variant symbols (e.g. the std::locale version of isalpha) add ambiguity.
   # FIXME: use these as a fallback rather than ignoring entirely.
-  variants_for_symbol = variants_to_accept.get(
-  (namespace or "") + symbol_name, ())
-  if variant and variant not in variants_for_symbol:
+  if variant:
 continue
   path = os.path.join(root_dir, symbol_page_path)
   if os.path.isfile(path):
@@ -166,13 +164,6 @@
   Args:
 parse_pages: a list of tuples (page_root_dir, index_page_name, namespace)
   """
-  # By default we prefer the non-variant versions, as they're more common. But
-  # there are some symbols, whose variant is more common. This list describes
-  # those symbols.
-  variants_to_accept = {
-  # std::remove<> has variant algorithm.
-  "std::remove": ("algorithm"),
-  }
   symbols = []
   # Run many workers to process individual symbol pages under the symbol index.
   # Don't allow workers to capture Ctrl-C.
@@ -180,8 +171,7 @@
   initializer=lambda: signal.signal(signal.SIGINT, signal.SIG_IGN))
   try:
 for root_dir, page_name, namespace in parse_pages:
-  symbols.extend(_GetSymbols(pool, root_dir, page_name, namespace,
- variants_to_accept))
+  symbols.extend(_GetSymbols(pool, root_dir, page_name, namespace))
   finally:
 pool.terminate()
 pool.join()
Index: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
===
--- clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -8,6 +8,7 @@
 
 #include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "clang/AST/Decl.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 
@@ -16,8 +17,9 @@
 namespace stdlib {
 
 static llvm::StringRef *HeaderNames;
-static std::pair *SymbolNames;
-static unsigned *SymbolHeaderIDs;
+static llvm::DenseMap>
+*SymbolNames;
+static llvm::SmallVector *SymbolHeaderIDs;
 static llvm::DenseMap *HeaderIDs;
 // Maps symbol name -> Symbol:

[PATCH] D140959: RFC: Multilib prototype

2023-01-23 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

Thanks for putting together this proposal.

Broadly, I think it's good, and I think it solves a lot of rough edges that I 
recall running into with the GCC multilib configuration files in the past.

I do worry about using `-cc1` args. On the one hand, it's the best place for 
getting access to information about e.g. exceptions, floating point abi, and 
other concepts (optimisation level?), but on the other hand, it is a reasonably 
unstable interface, and it's parsed in a complex and stateful way -- later 
options can override earlier ones -- which makes it difficult to parse with 
regular expressions.

To be clear: I don't think there's a better way of handling 
exceptions/no-exceptions library selection (than parsing the `-cc1` arguments) 
or the floating point abi library selection, so having a way to examining the 
`-cc1` arguments is a necessary "lowest common denominator" interface (I'll 
come back to this later), but I think there are places we can do better.

In terms of finding a more stable interface, the Arm ACLE recently added Beta 
support for Function Multi-Versioning 

 which is proposing a lot of stable identifiers for architectural features in 
v8-a and v8-r onwards. These names are expected to be written by programmers in 
their source code, so are a stable interface in a way that `-target-feature 
+` is absolutely not. These are resolved by clang in order to handle 
duplicating the same function to compile it for multiple targets, which to my 
mind is the exact same problem that multi-libs are trying to solve. We have 
specified stable names for a lot of features in the ACLE (and presumably will 
continue to do so), as well as a priority system for resolving how to choose 
which function should be used at runtime. I concede that these stable names do 
not cover M-profile or pre-v8 architectures, which are important to embedded 
toolchains.

The information about these stable feature names is known about by 
`AArch64TargetInfo` right now, and we are looking at where exactly this 
information should be best understood by LLVM in general (maybe the 
`TargetParser` library). Given where it is in clang's code, I think it should 
be usable by both the driver and internally inside `-cc1`, but I'm not 100% 
sure the C++ interface is perfect for both. But, we can always revisit the C++ 
interface to make it work for what we want.

So, to concretely turn this into a proposal, I think there are two things you 
could do:

- in the `arguments:` part of the yaml structure, you currently have `regex:` 
which is for matching on the `-cc1` arguments, we could have a `archFeatures:` 
for matching on a list/set of named features (instead of the `regex:`), to turn 
them into multilib library attributes.
- treat the stable architectural feature names like extra implicit attributes 
that don't show up in the `arguments:` section, but can be used in the 
`variants:` section like the `-cc1`-derived attributes. Here, we would need to 
be careful the architectural feature names didn't clash with the user-provided 
names from the `arguments:` section, and we might need to have a way to specify 
the absence of architectural features as well. I'm not 100% convinced that the 
implicit-ness of this option is good, but I think the stability wins are useful.

To cover some drawbacks of the approach of using these stable names:

- Not all targets support function multi-versioning. In this case, they are 
welcome to fall back to using `-cc1` arguments, as a lowest common denominator 
approach.
- Not all multilibs are chosen based on architectural features: again, you can 
fall-back to `-cc1` arguments, especially as I think e.g. `-fno-exceptions` is 
more stable than `-target-feature +`.
- Even for Arm/AArch64, there are pre-v8-a/v8-r architectures which don't have 
stable names in the ACLE yet. Again, in the short term we could use `-cc1` 
arguments, before we stabilise architectural names.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140959

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


[PATCH] D131915: [MLIR][OpenMP] Added target data, exit data, and enter data operation definition for MLIR.

2023-01-23 Thread Akash Banerjee via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa4699a43e426: [MLIR][OpenMP] Added target data, exit data, 
and enter data operation… (authored by TIFitis).

Changed prior to commit:
  https://reviews.llvm.org/D131915?vs=489881&id=491299#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131915

Files:
  mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
  mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
  mlir/test/Dialect/OpenMP/ops.mlir

Index: mlir/test/Dialect/OpenMP/ops.mlir
===
--- mlir/test/Dialect/OpenMP/ops.mlir
+++ mlir/test/Dialect/OpenMP/ops.mlir
@@ -495,6 +495,26 @@
 return
 }
 
+// CHECK-LABEL: omp_target_data
+func.func @omp_target_data (%if_cond : i1, %device : si32, %device_ptr: memref, %device_addr: memref, %map1: memref, %map2: memref) -> () {
+// CHECK: omp.target_data if(%[[VAL_0:.*]] : i1) device(%[[VAL_1:.*]] : si32) map((always, from -> %[[VAL_2:.*]] : memref))
+omp.target_data if(%if_cond : i1) device(%device : si32) map((always, from -> %map1 : memref)){}
+
+// CHECK: omp.target_data use_device_ptr(%[[VAL_3:.*]] : memref) use_device_addr(%[[VAL_4:.*]] : memref) map((close, present, to -> %[[VAL_2:.*]] : memref))
+omp.target_data use_device_ptr(%device_ptr : memref) use_device_addr(%device_addr : memref) map((close, present, to -> %map1 : memref)){}
+
+// CHECK: omp.target_data map((tofrom -> %[[VAL_2]] : memref), (alloc -> %[[VAL_5:.*]] : memref))
+omp.target_data map((tofrom -> %map1 : memref), (alloc -> %map2 : memref)){}
+
+// CHECK: omp.target_enter_data if(%[[VAL_0]] : i1) device(%[[VAL_1]] : si32) nowait map((alloc -> %[[VAL_2]] : memref))
+omp.target_enter_data if(%if_cond : i1) device(%device : si32) nowait map((alloc -> %map1 : memref))
+
+// CHECK: omp.target_exit_data if(%[[VAL_0]] : i1) device(%[[VAL_1]] : si32) nowait map((release -> %[[VAL_5]] : memref))
+omp.target_exit_data if(%if_cond : i1) device(%device : si32) nowait map((release -> %map2 : memref))
+
+return
+}
+
 // CHECK-LABEL: omp_target_pretty
 func.func @omp_target_pretty(%if_cond : i1, %device : si32,  %num_threads : i32) -> () {
 // CHECK: omp.target if({{.*}}) device({{.*}})
Index: mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
===
--- mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -22,6 +22,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/TypeSwitch.h"
+#include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include 
 
 #include "mlir/Dialect/OpenMP/OpenMPOpsDialect.cpp.inc"
@@ -552,6 +553,191 @@
   return success();
 }
 
+//===--===//
+// Parser, printer and verifier for Target Data
+//===--===//
+/// Parses a Map Clause.
+///
+/// map-clause = `map (` ( `(` `always, `? `close, `? `present, `? ( `to` |
+/// `from` | `delete` ) ` -> ` symbol-ref ` : ` type(symbol-ref) `)` )+ `)`
+/// Eg: map((release -> %1 : !llvm.ptr>), (always, close, from
+/// -> %2 : !llvm.ptr>))
+static ParseResult
+parseMapClause(OpAsmParser &parser,
+   SmallVectorImpl &map_operands,
+   SmallVectorImpl &map_operand_types, ArrayAttr &map_types) {
+  StringRef mapTypeMod;
+  OpAsmParser::UnresolvedOperand arg1;
+  Type arg1Type;
+  IntegerAttr arg2;
+  SmallVector mapTypesVec;
+  llvm::omp::OpenMPOffloadMappingFlags mapTypeBits;
+
+  auto parseTypeAndMod = [&]() -> ParseResult {
+if (parser.parseKeyword(&mapTypeMod))
+  return failure();
+
+if (mapTypeMod == "always")
+  mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_ALWAYS;
+if (mapTypeMod == "close")
+  mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_CLOSE;
+if (mapTypeMod == "present")
+  mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT;
+
+if (mapTypeMod == "to")
+  mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
+if (mapTypeMod == "from")
+  mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
+if (mapTypeMod == "tofrom")
+  mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO |
+ llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
+if (mapTypeMod == "delete")
+  mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
+return success();
+  };
+
+  auto parseMap = [&]() -> ParseResult {
+mapTypeBits = llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE;
+
+if (parser.parseLParen() ||
+parser.parseCommaSeparatedList(parseTypeAndMod) ||
+parser.parseArrow() || parser.parseOperand(arg1) ||
+parser.parseColon() || parser.pa

[PATCH] D142327: [clang][RISCV] Fix ABI handling of empty structs with hard FP calling conventions in C++

2023-01-23 Thread Luís Marques via Phabricator via cfe-commits
luismarques accepted this revision.
luismarques added a comment.
This revision is now accepted and ready to land.

LGMT.




Comment at: clang/lib/CodeGen/TargetInfo.cpp:591
   if (isa(RT->getDecl()) &&
-  (WasArray || !FD->hasAttr()))
+  (WasArray || (!FD->hasAttr() && !AsIfNoUniqueAddr)))
 return false;

Nit: the `!AsIfNoUniqueAddr` condition could be tested before the 
`!FD->hasAttr()` condition, and I imagine that would be 
slightly cheaper for the `AsIfNoUniqueAddr = true` case?


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

https://reviews.llvm.org/D142327

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


[PATCH] D142346: [docs] Add release notes for news in 16.x done by me, or otherwise relating to MinGW targets

2023-01-23 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.

Clang bits LGTM (so do the rest FWIW).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142346

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


[PATCH] D142334: [Clang[NFC] Fix bitmask for NullabilityPayload in Types.h

2023-01-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 491312.
xgupta added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142334

Files:
  clang/include/clang/APINotes/Types.h


Index: clang/include/clang/APINotes/Types.h
===
--- clang/include/clang/APINotes/Types.h
+++ clang/include/clang/APINotes/Types.h
@@ -482,7 +482,7 @@
 /// API notes for a function or method.
 class FunctionInfo : public CommonEntityInfo {
 private:
-  static constexpr const unsigned NullabilityKindMask = 0x3;
+  static constexpr const uint64_t NullabilityKindMask = 0x3;
   static constexpr const unsigned NullabilityKindSize = 2;
 
   static constexpr const unsigned ReturnInfoIndex = 0;


Index: clang/include/clang/APINotes/Types.h
===
--- clang/include/clang/APINotes/Types.h
+++ clang/include/clang/APINotes/Types.h
@@ -482,7 +482,7 @@
 /// API notes for a function or method.
 class FunctionInfo : public CommonEntityInfo {
 private:
-  static constexpr const unsigned NullabilityKindMask = 0x3;
+  static constexpr const uint64_t NullabilityKindMask = 0x3;
   static constexpr const unsigned NullabilityKindSize = 2;
 
   static constexpr const unsigned ReturnInfoIndex = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142334: [Clang[NFC] Fix bitmask for NullabilityPayload in Types.h

2023-01-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta marked an inline comment as done.
xgupta added inline comments.



Comment at: clang/include/clang/APINotes/Types.h:535
 NullabilityPayload &=
-~(NullabilityKindMask << (index * NullabilityKindSize));
+~(static_castNullabilityKindMask << (index * 
NullabilityKindSize));
 

aaron.ballman wrote:
> I think a cleaner way to solve this is to make `NullabilityKindMask` be 
> 64-bits. None of the other operations need this change, but it seems like it 
> will be a bit more future-proof that way. WDYT?
Yeah, I do agree. Thanks for the suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142334

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


[PATCH] D142199: [Docs] Replace recommonmark with myst-parser

2023-01-23 Thread Luke Lau via Phabricator via cfe-commits
luke added inline comments.



Comment at: flang/docs/ComplexOperations.md:37
 **FIR**
-```c
 func.func @_QPpow_self(%arg0: !fir.ref>) -> !fir.complex<4> {

luke wrote:
> tstellar wrote:
> > Do these changes have any affected on the output html?  Is there another 
> > way to specify the language?
> I’m not sure, I think I might be able to add this back in though since I 
> suppressed a warning about highlight errors.
> I had to remove the ones that specified MLIR as the lexer though since there 
> didn’t seem to be an option to suppress those warnings. They didn’t seem to 
> receive any syntax highlighting in the output html anyway
Looks like these weren't being highlighted anyway: 
https://flang.llvm.org/docs/ComplexOperations.html?highlight=complex#fir-representation

Ideally there would eventually be an MLIR lexer added to pygments. Until then 
is it better to remove the incorrect lexers?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142199

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


[PATCH] D142334: [Clang[NFC] Fix bitmask for NullabilityPayload in Types.h

2023-01-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/APINotes/Types.h:535
 NullabilityPayload &=
-~(NullabilityKindMask << (index * NullabilityKindSize));
+~(static_castNullabilityKindMask << (index * 
NullabilityKindSize));
 

I think a cleaner way to solve this is to make `NullabilityKindMask` be 
64-bits. None of the other operations need this change, but it seems like it 
will be a bit more future-proof that way. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142334

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


[clang] 6f96dad - [Clang][NFC] Remove documentation and mentions of deleted tools

2023-01-23 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-01-23T07:15:54-06:00
New Revision: 6f96dadb7a5b1593a0b6348539f66f7e945f2561

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

LOG: [Clang][NFC] Remove documentation and mentions of deleted tools

Summary:
These tools were deleted since LLVM 15. They are no longer present so we
should damnatio memoriae.

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp

Removed: 
clang/docs/ClangNvlinkWrapper.rst
clang/docs/ClangOffloadWrapper.rst



diff  --git a/clang/docs/ClangNvlinkWrapper.rst 
b/clang/docs/ClangNvlinkWrapper.rst
deleted file mode 100644
index 4e2935b67811c..0
--- a/clang/docs/ClangNvlinkWrapper.rst
+++ /dev/null
@@ -1,57 +0,0 @@
-
-Clang Nvlink Wrapper
-
-
-.. contents::
-   :local:
-
-.. _clang-nvlink-wrapper:
-
-Introduction
-
-
-This tool works as a wrapper over the ``nvlink`` program. It is required
-because ``nvlink`` does not support linking of archive files implicitly. It
-transparently passes every input option and object to ``nvlink`` except archive
-files. It reads each input archive file to extract the archived cubin files as
-temporary files. These temporary (\*.cubin) files are passed to ``nvlink``.
-
-Use Case
-
-
-During linking of heterogeneous device archive libraries with an OpenMP
-program, the :doc:`ClangOffloadBundler` creates a device specific archive of
-cubin files. Such an archive is then passed to this wrapper tool to extract
-cubin files before passing to ``nvlink``.
-
-Working
-===
-
-**Inputs**
-
-  A command line generated by the OpenMP-Clang driver targeting NVPTX,
-  containing a set of flags, cubin object files, and zero or more archive
-  files.
-
-Example::
-
-  clang-nvlink-wrapper main.cubin /tmp/libTest-nvptx-sm_50.a -o main-linked.out
-
-**Processing**
-
-  1. From each archive file extract all cubin files as temporary files and
- store their names in a list, `CubinFiles`.
-  2. Create a new command line, `NVLinkCommand`, such that
- * Program is ``nvlink``
- * All input flags are transparently passed on as flags
- * All input archive file are replaced with `CubinFiles`
-  3. Execute NVLinkCommand
-
-::
-
-  1. Extract (libTest-nvptx-sm_50.a) => /tmp/a.cubin /tmp/b.cubin
-  2. nvlink -o a.out-openmp-nvptx64 main.cubin /tmp/a.cubin /tmp/b.cubin
-
-**Output**
-
-  Output file generated by ``nvlink`` which links all cubin files.

diff  --git a/clang/docs/ClangOffloadWrapper.rst 
b/clang/docs/ClangOffloadWrapper.rst
deleted file mode 100644
index 9865bad8748aa..0
--- a/clang/docs/ClangOffloadWrapper.rst
+++ /dev/null
@@ -1,223 +0,0 @@
-=
-Clang Offload Wrapper
-=
-
-.. contents::
-   :local:
-
-.. _clang-offload-wrapper:
-
-Introduction
-
-
-This tool is used in OpenMP offloading toolchain to embed device code objects
-(usually ELF) into a wrapper host llvm IR (bitcode) file. The wrapper host IR
-is then assembled and linked with host code objects to generate the executable
-binary. See :ref:`image-binary-embedding-execution` for more details.
-
-Usage
-=
-
-This tool can be used as follows:
-
-.. code-block:: console
-
-  $ clang-offload-wrapper -help
-  OVERVIEW: A tool to create a wrapper bitcode for offload target binaries.
-  Takes offload target binaries as input and produces bitcode file containing
-  target binaries packaged as data and initialization code which registers
-  target binaries in offload runtime.
-  USAGE: clang-offload-wrapper [options] 
-  OPTIONS:
-  Generic Options:
---help - Display available options 
(--help-hidden for more)
---help-list- Display list of available options 
(--help-list-hidden for more)
---version  - Display the version of this program
-  clang-offload-wrapper options:
--o   - Output filename
---target=  - Target triple for the output module
-
-Example
-===
-
-.. code-block:: console
-
-  clang-offload-wrapper -target host-triple -o host-wrapper.bc 
gfx90a-binary.out
-
-.. _openmp-device-binary_embedding:
-
-OpenMP Device Binary Embedding
-==
-
-Various structures and functions used in the wrapper host IR form the interface
-between the executable binary and the OpenMP runtime.
-
-Enum Types
---
-
-:ref:`table-offloading-declare-target-flags` lists 
diff erent flag for
-offloading entries.
-
-  .. table:: Offloading Declare Target Flags Enum
-:name: table-offloading-declare-target-flags
-
-
+-+---+--+
-|  Name 

[clang] bcc05cb - [Clang] Remove flaky test line from linker wrapper test

2023-01-23 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-01-23T07:15:53-06:00
New Revision: bcc05cbfa8088db8ddb4beeea066147c2dc334ba

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

LOG: [Clang] Remove flaky test line from linker wrapper test

Summary:
This test is a little flaky and isn't as necessary anymore now that we
only generate one temporary file.

Added: 


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

Removed: 




diff  --git a/clang/test/Driver/linker-wrapper.c 
b/clang/test/Driver/linker-wrapper.c
index d515e316da0f4..2bd3f60541e4c 100644
--- a/clang/test/Driver/linker-wrapper.c
+++ b/clang/test/Driver/linker-wrapper.c
@@ -130,15 +130,3 @@
 // RUN:   -o a.out 2>&1 | FileCheck %s --check-prefix=MISSING-LIBRARY
 
 // MISSING-LIBRARY: error: unable to find library -ldummy
-
-/// Ensure that temp files aren't leftoever from static libraries.
-// RUN: clang-offload-packager -o %t-lib.out \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
-// RUN:   --image=file=%t.elf.o,kind=cuda,triple=nvptx64-nvidia-cuda,arch=sm_52
-// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t-lib.out
-// RUN: llvm-ar rcs %t.a %t.o
-// RUN: rm -f %t.o
-// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t-obj.o
-// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run 
--save-temps \
-// RUN:   --linker-path=/usr/bin/ld -- %t.a %t-obj.o -o a.out
-// RUN: not ls "*nvptx64*"



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


[PATCH] D141757: [clangd] allow extracting to variable for complete lambda expressions

2023-01-23 Thread Julian Schmidt via Phabricator via cfe-commits
5chmidti updated this revision to Diff 491319.
5chmidti added a comment.
Herald added a subscriber: ChuanqiXu.

1. addressed comments

2 bugfix (sorry, should've said something)
Local variables inside the lambda were previously added to the ReferencedDecls 
vector and would block the action inside of exprIsValidOutside (declarations 
are inside of the lambda).
Now only consider DeclRefExprs in the lambda captures.

3. I don't have commit access, someone else would need to commit this.

I don't know if you want to delay this patch due to the bugfix or not, either 
way is fine with me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141757

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
  clang-tools-extra/docs/ReleaseNotes.rst

Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -66,6 +66,11 @@
 Code completion
 ^^^
 
+Code actions
+
+
+- The extract variable tweak gained support for extracting complete lambda expressions to a variable.
+
 Signature help
 ^^
 
Index: clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
@@ -98,6 +98,7 @@
   return [[t]].bar([[t]].z);
 }
 void v() { return; }
+template  void callable_sink(T) {}
 // function default argument
 void f(int b = [[1]]) {
   // empty selection
@@ -131,6 +132,21 @@
   goto label;
   label:
 a = [[1]];
+
+  // lambdas
+  callable_sink([][[(){}]]);
+
+  // captures
+  int x = 0;
+  callable_sink([ [[=]] ](){});
+  callable_sink([ [[&]] ](){});
+  callable_sink([ [[x]] ](){});
+  callable_sink([ [[&x] ]](){});
+  callable_sink([y = [[x]] ](){});
+  callable_sink([ [[y = x]] ](){});
+
+  // default args
+  callable_sink([](int x = [[10]]){});
 }
   )cpp";
   EXPECT_UNAVAILABLE(UnavailableCases);
@@ -282,6 +298,67 @@
  void f() {
auto placeholder = S(2) + S(3) + S(4); S x = S(1) + placeholder + S(5);
  })cpp"},
+  // Complete lambda expressions
+  {R"cpp(template  void f(T) {}
+void f2() {
+  f([[ [](){ return 42; }]]);
+}
+)cpp",
+   R"cpp(template  void f(T) {}
+void f2() {
+  auto placeholder = [](){ return 42; }; f( placeholder);
+}
+)cpp"},
+  {R"cpp(auto foo(int VarA) {
+  return [VarA]() {
+return [[ [VarA, VarC = 42 + VarA](int VarB) { return VarA + VarB + VarC; }]];
+  };
+}
+)cpp",
+   R"cpp(auto foo(int VarA) {
+  return [VarA]() {
+auto placeholder = [VarA, VarC = 42 + VarA](int VarB) { return VarA + VarB + VarC; }; return  placeholder;
+  };
+}
+)cpp"},
+  {R"cpp(template  void f(T) {}
+void f2(int var) {
+  f([[ [&var](){ auto internal_val = 42; return var + internal_val; }]]);
+}
+)cpp",
+   R"cpp(template  void f(T) {}
+void f2(int var) {
+  auto placeholder = [&var](){ auto internal_val = 42; return var + internal_val; }; f( placeholder);
+}
+)cpp"},
+  {R"cpp(template  void f(T) { }
+struct A {
+void f2(int& var) {
+auto local_var = 42;
+f([[ [&var, &local_var, this]() {
+auto internal_val = 42;
+return var + local_var + internal_val + member;
+}]]);
+}
+
+int member = 42;
+};
+)cpp",
+   R"cpp(template  void f(T) { }
+struct A {
+void f2(int& var) {
+auto local_var = 42;
+auto placeholder = [&var, &local_var, this]() {
+auto internal_val = 42;
+return var + local_var + internal_val + member;
+}; f( placeholder);
+}
+
+int member = 42;
+};
+)cpp"},
+  {R"cpp(void f() { auto x = [[ [](){ return 42; }]]; })cpp",
+   R"cpp(void f() { auto placeholder = [](){ return 42; }; auto x =  placeholder; })cpp"},
   // Don't try t

[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-23 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 491320.
fpetrogalli added a comment.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, sstefan1.
Herald added a project: LLVM.

@mgorny, I have updated the patch according to the suggestions from @tstellar 
in https://reviews.llvm.org/D141581#4069857.

I have used the script below to test the stand-alone build of clang. Indeed, 
the error related to the cmake configuration for RISCVTargetParserDefs has 
disappeared. However, there is an (unreltaed) error that does not allow me to 
test the full build:

  CMake Error at 
/Users/fpetrogalli/projects/cpu-defs/install/lib/cmake/llvm/LLVMExports.cmake:1222
 (set_target_properties):
The link interface of target "LLVMLineEditor" contains:
  
  LibEdit::LibEdit
  
but the target was not found.  Possible reasons include:
  
  * There is a typo in the target name.
  * A find_package call is missing for an IMPORTED target.
  * An ALIAS target is missing.
  
  Call Stack (most recent call first):

/Users/fpetrogalli/projects/cpu-defs/install/lib/cmake/llvm/LLVMConfig.cmake:329
 (include)
CMakeLists.txt:38 (find_package)

Script used for testing:

  % cat standalone.sh
  #!/bin/sh
  
  build_llvm=`pwd`/build-llvm
  build_clang=`pwd`/build-clang
  installprefix=`pwd`/install
  llvm=`pwd`/llvm-project
  mkdir -p $build_llvm
  mkdir -p $installprefix
  
  cmake -G Ninja -S $llvm/llvm -B $build_llvm \
-DLLVM_INSTALL_UTILS=ON \
-DCMAKE_INSTALL_PREFIX=$installprefix \
-DCMAKE_BUILD_TYPE=Release
  
  ninja -C $build_llvm install
  
  cmake -G Ninja -S $llvm/clang -B $build_clang \
-DLLVM_EXTERNAL_LIT=$build_llvm/utils/lit \
-DLLVM_ROOT=$installprefix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

Files:
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Driver/CMakeLists.txt
  llvm/cmake/modules/LLVMConfig.cmake.in


Index: llvm/cmake/modules/LLVMConfig.cmake.in
===
--- llvm/cmake/modules/LLVMConfig.cmake.in
+++ llvm/cmake/modules/LLVMConfig.cmake.in
@@ -140,9 +140,9 @@
   @llvm_config_include_buildtree_only_exports@
 endif()
 
-# By creating intrinsics_gen, omp_gen and acc_gen here, subprojects that depend
-# on LLVM's tablegen-generated headers can always depend on this target whether
-# building in-tree with LLVM or not.
+# By creating the following targets here, subprojects that depend on
+# LLVM's tablegen-generated headers can always depend on this target
+# whether building in-tree with LLVM or not.
 if(NOT TARGET intrinsics_gen)
   add_custom_target(intrinsics_gen)
 endif()
@@ -152,6 +152,9 @@
 if(NOT TARGET acc_gen)
   add_custom_target(acc_gen)
 endif()
+if(NOT TARGET RISCVTargetParserTableGen)
+  add_custom_target(RISCVTargetParserTableGen)
+endif()
 
 set_property(GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED On)
 include(${LLVM_CMAKE_DIR}/LLVM-Config.cmake)
Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -93,7 +93,6 @@
 
   DEPENDS
   ClangDriverOptions
-  RISCVTargetParserTableGen
 
   LINK_LIBS
   clangBasic
Index: clang/lib/Basic/CMakeLists.txt
===
--- clang/lib/Basic/CMakeLists.txt
+++ clang/lib/Basic/CMakeLists.txt
@@ -110,7 +110,6 @@
 
   DEPENDS
   omp_gen
-  RISCVTargetParserTableGen
   )
 
 target_link_libraries(clangBasic


Index: llvm/cmake/modules/LLVMConfig.cmake.in
===
--- llvm/cmake/modules/LLVMConfig.cmake.in
+++ llvm/cmake/modules/LLVMConfig.cmake.in
@@ -140,9 +140,9 @@
   @llvm_config_include_buildtree_only_exports@
 endif()
 
-# By creating intrinsics_gen, omp_gen and acc_gen here, subprojects that depend
-# on LLVM's tablegen-generated headers can always depend on this target whether
-# building in-tree with LLVM or not.
+# By creating the following targets here, subprojects that depend on
+# LLVM's tablegen-generated headers can always depend on this target
+# whether building in-tree with LLVM or not.
 if(NOT TARGET intrinsics_gen)
   add_custom_target(intrinsics_gen)
 endif()
@@ -152,6 +152,9 @@
 if(NOT TARGET acc_gen)
   add_custom_target(acc_gen)
 endif()
+if(NOT TARGET RISCVTargetParserTableGen)
+  add_custom_target(RISCVTargetParserTableGen)
+endif()
 
 set_property(GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED On)
 include(${LLVM_CMAKE_DIR}/LLVM-Config.cmake)
Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -93,7 +93,6 @@
 
   DEPENDS
   ClangDriverOptions
-  RISCVTargetParserTableGen
 
   LINK_LIBS
   clangBasic
Index: clang/lib/Basic/CMakeLists.txt
==

[PATCH] D142199: [Docs] Replace recommonmark with myst-parser

2023-01-23 Thread Luke Lau via Phabricator via cfe-commits
luke updated this revision to Diff 491318.
luke added a comment.

Don't suppress misc.highlighting_failure warning

Instead just fix the flang code block that was failing to highlight


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142199

Files:
  .github/workflows/release-tasks.yml
  clang/docs/conf.py
  flang/docs/ComplexOperations.md
  flang/docs/DiagnosticsReference.md
  flang/docs/FIRArrayOperations.md
  flang/docs/FlangDriver.md
  flang/docs/HighLevelFIR.md
  flang/docs/OptionComparison.md
  flang/docs/ParameterizedDerivedTypes.md
  flang/docs/PolymorphicEntities.md
  flang/docs/PullRequestChecklist.md
  flang/docs/conf.py
  flang/docs/index.md
  flang/include/flang/Optimizer/Dialect/FIROps.td
  
llvm/docs/AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack/AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack.md
  llvm/docs/DeveloperPolicy.rst
  llvm/docs/GitRepositoryPolicy.md
  llvm/docs/MarkdownQuickstartTemplate.md
  llvm/docs/PointerAuth.md
  llvm/docs/SpeculativeLoadHardening.md
  llvm/docs/SphinxQuickstartTemplate.rst
  llvm/docs/conf.py
  llvm/utils/release/build-docs.sh

Index: llvm/utils/release/build-docs.sh
===
--- llvm/utils/release/build-docs.sh
+++ llvm/utils/release/build-docs.sh
@@ -15,7 +15,7 @@
 # ninja-build gcc-c++
 #   * pip install sphinx-markdown-tables
 # * Ubuntu:
-#   * apt-get install doxygen sphinx-common python3-recommonmark \
+#   * apt-get install doxygen sphinx-common python3-myst-parser \
 # ninja-build graphviz texlive-font-utils
 #   * pip install sphinx-markdown-tables
 #======#
Index: llvm/docs/conf.py
===
--- llvm/docs/conf.py
+++ llvm/docs/conf.py
@@ -37,7 +37,7 @@
 }
 
 try:
-  import recommonmark
+  import myst_parser
 except ImportError:
   # manpages do not use any .md sources
   if not tags.has('builder-man'):
@@ -46,10 +46,11 @@
   import sphinx
   if sphinx.version_info >= (3, 0):
 # This requires 0.5 or later.
-extensions.append('recommonmark')
+extensions.append('myst_parser')
   else:
-source_parsers = {'.md': 'recommonmark.parser.CommonMarkParser'}
+source_parsers = {'.md': 'myst_parser.parsers.sphinx_.MystParser'}
   source_suffix['.md'] = 'markdown'
+  myst_heading_anchors = 7
 
 # The encoding of source files.
 #source_encoding = 'utf-8-sig'
Index: llvm/docs/SphinxQuickstartTemplate.rst
===
--- llvm/docs/SphinxQuickstartTemplate.rst
+++ llvm/docs/SphinxQuickstartTemplate.rst
@@ -164,7 +164,8 @@
  .++:..
   ...
 
-
+.. _generating the documentation:
+			 
 Generating the documentation
 
 
@@ -172,19 +173,19 @@
 see what they would look like. In addition to the normal
 `build tools `_
 you need to install `Sphinx`_ and the
-`recommonmark `_ extension.
+`myst-parser `_ extension.
 
 On Debian you can install these with:
 
 .. code-block:: console
 
-   sudo apt install -y sphinx-doc python-recommonmark-doc
+   sudo apt install -y sphinx-doc python3-myst-parser
 
-On Ubuntu use pip to get an up-to-date version of recommonmark:
+On Ubuntu use pip to get an up-to-date version of myst-parser:
 
 .. code-block:: console
 
-   sudo pip install sphinx recommonmark
+   sudo pip install sphinx myst-parser
 
 Then run cmake to build the documentation inside the ``llvm-project`` checkout:
 
Index: llvm/docs/SpeculativeLoadHardening.md
===
--- llvm/docs/SpeculativeLoadHardening.md
+++ llvm/docs/SpeculativeLoadHardening.md
@@ -1,6 +1,6 @@
 # Speculative Load Hardening
 
-### A Spectre Variant #1 Mitigation Technique
+## A Spectre Variant #1 Mitigation Technique
 
 Author: Chandler Carruth - [chandl...@google.com](mailto:chandl...@google.com)
 
Index: llvm/docs/PointerAuth.md
===
--- llvm/docs/PointerAuth.md
+++ llvm/docs/PointerAuth.md
@@ -16,7 +16,7 @@
 * a [call operand bundle](#operand-bundle) (to authenticate called pointers)
 
 The current implementation leverages the
-[Armv8.3-A PAuth/Pointer Authentication Code](#armv8-3-a-pauth-pointer-authentication-code)
+[Armv8.3-A PAuth/Pointer Authentication Code](#armv83-a-pauth-pointer-authentication-code)
 instructions in the [AArch64 backend](#aarch64-support).
 This support is used to implement the Darwin arm64e ABI, as well as the
 [PAuth ABI Extension to ELF](https://github.com/ARM-software/abi-aa/blob/main/pauthabielf64/pauthabielf64.rst).
@@ -117,7 +117,7 @@
 signature is valid.
 
 ``key``

[PATCH] D140619: ExtractFunction: support extracting expressions and selected part of it

2023-01-23 Thread Kacper Kowalski via Phabricator via cfe-commits
KKoovalsky updated this revision to Diff 491324.
KKoovalsky added a comment.

1. Fixed lit fail: dereferencing a null pointer when calling `ignoreImplicit()` 
on `CommonAncestor` being `nullptr` - fixed with sanitization of 
`CommonAncestor` being `nullptr`.
2. Fixed link error: missing `ASTMatchers` lib.+


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

https://reviews.llvm.org/D140619

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/tool/CMakeLists.txt
  clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
@@ -24,8 +24,6 @@
 
   // Root statements should have common parent.
   EXPECT_EQ(apply("for(;;) [[1+2; 1+2;]]"), "unavailable");
-  // Expressions aren't extracted.
-  EXPECT_EQ(apply("int x = 0; [[x++;]]"), "unavailable");
   // We don't support extraction from lambdas.
   EXPECT_EQ(apply("auto lam = [](){ [[int x;]] }; "), "unavailable");
   // Partial statements aren't extracted.
@@ -190,6 +188,16 @@
 }]]
   )cpp";
   EXPECT_EQ(apply(CompoundFailInput), "unavailable");
+
+  std::string CompoundWithMultipleStatementsFailInput = R"cpp(
+void f() [[{
+  int a = 1;
+  int b = 2;
+  ++b;
+  b += a;
+}]]
+  )cpp";
+  EXPECT_EQ(apply(CompoundWithMultipleStatementsFailInput), "unavailable");
 }
 
 TEST_F(ExtractFunctionTest, DifferentHeaderSourceTest) {
@@ -571,6 +579,795 @@
   EXPECT_EQ(apply(Before), After);
 }
 
+TEST_F(ExtractFunctionTest, Expressions) {
+  std::vector> InputOutputs{
+  // FULL BINARY EXPRESSIONS
+  // Full binary expression, basic maths
+  {R"cpp(
+void wrapperFun() {
+  double a{2.0}, b{3.2}, c{31.55};
+  double v{[[b * b - 4 * a * c]]};
+}
+  )cpp",
+   R"cpp(
+double extracted(double &a, double &b, double &c) {
+return b * b - 4 * a * c;
+}
+void wrapperFun() {
+  double a{2.0}, b{3.2}, c{31.55};
+  double v{extracted(a, b, c)};
+}
+  )cpp"},
+  // Full binary expression composed of '+' operator overloads ops
+  {
+  R"cpp(
+struct S {
+  S operator+(const S&) {
+return *this;
+  }
+};
+void wrapperFun() {
+  S S1, S2, S3;
+  auto R{[[S1 + S2 + S3]]};
+}
+  )cpp",
+  R"cpp(
+struct S {
+  S operator+(const S&) {
+return *this;
+  }
+};
+S extracted(S &S1, S &S2, S &S3) {
+return S1 + S2 + S3;
+}
+void wrapperFun() {
+  S S1, S2, S3;
+  auto R{extracted(S1, S2, S3)};
+}
+  )cpp"},
+  // Boolean predicate as expression
+  {
+  R"cpp(
+void wrapperFun() {
+  int a{1};
+  auto R{[[a > 1]]};
+}
+  )cpp",
+  R"cpp(
+bool extracted(int &a) {
+return a > 1;
+}
+void wrapperFun() {
+  int a{1};
+  auto R{extracted(a)};
+}
+  )cpp"},
+  // Expression: captures no global variable
+  {R"cpp(
+static int a{2};
+void wrapperFun() {
+  int b{3}, c{31}, d{311};
+  auto v{[[a + b + c + d]]};
+}
+  )cpp",
+   R"cpp(
+static int a{2};
+int extracted(int &b, int &c, int &d) {
+return a + b + c + d;
+}
+void wrapperFun() {
+  int b{3}, c{31}, d{311};
+  auto v{extracted(b, c, d)};
+}
+  )cpp"},
+  // Full expr: infers return type of call returning by ref
+  {
+  R"cpp(
+struct S {
+  S& operator+(const S&) {
+return *this;
+  }
+};
+void wrapperFun() {
+  S S1, S2, S3;
+  auto R{[[S1 + S2 + S3]]};
+}
+  )cpp",
+  R"cpp(
+struct S {
+  S& operator+(const S&) {
+return *this;
+  }
+};
+S & extracted(S &S1, S &S2, S &S3) {
+return S1 + S2 + S3;
+}
+void wrapperFun() {
+  S S1, S2, S3;
+  auto R{extracted(S1, S2, S3)};
+}
+  )cpp"},
+  // Full expr: infers return type of call returning by const-ref
+  {
+  R"cpp(
+struct S {
+  const S& operator+(const S&) const {
+return *this;
+  }
+};
+void wrapperFun() {
+  S S1, S2, S3;
+  auto R{[[S1 + S2 + S3]]};
+}
+  )cpp",
+  R"cpp(
+struct S {
+  const S& operator+(const S&) const {
+return *this;
+  }
+};
+const S & extracted(S &S1, S &S2, S &S3) {
+return S1 + S2 + S3;
+}
+void wrapperFun() {
+  S S1, S2, S3;
+  auto R{extracted(S1, S2, S3)};
+}
+  )cpp"},
+  // Captures deeply nested arguments
+  {
+  R"cpp(
+int fw(int a) { return a; };
+int add(int a, int b) { return a + b; }
+void wrapper() {
+int a{0}, b{1}, c{2}, d{3}, e{4}, f{5};
+int r{[[fw(fw(fw(a))) + fw(fw(add(b, c))) + fw(fw(fw(add(d, e + fw(fw(f))]]};
+}
+  )cpp",
+  R"cpp(
+int fw(int a) { return a; };
+int add(int a, int b) { return a + b; }
+int extracted(int &a, int &b, int &c, int &d, int &e, int &f) {
+return fw(fw(fw(a))) + fw(fw(add(b, c))) + fw(fw(fw(add(d, e + fw(fw(f));
+}
+void wrapper() {
+int a{0}, b{1}, c{2}, d{3}, e{4}, f{5};
+int r{extracted(a, b, c

[PATCH] D142092: [include-mapping] Allow multiple headers for the same symbol. Choose the first header of available ones.

2023-01-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang/tools/include-mapping/cppreference_parser.py:174
-  # std::remove<> has variant algorithm.
-  "std::remove": ("algorithm"),
-  }

this is actually checking for something else (sorry for the confusing naming).

the `variant` here refers to library name mentioned in parentheses (this is 
same problem as `std::move`) on the std symbol index page 
https://en.cppreference.com/w/cpp/symbol_index (e.g. `remove<>() (algorithm)`). 
by getting rid of this we're introducing a regression, as previously 
`std::remove` wouldn't be recognized by the library, but now it'll be 
recognized and we'll keep suggesting `` for it.

so we should actually keep this around.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

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


[PATCH] D140434: readability-const-return-type: don't diagnose a template function returning T, even if sometimes instantiated with e.g. T = const int.

2023-01-23 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D140434#4071823 , @carlosgalvezp 
wrote:

> In D140434#4053053 , @suertreus 
> wrote:
>
>> Thanks for reviewing.
>>
>> I don't have commit access; can someone who does please do the thing?
>
> @suertreus I can help you land the patch, what user name and email should I 
> use for attribution?

Sorry for the delay -- I'm doing the commit now (just running tests first)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140434

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


[PATCH] D139010: [clang][WebAssembly] Implement support for table types and builtins

2023-01-23 Thread Alex Bradbury via Phabricator via cfe-commits
asb added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11827
+def err_wasm_builtin_arg_must_be_integer_type : Error <
+  "%ordinal0 argument must be an integer">;
 } // end of sema component.

aaron.ballman wrote:
> I'm a bit shocked by the number of new diagnostics for this type as it seems 
> incredibly restrictive and like the rules are going to be hard to understand. 
> For example, you cannot use this type in an exception specification despite 
> that being a compile-time property. Can you use it within a conditional 
> explicit clause (https://godbolt.org/z/sn3G8xE3T)? It must be static, but can 
> it be thread local?
> 
> Basically, it seems like this type is unlike basically any other type and 
> we're going to have to carry a significant amount of extra code around to 
> handle all the edge cases and those edge cases look a bit like whack-a-mole 
> in practice.
The whack-a-mole aspect of disallowing table uses is something I'm not fond of 
eitherbut I'm not sure I see a better approach. Do you have any 
alternatives in mind?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139010

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


[PATCH] D142354: [analyzer] Create a stub for an std::variant checker

2023-01-23 Thread Gábor Spaits via Phabricator via cfe-commits
spaits created this revision.
spaits added reviewers: Szelethus, steakhal, NoQ, gamesh411, xazax.hun.
spaits added a project: clang.
Herald added subscribers: manas, ASDenysPetrov, martong, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware.
Herald added a project: All.
spaits requested review of this revision.
Herald added a subscriber: cfe-commits.

As per the discussion on this thread i have started working on an std::variant 
checker.
https://discourse.llvm.org/t/analyzer-new-checker-for-std-any-as-a-bsc-thesis/65613/2

This patch is mostly a conversation starter. @Szelethus will supervise me on 
this project, and we shall discuss our next steps here.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142354

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/StdVariantChecker.cpp
  clang/test/Analysis/std-variant-checker.cpp


Index: clang/test/Analysis/std-variant-checker.cpp
===
--- /dev/null
+++ clang/test/Analysis/std-variant-checker.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core.StdVariant %s 
-verify
+
+namespace std {
+  template
+  class variant {};
+} //end of namespace std
+
+void g() {
+  std::variant v; // expected-warning{{Variant Created 
[alpha.core.StdVariant]}}
+}
\ No newline at end of file
Index: clang/lib/StaticAnalyzer/Checkers/StdVariantChecker.cpp
===
--- /dev/null
+++ clang/lib/StaticAnalyzer/Checkers/StdVariantChecker.cpp
@@ -0,0 +1,51 @@
+//===- StdVariantChecker.cpp -*- C++ 
-*-==//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+
+class StdVariantChecker : public Checker {
+CallDescription VariantConstructorCall{{"std", "variant"}, 0, 0};
+BugType VariantCreated{this, "VariantCreated", "VariantCreated"};
+
+public:
+void checkPreCall(const CallEvent &Call, CheckerContext &C) const {
+  if (!isa(Call))
+return;
+
+  if (!VariantConstructorCall.matches(Call))
+return;
+
+  ExplodedNode* ErrNode = C.generateNonFatalErrorNode();
+  if (!ErrNode)
+return;
+  llvm::SmallString<128> Str;
+  llvm::raw_svector_ostream OS(Str);
+  OS << "Variant Created";
+  auto R = std::make_unique(
+  VariantCreated, OS.str(), ErrNode);
+  C.emitReport(std::move(R));
+}
+};
+
+bool clang::ento::shouldRegisterStdVariantChecker(
+clang::ento::CheckerManager const &mgr) {
+  return true;
+}
+
+void clang::ento::registerStdVariantChecker(clang::ento::CheckerManager &mgr) {
+  mgr.registerChecker();
+}
\ No newline at end of file
Index: clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
===
--- clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -107,6 +107,7 @@
   SmartPtrModeling.cpp
   StackAddrEscapeChecker.cpp
   StdLibraryFunctionsChecker.cpp
+  StdVariantChecker.cpp
   STLAlgorithmModeling.cpp
   StreamChecker.cpp
   StringChecker.cpp
Index: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -305,6 +305,10 @@
   Dependencies<[PthreadLockBase]>,
   Documentation;
 
+def StdVariantChecker : Checker<"StdVariant">,
+  HelpText<"Check std::variant">,
+  Documentation;
+
 } // end "alpha.core"
 
 
//===--===//


Index: clang/test/Analysis/std-variant-checker.cpp
===
--- /dev/null
+++ clang/test/Analysis/std-variant-checker.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core.StdVariant %s -verify
+
+namespace std {
+  template
+  class variant {};
+} //end of namespace std
+
+void g() {
+  std::variant v; // expected-warning{{Variant Created [alpha.core.StdVariant]}}
+}
\ 

[PATCH] D140619: ExtractFunction: support extracting expressions and selected part of it

2023-01-23 Thread Kacper Kowalski via Phabricator via cfe-commits
KKoovalsky updated this revision to Diff 491331.
KKoovalsky added a comment.

1. Fixed lit fail: dereferencing a null pointer when calling `ignoreImplicit()` 
on `CommonAncestor` being `nullptr` - fixed with sanitization of 
`CommonAncestor` being `nullptr`.
2. Fixed link error: missing `ASTMatchers` lib.


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

https://reviews.llvm.org/D140619

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/tool/CMakeLists.txt
  clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
@@ -24,8 +24,6 @@
 
   // Root statements should have common parent.
   EXPECT_EQ(apply("for(;;) [[1+2; 1+2;]]"), "unavailable");
-  // Expressions aren't extracted.
-  EXPECT_EQ(apply("int x = 0; [[x++;]]"), "unavailable");
   // We don't support extraction from lambdas.
   EXPECT_EQ(apply("auto lam = [](){ [[int x;]] }; "), "unavailable");
   // Partial statements aren't extracted.
@@ -190,6 +188,16 @@
 }]]
   )cpp";
   EXPECT_EQ(apply(CompoundFailInput), "unavailable");
+
+  std::string CompoundWithMultipleStatementsFailInput = R"cpp(
+void f() [[{
+  int a = 1;
+  int b = 2;
+  ++b;
+  b += a;
+}]]
+  )cpp";
+  EXPECT_EQ(apply(CompoundWithMultipleStatementsFailInput), "unavailable");
 }
 
 TEST_F(ExtractFunctionTest, DifferentHeaderSourceTest) {
@@ -571,6 +579,795 @@
   EXPECT_EQ(apply(Before), After);
 }
 
+TEST_F(ExtractFunctionTest, Expressions) {
+  std::vector> InputOutputs{
+  // FULL BINARY EXPRESSIONS
+  // Full binary expression, basic maths
+  {R"cpp(
+void wrapperFun() {
+  double a{2.0}, b{3.2}, c{31.55};
+  double v{[[b * b - 4 * a * c]]};
+}
+  )cpp",
+   R"cpp(
+double extracted(double &a, double &b, double &c) {
+return b * b - 4 * a * c;
+}
+void wrapperFun() {
+  double a{2.0}, b{3.2}, c{31.55};
+  double v{extracted(a, b, c)};
+}
+  )cpp"},
+  // Full binary expression composed of '+' operator overloads ops
+  {
+  R"cpp(
+struct S {
+  S operator+(const S&) {
+return *this;
+  }
+};
+void wrapperFun() {
+  S S1, S2, S3;
+  auto R{[[S1 + S2 + S3]]};
+}
+  )cpp",
+  R"cpp(
+struct S {
+  S operator+(const S&) {
+return *this;
+  }
+};
+S extracted(S &S1, S &S2, S &S3) {
+return S1 + S2 + S3;
+}
+void wrapperFun() {
+  S S1, S2, S3;
+  auto R{extracted(S1, S2, S3)};
+}
+  )cpp"},
+  // Boolean predicate as expression
+  {
+  R"cpp(
+void wrapperFun() {
+  int a{1};
+  auto R{[[a > 1]]};
+}
+  )cpp",
+  R"cpp(
+bool extracted(int &a) {
+return a > 1;
+}
+void wrapperFun() {
+  int a{1};
+  auto R{extracted(a)};
+}
+  )cpp"},
+  // Expression: captures no global variable
+  {R"cpp(
+static int a{2};
+void wrapperFun() {
+  int b{3}, c{31}, d{311};
+  auto v{[[a + b + c + d]]};
+}
+  )cpp",
+   R"cpp(
+static int a{2};
+int extracted(int &b, int &c, int &d) {
+return a + b + c + d;
+}
+void wrapperFun() {
+  int b{3}, c{31}, d{311};
+  auto v{extracted(b, c, d)};
+}
+  )cpp"},
+  // Full expr: infers return type of call returning by ref
+  {
+  R"cpp(
+struct S {
+  S& operator+(const S&) {
+return *this;
+  }
+};
+void wrapperFun() {
+  S S1, S2, S3;
+  auto R{[[S1 + S2 + S3]]};
+}
+  )cpp",
+  R"cpp(
+struct S {
+  S& operator+(const S&) {
+return *this;
+  }
+};
+S & extracted(S &S1, S &S2, S &S3) {
+return S1 + S2 + S3;
+}
+void wrapperFun() {
+  S S1, S2, S3;
+  auto R{extracted(S1, S2, S3)};
+}
+  )cpp"},
+  // Full expr: infers return type of call returning by const-ref
+  {
+  R"cpp(
+struct S {
+  const S& operator+(const S&) const {
+return *this;
+  }
+};
+void wrapperFun() {
+  S S1, S2, S3;
+  auto R{[[S1 + S2 + S3]]};
+}
+  )cpp",
+  R"cpp(
+struct S {
+  const S& operator+(const S&) const {
+return *this;
+  }
+};
+const S & extracted(S &S1, S &S2, S &S3) {
+return S1 + S2 + S3;
+}
+void wrapperFun() {
+  S S1, S2, S3;
+  auto R{extracted(S1, S2, S3)};
+}
+  )cpp"},
+  // Captures deeply nested arguments
+  {
+  R"cpp(
+int fw(int a) { return a; };
+int add(int a, int b) { return a + b; }
+void wrapper() {
+int a{0}, b{1}, c{2}, d{3}, e{4}, f{5};
+int r{[[fw(fw(fw(a))) + fw(fw(add(b, c))) + fw(fw(fw(add(d, e + fw(fw(f))]]};
+}
+  )cpp",
+  R"cpp(
+int fw(int a) { return a; };
+int add(int a, int b) { return a + b; }
+int extracted(int &a, int &b, int &c, int &d, int &e, int &f) {
+return fw(fw(fw(a))) + fw(fw(add(b, c))) + fw(fw(fw(add(d, e + fw(fw(f));
+}
+void wrapper() {
+int a{0}, b{1}, c{2}, d{3}, e{4}, f{5};
+int r{extracted(a, b, c,

[PATCH] D141925: [ASTMatchers] Add `isDirectInit` matcher.

2023-01-23 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.
Herald added a subscriber: ChuanqiXu.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141925

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


[PATCH] D139010: [clang][WebAssembly] Implement support for table types and builtins

2023-01-23 Thread Paulo Matos via Phabricator via cfe-commits
pmatos marked 2 inline comments as done.
pmatos added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11797
+def err_typecheck_wasm_table_must_have_zero_length : Error<
+  "only zero-length WebAssembly tables are currently supported">;
+def err_wasm_table_in_function : Error<

aaron.ballman wrote:
> Do you plan to support non-zero-length tables in the near future? I'm 
> wondering if this should be reworded to remove the "currently supported" 
> phrasing.
Yes, the next phase of this work is to implement this together with element 
section to initialize tables.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139010

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


[PATCH] D142346: [docs] Add release notes for news in 16.x done by me, or otherwise relating to MinGW targets

2023-01-23 Thread Alvin Wong via Phabricator via cfe-commits
alvinhochun accepted this revision.
alvinhochun added a comment.

Thanks, LGTM for the parts I touched and also the rest of the stuff (but I 
didn't proofread carefully).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142346

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


[PATCH] D142092: [include-mapping] Allow multiple headers for the same symbol. Choose the first header of available ones.

2023-01-23 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Can you add a unittest in the `StandardLibraryTest.cpp`?




Comment at: clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc:1053
 SYMBOL(remainder, std::, )
+SYMBOL(remove, std::, )
 SYMBOL(remove_all_extents, std::, )

I think `std::remove` should not be in the scope of the patch, it has two 
variants:
- std::remove from ``
- and std::remove from ``.



Comment at: clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc:100
 SYMBOL(atoll, std::, )
+SYMBOL(atomic, std::, )
+SYMBOL(atomic, std::, )

Conceptually, this (and other `atomic_*` symbols) doesn't feel correct:
- `` provides the generic template `template struct atomic;`
-  `` provides partial template specializations for `std::shared_ptr` 
and `std::weak_ptr`  

They are variant symbols (ideally, they should be treat as the `std::move()`). 
The issue here is that unlike `std::move` which has two individual entries in 
the index page, we only have one entry for `std::atomic` (extending the 
cppreference_parser.py script to perfectly distinguish these two cases in the 
[page](https://en.cppreference.com/w/cpp/atomic/atomic) seems non-trivial).  
Some options:

1) treat them as multiple-header symbols (like what this patch does now)
2) special-case these symbols like `std::move()`
3) always prefer the header providing generic templates

@kadircet, what do you think?



Comment at: clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc:369
+SYMBOL(div, std::, )
+SYMBOL(div, std::, )
 SYMBOL(div_t, std::, )

this one as well, both headers provide different overloads.



Comment at: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp:20
 static llvm::StringRef *HeaderNames;
-static std::pair *SymbolNames;
-static unsigned *SymbolHeaderIDs;
+static llvm::DenseMap>
+*SymbolNames;

int => unsigned.

Any reason to change it to a map? My understanding is that SymbolNames is a 
mapping from the SymbolID => {Scope, Name}, it should not be affected if we add 
multiple-header symbols.



Comment at: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp:57
+bool IsNewSymbol = true;
+int SymIndex = NextAvailSymIndex;
+if (NSSymbolMap *NSSymbols = NamespaceSymbols->lookup(NS)) {

int => unsigned.



Comment at: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp:58
+int SymIndex = NextAvailSymIndex;
+if (NSSymbolMap *NSSymbols = NamespaceSymbols->lookup(NS)) {
+  auto It = NSSymbols->find(Name);

Given the fact that multiple-header symbols are grouped in the .inc file, we 
could simplify the code of checking a new symbol by looking at the last 
available SymIndex:

```
if (NextAvailSymIndex > 0 && SymbolNames[NextAvailSymIndex-1].first == NS && 
SymbolNames[NextAvailSymIndex-1].second == Name) {
   // this is not a new symbol.
}
```



Comment at: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp:69
+unsigned HeaderID = AddHeader(HeaderName);
+SymbolHeaderIDs[SymIndex].emplace_back(HeaderID);
 

nit: inline the `HeaderID`.



Comment at: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp:103
+llvm::StringRef Symbol::scope() const {
+  auto It = SymbolNames->find(ID);
+  if (It != SymbolNames->end()) {

The `ID` field is guaranteed to be valid, so no need to do the sanity check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

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


[PATCH] D139921: [include-cleaner] Ranking of providers based on hints

2023-01-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG749c6a708340: [include-cleaner] Ranking of providers based 
on hints (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139921

Files:
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
  clang-tools-extra/include-cleaner/lib/Analysis.cpp
  clang-tools-extra/include-cleaner/lib/AnalysisInternal.h
  clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
  clang-tools-extra/include-cleaner/lib/HTMLReport.cpp
  clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp
  clang-tools-extra/include-cleaner/lib/Types.cpp
  clang-tools-extra/include-cleaner/lib/TypesInternal.h
  clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
  clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
  clang-tools-extra/include-cleaner/unittests/LocateSymbolTest.cpp

Index: clang-tools-extra/include-cleaner/unittests/LocateSymbolTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/LocateSymbolTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/LocateSymbolTest.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 #include "AnalysisInternal.h"
+#include "TypesInternal.h"
 #include "clang-include-cleaner/Types.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
@@ -20,6 +21,7 @@
 #include "gtest/gtest.h"
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -27,8 +29,11 @@
 
 namespace clang::include_cleaner {
 namespace {
+using testing::Each;
 using testing::ElementsAre;
 using testing::ElementsAreArray;
+using testing::Eq;
+using testing::Field;
 using testing::Pair;
 using testing::UnorderedElementsAre;
 
@@ -55,6 +60,10 @@
   llvm::StringRef NameToFind;
   const NamedDecl *Out = nullptr;
   bool VisitNamedDecl(const NamedDecl *ND) {
+// Skip the templated decls, as they have the same name and matches in
+// this file care about the outer template name.
+if (auto *TD = ND->getDescribedTemplate())
+  ND = TD;
 if (ND->getName() == NameToFind) {
   EXPECT_TRUE(Out == nullptr || Out == ND->getCanonicalDecl())
   << "Found multiple matches for " << NameToFind;
@@ -125,5 +134,57 @@
   ElementsAreArray(Test.points()));
 }
 
+MATCHER_P2(HintedSymbol, Symbol, Hint, "") {
+  return std::tie(arg.Hint, arg) == std::tie(Hint, Symbol);
+}
+TEST(LocateSymbol, CompleteSymbolHint) {
+  {
+// stdlib symbols are always complete.
+LocateExample Test("namespace std { struct vector; }");
+EXPECT_THAT(locateSymbol(Test.findDecl("vector")),
+ElementsAre(HintedSymbol(
+*tooling::stdlib::Symbol::named("std::", "vector"),
+Hints::CompleteSymbol)));
+  }
+  {
+// macros are always complete.
+LocateExample Test("#define ^FOO");
+EXPECT_THAT(locateSymbol(Test.findMacro("FOO")),
+ElementsAre(HintedSymbol(Test.points().front(),
+ Hints::CompleteSymbol)));
+  }
+  {
+// Completeness is only absent in cases that matters.
+const llvm::StringLiteral Cases[] = {
+"struct ^foo; struct ^foo {};",
+"template  struct ^foo; template  struct ^foo {};",
+"template  void ^foo(); template  void ^foo() {};",
+};
+for (auto &Case : Cases) {
+  SCOPED_TRACE(Case);
+  LocateExample Test(Case);
+  EXPECT_THAT(locateSymbol(Test.findDecl("foo")),
+  ElementsAre(HintedSymbol(Test.points().front(), Hints::None),
+  HintedSymbol(Test.points().back(),
+   Hints::CompleteSymbol)));
+}
+  }
+  {
+// All declarations should be marked as complete in cases that a definition
+// is not usually needed.
+const llvm::StringLiteral Cases[] = {
+"void foo(); void foo() {}",
+"extern int foo; int foo;",
+};
+for (auto &Case : Cases) {
+  SCOPED_TRACE(Case);
+  LocateExample Test(Case);
+  EXPECT_THAT(locateSymbol(Test.findDecl("foo")),
+  Each(Field(&Hinted::Hint,
+ Eq(Hints::CompleteSymbol;
+}
+  }
+}
+
 } // namespace
 } // namespace clang::include_cleaner
Index: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
@@ -7,7 +7,7 @@
 //===--===//
 
 #include "AnalysisInternal.h"
-#include "clang-include-cleaner/Analysis.h"
+#include "TypesInternal.h"
 #include "clang-include-cle

[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-23 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In D141581#4072692 , @kwk wrote:

> In D141581#4071617 , @thesamesam 
> wrote:
>
>> This is currently holding back further testing on our end which is 
>> concerning me a bit, especially as we approach the branch point. Could you 
>> revert this please if a fix isn't imminent? Thank you!
>
> @thesamesam what do you mean with "revert"? Just by looking at this 
> differential I cannot see that this patch has landed. Has it?

He was referring to reverting ac1ffd3caca12c254e0b8c847aa8ce8e51b6cfbf 
, i.e. the 
change that introduced the problem. However, FWICS reverting it is non-trivial 
and will probably cause quite a mess.

So, well, we're stuck for two weeks now being unable to test new LLVM versions, 
the branching point is approaching fast and it's quite likely we'll have to put 
a lot of effort afterwards to fix everything and request backporting our fixes 
to 16.x.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D141925: [ASTMatchers] Add `isDirectInit` matcher.

2023-01-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

You also need to add the new matcher to Registry.cpp so it's usable from the 
dynamic matchers, and you should add a release note for the new matcher.

Are you planning to use this matcher in-tree for something? (We don't usually 
add new matchers until there's a need for them given how expensive AST matchers 
are on compile times.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141925

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


[clang-tools-extra] 749c6a7 - [include-cleaner] Ranking of providers based on hints

2023-01-23 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2023-01-23T15:22:47+01:00
New Revision: 749c6a708340f772f72e1d33594cdb51bb28e190

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

LOG: [include-cleaner] Ranking of providers based on hints

Introduce signals to rank providers of a symbol.

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

Added: 
clang-tools-extra/include-cleaner/lib/TypesInternal.h

Modified: 
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
clang-tools-extra/include-cleaner/lib/Analysis.cpp
clang-tools-extra/include-cleaner/lib/AnalysisInternal.h
clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
clang-tools-extra/include-cleaner/lib/HTMLReport.cpp
clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp
clang-tools-extra/include-cleaner/lib/Types.cpp
clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
clang-tools-extra/include-cleaner/unittests/LocateSymbolTest.cpp

Removed: 




diff  --git 
a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h 
b/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
index 102f5bc21a84c..05cb96ebec1ff 100644
--- a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
+++ b/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
@@ -29,6 +29,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include 
+#include 
 #include 
 
 namespace llvm {
@@ -71,7 +72,11 @@ struct Symbol {
   // Order must match Kind enum!
   std::variant Storage;
 
-  Symbol(decltype(Storage) Sentinel) : Storage(std::move(Sentinel)) {}
+  // Disambiguation tag to make sure we can call the right constructor from
+  // DenseMapInfo methods.
+  struct SentinelTag {};
+  Symbol(SentinelTag, decltype(Storage) Sentinel)
+  : Storage(std::move(Sentinel)) {}
   friend llvm::DenseMapInfo;
 };
 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Symbol &);
@@ -117,6 +122,7 @@ struct Header {
 
   Kind kind() const { return static_cast(Storage.index()); }
   bool operator==(const Header &RHS) const { return Storage == RHS.Storage; }
+  bool operator<(const Header &RHS) const;
 
   const FileEntry *physical() const { return std::get(Storage); }
   tooling::stdlib::Header standard() const {
@@ -127,6 +133,13 @@ struct Header {
 private:
   // Order must match Kind enum!
   std::variant Storage;
+
+  // Disambiguation tag to make sure we can call the right constructor from
+  // DenseMapInfo methods.
+  struct SentinelTag {};
+  Header(SentinelTag, decltype(Storage) Sentinel)
+  : Storage(std::move(Sentinel)) {}
+  friend llvm::DenseMapInfo;
 };
 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Header &);
 
@@ -178,8 +191,12 @@ template <> struct 
DenseMapInfo {
   using Outer = clang::include_cleaner::Symbol;
   using Base = DenseMapInfo;
 
-  static inline Outer getEmptyKey() { return {Base::getEmptyKey()}; }
-  static inline Outer getTombstoneKey() { return {Base::getTombstoneKey()}; }
+  static inline Outer getEmptyKey() {
+return {Outer::SentinelTag{}, Base::getEmptyKey()};
+  }
+  static inline Outer getTombstoneKey() {
+return {Outer::SentinelTag{}, Base::getTombstoneKey()};
+  }
   static unsigned getHashValue(const Outer &Val) {
 return Base::getHashValue(Val.Storage);
   }
@@ -202,6 +219,23 @@ template <> struct 
DenseMapInfo {
 return Base::isEqual(LHS.Definition, RHS.Definition);
   }
 };
+template <> struct DenseMapInfo {
+  using Outer = clang::include_cleaner::Header;
+  using Base = DenseMapInfo;
+
+  static inline Outer getEmptyKey() {
+return {Outer::SentinelTag{}, Base::getEmptyKey()};
+  }
+  static inline Outer getTombstoneKey() {
+return {Outer::SentinelTag{}, Base::getTombstoneKey()};
+  }
+  static unsigned getHashValue(const Outer &Val) {
+return Base::getHashValue(Val.Storage);
+  }
+  static bool isEqual(const Outer &LHS, const Outer &RHS) {
+return Base::isEqual(LHS.Storage, RHS.Storage);
+  }
+};
 } // namespace llvm
 
 #endif

diff  --git a/clang-tools-extra/include-cleaner/lib/Analysis.cpp 
b/clang-tools-extra/include-cleaner/lib/Analysis.cpp
index 1c7ac33cfa080..c5559db57e14c 100644
--- a/clang-tools-extra/include-cleaner/lib/Analysis.cpp
+++ b/clang-tools-extra/include-cleaner/lib/Analysis.cpp
@@ -12,29 +12,19 @@
 #include "clang-include-cleaner/Types.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Format/Format.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Tooling/Core/Replacement.h"
-#include "clang/Tooling/Inclusions/HeaderIncludes.h"
 #include "clang

[PATCH] D142346: [docs] Add release notes for news in 16.x done by me, or otherwise relating to MinGW targets

2023-01-23 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.



Comment at: lld/docs/ReleaseNotes.rst:78
+  if ``-static`` has been specified. This fixes conformance to what
+  GNU ld dpes. (`D135651 `_)
+

`s/dpes/does/`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142346

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


[PATCH] D141925: [ASTMatchers] Add `isDirectInit` matcher.

2023-01-23 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.

In D141925#4073385 , @aaron.ballman 
wrote:

> You also need to add the new matcher to Registry.cpp so it's usable from the 
> dynamic matchers, and you should add a release note for the new matcher.

Thanks, will do.

> (We don't usually add new matchers until there's a need for them given how 
> expensive AST matchers are on compile times.)

Ah, that's too bad.

> Are you planning to use this matcher in-tree for something?

I was going to use it out-of-tree but figured it's a nice thing to have as many 
matchers as possible available for common use. There's also always the use case 
of people using clang-query (typically through godbolt).

I can live with the matcher being out-of-tree though, so you decide :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141925

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


[PATCH] D140619: ExtractFunction: support extracting expressions and selected part of it

2023-01-23 Thread Kacper Kowalski via Phabricator via cfe-commits
KKoovalsky updated this revision to Diff 491347.
KKoovalsky added a comment.

Fixed nullptr dereferencing and missing ASTMatchers lib linking

1. Fixed lit fail: dereferencing a null pointer when calling ignoreImplicit() 
on CommonAncestor being nullptr - fixed with sanitization of CommonAncestor 
being nullptr.
2. Fixed link error: missing ASTMatchers lib.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140619

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/tool/CMakeLists.txt
  clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
@@ -24,8 +24,6 @@
 
   // Root statements should have common parent.
   EXPECT_EQ(apply("for(;;) [[1+2; 1+2;]]"), "unavailable");
-  // Expressions aren't extracted.
-  EXPECT_EQ(apply("int x = 0; [[x++;]]"), "unavailable");
   // We don't support extraction from lambdas.
   EXPECT_EQ(apply("auto lam = [](){ [[int x;]] }; "), "unavailable");
   // Partial statements aren't extracted.
@@ -190,6 +188,16 @@
 }]]
   )cpp";
   EXPECT_EQ(apply(CompoundFailInput), "unavailable");
+
+  std::string CompoundWithMultipleStatementsFailInput = R"cpp(
+void f() [[{
+  int a = 1;
+  int b = 2;
+  ++b;
+  b += a;
+}]]
+  )cpp";
+  EXPECT_EQ(apply(CompoundWithMultipleStatementsFailInput), "unavailable");
 }
 
 TEST_F(ExtractFunctionTest, DifferentHeaderSourceTest) {
@@ -571,6 +579,795 @@
   EXPECT_EQ(apply(Before), After);
 }
 
+TEST_F(ExtractFunctionTest, Expressions) {
+  std::vector> InputOutputs{
+  // FULL BINARY EXPRESSIONS
+  // Full binary expression, basic maths
+  {R"cpp(
+void wrapperFun() {
+  double a{2.0}, b{3.2}, c{31.55};
+  double v{[[b * b - 4 * a * c]]};
+}
+  )cpp",
+   R"cpp(
+double extracted(double &a, double &b, double &c) {
+return b * b - 4 * a * c;
+}
+void wrapperFun() {
+  double a{2.0}, b{3.2}, c{31.55};
+  double v{extracted(a, b, c)};
+}
+  )cpp"},
+  // Full binary expression composed of '+' operator overloads ops
+  {
+  R"cpp(
+struct S {
+  S operator+(const S&) {
+return *this;
+  }
+};
+void wrapperFun() {
+  S S1, S2, S3;
+  auto R{[[S1 + S2 + S3]]};
+}
+  )cpp",
+  R"cpp(
+struct S {
+  S operator+(const S&) {
+return *this;
+  }
+};
+S extracted(S &S1, S &S2, S &S3) {
+return S1 + S2 + S3;
+}
+void wrapperFun() {
+  S S1, S2, S3;
+  auto R{extracted(S1, S2, S3)};
+}
+  )cpp"},
+  // Boolean predicate as expression
+  {
+  R"cpp(
+void wrapperFun() {
+  int a{1};
+  auto R{[[a > 1]]};
+}
+  )cpp",
+  R"cpp(
+bool extracted(int &a) {
+return a > 1;
+}
+void wrapperFun() {
+  int a{1};
+  auto R{extracted(a)};
+}
+  )cpp"},
+  // Expression: captures no global variable
+  {R"cpp(
+static int a{2};
+void wrapperFun() {
+  int b{3}, c{31}, d{311};
+  auto v{[[a + b + c + d]]};
+}
+  )cpp",
+   R"cpp(
+static int a{2};
+int extracted(int &b, int &c, int &d) {
+return a + b + c + d;
+}
+void wrapperFun() {
+  int b{3}, c{31}, d{311};
+  auto v{extracted(b, c, d)};
+}
+  )cpp"},
+  // Full expr: infers return type of call returning by ref
+  {
+  R"cpp(
+struct S {
+  S& operator+(const S&) {
+return *this;
+  }
+};
+void wrapperFun() {
+  S S1, S2, S3;
+  auto R{[[S1 + S2 + S3]]};
+}
+  )cpp",
+  R"cpp(
+struct S {
+  S& operator+(const S&) {
+return *this;
+  }
+};
+S & extracted(S &S1, S &S2, S &S3) {
+return S1 + S2 + S3;
+}
+void wrapperFun() {
+  S S1, S2, S3;
+  auto R{extracted(S1, S2, S3)};
+}
+  )cpp"},
+  // Full expr: infers return type of call returning by const-ref
+  {
+  R"cpp(
+struct S {
+  const S& operator+(const S&) const {
+return *this;
+  }
+};
+void wrapperFun() {
+  S S1, S2, S3;
+  auto R{[[S1 + S2 + S3]]};
+}
+  )cpp",
+  R"cpp(
+struct S {
+  const S& operator+(const S&) const {
+return *this;
+  }
+};
+const S & extracted(S &S1, S &S2, S &S3) {
+return S1 + S2 + S3;
+}
+void wrapperFun() {
+  S S1, S2, S3;
+  auto R{extracted(S1, S2, S3)};
+}
+  )cpp"},
+  // Captures deeply nested arguments
+  {
+  R"cpp(
+int fw(int a) { return a; };
+int add(int a, int b) { return a + b; }
+void wrapper() {
+int a{0}, b{1}, c{2}, d{3}, e{4}, f{5};
+int r{[[fw(fw(fw(a))) + fw(fw(add(b, c))) + fw(fw(fw(add(d, e + fw(fw(f))]]};
+}
+  )cpp",
+  R"cpp(
+int fw(int a) { return a; };
+int add(int a, int b) { return a + b; }
+int extracted(int &a, int &b, int &c, int &d, int &e, int &f) {
+return fw(fw(fw(a))) + fw(fw(add(b, c))) + fw(fw(fw(add(d, e + fw(fw(f));
+}

[PATCH] D142265: [AArch64] Function multi-versioning release notes added. NFC.

2023-01-23 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss accepted this revision.
danielkiss 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/D142265/new/

https://reviews.llvm.org/D142265

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


[clang] 7ac7763 - Fix MSVC "not all control paths return a value" warning. NFC.

2023-01-23 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2023-01-23T14:13:09Z
New Revision: 7ac776310a1e3016f6aafc7c9aac6c0c9274a513

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

LOG: Fix MSVC "not all control paths return a value" warning. NFC.

Added: 


Modified: 
clang/lib/Basic/Builtins.cpp

Removed: 




diff  --git a/clang/lib/Basic/Builtins.cpp b/clang/lib/Basic/Builtins.cpp
index 2c1c09e38e03..df0fcf23b35f 100644
--- a/clang/lib/Basic/Builtins.cpp
+++ b/clang/lib/Basic/Builtins.cpp
@@ -26,6 +26,7 @@ const char *HeaderDesc::getName() const {
 #include "clang/Basic/BuiltinHeaders.def"
 #undef HEADER
   };
+  llvm_unreachable("Unknown HeaderDesc::HeaderID enum");
 }
 
 static constexpr Builtin::Info BuiltinInfo[] = {



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


[PATCH] D141925: [ASTMatchers] Add `isDirectInit` matcher.

2023-01-23 Thread Clement Courbet via Phabricator via cfe-commits
courbet updated this revision to Diff 491348.
courbet added a comment.

add matcher to registry and add release note


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141925

Files:
  clang/docs/LibASTMatchersReference.html
  clang/docs/ReleaseNotes.rst
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1439,6 +1439,20 @@
   EXPECT_TRUE(notMatches("int X;", M));
 }
 
+TEST_P(ASTMatchersTest, IsDirectInit) {
+  auto M = varDecl(isDirectInit());
+  EXPECT_TRUE(notMatches("int i1 = 3;", M));
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(matches("int i2(3);", M));
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
+  EXPECT_TRUE(matches("int i3{3};", M));
+  EXPECT_TRUE(notMatches("int i4;", M));
+}
+
 TEST_P(ASTMatchersTest, StorageDuration) {
   StringRef T =
   "void f() { int x; static int y; } int a;static int b;extern int c;";
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -391,6 +391,7 @@
   REGISTER_MATCHER(isDefinition);
   REGISTER_MATCHER(isDelegatingConstructor);
   REGISTER_MATCHER(isDeleted);
+  REGISTER_MATCHER(isDirectInit);
   REGISTER_MATCHER(isEnum);
   REGISTER_MATCHER(isExceptionVariable);
   REGISTER_MATCHER(isExpandedFromMacro);
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4114,6 +4114,22 @@
   InnerMatcher.matches(*Initializer, Finder, Builder));
 }
 
+/// \brief Matches a variable initializer that is a direct-initializer.
+///
+/// Example matches i2 and i2, but not i1 or i4
+/// (matcher = varDecl(isStaticLocal()))
+/// \code
+/// void f() {
+///   int i1 = 3;
+///   int i2(3);
+///   int i3{3};
+///   int i4;
+/// }
+/// \endcode
+AST_MATCHER(VarDecl, isDirectInit) {
+  return Node.isDirectInit();
+}
+
 /// \brief Matches a static variable with local scope.
 ///
 /// Example matches y (matcher = varDecl(isStaticLocal()))
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -156,7 +156,8 @@
 AST Matchers
 
 
-- ...
+- `isDirectInit` matches variables that are direct-initialized (`int i2(3);`,
+  but not `int i1 = 3;`).
 
 clang-format
 
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -5446,6 +5446,20 @@
 
 
 
+MatcherVarDecl>isDirectInit
+Matches a variable initializer that is a direct-initializer.
+
+Example matches i2 and i2, but not i1 or i4
+(matcher = varDecl(isStaticLocal()))
+void f() {
+  int i1 = 3;
+  int i2(3);
+  int i3{3};
+  int i4;
+}
+
+
+
 MatcherVarDecl>isExceptionVariable
 Matches a variable declaration that is an exception variable from
 a C++ catch block, or an Objective-C statement.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137944: [ObjC][ARC] Teach the OptimizeSequences step of ObjCARCOpts about WinEH funclet tokens

2023-01-23 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision.
ahatanak added a comment.
This revision is now accepted and ready to land.

I'm not familiar with the WinEH stuff, but the other parts (the code that adds 
bundles, etc.) LGTM.




Comment at: llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp:597
+  assert(CV.size() > 0 && "Uncolored block");
+  for (BasicBlock *EHPadBB : CV)
+if (auto *EHPad = dyn_cast(EHPadBB->getFirstNonPHI())) 
{

This piece of code does something similar to `cloneCallInstForBB`, but it's 
slightly different from it. It iterates over the entries in `CV` whereas the 
code above just looks at the first entry. 

Is this a bug that is fixed in https://reviews.llvm.org/D137945?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137944

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


[PATCH] D141925: [ASTMatchers] Add `isDirectInit` matcher.

2023-01-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D141925#4073405 , @courbet wrote:

> In D141925#4073385 , @aaron.ballman 
> wrote:
>
>> You also need to add the new matcher to Registry.cpp so it's usable from the 
>> dynamic matchers, and you should add a release note for the new matcher.
>
> Thanks, will do.
>
>> (We don't usually add new matchers until there's a need for them given how 
>> expensive AST matchers are on compile times.)
>
> Ah, that's too bad.
>
>> Are you planning to use this matcher in-tree for something?
>
> I was going to use it out-of-tree but figured it's a nice thing to have as 
> many matchers as possible available for common use. There's also always the 
> use case of people using clang-query (typically through godbolt).
>
> I can live with the matcher being out-of-tree though, so you decide :)

I'd say let's leave it off for now -- if we find an in-tree need at some point, 
we can definitely add it then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141925

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


[PATCH] D142334: [Clang[NFC] Fix bitmask for NullabilityPayload in Types.h

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142334

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


[PATCH] D141824: [clang-repl] Add a command to load dynamic libraries

2023-01-23 Thread Stefan Gränitz via Phabricator via cfe-commits
sgraenitz added a comment.

Thanks for working on this! It looks like this is going to be the clang-repl 
equivalent for Cling's `.L` command. Do you think we can get test coverage for 
it?

So far, the only tests I found for `libclangInterpreter` are unit tests in 
https://github.com/llvm/llvm-project/tree/main/clang/unittests/Interpreter -- 
e.g. there is a test for the `%undo` command. I guess the `%lib` command would 
be a good candidate for a LIT test, because it requires a dynamic library to 
load from disk. The tests for `.L` in Cling may give you a hint on how this 
could look like: 
https://github.com/root-project/cling/tree/master/test/LibraryCall




Comment at: clang/include/clang/Interpreter/Interpreter.h:62
   const CompilerInstance *getCompilerInstance() const;
-  const llvm::orc::LLJIT *getExecutionEngine() const;
+  llvm::Expected GetExecutionEngine();
+

Do we really want these functions capitalized? IIRC in the clang code-base they 
are used to highlight core API functions. It looks like these two functions are 
only used as helpers inside `Interpreter` itself.



Comment at: clang/include/clang/Interpreter/Interpreter.h:78
 
+  /// Link a dyanmic library
+  llvm::Error LoadDynamicLibrary(const char *name);

Typo `dynamic`



Comment at: clang/lib/Interpreter/Interpreter.cpp:223
 
+llvm::Error Interpreter::CreateExecutor() {
+  const clang::TargetInfo &TI =

Factoring out this function looks like an independent change. Is it related to 
the load-library command in any way?



Comment at: clang/tools/clang-repl/ClangRepl.cpp:126
   }
+  if (Line->rfind(R"(%lib )", 0) == 0) {
+if (auto Err = Interp->LoadDynamicLibrary(Line->data() + 5)) {

I see this is analog to existing code, but is there a good reason for using the 
multi-line string syntax here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141824

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


[PATCH] D142358: Opting out of Clang 15 ABI Changes for AIX and z/OS

2023-01-23 Thread Nicole Rabjohn via Phabricator via cfe-commits
nicolerabjohn created this revision.
nicolerabjohn added reviewers: hubert.reinterpretcast, cebowleratibm, daltenty, 
dblaikie.
Herald added a project: All.
nicolerabjohn requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

There is already a GCC compatibility gap on AIX, & GCC compatibility is not a 
concern on z/OS. GCC compatibility is not sufficient motivation for breaking 
ABI on AIX and z/OS. This opts out of changes introduced in 
https://reviews.llvm.org/D119051.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142358

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/SemaCXX/class-layout.cpp


Index: clang/test/SemaCXX/class-layout.cpp
===
--- clang/test/SemaCXX/class-layout.cpp
+++ clang/test/SemaCXX/class-layout.cpp
@@ -9,6 +9,8 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
 // expected-no-diagnostics
 
+#if !defined(__MVS__) && !defined(_AIX)
+
 #define SA(n, p) int a##n[(p) ? 1 : -1]
 
 struct A {
@@ -611,6 +613,9 @@
 #pragma pack(pop)
 }
 
+// This ends the #if !defined(__MVS__) && !defined(__AIX__) block from line 12 
+#endif
+
 namespace non_pod {
 struct t1 {
 protected:
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -773,6 +773,10 @@
   }
 
   bool defaultsToAIXPowerAlignment() const override { return true; }
+
+  bool areDefaultedSMFStillPOD(const LangOptions &) const override {
+return false;
+  }
 };
 
 // z/OS target
@@ -831,6 +835,10 @@
 this->UseLeadingZeroLengthBitfield = false;
 this->ZeroLengthBitfieldBoundary = 32;
   }
+
+  bool areDefaultedSMFStillPOD(const LangOptions &) const override {
+return false;
+  }
 };
 
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -819,7 +819,7 @@
   ``-fclang-abi-compat=15.0``.
 - GCC allows POD types to have defaulted special members. Clang historically
   classified such types as non-POD (for the purposes of Itanium ABI). Clang now
-  matches the gcc behavior (except on Darwin and PS4). You can switch back to
+  matches the gcc behavior (except on Darwin, PS4, AIX and z/OS). You can 
switch back to
   the old ABI behavior with the flag: ``-fclang-abi-compat=15.0``.
 
 OpenMP Support in Clang


Index: clang/test/SemaCXX/class-layout.cpp
===
--- clang/test/SemaCXX/class-layout.cpp
+++ clang/test/SemaCXX/class-layout.cpp
@@ -9,6 +9,8 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
 // expected-no-diagnostics
 
+#if !defined(__MVS__) && !defined(_AIX)
+
 #define SA(n, p) int a##n[(p) ? 1 : -1]
 
 struct A {
@@ -611,6 +613,9 @@
 #pragma pack(pop)
 }
 
+// This ends the #if !defined(__MVS__) && !defined(__AIX__) block from line 12 
+#endif
+
 namespace non_pod {
 struct t1 {
 protected:
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -773,6 +773,10 @@
   }
 
   bool defaultsToAIXPowerAlignment() const override { return true; }
+
+  bool areDefaultedSMFStillPOD(const LangOptions &) const override {
+return false;
+  }
 };
 
 // z/OS target
@@ -831,6 +835,10 @@
 this->UseLeadingZeroLengthBitfield = false;
 this->ZeroLengthBitfieldBoundary = 32;
   }
+
+  bool areDefaultedSMFStillPOD(const LangOptions &) const override {
+return false;
+  }
 };
 
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -819,7 +819,7 @@
   ``-fclang-abi-compat=15.0``.
 - GCC allows POD types to have defaulted special members. Clang historically
   classified such types as non-POD (for the purposes of Itanium ABI). Clang now
-  matches the gcc behavior (except on Darwin and PS4). You can switch back to
+  matches the gcc behavior (except on Darwin, PS4, AIX and z/OS). You can switch back to
   the old ABI behavior with the flag: ``-fclang-abi-compat=15.0``.
 
 OpenMP Support in Clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142315: [clang] Add test for CWG1111

2023-01-23 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/test/CXX/drs/dr11xx.cpp:31
+  }
+}
+

Can you also add the last example (with struct A) from the issue, and find a 
way to confirm that it is calling the right version?



Comment at: clang/www/cxx_dr_status.html:6476
 Remove dual-scope lookup of member template names
-Unknown
+Clang 6
   

Were you able to track down which patch fixed this in clang 6?

I also don't think we can mark this as 'full' support, if its still broken in 
C++98.  Unless we can find a good reason this wasn't/wont be done for C++98 as 
well, I don't know if we can mark this as 'done'.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142315

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


[PATCH] D139010: [clang][WebAssembly] Implement support for table types and builtins

2023-01-23 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 491353.
pmatos marked 7 inline comments as done.
pmatos added a comment.

Address more comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139010

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/TypeBitCodes.def
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGValue.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/WebAssembly/builtins-table.c
  clang/test/CodeGen/WebAssembly/table.c
  clang/test/Sema/builtins-wasm.c
  clang/test/Sema/wasm-refs.c
  clang/test/SemaCXX/wasm-refs-and-tables.cpp
  clang/test/SemaCXX/wasm-refs.cpp
  llvm/include/llvm/CodeGen/WasmAddressSpaces.h
  llvm/include/llvm/IR/Type.h
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp

Index: llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
@@ -62,8 +62,9 @@
   for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
 PtrToIntInst *PTI = dyn_cast(&*I);
 IntToPtrInst *ITP = dyn_cast(&*I);
-if (!(PTI && WebAssembly::isRefType(PTI->getPointerOperand()->getType())) &&
-!(ITP && WebAssembly::isRefType(ITP->getDestTy(
+if (!(PTI &&
+  PTI->getPointerOperand()->getType()->isWebAssemblyReferenceType()) &&
+!(ITP && ITP->getDestTy()->isWebAssemblyReferenceType()))
   continue;
 
 UndefValue *U = UndefValue::get(I->getType());
Index: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -1202,7 +1202,7 @@
   // Lastly, if this is a call to a funcref we need to add an instruction
   // table.set to the chain and transform the call.
   if (CLI.CB &&
-  WebAssembly::isFuncrefType(CLI.CB->getCalledOperand()->getType())) {
+  CLI.CB->getCalledOperand()->getType()->isWebAssemblyFuncrefType()) {
 // In the absence of function references proposal where a funcref call is
 // lowered to call_ref, using reference types we generate a table.set to set
 // the funcref to a special table used solely for this purpose, followed by
Index: llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
===
--- llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
+++ llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
@@ -45,43 +45,6 @@
   Multivalue = 0x,
 };
 
-enum WasmAddressSpace : unsigned {
-  // Default address space, for pointers to linear memory (stack, heap, data).
-  WASM_ADDRESS_SPACE_DEFAULT = 0,
-  // A non-integral address space for pointers to named objects outside of
-  // linear memory: WebAssembly globals or WebAssembly locals.  Loads and stores
-  // to these pointers are lowered to global.get / global.set or local.get /
-  // local.set, as appropriate.
-  WASM_ADDRESS_SPACE_VAR = 1,
-  // A non-integral address space for externref values
-  WASM_ADDRESS_SPACE_EXTERNREF = 10,
-  // A non-integral address space for funcref values
-  WASM_ADDRESS_SPACE_FUNCREF = 20,
-};
-
-inline bool isDefaultAddressSpace(unsigned AS) {
-  return AS == WASM_ADDRESS_SPACE_DEFAULT;
-}
-inline bool isWasmVarAddressSpace(unsigned AS) {
-  return AS == WASM_ADDRESS_SPACE_VAR;
-}
-inline bool isValidAddressSpace(unsigned AS) {
-  return isDefaultAddressSpace(AS) || isWasmVarAddressSpace(AS);
-}
-inline bool isFuncrefType(const Type *Ty) {
-  return isa(Ty) &&
- Ty->getPointerAddressSpace() ==
- WasmAddressSpace::WASM_ADDRESS_SPACE_FUNCREF;
-}
-inline bool isExternrefType(const Type *Ty) {
-  return isa(Ty) &&
- Ty->getPointerAddressSpace() ==
- WasmAddressSpace::WASM_ADDRESS_SPACE_EXTE

[PATCH] D142334: [Clang[NFC] Fix bitmask for NullabilityPayload in Types.h

2023-01-23 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
xgupta marked an inline comment as done.
Closed by commit rG68b890831615: [Clang[NFC] Fix bitmask for NullabilityPayload 
in Types.h (authored by xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142334

Files:
  clang/include/clang/APINotes/Types.h


Index: clang/include/clang/APINotes/Types.h
===
--- clang/include/clang/APINotes/Types.h
+++ clang/include/clang/APINotes/Types.h
@@ -482,7 +482,7 @@
 /// API notes for a function or method.
 class FunctionInfo : public CommonEntityInfo {
 private:
-  static constexpr const unsigned NullabilityKindMask = 0x3;
+  static constexpr const uint64_t NullabilityKindMask = 0x3;
   static constexpr const unsigned NullabilityKindSize = 2;
 
   static constexpr const unsigned ReturnInfoIndex = 0;


Index: clang/include/clang/APINotes/Types.h
===
--- clang/include/clang/APINotes/Types.h
+++ clang/include/clang/APINotes/Types.h
@@ -482,7 +482,7 @@
 /// API notes for a function or method.
 class FunctionInfo : public CommonEntityInfo {
 private:
-  static constexpr const unsigned NullabilityKindMask = 0x3;
+  static constexpr const uint64_t NullabilityKindMask = 0x3;
   static constexpr const unsigned NullabilityKindSize = 2;
 
   static constexpr const unsigned ReturnInfoIndex = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 68b8908 - [Clang[NFC] Fix bitmask for NullabilityPayload in Types.h

2023-01-23 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-01-23T20:18:08+05:30
New Revision: 68b890831615fc4350a47cf7ec404156128d03ac

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

LOG: [Clang[NFC] Fix bitmask for NullabilityPayload in Types.h

Found by PVS-Studio - https://pvs-studio.com/en/blog/posts/cpp/1003/, N37.

The code you is using the bit mask NullabilityKindMask which is 0x3
(0011 in binary) to clear the bits in the NullabilityPayload variable.
Since NullabilityPayload is a 64-bit variable and NullabilityKindMask is
only a 8-bit variable(0x3), it will only affect the last 8 bits of the
variable. The higher 56 bits will remain unchanged.

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

Added: 


Modified: 
clang/include/clang/APINotes/Types.h

Removed: 




diff  --git a/clang/include/clang/APINotes/Types.h 
b/clang/include/clang/APINotes/Types.h
index af5f05bc0d365..61f3592ea145b 100644
--- a/clang/include/clang/APINotes/Types.h
+++ b/clang/include/clang/APINotes/Types.h
@@ -482,7 +482,7 @@ inline bool operator!=(const ParamInfo &LHS, const 
ParamInfo &RHS) {
 /// API notes for a function or method.
 class FunctionInfo : public CommonEntityInfo {
 private:
-  static constexpr const unsigned NullabilityKindMask = 0x3;
+  static constexpr const uint64_t NullabilityKindMask = 0x3;
   static constexpr const unsigned NullabilityKindSize = 2;
 
   static constexpr const unsigned ReturnInfoIndex = 0;



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


[PATCH] D142315: [clang] Add test for CWG1111

2023-01-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/www/cxx_dr_status.html:6476
 Remove dual-scope lookup of member template names
-Unknown
+Clang 6
   

erichkeane wrote:
> Were you able to track down which patch fixed this in clang 6?
> 
> I also don't think we can mark this as 'full' support, if its still broken in 
> C++98.  Unless we can find a good reason this wasn't/wont be done for C++98 
> as well, I don't know if we can mark this as 'done'.
We can mark it as `partial` and put the reason in the details. I'm not certain 
if the python script has a way to do that easily or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142315

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


[PATCH] D138802: [clang][Interp] Implement DecompositionDecls

2023-01-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:34-35
 
+  virtual ~DeclScope() override { this->emitDestruction(); }
+
   void addExtended(const Scope::Local &Local) override {

The destructor for `LocalScope` already calls `emitDestruction()` which is a 
virtual function, so is this necessary?



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:1370-1372
+BD && BD->getDecomposedDecl()->getType()->isReferenceType()) {
+  VarT = PT_Ptr;
+}





Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:1386-1389
+if (Init && Init->isLValue() && *VarT != PT_Ptr) {
+  if (!this->emitLoadPop(*VarT, VD))
+return false;
+}





Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:1417-1418
+  assert(!BD->getHoldingVar()); // FIXME
+  if (!this->allocateVariable(BD, BD->getBinding()))
+return false;
+}

Is this correct? IIRC, the decomposition declaration is its own 
object, but the bindings themselves are references back to the decomposition 
declaration object directly and so they're not distinct objects themselves 
(they're more like aliases).


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

https://reviews.llvm.org/D138802

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


[PATCH] D142304: [Clang] Fix a Wbitfield-enum-conversion warning in DirectoryLookup.h

2023-01-23 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 but can you find a test case that would show we don't regress this in the 
future?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142304

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


[PATCH] D140222: [AArch64] Check 128-bit Sysreg Builtins

2023-01-23 Thread Sam Elliott via Phabricator via cfe-commits
lenary added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:8297
  << Arg->getSourceRange();
   } else if (IsAArch64Builtin && Fields.size() == 1) {
+// If this is a write ...

tmatheson wrote:
> It might be more readable to outline this whole branch and remove the 
> redundant "else".
Sorry, this is not done, but I'm not sure that fundamentally helps this very 
long function doing too many different things be more readable. I'm going to 
land this today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140222

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


[PATCH] D142092: [include-mapping] Allow multiple headers for the same symbol. Choose the first header of available ones.

2023-01-23 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 491367.
VitaNuo added a comment.

Re-introduce the special std::remove handling for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

Files:
  clang/include/clang/Tooling/Inclusions/CSymbolMap.inc
  clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc
  clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
  clang/tools/include-mapping/cppreference_parser.py
  clang/tools/include-mapping/gen_std.py

Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -14,10 +14,7 @@
 The generated files are located in clang/include/Tooling/Inclusions.
 
 Caveats and FIXMEs:
-  - only symbols directly in "std" namespace are added, we should also add std's
-subnamespace symbols (e.g. chrono).
-  - symbols with multiple variants or defined in multiple headers aren't added,
-e.g. std::move, std::swap
+  - symbols with multiple variants aren't added, e.g., std::move
 
 Usage:
   1. Install BeautifulSoup dependency, see instruction:
@@ -110,17 +107,12 @@
 os.stat(index_page_path).st_mtime).strftime('%Y-%m-%d')
   print(CODE_PREFIX % (args.symbols.upper(), cppreference_modified_date))
   for symbol in symbols:
-if len(symbol.headers) == 1:
-  # SYMBOL(unqualified_name, namespace, header)
-  print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
-symbol.headers[0]))
-elif len(symbol.headers) == 0:
+if len(symbol.headers) == 0:
   sys.stderr.write("No header found for symbol %s\n" % symbol.name)
 else:
-  # FIXME: support symbols with multiple headers (e.g. std::move).
-  sys.stderr.write("Ambiguous header for symbol %s: %s\n" % (
-  symbol.name, ', '.join(symbol.headers)))
-
-
+  for header in symbol.headers:
+# SYMBOL(unqualified_name, namespace, header)
+print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
+  header))
 if __name__ == '__main__':
   main()
Index: clang/tools/include-mapping/cppreference_parser.py
===
--- clang/tools/include-mapping/cppreference_parser.py
+++ clang/tools/include-mapping/cppreference_parser.py
@@ -180,8 +180,7 @@
   initializer=lambda: signal.signal(signal.SIGINT, signal.SIG_IGN))
   try:
 for root_dir, page_name, namespace in parse_pages:
-  symbols.extend(_GetSymbols(pool, root_dir, page_name, namespace,
- variants_to_accept))
+  symbols.extend(_GetSymbols(pool, root_dir, page_name, namespace, variants_to_accept))
   finally:
 pool.terminate()
 pool.join()
Index: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
===
--- clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -8,6 +8,7 @@
 
 #include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "clang/AST/Decl.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 
@@ -16,8 +17,9 @@
 namespace stdlib {
 
 static llvm::StringRef *HeaderNames;
-static std::pair *SymbolNames;
-static unsigned *SymbolHeaderIDs;
+static llvm::DenseMap>
+*SymbolNames;
+static llvm::SmallVector *SymbolHeaderIDs;
 static llvm::DenseMap *HeaderIDs;
 // Maps symbol name -> Symbol::ID, within a namespace.
 using NSSymbolMap = llvm::DenseMap;
@@ -29,7 +31,7 @@
 #include "clang/Tooling/Inclusions/CSymbolMap.inc"
 #include "clang/Tooling/Inclusions/StdSymbolMap.inc"
 #undef SYMBOL
-  SymbolNames = new std::remove_reference_t[SymCount];
+  SymbolNames = new std::remove_reference_t;
   SymbolHeaderIDs =
   new std::remove_reference_t[SymCount];
   NamespaceSymbols = new std::remove_reference_t;
@@ -46,18 +48,31 @@
 return HeaderIDs->try_emplace(Header, HeaderIDs->size()).first->second;
   };
 
-  auto Add = [&, SymIndex(0)](llvm::StringRef Name, llvm::StringRef NS,
-  llvm::StringRef HeaderName) mutable {
+  auto Add = [&, NextAvailSymIndex(0)](llvm::StringRef Name, llvm::StringRef NS,
+   llvm::StringRef HeaderName) mutable {
 if (NS == "None")
   NS = "";
 
-SymbolNames[SymIndex] = {NS, Name};
-SymbolHeaderIDs[SymIndex] = AddHeader(HeaderName);
+bool IsNewSymbol = true;
+int SymIndex = NextAvailSymIndex;
+if (NSSymbolMap *NSSymbols = NamespaceSymbols->lookup(NS)) {
+  auto It = NSSymbols->find(Name);
+  if (It != NSSymbols->end()) {
+SymIndex = It->getSecond();
+IsNewSymbol = false;
+  }
+}
+
+SymbolNames->try_emplace(SymIndex, std::make_pair(NS, Name));
+
+unsigned HeaderID = AddHeader

[PATCH] D142092: [include-mapping] Allow multiple headers for the same symbol. Choose the first header of available ones.

2023-01-23 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo added inline comments.



Comment at: clang/tools/include-mapping/cppreference_parser.py:174
-  # std::remove<> has variant algorithm.
-  "std::remove": ("algorithm"),
-  }

kadircet wrote:
> this is actually checking for something else (sorry for the confusing naming).
> 
> the `variant` here refers to library name mentioned in parentheses (this is 
> same problem as `std::move`) on the std symbol index page 
> https://en.cppreference.com/w/cpp/symbol_index (e.g. `remove<>() 
> (algorithm)`). by getting rid of this we're introducing a regression, as 
> previously `std::remove` wouldn't be recognized by the library, but now it'll 
> be recognized and we'll keep suggesting `` for it.
> 
> so we should actually keep this around.
Ok, I can keep this out of this patch, but we'll have to remove this logic 
evetually when we deal with overloads.

I have a slight suspicion that this code might be buggy, because it suggests 
that one _of_ the variants should be accepted. What is does in reality, though, 
is it keeps `algorithm` in the list of headers suitable for `std::remove` 
alongside `cstdio`, and then in the last step `std::remove` is ignored by the 
generator because of being defined in two headers.

With this patch, the result will be both `{cstdio, algorithm}`. Is this (more) 
satisfactory for now compared to skipping `algorithm` due to being an overload?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

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


[clang] 03ef89f - [AArch64] Check 128-bit Sysreg Builtins

2023-01-23 Thread Archibald Elliott via cfe-commits

Author: Archibald Elliott
Date: 2023-01-23T15:24:30Z
New Revision: 03ef89f8d9094bf70416e19d0e909909b100a4a0

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

LOG: [AArch64] Check 128-bit Sysreg Builtins

This patch contains several related changes:

1. We move to using TARGET_BUILTIN for the 128-bit system register
   builtins to give better error messages when d128 has not been
   enabled, or has been enabled in a per-function manner.

2. We now validate the inputs to the 128-bit system register builtins,
   like we validate the other system register builtins.

3. We update the list of named PSTATE accessors for MSR (immediate), and
   now correctly enforce the expected ranges of the immediates. There is
   a long comment about how we chose to do this to comply with the ACLE
   when most of the PSTATE accessors for MSR (immediate) have aliased
   system registers for MRS/MSR which expect different values. In short,
   the MSR (immediate) names are prioritised, rather than falling-back
   to the register form when the value is out of range.

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

Added: 
clang/test/CodeGen/aarch64-sysregs-target.c

Modified: 
clang/include/clang/Basic/BuiltinsAArch64.def
clang/lib/Headers/arm_acle.h
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/aarch64-special-register.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAArch64.def 
b/clang/include/clang/Basic/BuiltinsAArch64.def
index 61e6a5186ed98..e6672a1702e94 100644
--- a/clang/include/clang/Basic/BuiltinsAArch64.def
+++ b/clang/include/clang/Basic/BuiltinsAArch64.def
@@ -82,11 +82,11 @@ BUILTIN(__builtin_arm_prefetch, "vvC*UiUiUiUi", "nc")
 // System Registers
 BUILTIN(__builtin_arm_rsr, "UicC*", "nc")
 BUILTIN(__builtin_arm_rsr64, "WUicC*", "nc")
-BUILTIN(__builtin_arm_rsr128, "LLLUicC*", "nc")
+TARGET_BUILTIN(__builtin_arm_rsr128, "LLLUicC*", "nc", "d128")
 BUILTIN(__builtin_arm_rsrp, "v*cC*", "nc")
 BUILTIN(__builtin_arm_wsr, "vcC*Ui", "nc")
 BUILTIN(__builtin_arm_wsr64, "vcC*WUi", "nc")
-BUILTIN(__builtin_arm_wsr128, "vcC*LLLUi", "nc")
+TARGET_BUILTIN(__builtin_arm_wsr128, "vcC*LLLUi", "nc", "d128")
 BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
 
 // MSVC

diff  --git a/clang/lib/Headers/arm_acle.h b/clang/lib/Headers/arm_acle.h
index 469f24eadaf33..e086f1f02dad0 100644
--- a/clang/lib/Headers/arm_acle.h
+++ b/clang/lib/Headers/arm_acle.h
@@ -712,17 +712,13 @@ __arm_st64bv0(void *__addr, data512_t __value) {
 /* 10.1 Special register intrinsics */
 #define __arm_rsr(sysreg) __builtin_arm_rsr(sysreg)
 #define __arm_rsr64(sysreg) __builtin_arm_rsr64(sysreg)
-#if __ARM_FEATURE_SYSREG128
 #define __arm_rsr128(sysreg) __builtin_arm_rsr128(sysreg)
-#endif
 #define __arm_rsrp(sysreg) __builtin_arm_rsrp(sysreg)
 #define __arm_rsrf(sysreg) __builtin_bit_cast(float, __arm_rsr(sysreg))
 #define __arm_rsrf64(sysreg) __builtin_bit_cast(double, __arm_rsr64(sysreg))
 #define __arm_wsr(sysreg, v) __builtin_arm_wsr(sysreg, v)
 #define __arm_wsr64(sysreg, v) __builtin_arm_wsr64(sysreg, v)
-#if __ARM_FEATURE_SYSREG128
 #define __arm_wsr128(sysreg, v) __builtin_arm_wsr128(sysreg, v)
-#endif
 #define __arm_wsrp(sysreg, v) __builtin_arm_wsrp(sysreg, v)
 #define __arm_wsrf(sysreg, v) __arm_wsr(sysreg, __builtin_bit_cast(uint32_t, 
v))
 #define __arm_wsrf64(sysreg, v) __arm_wsr64(sysreg, 
__builtin_bit_cast(uint64_t, v))

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 07325d56f3621..ea21171aaac62 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3292,7 +3292,9 @@ bool Sema::CheckAArch64BuiltinFunctionCall(const 
TargetInfo &TI,
   }
 
   if (BuiltinID == AArch64::BI__builtin_arm_rsr64 ||
-  BuiltinID == AArch64::BI__builtin_arm_wsr64)
+  BuiltinID == AArch64::BI__builtin_arm_wsr64 ||
+  BuiltinID == AArch64::BI__builtin_arm_rsr128 ||
+  BuiltinID == AArch64::BI__builtin_arm_wsr128)
 return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 5, true);
 
   // Memory Tagging Extensions (MTE) Intrinsics
@@ -8314,6 +8316,8 @@ bool Sema::SemaBuiltinARMSpecialReg(unsigned BuiltinID, 
CallExpr *TheCall,
   BuiltinID == ARM::BI__builtin_arm_wsrp;
   bool IsAArch64Builtin = BuiltinID == AArch64::BI__builtin_arm_rsr64 ||
   BuiltinID == AArch64::BI__builtin_arm_wsr64 ||
+  BuiltinID == AArch64::BI__builtin_arm_rsr128 ||
+  BuiltinID == AArch64::BI__builtin_arm_wsr128 ||
   BuiltinID == AArch64::BI__builtin_arm_rsr ||
   BuiltinID == AArch64::BI__builtin_arm_rsrp ||
   BuiltinID == AArch64::BI__builtin_arm_wsr ||
@@ -8381,21 +8385,51 @@ boo

[PATCH] D140222: [AArch64] Check 128-bit Sysreg Builtins

2023-01-23 Thread Sam Elliott 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 rG03ef89f8d909: [AArch64] Check 128-bit Sysreg Builtins 
(authored by lenary).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140222

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/Headers/arm_acle.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/aarch64-sysregs-target.c
  clang/test/Sema/aarch64-special-register.c

Index: clang/test/Sema/aarch64-special-register.c
===
--- clang/test/Sema/aarch64-special-register.c
+++ clang/test/Sema/aarch64-special-register.c
@@ -16,6 +16,10 @@
   __builtin_arm_wsr64("sysreg", v);
 }
 
+void wsr128_1(__uint128_t v) {
+  __builtin_arm_wsr128("sysreg", v);
+}
+
 unsigned rsr_1(void) {
   return __builtin_arm_rsr("sysreg");
 }
@@ -28,6 +32,10 @@
   return __builtin_arm_rsr64("sysreg");
 }
 
+__uint128_t rsr128_1(void) {
+  return __builtin_arm_rsr128("sysreg");
+}
+
 void wsr_2(unsigned v) {
   __builtin_arm_wsr("0:1:2:3:4", v);
 }
@@ -52,6 +60,10 @@
   return __builtin_arm_rsr64("0:1:15:15:4");
 }
 
+__uint128_t rsr128_2(void) {
+  return __builtin_arm_rsr128("0:1:15:15:4");
+}
+
 void wsr_3(unsigned v) {
   __builtin_arm_wsr("0:1:2", v); //expected-error {{invalid special register for builtin}}
 }
@@ -64,6 +76,10 @@
   __builtin_arm_wsr64("0:1:2", v); //expected-error {{invalid special register for builtin}}
 }
 
+void wsr128_3(__uint128_t v) {
+  __builtin_arm_wsr128("0:1:2", v); //expected-error {{invalid special register for builtin}}
+}
+
 unsigned rsr_3(void) {
   return __builtin_arm_rsr("0:1:2"); //expected-error {{invalid special register for builtin}}
 }
@@ -99,3 +115,101 @@
 unsigned long rsr64_6(void) {
   return __builtin_arm_rsr64("0:1:16:16:2"); //expected-error {{invalid special register for builtin}}
 }
+
+__uint128_t rsr128_3(void) {
+  return __builtin_arm_rsr128("0:1:2"); //expected-error {{invalid special register for builtin}}
+}
+
+__uint128_t rsr128_4(void) {
+  return __builtin_arm_rsr128("0:1:2:3:8"); //expected-error {{invalid special register for builtin}}
+}
+
+__uint128_t rsr128_5(void) {
+  return __builtin_arm_rsr128("0:8:2:3:4"); //expected-error {{invalid special register for builtin}}
+}
+
+__uint128_t rsr128_6(void) {
+  return __builtin_arm_rsr128("0:1:16:16:2"); //expected-error {{invalid special register for builtin}}
+}
+
+void wsr_4(void) {
+  __builtin_arm_wsr("spsel", 15);
+  __builtin_arm_wsr("daifclr", 15);
+  __builtin_arm_wsr("daifset", 15);
+  __builtin_arm_wsr("pan", 15);
+  __builtin_arm_wsr("uao", 15);
+  __builtin_arm_wsr("dit", 15);
+  __builtin_arm_wsr("ssbs", 15);
+  __builtin_arm_wsr("tco", 15);
+
+  __builtin_arm_wsr("allint", 1);
+  __builtin_arm_wsr("pm", 1);
+}
+
+void wsr64_4(void) {
+  __builtin_arm_wsr("spsel", 15);
+  __builtin_arm_wsr("daifclr", 15);
+  __builtin_arm_wsr("daifset", 15);
+  __builtin_arm_wsr("pan", 15);
+  __builtin_arm_wsr("uao", 15);
+  __builtin_arm_wsr("dit", 15);
+  __builtin_arm_wsr("ssbs", 15);
+  __builtin_arm_wsr("tco", 15);
+
+  __builtin_arm_wsr("allint", 1);
+  __builtin_arm_wsr("pm", 1);
+}
+
+void wsr_5(unsigned v) {
+  __builtin_arm_wsr("spsel", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr("daifclr", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr("daifset", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr("pan", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr("uao", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr("dit", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr("ssbs", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr("tco", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr("allint", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr("pm", v); // expected-error {{must be a constant integer}}
+}
+
+void wsr64_5(unsigned long v) {
+  __builtin_arm_wsr64("spsel", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr64("daifclr", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr64("daifset", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr64("pan", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr64("uao", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr64("dit", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr64("ssbs", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr64("tco", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr64("allint", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr64("pm", v); // expected-error {{m

[PATCH] D141824: [clang-repl] Add a command to load dynamic libraries

2023-01-23 Thread Anubhab Ghosh via Phabricator via cfe-commits
argentite added inline comments.



Comment at: clang/include/clang/Interpreter/Interpreter.h:62
   const CompilerInstance *getCompilerInstance() const;
-  const llvm::orc::LLJIT *getExecutionEngine() const;
+  llvm::Expected GetExecutionEngine();
+

sgraenitz wrote:
> Do we really want these functions capitalized? IIRC in the clang code-base 
> they are used to highlight core API functions. It looks like these two 
> functions are only used as helpers inside `Interpreter` itself.
I guess we can keep them without capitalizing.



Comment at: clang/lib/Interpreter/Interpreter.cpp:223
 
+llvm::Error Interpreter::CreateExecutor() {
+  const clang::TargetInfo &TI =

sgraenitz wrote:
> Factoring out this function looks like an independent change. Is it related 
> to the load-library command in any way?
The `IncrementalExecutor` was being created on the first call to `Execute()`. 
It is created lazily for `-fsyntax-only` support. It holds the Execution Engine 
that we need for loading the library. So we need to be able to create it in 
`getExecutionEngine()` as well because a library can be loaded before any code 
is executed.



Comment at: clang/tools/clang-repl/ClangRepl.cpp:126
   }
+  if (Line->rfind(R"(%lib )", 0) == 0) {
+if (auto Err = Interp->LoadDynamicLibrary(Line->data() + 5)) {

sgraenitz wrote:
> I see this is analog to existing code, but is there a good reason for using 
> the multi-line string syntax here?
Yeah I am confused as well. But I tried to maintain the style.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141824

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


[PATCH] D142358: Opting out of Clang 15 ABI Changes for AIX and z/OS

2023-01-23 Thread David Tenty via Phabricator via cfe-commits
daltenty added inline comments.



Comment at: clang/test/SemaCXX/class-layout.cpp:616-617
 
+// This ends the #if !defined(__MVS__) && !defined(__AIX__) block from line 12 
+#endif
+

nit: line numbers may shift on you as other commits touch this file. Prefer  a 
same line comment that keeps the comment together with the actual directive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142358

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


[PATCH] D142326: [clang][RISCV][test] Add test cases for empty structs and the FP calling conventions

2023-01-23 Thread Luís Marques via Phabricator via cfe-commits
luismarques accepted this revision.
luismarques added a comment.
This revision is now accepted and ready to land.

LGTM but others should also chime in.




Comment at: clang/test/CodeGen/RISCV/abi-empty-structs.c:101
+
+struct s5 { struct empty e[1]; float f; };
+

Should we also test a case with an array size 0 like `ct s { struct empty e[0]; 
float f; };`? I think that's a GNU extension and I don't expect the result to 
be different but...



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142326

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


[PATCH] D142367: Add support for clang-cl's option -fexcess-precision.

2023-01-23 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam created this revision.
zahiraam added reviewers: mdtoguchi, andrew.w.kaylor.
Herald added a project: All.
zahiraam requested review of this revision.
Herald added a project: clang.

This option is useful for clang and clang-cl.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142367

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/fexcess-precision.c


Index: clang/test/Driver/fexcess-precision.c
===
--- clang/test/Driver/fexcess-precision.c
+++ clang/test/Driver/fexcess-precision.c
@@ -1,29 +1,65 @@
+// Note: %s must be preceded by --, otherwise it may be interpreted as a
+// command-line option, e.g. on Mac where %s is commonly under /Users.
+
 // RUN: %clang -### -target i386 -fexcess-precision=fast -c %s 2>&1  \
 // RUN:   | FileCheck --check-prefix=CHECK-FAST %s
+// RUN: %clang_cl -### -target i386 -fexcess-precision=fast -c -- %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FAST %s
+
 // RUN: %clang -### -target i386 -fexcess-precision=standard -c %s 2>&1  \
 // RUN:   | FileCheck --check-prefix=CHECK-STD %s
+// RUN: %clang_cl -### -target i386 -fexcess-precision=standard -c -- %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-STD %s
+
 // RUN: %clang -### -target i386 -fexcess-precision=16 -c %s 2>&1  \
 // RUN:   | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang_cl -### -target i386 -fexcess-precision=16 -c -- %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NONE %s
+
 // RUN: %clang -### -target i386 -fexcess-precision=none -c %s 2>&1  \
 // RUN:   | FileCheck --check-prefix=CHECK-ERR-NONE %s
+// RUN: %clang_cl -### -target i386 -fexcess-precision=none -c -- %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ERR-NONE %s
 
 // RUN: %clang -### -target x86_64 -fexcess-precision=fast -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-FAST %s
+// RUN: %clang_cl -### -target x86_64 -fexcess-precision=fast -c -- %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FAST %s
+
 // RUN: %clang -### -target x86_64 -fexcess-precision=standard -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-STD %s
+// RUN: %clang_cl -### -target x86_64 -fexcess-precision=standard -c \
+// RUN: -- %s 2>&1 | FileCheck --check-prefix=CHECK-STD %s
+
 // RUN: %clang -### -target x86_64 -fexcess-precision=16 -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang_cl -### -target x86_64 -fexcess-precision=16 -c -- %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NONE %s
+
 // RUN: %clang -### -target x86_64 -fexcess-precision=none -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefixes=CHECK-ERR-NONE %s
+// RUN: %clang_cl -### -target x86_64 -fexcess-precision=none -c -- %s 2>&1 \
+// RUN:   | FileCheck --check-prefixes=CHECK-ERR-NONE %s
 
 // RUN: %clang -### -target aarch64 -fexcess-precision=fast -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK %s
+// RUN: %clang_cl -### -target aarch64 -fexcess-precision=fast -c -- %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK %s
+
 // RUN: %clang -### -target aarch64 -fexcess-precision=standard -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK %s
+// RUN: %clang_cl -### -target aarch64 -fexcess-precision=standard -c \
+// RUN: -- %s 2>&1 | FileCheck --check-prefix=CHECK %s
+
 // RUN: %clang -### -target aarch64 -fexcess-precision=16 -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-ERR-16 %s
+// RUN: %clang_cl -### -target aarch64 -fexcess-precision=16 -c -- %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ERR-16 %s
+
 // RUN: %clang -### -target aarch64 -fexcess-precision=none -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-ERR-NONE %s
+// RUN: %clang_cl -### -target aarch64 -fexcess-precision=none -c -- %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ERR-NONE %s
 
 // CHECK-FAST: "-ffloat16-excess-precision=fast"
 // CHECK-STD: "-ffloat16-excess-precision=standard"
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1579,6 +1579,7 @@
   HelpText<"Enable support for ignoring exception handling constructs">,
   MarshallingInfoFlag>;
 def fexcess_precision_EQ : Joined<["-"], "fexcess-precision=">, Group,
+  Flags<[CoreOption]>,
   HelpText<"Allows control over excess precision on targets where native "
   "support for the precision types is not available. By default, excess "
   "precision is used to calculate intermediate results following the "


Index: clang/test/Driver/fexcess-precision.c
===
--- clang/test/Driver/fexcess-precision.c
+++ clang/test/Driver/fexcess-precision.c
@@ -1,29 +1,65 @@
+// Note: %s must be preceded by --, otherwise it may be interpreted as a
+// command-line option, e.g. on Mac where %s is commonly under /Users.
+
 // RUN: %clang -### -

[PATCH] D142358: Opting out of Clang 15 ABI Changes for AIX and z/OS

2023-01-23 Thread Nicole Rabjohn via Phabricator via cfe-commits
nicolerabjohn updated this revision to Diff 491375.
nicolerabjohn added a comment.

Updating comment


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

https://reviews.llvm.org/D142358

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/SemaCXX/class-layout.cpp


Index: clang/test/SemaCXX/class-layout.cpp
===
--- clang/test/SemaCXX/class-layout.cpp
+++ clang/test/SemaCXX/class-layout.cpp
@@ -9,6 +9,8 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
 // expected-no-diagnostics
 
+#if !defined(__MVS__) && !defined(_AIX)
+
 #define SA(n, p) int a##n[(p) ? 1 : -1]
 
 struct A {
@@ -611,6 +613,8 @@
 #pragma pack(pop)
 }
 
+#endif // !defined(__MVS__) && !defined(__AIX__)
+
 namespace non_pod {
 struct t1 {
 protected:
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -773,6 +773,10 @@
   }
 
   bool defaultsToAIXPowerAlignment() const override { return true; }
+
+  bool areDefaultedSMFStillPOD(const LangOptions &) const override {
+return false;
+  }
 };
 
 // z/OS target
@@ -831,6 +835,10 @@
 this->UseLeadingZeroLengthBitfield = false;
 this->ZeroLengthBitfieldBoundary = 32;
   }
+
+  bool areDefaultedSMFStillPOD(const LangOptions &) const override {
+return false;
+  }
 };
 
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -819,7 +819,7 @@
   ``-fclang-abi-compat=15.0``.
 - GCC allows POD types to have defaulted special members. Clang historically
   classified such types as non-POD (for the purposes of Itanium ABI). Clang now
-  matches the gcc behavior (except on Darwin and PS4). You can switch back to
+  matches the gcc behavior (except on Darwin, PS4, AIX and z/OS). You can 
switch back to
   the old ABI behavior with the flag: ``-fclang-abi-compat=15.0``.
 
 OpenMP Support in Clang


Index: clang/test/SemaCXX/class-layout.cpp
===
--- clang/test/SemaCXX/class-layout.cpp
+++ clang/test/SemaCXX/class-layout.cpp
@@ -9,6 +9,8 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
 // expected-no-diagnostics
 
+#if !defined(__MVS__) && !defined(_AIX)
+
 #define SA(n, p) int a##n[(p) ? 1 : -1]
 
 struct A {
@@ -611,6 +613,8 @@
 #pragma pack(pop)
 }
 
+#endif // !defined(__MVS__) && !defined(__AIX__)
+
 namespace non_pod {
 struct t1 {
 protected:
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -773,6 +773,10 @@
   }
 
   bool defaultsToAIXPowerAlignment() const override { return true; }
+
+  bool areDefaultedSMFStillPOD(const LangOptions &) const override {
+return false;
+  }
 };
 
 // z/OS target
@@ -831,6 +835,10 @@
 this->UseLeadingZeroLengthBitfield = false;
 this->ZeroLengthBitfieldBoundary = 32;
   }
+
+  bool areDefaultedSMFStillPOD(const LangOptions &) const override {
+return false;
+  }
 };
 
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -819,7 +819,7 @@
   ``-fclang-abi-compat=15.0``.
 - GCC allows POD types to have defaulted special members. Clang historically
   classified such types as non-POD (for the purposes of Itanium ABI). Clang now
-  matches the gcc behavior (except on Darwin and PS4). You can switch back to
+  matches the gcc behavior (except on Darwin, PS4, AIX and z/OS). You can switch back to
   the old ABI behavior with the flag: ``-fclang-abi-compat=15.0``.
 
 OpenMP Support in Clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142315: [clang] Add test for CWG1111

2023-01-23 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/www/cxx_dr_status.html:6476
 Remove dual-scope lookup of member template names
-Unknown
+Clang 6
   

aaron.ballman wrote:
> erichkeane wrote:
> > Were you able to track down which patch fixed this in clang 6?
> > 
> > I also don't think we can mark this as 'full' support, if its still broken 
> > in C++98.  Unless we can find a good reason this wasn't/wont be done for 
> > C++98 as well, I don't know if we can mark this as 'done'.
> We can mark it as `partial` and put the reason in the details. I'm not 
> certain if the python script has a way to do that easily or not.
I think this might be related as well: 
https://github.com/llvm/llvm-project/issues/59910


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142315

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


[PATCH] D142092: [include-mapping] Allow multiple headers for the same symbol. Choose the first header of available ones.

2023-01-23 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 491380.
VitaNuo marked 2 inline comments as done.
VitaNuo added a comment.

Address review comments regarding data structure use and style.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

Files:
  clang/include/clang/Tooling/Inclusions/CSymbolMap.inc
  clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc
  clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
  clang/tools/include-mapping/cppreference_parser.py
  clang/tools/include-mapping/gen_std.py

Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -14,10 +14,7 @@
 The generated files are located in clang/include/Tooling/Inclusions.
 
 Caveats and FIXMEs:
-  - only symbols directly in "std" namespace are added, we should also add std's
-subnamespace symbols (e.g. chrono).
-  - symbols with multiple variants or defined in multiple headers aren't added,
-e.g. std::move, std::swap
+  - symbols with multiple variants aren't added, e.g., std::move
 
 Usage:
   1. Install BeautifulSoup dependency, see instruction:
@@ -110,17 +107,12 @@
 os.stat(index_page_path).st_mtime).strftime('%Y-%m-%d')
   print(CODE_PREFIX % (args.symbols.upper(), cppreference_modified_date))
   for symbol in symbols:
-if len(symbol.headers) == 1:
-  # SYMBOL(unqualified_name, namespace, header)
-  print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
-symbol.headers[0]))
-elif len(symbol.headers) == 0:
+if len(symbol.headers) == 0:
   sys.stderr.write("No header found for symbol %s\n" % symbol.name)
 else:
-  # FIXME: support symbols with multiple headers (e.g. std::move).
-  sys.stderr.write("Ambiguous header for symbol %s: %s\n" % (
-  symbol.name, ', '.join(symbol.headers)))
-
-
+  for header in symbol.headers:
+# SYMBOL(unqualified_name, namespace, header)
+print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
+  header))
 if __name__ == '__main__':
   main()
Index: clang/tools/include-mapping/cppreference_parser.py
===
--- clang/tools/include-mapping/cppreference_parser.py
+++ clang/tools/include-mapping/cppreference_parser.py
@@ -180,8 +180,7 @@
   initializer=lambda: signal.signal(signal.SIGINT, signal.SIG_IGN))
   try:
 for root_dir, page_name, namespace in parse_pages:
-  symbols.extend(_GetSymbols(pool, root_dir, page_name, namespace,
- variants_to_accept))
+  symbols.extend(_GetSymbols(pool, root_dir, page_name, namespace, variants_to_accept))
   finally:
 pool.terminate()
 pool.join()
Index: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
===
--- clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -8,6 +8,7 @@
 
 #include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "clang/AST/Decl.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 
@@ -17,7 +18,7 @@
 
 static llvm::StringRef *HeaderNames;
 static std::pair *SymbolNames;
-static unsigned *SymbolHeaderIDs;
+static llvm::SmallVector *SymbolHeaderIDs;
 static llvm::DenseMap *HeaderIDs;
 // Maps symbol name -> Symbol::ID, within a namespace.
 using NSSymbolMap = llvm::DenseMap;
@@ -46,18 +47,29 @@
 return HeaderIDs->try_emplace(Header, HeaderIDs->size()).first->second;
   };
 
-  auto Add = [&, SymIndex(0)](llvm::StringRef Name, llvm::StringRef NS,
-  llvm::StringRef HeaderName) mutable {
+  auto Add = [&, NextAvailSymIndex(0)](llvm::StringRef Name, llvm::StringRef NS,
+   llvm::StringRef HeaderName) mutable {
 if (NS == "None")
   NS = "";
 
+bool IsNewSymbol = true;
+unsigned SymIndex = NextAvailSymIndex;
+if (NSSymbolMap *NSSymbols = NamespaceSymbols->lookup(NS)) {
+  auto It = NSSymbols->find(Name);
+  if (It != NSSymbols->end()) {
+SymIndex = It->getSecond();
+IsNewSymbol = false;
+  }
+}
+
 SymbolNames[SymIndex] = {NS, Name};
-SymbolHeaderIDs[SymIndex] = AddHeader(HeaderName);
+SymbolHeaderIDs[SymIndex].emplace_back(AddHeader(HeaderName));
 
 NSSymbolMap &NSSymbols = AddNS(NS);
 NSSymbols.try_emplace(Name, SymIndex);
 
-++SymIndex;
+if (IsNewSymbol)
+  ++NextAvailSymIndex;
   };
 #define SYMBOL(Name, NS, Header) Add(#Name, #NS, #Header);
 #include "clang/Tooling/Inclusions/CSymbolMap.inc"
@@ -96,9 +108,14 @@
   }
   return std::nullopt;
 }
-Header Symbol::header() const { return Header(SymbolHeaderIDs[ID]); }
+
+H

[PATCH] D142092: [include-mapping] Allow multiple headers for the same symbol. Choose the first header of available ones.

2023-01-23 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 491382.
VitaNuo added a comment.

Fix formatting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

Files:
  clang/include/clang/Tooling/Inclusions/CSymbolMap.inc
  clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc
  clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
  clang/tools/include-mapping/cppreference_parser.py
  clang/tools/include-mapping/gen_std.py

Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -14,10 +14,7 @@
 The generated files are located in clang/include/Tooling/Inclusions.
 
 Caveats and FIXMEs:
-  - only symbols directly in "std" namespace are added, we should also add std's
-subnamespace symbols (e.g. chrono).
-  - symbols with multiple variants or defined in multiple headers aren't added,
-e.g. std::move, std::swap
+  - symbols with multiple variants aren't added, e.g., std::move
 
 Usage:
   1. Install BeautifulSoup dependency, see instruction:
@@ -110,17 +107,12 @@
 os.stat(index_page_path).st_mtime).strftime('%Y-%m-%d')
   print(CODE_PREFIX % (args.symbols.upper(), cppreference_modified_date))
   for symbol in symbols:
-if len(symbol.headers) == 1:
-  # SYMBOL(unqualified_name, namespace, header)
-  print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
-symbol.headers[0]))
-elif len(symbol.headers) == 0:
+if len(symbol.headers) == 0:
   sys.stderr.write("No header found for symbol %s\n" % symbol.name)
 else:
-  # FIXME: support symbols with multiple headers (e.g. std::move).
-  sys.stderr.write("Ambiguous header for symbol %s: %s\n" % (
-  symbol.name, ', '.join(symbol.headers)))
-
-
+  for header in symbol.headers:
+# SYMBOL(unqualified_name, namespace, header)
+print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
+  header))
 if __name__ == '__main__':
   main()
Index: clang/tools/include-mapping/cppreference_parser.py
===
--- clang/tools/include-mapping/cppreference_parser.py
+++ clang/tools/include-mapping/cppreference_parser.py
@@ -180,8 +180,7 @@
   initializer=lambda: signal.signal(signal.SIGINT, signal.SIG_IGN))
   try:
 for root_dir, page_name, namespace in parse_pages:
-  symbols.extend(_GetSymbols(pool, root_dir, page_name, namespace,
- variants_to_accept))
+  symbols.extend(_GetSymbols(pool, root_dir, page_name, namespace, variants_to_accept))
   finally:
 pool.terminate()
 pool.join()
Index: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
===
--- clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -8,6 +8,7 @@
 
 #include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "clang/AST/Decl.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 
@@ -17,7 +18,7 @@
 
 static llvm::StringRef *HeaderNames;
 static std::pair *SymbolNames;
-static unsigned *SymbolHeaderIDs;
+static llvm::SmallVector *SymbolHeaderIDs;
 static llvm::DenseMap *HeaderIDs;
 // Maps symbol name -> Symbol::ID, within a namespace.
 using NSSymbolMap = llvm::DenseMap;
@@ -46,18 +47,29 @@
 return HeaderIDs->try_emplace(Header, HeaderIDs->size()).first->second;
   };
 
-  auto Add = [&, SymIndex(0)](llvm::StringRef Name, llvm::StringRef NS,
-  llvm::StringRef HeaderName) mutable {
+  auto Add = [&, NextAvailSymIndex(0)](llvm::StringRef Name, llvm::StringRef NS,
+   llvm::StringRef HeaderName) mutable {
 if (NS == "None")
   NS = "";
 
+bool IsNewSymbol = true;
+unsigned SymIndex = NextAvailSymIndex;
+if (NSSymbolMap *NSSymbols = NamespaceSymbols->lookup(NS)) {
+  auto It = NSSymbols->find(Name);
+  if (It != NSSymbols->end()) {
+SymIndex = It->getSecond();
+IsNewSymbol = false;
+  }
+}
+
 SymbolNames[SymIndex] = {NS, Name};
-SymbolHeaderIDs[SymIndex] = AddHeader(HeaderName);
+SymbolHeaderIDs[SymIndex].emplace_back(AddHeader(HeaderName));
 
 NSSymbolMap &NSSymbols = AddNS(NS);
 NSSymbols.try_emplace(Name, SymIndex);
 
-++SymIndex;
+if (IsNewSymbol)
+  ++NextAvailSymIndex;
   };
 #define SYMBOL(Name, NS, Header) Add(#Name, #NS, #Header);
 #include "clang/Tooling/Inclusions/CSymbolMap.inc"
@@ -87,7 +99,7 @@
 llvm::StringRef Symbol::scope() const { return SymbolNames[ID].first; }
 llvm::StringRef Symbol::name() const { return SymbolNames[ID].second; }
 std::optional Symbol::named(llvm::StringRef Scope,
-

[PATCH] D141403: [AArch64] Add command line support for v9.4-A's Instrumentation Extension

2023-01-23 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas updated this revision to Diff 491384.
pratlucas added a comment.

Rebasing, including minor changes due to recent target parser refactoring.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141403

Files:
  clang/test/Driver/aarch64-ite.c
  llvm/include/llvm/TargetParser/AArch64TargetParser.h
  llvm/unittests/TargetParser/TargetParserTest.cpp


Index: llvm/unittests/TargetParser/TargetParserTest.cpp
===
--- llvm/unittests/TargetParser/TargetParserTest.cpp
+++ llvm/unittests/TargetParser/TargetParserTest.cpp
@@ -1553,6 +1553,7 @@
   AArch64::AEK_B16B16,  AArch64::AEK_SMEF16F16, AArch64::AEK_CSSC,
   AArch64::AEK_RCPC3,   AArch64::AEK_THE,   AArch64::AEK_D128,
   AArch64::AEK_LSE128,  AArch64::AEK_SPECRES2,  AArch64::AEK_RASv2,
+  AArch64::AEK_ITE,
   };
 
   std::vector Features;
@@ -1624,6 +1625,7 @@
   EXPECT_TRUE(llvm::is_contained(Features, "+d128"));
   EXPECT_TRUE(llvm::is_contained(Features, "+lse128"));
   EXPECT_TRUE(llvm::is_contained(Features, "+specres2"));
+  EXPECT_TRUE(llvm::is_contained(Features, "+ite"));
 
   // Assuming we listed every extension above, this should produce the same
   // result. (note that AEK_NONE doesn't have a name so it won't be in the
Index: llvm/include/llvm/TargetParser/AArch64TargetParser.h
===
--- llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -147,6 +147,7 @@
   AEK_LSE128 =  1ULL << 52, // FEAT_LSE128
   AEK_SPECRES2 =1ULL << 53, // FEAT_SPECRES2
   AEK_RASv2 =   1ULL << 54, // FEAT_RASv2
+  AEK_ITE = 1ULL << 55, // FEAT_ITE
 };
 // clang-format on
 
@@ -196,6 +197,7 @@
 {"frintts", AArch64::AEK_NONE, {}, {}, FEAT_FRINTTS, "+fptoint", 250},
 {"hbc", AArch64::AEK_HBC, "+hbc", "-hbc", FEAT_MAX, "", 0},
 {"i8mm", AArch64::AEK_I8MM, "+i8mm", "-i8mm", FEAT_I8MM, "+i8mm", 270},
+{"ite", AArch64::AEK_ITE, "+ite", "-ite", FEAT_MAX, "", 0},
 {"jscvt", AArch64::AEK_NONE, {}, {}, FEAT_JSCVT, 
"+fp-armv8,+neon,+jsconv", 210},
 {"ls64_accdata", AArch64::AEK_NONE, {}, {}, FEAT_LS64_ACCDATA, "+ls64", 
540},
 {"ls64_v", AArch64::AEK_NONE, {}, {}, FEAT_LS64_V, "", 530},
Index: clang/test/Driver/aarch64-ite.c
===
--- /dev/null
+++ clang/test/Driver/aarch64-ite.c
@@ -0,0 +1,17 @@
+// Test that target feature ite is implemented and available correctly
+
+// FEAT_ITE is optional (off by default) for v8.9a/9.4a and older, and can be 
enabled using +ite
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a   %s 
2>&1 | FileCheck %s --check-prefix=NOT_ENABLED
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+ite   %s 
2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+noite %s 
2>&1 | FileCheck %s --check-prefix=DISABLED
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a   %s 
2>&1 | FileCheck %s --check-prefix=NOT_ENABLED
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a+ite   %s 
2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a+noite %s 
2>&1 | FileCheck %s --check-prefix=DISABLED
+
+// FEAT_ITE is invalid before v8
+// RUN: %clang -### -target arm-none-none-eabi -march=armv7-a+ite %s 2>&1 
| FileCheck %s --check-prefix=INVALID
+
+// INVALID: error: unsupported argument 'armv7-a+ite' to option '-march='
+// ENABLED: "-target-feature" "+ite"
+// NOT_ENABLED-NOT: "-target-feature" "+ite"
+// DISABLED: "-target-feature" "-ite"


Index: llvm/unittests/TargetParser/TargetParserTest.cpp
===
--- llvm/unittests/TargetParser/TargetParserTest.cpp
+++ llvm/unittests/TargetParser/TargetParserTest.cpp
@@ -1553,6 +1553,7 @@
   AArch64::AEK_B16B16,  AArch64::AEK_SMEF16F16, AArch64::AEK_CSSC,
   AArch64::AEK_RCPC3,   AArch64::AEK_THE,   AArch64::AEK_D128,
   AArch64::AEK_LSE128,  AArch64::AEK_SPECRES2,  AArch64::AEK_RASv2,
+  AArch64::AEK_ITE,
   };
 
   std::vector Features;
@@ -1624,6 +1625,7 @@
   EXPECT_TRUE(llvm::is_contained(Features, "+d128"));
   EXPECT_TRUE(llvm::is_contained(Features, "+lse128"));
   EXPECT_TRUE(llvm::is_contained(Features, "+specres2"));
+  EXPECT_TRUE(llvm::is_contained(Features, "+ite"));
 
   // Assuming we listed every extension above, this should produce the same
   // result. (note that AEK_NONE doesn't have a name so it won't be in the
Index: llvm/include/llvm/TargetParser/AArch64TargetParser.h
===
--- llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ llvm/include/llvm/TargetParser/AArch64TargetPa

[PATCH] D142092: [include-mapping] Allow multiple headers for the same symbol. Choose the first header of available ones.

2023-01-23 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo added inline comments.



Comment at: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp:20
 static llvm::StringRef *HeaderNames;
-static std::pair *SymbolNames;
-static unsigned *SymbolHeaderIDs;
+static llvm::DenseMap>
+*SymbolNames;

hokein wrote:
> int => unsigned.
> 
> Any reason to change it to a map? My understanding is that SymbolNames is a 
> mapping from the SymbolID => {Scope, Name}, it should not be affected if we 
> add multiple-header symbols.
Right. I am not sure what I was thinking. Possibly I was thinking that symbol 
IDs won't be continuous anymore after this change, but they actually are. 
Thanks!



Comment at: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp:58
+int SymIndex = NextAvailSymIndex;
+if (NSSymbolMap *NSSymbols = NamespaceSymbols->lookup(NS)) {
+  auto It = NSSymbols->find(Name);

hokein wrote:
> Given the fact that multiple-header symbols are grouped in the .inc file, we 
> could simplify the code of checking a new symbol by looking at the last 
> available SymIndex:
> 
> ```
> if (NextAvailSymIndex > 0 && SymbolNames[NextAvailSymIndex-1].first == NS && 
> SymbolNames[NextAvailSymIndex-1].second == Name) {
>// this is not a new symbol.
> }
> ```
I know this is easier in terms of code, but this heavily relies on the order in 
the generated files. I would prefer to keep the library and the generator as 
decoupled as possible, even if it means slightly more complex code here. 
Overall, it seems more future-proof in case of unrelated generator changes 
(bugs?) that might change the order.



Comment at: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp:103
+llvm::StringRef Symbol::scope() const {
+  auto It = SymbolNames->find(ID);
+  if (It != SymbolNames->end()) {

hokein wrote:
> The `ID` field is guaranteed to be valid, so no need to do the sanity check.
This is all gone now, since the code is back to the array version of 
SymbolNames.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

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


[PATCH] D141404: [AArch64][Clang] Adjust default features for v8.9-A/v9.4-A in clang driver

2023-01-23 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas updated this revision to Diff 491385.
pratlucas added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Updated to use the same approach as D141518 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141404

Files:
  clang/test/Driver/aarch64-cssc.c
  llvm/include/llvm/TargetParser/AArch64TargetParser.h


Index: llvm/include/llvm/TargetParser/AArch64TargetParser.h
===
--- llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -315,12 +315,12 @@
 inline constexpr ArchInfo ARMV8_6A  = { VersionTuple{8, 6}, AProfile, 
"armv8.6-a", "+v8.6a", (BaseNoCrypto | AArch64::AEK_SM4 | AArch64::AEK_SHA3 | 
AArch64::AEK_BF16 | AArch64::AEK_SHA2 | AArch64::AEK_AES | AArch64::AEK_I8MM)};
 inline constexpr ArchInfo ARMV8_7A  = { VersionTuple{8, 7}, AProfile, 
"armv8.7-a", "+v8.7a", (ARMV8_6A.DefaultExts)};
 inline constexpr ArchInfo ARMV8_8A  = { VersionTuple{8, 8}, AProfile, 
"armv8.8-a", "+v8.8a", (ARMV8_7A.DefaultExts | AArch64::AEK_MOPS | 
AArch64::AEK_HBC)};
-inline constexpr ArchInfo ARMV8_9A  = { VersionTuple{8, 9}, AProfile, 
"armv8.9-a", "+v8.9a", (ARMV8_8A.DefaultExts)};
+inline constexpr ArchInfo ARMV8_9A  = { VersionTuple{8, 9}, AProfile, 
"armv8.9-a", "+v8.9a", (ARMV8_8A.DefaultExts | AArch64::AEK_SPECRES2 | 
AArch64::AEK_CSSC | AArch64::AEK_RASv2)};
 inline constexpr ArchInfo ARMV9A= { VersionTuple{9, 0}, AProfile, 
"armv9-a", "+v9a", (BaseNoCrypto | AArch64::AEK_FP16 | AArch64::AEK_SVE | 
AArch64::AEK_SVE2)};
 inline constexpr ArchInfo ARMV9_1A  = { VersionTuple{9, 1}, AProfile, 
"armv9.1-a", "+v9.1a", (ARMV9A.DefaultExts | AArch64::AEK_BF16 | 
AArch64::AEK_I8MM)};
 inline constexpr ArchInfo ARMV9_2A  = { VersionTuple{9, 2}, AProfile, 
"armv9.2-a", "+v9.2a", (ARMV9_1A.DefaultExts)};
 inline constexpr ArchInfo ARMV9_3A  = { VersionTuple{9, 3}, AProfile, 
"armv9.3-a", "+v9.3a", (ARMV9_2A.DefaultExts | AArch64::AEK_MOPS | 
AArch64::AEK_HBC)};
-inline constexpr ArchInfo ARMV9_4A  = { VersionTuple{9, 4}, AProfile, 
"armv9.4-a", "+v9.4a", (ARMV9_3A.DefaultExts)};
+inline constexpr ArchInfo ARMV9_4A  = { VersionTuple{9, 4}, AProfile, 
"armv9.4-a", "+v9.4a", (ARMV9_3A.DefaultExts | AArch64::AEK_SPECRES2 | 
AArch64::AEK_CSSC | AArch64::AEK_RASv2)};
 // For v8-R, we do not enable crypto and align with GCC that enables a more 
minimal set of optional architecture extensions.
 inline constexpr ArchInfo ARMV8R= { VersionTuple{8, 0}, RProfile, 
"armv8-r", "+v8r", ((BaseNoCrypto ^ AArch64::AEK_LSE) | AArch64::AEK_SSBS | 
AArch64::AEK_FP16 | AArch64::AEK_FP16FML | AArch64::AEK_SB), };
 // clang-format on
Index: clang/test/Driver/aarch64-cssc.c
===
--- clang/test/Driver/aarch64-cssc.c
+++ clang/test/Driver/aarch64-cssc.c
@@ -1,15 +1,17 @@
 // Test that target feature cssc is implemented and available correctly
-// RUN: %clang -### -target aarch64-none-none-eabi %s 
2>&1 | FileCheck %s --check-prefix=ABSENT_CSSC
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+cssc   %s 
2>&1 | FileCheck %s
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.9-a%s 
2>&1 | FileCheck %s --check-prefix=ABSENT_CSSC
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+cssc   %s 
2>&1 | FileCheck %s
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.9-a+nocssc %s 
2>&1 | FileCheck %s --check-prefix=NO_CSSC
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a+cssc   %s 
2>&1 | FileCheck %s
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.4-a%s 
2>&1 | FileCheck %s --check-prefix=ABSENT_CSSC
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a+cssc   %s 
2>&1 | FileCheck %s
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.4-a+nocssc %s 
2>&1 | FileCheck %s --check-prefix=NO_CSSC
+// FEAT_CSSC is a required part of v8.9a/v9.4a and optional from v8.7a/v9.3a 
onwards.
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi   
  %s 2>&1 | FileCheck %s --check-prefix=ABSENT_CSSC
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv8.7-a+cssc   %s 2>&1 | FileCheck %s
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv8.9-a%s 2>&1 | FileCheck %s
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv8.9-a+cssc   %s 2>&1 | FileCheck %s
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv8.9-a+nocssc %s 2>&1 | FileCheck %s --check-prefix=NO_CSSC
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv9.2-a+cssc   %s 2>&1 | FileCheck %s
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none

[PATCH] D142304: [Clang] Fix a Wbitfield-enum-conversion warning in DirectoryLookup.h

2023-01-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

In D142304#4073573 , @aaron.ballman 
wrote:

> LGTM but can you find a test case that would show we don't regress this in 
> the future?

I haven't found the test case, but I found a commit 

 that increases CharacteristicKind enum's values from 3 to 5. Seems they missed 
updating DirCharacteristic. Do you have suggestions on where/how to add a test 
case for this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142304

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


[PATCH] D142316: [clang] Add test for CWG2396

2023-01-23 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

You mention CWG2385  as na but you don't explain how 
it was resolved, was it superceded by p1787 
.

Also nitpick you mentioned `P1787` in the description but it links to a phab 
review, you should probably just use a link like I did above to refer to 
papers. Same with the defect reports also like I did above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142316

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


[PATCH] D142315: [clang] Add test for CWG1111

2023-01-23 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill added inline comments.



Comment at: clang/www/cxx_dr_status.html:6476
 Remove dual-scope lookup of member template names
-Unknown
+Clang 6
   

shafik wrote:
> aaron.ballman wrote:
> > erichkeane wrote:
> > > Were you able to track down which patch fixed this in clang 6?
> > > 
> > > I also don't think we can mark this as 'full' support, if its still 
> > > broken in C++98.  Unless we can find a good reason this wasn't/wont be 
> > > done for C++98 as well, I don't know if we can mark this as 'done'.
> > We can mark it as `partial` and put the reason in the details. I'm not 
> > certain if the python script has a way to do that easily or not.
> I think this might be related as well: 
> https://github.com/llvm/llvm-project/issues/59910
> Were you able to track down which patch fixed this in clang 6?
I haven't even tried, since I don't intend to fix this for now.

> We can mark it as partial and put the reason in the details.
Is false-positive //warning// enough to degrade `full` to `partial` despite the 
correct behavior? Just confirming here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142315

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


[PATCH] D141404: [AArch64][Clang] Adjust default features for v8.9-A/v9.4-A in clang driver

2023-01-23 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added inline comments.



Comment at: clang/test/Driver/aarch64-cssc.c:11
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv9.4-a+cssc   %s 2>&1 | FileCheck %s
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv9.4-a+nocssc %s 2>&1 | FileCheck %s --check-prefix=NO_CSSC
 

Missing -###?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141404

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


  1   2   3   4   >