[PATCH] D127189: [clang][AIX] Add option to control quadword lock free atomics ABI on AIX

2022-07-17 Thread Kai Luo via Phabricator via cfe-commits
lkail added a comment.

Gentle ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127189

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


[PATCH] D129940: [clang-format] Fix misannotation of colon in presence of requires clause

2022-07-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:820-833
+  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
+  ASSERT_EQ(ConstrainedTokens.size(),
+NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
+  << ConstrainedTokens;
+
+  for (auto I = 0u; I < NumberOfBaseTokens; ++I) {
+if (I < NumberOfTokensBeforeRequires) {

curdeius wrote:
> owenpan wrote:
> > HazardyKnusperkeks wrote:
> > > curdeius wrote:
> > > > owenpan wrote:
> > > > > Can you make it a function or lambda?
> > > > :+1:
> > > Often thought about that. But as @MyDeveloperDay mentioned in different 
> > > other reviews, we would loose the line where the EXPECT failed, since it 
> > > would always be the same line.
> > > 
> > > One step to mitigate that would be to return a `bool`, then one would 
> > > loose the "subexpect", only knows which subtest failed.
> > > 
> > > But an idea I have right now would be to add a StringRef parameter which 
> > > is then fed into the expect/assert to identify the subtest.
> > Let's take care of this in a separate patch then. If a function or lambda 
> > won't do, we can at least use a macro instead?
> You can then add a function taking a source location maybe (+ optionally a 
> macro passing `__FILE__` and `__LINE__`). WDYT?
See D129982.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129940

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


[PATCH] D129982: [clang-format][NFC] Refactor RequiresDoesNotChangeParsingOfTheRest

2022-07-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: HazardyKnusperkeks, curdeius, MyDeveloperDay.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129982

Files:
  clang/unittests/Format/TokenAnnotatorTest.cpp

Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -549,259 +549,107 @@
 }
 
 TEST_F(TokenAnnotatorTest, RequiresDoesNotChangeParsingOfTheRest) {
-  auto NumberOfAdditionalRequiresClauseTokens = 5u;
-  auto NumberOfTokensBeforeRequires = 5u;
-
-  auto BaseTokens = annotate("template\n"
- "T Pi = 3.14;");
-  auto ConstrainedTokens = annotate("template\n"
-"  requires Foo\n"
-"T Pi = 3.14;");
-
-  auto NumberOfBaseTokens = 11u;
-
-  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
-  ASSERT_EQ(ConstrainedTokens.size(),
-NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
-  << ConstrainedTokens;
-
-  for (auto I = 0u; I < NumberOfBaseTokens; ++I) {
-if (I < NumberOfTokensBeforeRequires) {
-  EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I;
-} else {
-  EXPECT_EQ(*BaseTokens[I],
-*ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens])
-  << I;
+  StringRef Requires;
+  StringRef Prefix;
+  StringRef Suffix;
+  auto RequiresTokenCount = 0u;
+  auto PrefixTokenCount = 0u;
+  auto SuffixTokenCount = 0u;
+
+  auto TestRequires = [&](int Line) {
+const auto BaseTokenCount = PrefixTokenCount + SuffixTokenCount;
+
+auto BaseCode = std::string(Prefix);
+BaseCode += Suffix;
+auto BaseTokens = annotate(BaseCode);
+
+auto ConstrainedCode = std::string(Prefix);
+ConstrainedCode += Requires;
+ConstrainedCode += Suffix;
+auto ConstrainedTokens = annotate(ConstrainedCode);
+
+ASSERT_EQ(BaseTokens.size(), BaseTokenCount)
+<< BaseTokens << " (Line " << Line << ')';
+ASSERT_EQ(ConstrainedTokens.size(), BaseTokenCount + RequiresTokenCount)
+<< ConstrainedTokens << " (Line " << Line << ')';
+
+for (auto I = 0u; I < BaseTokenCount; ++I) {
+  EXPECT_EQ(
+  *BaseTokens[I],
+  *ConstrainedTokens[I < PrefixTokenCount ? I : I + RequiresTokenCount])
+  << I << " (Line " << Line << ')';
 }
-  }
-
-  BaseTokens = annotate("template\n"
-"struct Bar;");
-  ConstrainedTokens = annotate("template\n"
-   "  requires Foo\n"
-   "struct Bar;");
-  NumberOfBaseTokens = 9u;
-
-  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
-  ASSERT_EQ(ConstrainedTokens.size(),
-NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
-  << ConstrainedTokens;
-
-  for (auto I = 0u; I < NumberOfBaseTokens; ++I) {
-if (I < NumberOfTokensBeforeRequires) {
-  EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I;
-} else {
-  EXPECT_EQ(*BaseTokens[I],
-*ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens])
-  << I;
-}
-  }
-
-  BaseTokens = annotate("template\n"
-"struct Bar {"
-"  T foo();\n"
-"  T bar();\n"
-"};");
-  ConstrainedTokens = annotate("template\n"
-   "  requires Foo\n"
-   "struct Bar {"
-   "  T foo();\n"
-   "  T bar();\n"
-   "};");
-  NumberOfBaseTokens = 21u;
-
-  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
-  ASSERT_EQ(ConstrainedTokens.size(),
-NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
-  << ConstrainedTokens;
-
-  for (auto I = 0u; I < NumberOfBaseTokens; ++I) {
-if (I < NumberOfTokensBeforeRequires) {
-  EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I;
-} else {
-  EXPECT_EQ(*BaseTokens[I],
-*ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens])
-  << I;
-}
-  }
-
-  BaseTokens = annotate("template\n"
-"Bar(T) -> Bar;");
-  ConstrainedTokens = annotate("template\n"
-   "  requires Foo\n"
-   "Bar(T) -> Bar;");
-  NumberOfBaseTokens = 16u;
-
-  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
-  ASSERT_EQ(ConstrainedTokens.size(),
-NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
-  << ConstrainedTokens;
-
-  for (auto I = 0u; I < NumberOfBaseTokens; ++I) 

[PATCH] D129748: [Modules] Disable preferred_name attribute in C++20 Modules

2022-07-17 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D129748#3654918 , @aaron.ballman 
wrote:

> For example, I would be IBOutletCollection, OwnerAttr, PointerAttr, and 
> TypeTagForDatatypeAttr all behave the same way as they all take a type 
> argument. I don't think we want to selectively disable so many attributes 
> (for example, disallowing owner and pointer attributes means we lose out on 
> C++ Core Guideline features that people will likely expect to be able to use 
> with modules.

I agree that there may be other problematic cases. But all of 
`IBOutletCollection`,`OwnerAttr`, `PointerAttr` and  `TypeTagForDatatypeAttr` 
wouldn't meet the same problem. And from what I can see, now `PreferredName` is 
special indeed. Since `PreferredName` is the only attribute whose argument type 
is `TypeArgument<"TypedefType">`. The reason is stated below.

In D129748#3655572 , @tahonermann 
wrote:

> I'm not following what the root problem is. You stated:
>
>> When we write the attribute preferred_name(foo) in ASTWriter, the compiler 
>> would try to write the type for the argument foo. Then when the compiler 
>> write the type for foo, the compiler find the type for foo is a TypeDef 
>> type. So the compiler would write the corresponding type foo_templ. 
>> The key point here is that the AST for foo_templ is complete now. 
>> Since the AST for foo_templ is constructed in Sema.
>
> Are you saying that the act of writing the AST is triggering the 
> instantiation/completion of `foo_templ`? Serialization should certainly 
> not cause such side effects.

No, I don't mention that.

> I'm likewise not following the concern with reading the AST:
>
>> When we read the attribute preferred_name(foo), we would read the type for 
>> the argument foo and then we would try to read the type foo_templ 
>> later. However, the key problem here is that when we read foo_templ, 
>> its AST is not constructed yet! So we get a different type with the writer 
>> writes. So here is the ODR violation.
>
> I wouldn't expect the same `Sema` instance to be used to both write and read 
> the same AST.

Yeah, I wouldn't expect that too.

> Can you try again to explain the root problem? Perhaps with references to 
> relevant code?

Yeah, following of  is my explanation to the root problem. It might be a little 
bit long. First, for the following code:

  C++
  template
  class basic_string_view;
  
  typedef basic_string_view string_view;
  
  template
  class
  __attribute__((__preferred_name__(string_view)))
  basic_string_view {
  public:
  basic_string_view() 
  {
  }
  };
  
  inline basic_string_view foo()
  {
return basic_string_view();
  }

The dumped AST would be:

  |-ClassTemplateDecl 0x7913ac8 <./string_view.h:1:1, line:2:7> col:7 in 
A. hidden basic_string_view
  | |-TemplateTypeParmDecl 0x7913950  col:16 in A. 
hidden class depth 0 index 0 _CharT
  | |-CXXRecordDecl 0x7913a18  col:7 in A. hidden 
class basic_string_view
  | `-ClassTemplateSpecializationDecl 0x7913cd0  line:9:1 
in A. class basic_string_view definition
  |   |-DefinitionData pass_in_registers empty standard_layout 
trivially_copyable has_user_declared_ctor can_const_default_init
  |   | |-DefaultConstructor exists non_trivial user_provided 
defaulted_is_constexpr
  |   | |-CopyConstructor simple trivial has_const_param 
implicit_has_const_param
  |   | |-MoveConstructor exists simple trivial
  |   | |-CopyAssignment simple trivial has_const_param needs_implicit 
implicit_has_const_param
  |   | |-MoveAssignment exists simple trivial needs_implicit
  |   | `-Destructor simple irrelevant trivial constexpr
  |   |-TemplateArgument type 'char'
  |   | `-BuiltinType 0x78c77b0 'char'
  |   |-PreferredNameAttr 0x79143c8  string_view
  |   |-CXXRecordDecl 0x7914698  col:1 in A. 
implicit class basic_string_view
  |   |-AccessSpecDecl 0x7914748  col:1 in A. public
  |   |-CXXConstructorDecl 0x7935158  line:11:5 in 
A. used basic_string_view 'void ()'
  |   | `-CompoundStmt 0x79143a8 
  |   |-CXXConstructorDecl 0x7935300  col:1 in A. implicit 
constexpr basic_string_view 'void (const string_view &)' inline default trivial 
noexcept-unevaluated 0x7935300
  |   | `-ParmVarDecl 0x7935420  col:1 in A. 'const string_view 
&'
  |   |-CXXConstructorDecl 0x79354d0  col:1 in A. implicit 
constexpr basic_string_view 'void (string_view &&)' inline default trivial 
noexcept-unevaluated 0x79354d0
  |   | `-ParmVarDecl 0x79355f0  col:1 in A. 'string_view &&'
  |   `-CXXDestructorDecl 0x79357d0  col:1 in A. implicit 
referenced constexpr ~basic_string_view 'void () noexcept' inline default 
trivial
  |-TypedefDecl 0x7913e78  col:33 in A. hidden 
referenced string_view 'basic_string_view':'string_view'
  | `-TemplateSpecializationType 0x7913df0 'basic_string_view' sugar 
basic_string_view
  |   |-TemplateArgument type 'char'
  |   | `-BuiltinType 0x78c77b0 'char'
  |   `-RecordType 0x7913dd0 'string_view'
  |  

[PATCH] D128276: clang: perform deduction at the right depth on Sema::AddMethodTemplateCandidate

2022-07-17 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov edited the summary of this revision.
mizvekov updated this revision to Diff 445370.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128276

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p5-cxx20.cpp


Index: clang/test/CXX/temp/temp.decls/temp.variadic/p5-cxx20.cpp
===
--- /dev/null
+++ clang/test/CXX/temp/temp.decls/temp.variadic/p5-cxx20.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+namespace pr28087 {
+template  auto apply(F f) { f(); }
+template  struct S {
+  template  auto f(decltype(apply([](auto...) {})));
+};
+template struct S<>;
+} // namespace pr28087
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -7084,7 +7084,8 @@
   //   functions. In such a case, the candidate functions generated from each
   //   function template are combined with the set of non-template candidate
   //   functions.
-  TemplateDeductionInfo Info(CandidateSet.getLocation());
+  TemplateDeductionInfo Info(CandidateSet.getLocation(),
+ MethodTmpl->getTemplateParameters()->getDepth());
   FunctionDecl *Specialization = nullptr;
   ConversionSequenceList Conversions;
   if (TemplateDeductionResult Result = DeduceTemplateArguments(
@@ -14171,8 +14172,12 @@
   IsError |= InputInit.isInvalid();
   Arg = InputInit.getAs();
 } else {
-  ExprResult DefArg =
-  S.BuildCXXDefaultArgExpr(LParenLoc, Method, Method->getParamDecl(i));
+  ParmVarDecl *Param = Method->getParamDecl(i);
+  if (!Param->hasDefaultArg()) {
+IsError = true;
+break;
+  }
+  ExprResult DefArg = S.BuildCXXDefaultArgExpr(LParenLoc, Method, Param);
   if (DefArg.isInvalid()) {
 IsError = true;
 break;


Index: clang/test/CXX/temp/temp.decls/temp.variadic/p5-cxx20.cpp
===
--- /dev/null
+++ clang/test/CXX/temp/temp.decls/temp.variadic/p5-cxx20.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+namespace pr28087 {
+template  auto apply(F f) { f(); }
+template  struct S {
+  template  auto f(decltype(apply([](auto...) {})));
+};
+template struct S<>;
+} // namespace pr28087
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -7084,7 +7084,8 @@
   //   functions. In such a case, the candidate functions generated from each
   //   function template are combined with the set of non-template candidate
   //   functions.
-  TemplateDeductionInfo Info(CandidateSet.getLocation());
+  TemplateDeductionInfo Info(CandidateSet.getLocation(),
+ MethodTmpl->getTemplateParameters()->getDepth());
   FunctionDecl *Specialization = nullptr;
   ConversionSequenceList Conversions;
   if (TemplateDeductionResult Result = DeduceTemplateArguments(
@@ -14171,8 +14172,12 @@
   IsError |= InputInit.isInvalid();
   Arg = InputInit.getAs();
 } else {
-  ExprResult DefArg =
-  S.BuildCXXDefaultArgExpr(LParenLoc, Method, Method->getParamDecl(i));
+  ParmVarDecl *Param = Method->getParamDecl(i);
+  if (!Param->hasDefaultArg()) {
+IsError = true;
+break;
+  }
+  ExprResult DefArg = S.BuildCXXDefaultArgExpr(LParenLoc, Method, Param);
   if (DefArg.isInvalid()) {
 IsError = true;
 break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128095: clang: fix checking parameter packs for expansion

2022-07-17 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov edited the summary of this revision.
mizvekov updated this revision to Diff 445369.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128095

Files:
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/SemaInternal.h
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp

Index: clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
+++ clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
@@ -469,3 +469,25 @@
   bar(b);
 }
 }
+
+namespace pr56094 {
+template  struct D {
+  template  using B = int(int (*...p)(T, U));
+  // expected-error@-1 {{pack expansion contains parameter packs 'T' and 'U' that have different lengths (1 vs. 2)}}
+  template  D(B *);
+  // expected-note@-1 {{in instantiation of template type alias 'B' requested here}}
+};
+using t1 = D::B;
+// expected-note@-1 {{in instantiation of template class 'pr56094::D' requested here}}
+
+template  struct F {};
+template  struct G {};
+template  struct E {
+  template  using B = G...>;
+  // expected-error@-1 {{pack expansion contains parameter pack 'U' that has a different length (1 vs. 2) from outer parameter packs}}
+  template  E(B *);
+  // expected-note@-1 {{in instantiation of template type alias 'B' requested here}}
+};
+using t2 = E::B;
+// expected-note@-1 {{in instantiation of template class 'pr56094::E' requested here}}
+} // namespace pr56094
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -88,6 +88,17 @@
   return true;
 }
 
+bool VisitSubstTemplateTypeParmPackType(SubstTemplateTypeParmPackType *T) {
+  Unexpanded.push_back({T, SourceLocation()});
+  return true;
+}
+
+bool
+VisitSubstNonTypeTemplateParmPackExpr(SubstNonTypeTemplateParmPackExpr *E) {
+  Unexpanded.push_back({E, E->getParameterPackLocation()});
+  return true;
+}
+
 /// Record occurrences of function and non-type template
 /// parameter packs in an expression.
 bool VisitDeclRefExpr(DeclRefExpr *E) {
@@ -306,7 +317,8 @@
   auto *TTPD = dyn_cast(LocalPack);
   return TTPD && TTPD->getTypeForDecl() == TTPT;
 }
-return declaresSameEntity(Pack.first.get(), LocalPack);
+return declaresSameEntity(Pack.first.get(),
+  LocalPack);
   };
   if (llvm::any_of(LSI->LocalPacks, DeclaresThisPack))
 LambdaParamPackReferences.push_back(Pack);
@@ -358,7 +370,7 @@
   = Unexpanded[I].first.dyn_cast())
   Name = TTP->getIdentifier();
 else
-  Name = Unexpanded[I].first.get()->getIdentifier();
+  Name = Unexpanded[I].first.get()->getIdentifier();
 
 if (Name && NamesKnown.insert(Name).second)
   Names.push_back(Name);
@@ -421,7 +433,7 @@
   llvm::SmallPtrSet ParmSet(Parms.begin(), Parms.end());
   SmallVector UnexpandedParms;
   for (auto Parm : Unexpanded)
-if (ParmSet.contains(Parm.first.dyn_cast()))
+if (ParmSet.contains(Parm.first.dyn_cast()))
   UnexpandedParms.push_back(Parm);
   if (UnexpandedParms.empty())
 return false;
@@ -681,42 +693,51 @@
 // Compute the depth and index for this parameter pack.
 unsigned Depth = 0, Index = 0;
 IdentifierInfo *Name;
-bool IsVarDeclPack = false;
+unsigned NewPackSize;
+bool NotPack = true;
 
-if (const TemplateTypeParmType *TTP =
+if (const auto *TTP =
 ParmPack.first.dyn_cast()) {
   Depth = TTP->getDepth();
   Index = TTP->getIndex();
   Name = TTP->getIdentifier();
+} else if (const auto *STP =
+   ParmPack.first
+   .dyn_cast()) {
+  NewPackSize = STP->getNumArgs();
+  Name = STP->getIdentifier();
+  NotPack = false;
+} else if (const auto *SEP =
+   ParmPack.first
+   .dyn_cast()) {
+  NewPackSize = SEP->getArgumentPack().pack_size();
+  Name = SEP->getParameterPack()->getIdentifier();
+  NotPack = false;
 } else {
-  NamedDecl *ND = ParmPack.first.get();
-  if (isa(ND))
-IsVarDeclPack = true;
-  else
+  const auto *ND = ParmPack.first.get();
+  if (isa(ND)) {
+// Figure out whether we're instantiating to an argument pack or not.
+using DeclArgumentPack = LocalInstantiationScope::DeclArgumentPack;
+llvm::PointerUnion *Instantiation =
+CurrentInstantiationScope->findInstantiationOf(
+ParmPack.first.get());
+if (Instantiation->is()) {
+  // We could expand this function parameter pack.
+  NewPackSize = Instantiation->get()->size();
+ 

[PATCH] D128113: Clang: fix AST representation of expanded template arguments.

2022-07-17 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov edited the summary of this revision.
mizvekov updated this revision to Diff 445368.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128113

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/JSONNodeDumper.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/AST/ast-dump-template-decls.cpp

Index: clang/test/AST/ast-dump-template-decls.cpp
===
--- clang/test/AST/ast-dump-template-decls.cpp
+++ clang/test/AST/ast-dump-template-decls.cpp
@@ -136,13 +136,13 @@
 };
 using t1 = foo::bind;
 // CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'Y' sugar Y
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar pack_index 0
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar pack_index 1
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar pack_index 2
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar pack_index 3
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
 
 template  struct D {
@@ -152,13 +152,13 @@
 // CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'B' sugar alias B
 // CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (int (*)(float, int), int (*)(char, short))' cdecl
 // CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (float, int)' cdecl
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar pack_index 0
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar pack_index 0
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent contains_unexpanded_pack depth 0 index 0 pack
 // CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (char, short)' cdecl
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar pack_index 1
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar pack_index 1
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent contains_unexpanded_pack depth 0 index 0 pack
 } // namespace PR56099
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -4854,7 +4854,8 @@
 Replacement = SemaRef.Context.getQualifiedType(
 Replacement.getUnqualifiedType(), Qs);
 T = SemaRef.Context.getSubstTemplateTypeParmType(
-SubstTypeParam->getReplacedParameter(), Replacement);
+SubstTypeParam->getReplacedParameter(), Replacement,
+SubstTypeParam->getPackIndex());
   } else if ((AutoTy = dyn_cast(T)) && AutoTy->isDeduced()) {
 // 'auto' types behave the same way as template parameters.
 QualType Deduced = AutoTy->getDeducedType();
@@ -6410,9 +6411,8 @@
 
   // Always canonicalize the replacement type.
   Replacement = SemaRef.Context.getCanonicalType(Replacement);
-  QualType Result
-= SemaRef.Context.getSubstTemplateTypeParmType(T->getReplacedParameter(),
-   Replacement);
+  QualType Result = SemaRef.Context.getSubstTemplateTypeParmType(
+  T->getReplacedParameter(), Replacement, T->getPackIndex());
 
   // Propagate type-source information.
   SubstTemplateTypeParmTypeLoc NewTL
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ 

[PATCH] D129573: [Clang] add a diagnostic note 'while loop outside functions' at global scope

2022-07-17 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/test/Parser/while-loop-outside-function.c:3-4
+
+while(1) {}; // expected-error {{expected identifier or '('}} \
+ // expected-note {{while loop outside of functions}}
+

inclyc wrote:
> mizvekov wrote:
> > How about just making the error be the same thing the note would say?
> > 
> > 
> OK, so just create a new error directly, and then report the error when 
> encountering the `while` token?
Well the end result should be that there is only one error, `while` outside of 
function, because that explains everything the user needs to know.

It would be strange to report the `expected identifier or ...` error in 
addition to this one, it would be just noise.

How to go about implementing that I leave it up to you :P
Unless you need some specific help of course.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129573

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


[PATCH] D111509: [clang] use getCommonSugar in an assortment of places

2022-07-17 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 445365.
mizvekov marked 2 inline comments as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111509

Files:
  clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-ignoreconversionfromtypes-option.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/AST/ast-dump-fpfeatures.cpp
  clang/test/CodeGen/compound-assign-overflow.c
  clang/test/Sema/matrix-type-operators.c
  clang/test/Sema/nullability.c
  clang/test/Sema/sugar-common-types.c
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaCXX/sugar-common-types.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaObjC/format-strings-objc.m
  compiler-rt/test/ubsan/TestCases/Integer/add-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/no-recover.cpp
  compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
  libcxx/DELETE.ME

Index: libcxx/DELETE.ME
===
--- libcxx/DELETE.ME
+++ libcxx/DELETE.ME
@@ -1 +1,2 @@
 D111283
+D111509
Index: compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
@@ -12,12 +12,12 @@
 
 #ifdef SUB_I32
   (void)(uint32_t(1) - uint32_t(2));
-  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int'
+  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 #endif
 
 #ifdef SUB_I64
   (void)(uint64_t(800ll) - uint64_t(900ll));
-  // CHECK-SUB_I64: 800 - 900 cannot be represented in type 'unsigned {{long( long)?}}'
+  // CHECK-SUB_I64: 800 - 900 cannot be represented in type '{{uint64_t|unsigned long( long)?}}'
 #endif
 
 #ifdef SUB_I128
@@ -26,6 +26,6 @@
 # else
   puts("__int128 not supported\n");
 # endif
-  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
+  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type '__uint128_t'|__int128 not supported}}
 #endif
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
@@ -13,7 +13,7 @@
   (void)(uint16_t(0x) * uint16_t(0x8001));
 
   (void)(uint32_t(0x) * uint32_t(0x2));
-  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type 'unsigned int'
+  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 
   return 0;
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
@@ -18,7 +18,7 @@
 
 #ifdef ADD_I64
   (void)(uint64_t(1000ull) + uint64_t(900ull));
-  // CHECK-ADD_I64: 1000 + 900 cannot be represented in type 'unsigned {{long( long)?}}'
+  // CHECK-ADD_I64: 1000 + 900 cannot be represented in type '{{uint64_t|unsigned long( long)?}}'
 #endif
 
 #ifdef ADD_I128
@@ -27,6 +27,6 @@
 # else
   puts("__int128 not supported");
 # endif
-  // CHECK-ADD_I128: {{0x8000 \+ 0x8000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
+  // CHECK-ADD_I128: {{0x8000 \+ 0x8000 cannot be represented in type '__uint128_t'|__int128 not supported}}
 #endif
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
@@ -12,12 +12,12 @@
 
 #ifdef SUB_I32
   (void)(int32_t(-2) - int32_t(0x7fff));
-  // CHECK-SUB_I32: 

[PATCH] D129573: [Clang] add a diagnostic note 'while loop outside functions' at global scope

2022-07-17 Thread YingChi Long via Phabricator via cfe-commits
inclyc added inline comments.



Comment at: clang/test/Parser/while-loop-outside-function.c:3-4
+
+while(1) {}; // expected-error {{expected identifier or '('}} \
+ // expected-note {{while loop outside of functions}}
+

mizvekov wrote:
> How about just making the error be the same thing the note would say?
> 
> 
OK, so just create a new error directly, and then report the error when 
encountering the `while` token?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129573

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


[PATCH] D111283: [clang] template / auto deduction deduces common sugar

2022-07-17 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:11578
+  default:
+return X;
+  }

rsmith wrote:
> mizvekov wrote:
> > rsmith wrote:
> > > For `TemplateArgument::ArgKind::Declaration`, I think it'd make sense to 
> > > take the common type of the `getParamTypeForDecl`s.
> > Yeah, but this has been dead code since we went back to canonical template 
> > parameter / arguments.
> > I have removed it and put some unreachables in place.
> > We will circle back around to add it with this suggestion later.
> This will need to deal with all the cases that can arrive here. If it sees 
> resolved template arguments, then this includes `Type`, `Declaration`, 
> `NullPtr`, `Integral`, `Template`, `TemplateExpansion`, and `Pack`. If it 
> sees unresolved template arguments, then this includes at least `Type`, 
> `Expression`, `Template`, and `TemplateExpansion`. This function currently 
> doesn't cover either set, so I strongly suspect that this `llvm_unreachable` 
> is actually reachable.
> 
> Can we just `return X;` on all the cases we don't currently handle?
Yeah I will just return X for the peace of mind for now, but I think what is 
happening here is that we only see unresolved template arguments, so we would 
theoretically be missing the handling of Template and TemplateExpansion cases.

The problem is, I think we are not actually preserving type sugar of those two 
cases, because of a profiling bug.
I pointed this problem out recently in this revision: 
https://reviews.llvm.org/D126172

So this is probably pretty hard to test right now, and we would not even get 
any results from handling it, so I will
leave a FIXME instead.



Comment at: clang/lib/AST/ASTContext.cpp:12378-12379
+
+if (EPIX.EllipsisLoc != EPIY.EllipsisLoc)
+  EPIX.EllipsisLoc = SourceLocation();
+EPIX.HasTrailingReturn = EPIX.HasTrailingReturn && EPIY.HasTrailingReturn;

rsmith wrote:
> Can we cope with a variadic function with no ellipsis location? I'd expect 
> that to confuse some parts of Clang. Picking one of the two arbitrarily isn't 
> great but may be the best we can do.
> Can we cope with a variadic function with no ellipsis location? I'd expect 
> that to confuse some parts of Clang. Picking one of the two arbitrarily isn't 
> great but may be the best we can do.

Will leave that out for now with a FIXME.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:4715-4716
+ "substituting template parameter for 'auto' failed");
+  if (!Result.isNull())
+Deduced[0] = DeducedTemplateArgument(Result);
+  if (auto TDK = DeduceTemplateArgumentsFromCallArgument(

rsmith wrote:
> I do like this approach to repeated deduction, but I'm not sure that it 
> actually works. For example:
> 
> ```
> void f();
> void g();
> void g(int);
> auto h(bool b) {
>   if (b) return f;
>   return g;
> }
> ```
> I think this is required to fail to compile, because we can't deduce the 
> return type from the returned expression `g`. But I think what will happen 
> here is that we'll say that `g` is a non-deduced context and then succeed 
> because we pre-populated the deduced type from the `void(*)()` from `f`.
> 
> Instead, how about not pre-populating `Deduced[0]`, and instead "deducing" 
> the template parameter from `Result` after we check for the `TDK_Incomplete` 
> case below? That should still let us reuse the logic for merging deductions.
Nice find. We don't actually need to repeat the deduction. We only need to 
return Inconsistent deduction if Result and Deduced[0] are different, and get 
the common sugar otherwise.

We already had to do so for the `decltype(auto)` case, and we could have 
totally resugared the initializer lists but forgot as you pointed out, and we 
had to make this same check for that case anyway.

So I combined all these cases, further simplifying things, and added the new 
test case for initializer_list.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111283

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


[PATCH] D111283: [clang] template / auto deduction deduces common sugar

2022-07-17 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 445364.
mizvekov marked 9 inline comments as done.
Herald added subscribers: usaxena95, kadircet, arphaman.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111283

Files:
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
  clang/test/SemaCXX/deduced-return-void.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaTemplate/deduction.cpp
  libcxx/DELETE.ME

Index: libcxx/DELETE.ME
===
--- /dev/null
+++ libcxx/DELETE.ME
@@ -0,0 +1 @@
+D111283
Index: clang/test/SemaTemplate/deduction.cpp
===
--- clang/test/SemaTemplate/deduction.cpp
+++ clang/test/SemaTemplate/deduction.cpp
@@ -162,6 +162,15 @@
 
 } // namespace test4
 
+namespace test5 {
+
+template  class a {};
+template  void c(b, b);
+template  void c(a, a);
+void d() { c(a(), a()); }
+
+} // namespace test5
+
 // Verify that we can deduce enum-typed arguments correctly.
 namespace test14 {
   enum E { E0, E1 };
Index: clang/test/SemaCXX/sugared-auto.cpp
===
--- clang/test/SemaCXX/sugared-auto.cpp
+++ clang/test/SemaCXX/sugared-auto.cpp
@@ -1,4 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20
+// RUN: %clang_cc1 -fsyntax-only -verify -xobjective-c++ %s -std=c++20 -fblocks -fobjc-arc -fobjc-runtime-has-weak -fenable-matrix -Wno-dynamic-exception-spec
+
+namespace std {
+template struct initializer_list {
+  const T *begin, *end;
+  initializer_list();
+};
+} // namespace std
 
 enum class N {};
 
@@ -9,6 +16,26 @@
 using Man = Animal;
 using Dog = Animal;
 
+using ManPtr = Man *;
+using DogPtr = Dog *;
+
+using SocratesPtr = ManPtr;
+
+using ConstMan = const Man;
+using ConstDog = const Dog;
+
+using Virus = void;
+using SARS = Virus;
+using Ebola = Virus;
+
+using Bacteria = float;
+using Bacilli = Bacteria;
+using Vibrio = Bacteria;
+
+struct Plant;
+using Gymnosperm = Plant;
+using Angiosperm = Plant;
+
 namespace variable {
 
 auto x1 = Animal();
@@ -25,6 +52,9 @@
 N t4 = x4; // expected-error {{lvalue of type 'Man' (aka 'int')}}
 N t5 = x5; // expected-error {{lvalue of type 'Dog' (aka 'int')}}
 
+auto x6 = { Man(), Dog() };
+N t6 = x6; // expected-error {{from 'std::initializer_list' (aka 'initializer_list')}}
+
 } // namespace variable
 
 namespace function_basic {
@@ -41,3 +71,134 @@
 N t3 = x3; // expected-error {{lvalue of type 'Animal' (aka 'int')}}
 
 } // namespace function_basic
+
+namespace function_multiple_basic {
+
+N t1 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t2 = []() -> decltype(auto) { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t3 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Dog();
+  auto x = Man();
+  return x;
+}();
+
+N t4 = [] { // expected-error {{rvalue of type 'int'}}
+  if (true)
+return Dog();
+  return 1;
+}();
+
+N t5 = [] { // expected-error {{rvalue of type 'Virus' (aka 'void')}}
+  if (true)
+return Ebola();
+  return SARS();
+}();
+
+N t6 = [] { // expected-error {{rvalue of type 'void'}}
+  if (true)
+return SARS();
+  return;
+}();
+
+} // namespace function_multiple_basic
+
+#define TEST_AUTO(X, A, B) \
+  auto X(A a, B b) {   \
+if (0) \
+  return a;\
+if (0) \
+  return b;\
+return N();\
+  }
+#define TEST_DAUTO(X, A, B) \
+  decltype(auto) X(A a, B b) {  \
+if (0)  \
+  return static_cast(a); \
+if (0)  \
+  return static_cast(b); \
+return N(); \
+  }
+
+namespace misc {
+
+TEST_AUTO(t1, ManPtr, DogPtr)  // expected-error {{but deduced as 'Animal *' (aka 'int *')}}
+TEST_AUTO(t2, ManPtr, int *)   // expected-error {{but deduced as 'int *'}}
+TEST_AUTO(t3, SocratesPtr, ManPtr) // expected-error {{but deduced as 'ManPtr' (aka 'int *')}}
+
+TEST_AUTO(t4, _Atomic(Man), _Atomic(Dog)) // expected-error {{but deduced as '_Atomic(Animal)'}}
+
+using block_man = void (^)(Man);
+using block_dog = void (^)(Dog);
+TEST_AUTO(t5, block_man, block_dog) // expected-error {{but deduced 

[PATCH] D123319: Change how we handle auto return types for lambda operator() to be consistent with gcc

2022-07-17 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123319

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


[PATCH] D119051: Extend the C++03 definition of POD to include defaulted functions

2022-07-17 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119051

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


[PATCH] D111283: [clang] template / auto deduction deduces common sugar

2022-07-17 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 445358.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111283

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
  clang/test/SemaCXX/deduced-return-void.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaTemplate/deduction.cpp
  libcxx/DELETE.ME

Index: libcxx/DELETE.ME
===
--- /dev/null
+++ libcxx/DELETE.ME
@@ -0,0 +1 @@
+D111283
Index: clang/test/SemaTemplate/deduction.cpp
===
--- clang/test/SemaTemplate/deduction.cpp
+++ clang/test/SemaTemplate/deduction.cpp
@@ -162,6 +162,15 @@
 
 } // namespace test4
 
+namespace test5 {
+
+template  class a {};
+template  void c(b, b);
+template  void c(a, a);
+void d() { c(a(), a()); }
+
+} // namespace test5
+
 // Verify that we can deduce enum-typed arguments correctly.
 namespace test14 {
   enum E { E0, E1 };
Index: clang/test/SemaCXX/sugared-auto.cpp
===
--- clang/test/SemaCXX/sugared-auto.cpp
+++ clang/test/SemaCXX/sugared-auto.cpp
@@ -1,4 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20
+// RUN: %clang_cc1 -fsyntax-only -verify -xobjective-c++ %s -std=c++20 -fblocks -fobjc-arc -fobjc-runtime-has-weak -fenable-matrix -Wno-dynamic-exception-spec
+
+namespace std {
+template struct initializer_list {
+  const T *begin, *end;
+  initializer_list();
+};
+} // namespace std
 
 enum class N {};
 
@@ -9,6 +16,26 @@
 using Man = Animal;
 using Dog = Animal;
 
+using ManPtr = Man *;
+using DogPtr = Dog *;
+
+using SocratesPtr = ManPtr;
+
+using ConstMan = const Man;
+using ConstDog = const Dog;
+
+using Virus = void;
+using SARS = Virus;
+using Ebola = Virus;
+
+using Bacteria = float;
+using Bacilli = Bacteria;
+using Vibrio = Bacteria;
+
+struct Plant;
+using Gymnosperm = Plant;
+using Angiosperm = Plant;
+
 namespace variable {
 
 auto x1 = Animal();
@@ -25,6 +52,9 @@
 N t4 = x4; // expected-error {{lvalue of type 'Man' (aka 'int')}}
 N t5 = x5; // expected-error {{lvalue of type 'Dog' (aka 'int')}}
 
+auto x6 = { Man(), Dog() };
+N t6 = x6; // expected-error {{from 'std::initializer_list' (aka 'initializer_list')}}
+
 } // namespace variable
 
 namespace function_basic {
@@ -41,3 +71,134 @@
 N t3 = x3; // expected-error {{lvalue of type 'Animal' (aka 'int')}}
 
 } // namespace function_basic
+
+namespace function_multiple_basic {
+
+N t1 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t2 = []() -> decltype(auto) { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t3 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Dog();
+  auto x = Man();
+  return x;
+}();
+
+N t4 = [] { // expected-error {{rvalue of type 'int'}}
+  if (true)
+return Dog();
+  return 1;
+}();
+
+N t5 = [] { // expected-error {{rvalue of type 'Virus' (aka 'void')}}
+  if (true)
+return Ebola();
+  return SARS();
+}();
+
+N t6 = [] { // expected-error {{rvalue of type 'void'}}
+  if (true)
+return SARS();
+  return;
+}();
+
+} // namespace function_multiple_basic
+
+#define TEST_AUTO(X, A, B) \
+  auto X(A a, B b) {   \
+if (0) \
+  return a;\
+if (0) \
+  return b;\
+return N();\
+  }
+#define TEST_DAUTO(X, A, B) \
+  decltype(auto) X(A a, B b) {  \
+if (0)  \
+  return static_cast(a); \
+if (0)  \
+  return static_cast(b); \
+return N(); \
+  }
+
+namespace misc {
+
+TEST_AUTO(t1, ManPtr, DogPtr)  // expected-error {{but deduced as 'Animal *' (aka 'int *')}}
+TEST_AUTO(t2, ManPtr, int *)   // expected-error {{but deduced as 'int *'}}
+TEST_AUTO(t3, SocratesPtr, ManPtr) // expected-error {{but deduced as 'ManPtr' (aka 'int *')}}
+
+TEST_AUTO(t4, _Atomic(Man), _Atomic(Dog)) // expected-error {{but deduced as '_Atomic(Animal)'}}
+
+using block_man = void (^)(Man);
+using block_dog = void (^)(Dog);
+TEST_AUTO(t5, block_man, block_dog) // expected-error {{but deduced as 'void (^__strong)(Animal)'}}
+
+using fp1 = SARS (*)(Man, DogPtr) throw(Vibrio);
+using fp2 = Ebola (*)(Dog, ManPtr) throw(Bacilli);
+TEST_AUTO(t6, fp1, fp2); // expected-error {{but deduced as 'Virus (*)(Animal, Animal *) throw(Bacteria)' 

[clang] 8b3ed1f - Remove redundant return statements (NFC)

2022-07-17 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-17T15:37:46-07:00
New Revision: 8b3ed1fa984b07c88f218d0ddc6b3e2c0629a9fa

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

LOG: Remove redundant return statements (NFC)

Identified with readability-redundant-control-flow.

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
flang/lib/Frontend/TextDiagnosticPrinter.cpp
flang/lib/Lower/Allocatable.cpp
flang/lib/Lower/ConvertType.cpp
flang/lib/Optimizer/Transforms/AffinePromotion.cpp
flang/lib/Semantics/check-directive-structure.h
lldb/include/lldb/Symbol/SymbolFile.h
llvm/lib/Transforms/Scalar/LoopInterchange.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c04186dea43eb..0b4c450f76e0d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -19721,7 +19721,6 @@ class EvaluatedExprMarker : public 
UsedDeclVisitor {
   void VisitConstantExpr(ConstantExpr *E) {
 // Don't mark declarations within a ConstantExpression, as this expression
 // will be evaluated and folded to a value.
-return;
   }
 
   void VisitDeclRefExpr(DeclRefExpr *E) {

diff  --git a/flang/lib/Frontend/TextDiagnosticPrinter.cpp 
b/flang/lib/Frontend/TextDiagnosticPrinter.cpp
index 5ee4122af1053..12c41d77ba467 100644
--- a/flang/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/flang/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -56,5 +56,4 @@ void TextDiagnosticPrinter::HandleDiagnostic(
   diagMessageStream.str(), diagOpts->ShowColors);
 
   os.flush();
-  return;
 }

diff  --git a/flang/lib/Lower/Allocatable.cpp b/flang/lib/Lower/Allocatable.cpp
index 01a13b8555fa8..08a90f168 100644
--- a/flang/lib/Lower/Allocatable.cpp
+++ b/flang/lib/Lower/Allocatable.cpp
@@ -500,7 +500,6 @@ void Fortran::lower::genAllocateStmt(
 Fortran::lower::AbstractConverter ,
 const Fortran::parser::AllocateStmt , mlir::Location loc) {
   AllocateStmtHelper{converter, stmt, loc}.lower();
-  return;
 }
 
 
//===--===//

diff  --git a/flang/lib/Lower/ConvertType.cpp b/flang/lib/Lower/ConvertType.cpp
index 0ab9d2d1b48e0..772c8508b7c05 100644
--- a/flang/lib/Lower/ConvertType.cpp
+++ b/flang/lib/Lower/ConvertType.cpp
@@ -368,7 +368,6 @@ struct TypeBuilder {
   params.push_back(getCharacterLength(exprOrSym));
 else if (category == Fortran::common::TypeCategory::Derived)
   TODO(converter.getCurrentLocation(), "derived type length parameters");
-return;
   }
   Fortran::lower::LenParameterTy
   getCharacterLength(const Fortran::semantics::Symbol ) {

diff  --git a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp 
b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
index c6df98769a64b..90b4364866c96 100644
--- a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
+++ b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
@@ -242,7 +242,6 @@ struct AffineIfCondition {
 integerSet = mlir::IntegerSet::get(dimCount, symCount,
{constraintPair.getValue().first},
{constraintPair.getValue().second});
-return;
   }
 
   llvm::Optional>
@@ -392,7 +391,6 @@ static void populateIndexArgs(fir::ArrayCoorOp acoOp,
 return populateIndexArgs(acoOp, shapeShift, indexArgs, rewriter);
   if (auto slice = acoOp.getShape().getDefiningOp())
 return populateIndexArgs(acoOp, slice, indexArgs, rewriter);
-  return;
 }
 
 /// Returns affine.apply and fir.convert from array_coor and gendims

diff  --git a/flang/lib/Semantics/check-directive-structure.h 
b/flang/lib/Semantics/check-directive-structure.h
index 6444e839967df..3fdcbf2b88ec4 100644
--- a/flang/lib/Semantics/check-directive-structure.h
+++ b/flang/lib/Semantics/check-directive-structure.h
@@ -142,7 +142,6 @@ template  class NoBranchingEnforce {
 // did not found an enclosing looping construct within the OpenMP/OpenACC
 // directive
 EmitUnlabelledBranchOutError(stmt);
-return;
   }
 
   SemanticsContext _;

diff  --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index 1470b96f24917..ed0de1b5bce6b 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -132,7 +132,7 @@ class SymbolFile : public PluginInterface {
   /// Specify debug info should be loaded.
   ///
   /// It will be no-op for most implementations except SymbolFileOnDemand.
-  virtual void SetLoadDebugInfoEnabled() { return; }
+  virtual void SetLoadDebugInfoEnabled() {}
 
   // Compile Unit function calls
   // Approach 1 - iterator

diff  --git a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp 
b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
index 1d3023d04463f..18daa42952242 

[clang] 8dfdb80 - Ensure newlines at the end of files (NFC)

2022-07-17 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-17T15:37:45-07:00
New Revision: 8dfdb80f72c080585517f10862b3b08d745b9155

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

LOG: Ensure newlines at the end of files (NFC)

Added: 


Modified: 
clang/lib/Basic/MakeSupport.cpp
libc/src/math/generic/CMakeLists.txt
llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.cpp
llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h
mlir/lib/Conversion/VectorToGPU/NvGpuSupport.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMIntrinsicOps.cpp

Removed: 




diff  --git a/clang/lib/Basic/MakeSupport.cpp b/clang/lib/Basic/MakeSupport.cpp
index 37838f7bbc7bc..4ddfcc350410c 100644
--- a/clang/lib/Basic/MakeSupport.cpp
+++ b/clang/lib/Basic/MakeSupport.cpp
@@ -32,4 +32,4 @@ void clang::quoteMakeTarget(StringRef Target, 
SmallVectorImpl ) {
 
 Res.push_back(Target[i]);
   }
-}
\ No newline at end of file
+}

diff  --git a/libc/src/math/generic/CMakeLists.txt 
b/libc/src/math/generic/CMakeLists.txt
index 1a693e6d5c2c9..41588104cf62f 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -1115,4 +1115,4 @@ add_entrypoint_object(
 libc.src.__support.FPUtil.generic.fmod
   COMPILE_OPTIONS
 -O3
-)
\ No newline at end of file
+)

diff  --git a/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp 
b/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
index 43b9c2ba400b7..dc07eaeaf615c 100644
--- a/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
@@ -524,4 +524,4 @@ COFFLinkGraphBuilder::exportCOMDATSymbol(COFFSymbolIndex 
SymIndex,
 }
 
 } // namespace jitlink
-} // namespace llvm
\ No newline at end of file
+} // namespace llvm

diff  --git a/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.cpp 
b/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.cpp
index 57cd4bafd3516..1926977ea66ea 100644
--- a/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.cpp
@@ -92,4 +92,4 @@ void SPIRVGeneralDuplicatesTracker::buildDepsGraph(
   }
 }
   }
-}
\ No newline at end of file
+}

diff  --git a/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h 
b/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h
index 58ae1f86ce42c..c2801faf6f0eb 100644
--- a/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h
+++ b/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h
@@ -171,4 +171,4 @@ class SPIRVGeneralDuplicatesTracker {
   }
 };
 } // namespace llvm
-#endif
\ No newline at end of file
+#endif

diff  --git a/mlir/lib/Conversion/VectorToGPU/NvGpuSupport.cpp 
b/mlir/lib/Conversion/VectorToGPU/NvGpuSupport.cpp
index af14aaa1deeec..65f97da634675 100644
--- a/mlir/lib/Conversion/VectorToGPU/NvGpuSupport.cpp
+++ b/mlir/lib/Conversion/VectorToGPU/NvGpuSupport.cpp
@@ -332,4 +332,4 @@ 
PrepareContractToGPUMMASync::matchAndRewrite(vector::ContractionOp op,
 }
 
 } // namespace nvgpu
-} // namespace mlir
\ No newline at end of file
+} // namespace mlir

diff  --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMIntrinsicOps.cpp 
b/mlir/lib/Dialect/LLVMIR/IR/LLVMIntrinsicOps.cpp
index 15f15b745e190..a5d85a7cf4ccb 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMIntrinsicOps.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMIntrinsicOps.cpp
@@ -4,4 +4,4 @@ using namespace mlir;
 using namespace mlir::LLVM;
 
 #define GET_OP_CLASSES
-#include "mlir/Dialect/LLVMIR/LLVMIntrinsicOps.cpp.inc"
\ No newline at end of file
+#include "mlir/Dialect/LLVMIR/LLVMIntrinsicOps.cpp.inc"



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


[PATCH] D128619: [Clang] Implement P0848 (Conditionally Trivial Special Member Functions)

2022-07-17 Thread H. Vetinari via Phabricator via cfe-commits
h-vetinari added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:494-497
+- Implemented "Conditionally Trivial Special Member Functions" (`P0848 
`_).
+  Note: The handling of deleted functions is not yet compliant, as Clang
+  does not implement `DR1496 
`_
+  and `DR1734 
`_.

Is that lack of compliance worth a note in `cxx_status`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128619

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


[PATCH] D129940: [clang-format] Fix misannotation of colon in presence of requires clause

2022-07-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added inline comments.



Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:820-833
+  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
+  ASSERT_EQ(ConstrainedTokens.size(),
+NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
+  << ConstrainedTokens;
+
+  for (auto I = 0u; I < NumberOfBaseTokens; ++I) {
+if (I < NumberOfTokensBeforeRequires) {

HazardyKnusperkeks wrote:
> curdeius wrote:
> > owenpan wrote:
> > > Can you make it a function or lambda?
> > :+1:
> Often thought about that. But as @MyDeveloperDay mentioned in different other 
> reviews, we would loose the line where the EXPECT failed, since it would 
> always be the same line.
> 
> One step to mitigate that would be to return a `bool`, then one would loose 
> the "subexpect", only knows which subtest failed.
> 
> But an idea I have right now would be to add a StringRef parameter which is 
> then fed into the expect/assert to identify the subtest.
Let's take care of this in a separate patch then. If a function or lambda won't 
do, we can at least use a macro instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129940

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


[PATCH] D128619: [Clang] Implement P0848 (Conditionally Trivial Special Member Functions)

2022-07-17 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 445350.
royjacobson marked an inline comment as not done.
royjacobson added a comment.

Add a test case with more subsumption


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128619

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/AST/conditionally-trivial-smfs.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/SemaCXX/constrained-special-member-functions.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -927,7 +927,7 @@
   

 https://wg21.link/p0848r3;>P0848R3
-No
+Clang 15
   
   
 https://wg21.link/p1616r1;>P1616R1
Index: clang/test/SemaCXX/constrained-special-member-functions.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constrained-special-member-functions.cpp
@@ -0,0 +1,186 @@
+// RUN: %clang_cc1 -verify -std=c++20 %s
+// expected-no-diagnostics
+
+template 
+concept C0 = (N == 0);
+template 
+concept C1 = (N == 1);
+template 
+concept C2 = (N == 2);
+
+// Checks are indexed by:
+// Definition:
+//  1. Explicitly defaulted definition
+//  2. Deleted definition
+//  3. User provided definition
+// We have a less constrained user provided method that should not disable
+// the (copyable) triviality of the type.
+
+// Note that because Clang does not implement DRs 1496 and 1734, we say some
+// classes are trivial when the SMFs are deleted.
+
+template 
+struct DefaultConstructorChecker {
+DefaultConstructorChecker() requires C0 = default;
+DefaultConstructorChecker() requires C1 = delete;
+DefaultConstructorChecker() requires C2;
+DefaultConstructorChecker();
+};
+static_assert(__is_trivially_copyable(DefaultConstructorChecker<0>));
+static_assert(__is_trivially_copyable(DefaultConstructorChecker<1>));
+static_assert(__is_trivially_copyable(DefaultConstructorChecker<2>));
+static_assert(__is_trivially_copyable(DefaultConstructorChecker<3>));
+static_assert(__is_trivial(DefaultConstructorChecker<0>));
+// FIXME: DR1496
+static_assert(__is_trivial(DefaultConstructorChecker<1>));
+static_assert(!__is_trivial(DefaultConstructorChecker<2>));
+static_assert(!__is_trivial(DefaultConstructorChecker<3>));
+
+template 
+struct CopyConstructorChecker {
+CopyConstructorChecker(const CopyConstructorChecker&) requires C0 = default;
+CopyConstructorChecker(const CopyConstructorChecker&) requires C1 = delete;
+CopyConstructorChecker(const CopyConstructorChecker&) requires C2;
+CopyConstructorChecker(const CopyConstructorChecker&);
+};
+
+static_assert(__is_trivially_copyable(CopyConstructorChecker<0>));
+// FIXME: DR1734
+static_assert(__is_trivially_copyable(CopyConstructorChecker<1>));
+static_assert(!__is_trivially_copyable(CopyConstructorChecker<2>));
+static_assert(!__is_trivially_copyable(CopyConstructorChecker<3>));
+static_assert(!__is_trivial(CopyConstructorChecker<0>));
+static_assert(!__is_trivial(CopyConstructorChecker<1>));
+static_assert(!__is_trivial(CopyConstructorChecker<2>));
+static_assert(!__is_trivial(CopyConstructorChecker<3>));
+
+template 
+struct MoveConstructorChecker {
+MoveConstructorChecker(MoveConstructorChecker&&) requires C0 = default;
+MoveConstructorChecker(MoveConstructorChecker&&) requires C1 = delete;
+MoveConstructorChecker(MoveConstructorChecker&&) requires C2;
+MoveConstructorChecker(MoveConstructorChecker&&);
+};
+
+static_assert(__is_trivially_copyable(MoveConstructorChecker<0>));
+// FIXME: DR1734
+static_assert(__is_trivially_copyable(MoveConstructorChecker<1>));
+static_assert(!__is_trivially_copyable(MoveConstructorChecker<2>));
+static_assert(!__is_trivially_copyable(MoveConstructorChecker<3>));
+static_assert(!__is_trivial(MoveConstructorChecker<0>));
+static_assert(!__is_trivial(MoveConstructorChecker<1>));
+static_assert(!__is_trivial(MoveConstructorChecker<2>));
+static_assert(!__is_trivial(MoveConstructorChecker<3>));
+
+template 
+struct MoveAssignmentChecker {
+MoveAssignmentChecker& operator=(MoveAssignmentChecker&&) requires C0 = default;
+MoveAssignmentChecker& operator=(MoveAssignmentChecker&&) requires C1 = delete;
+MoveAssignmentChecker& operator=(MoveAssignmentChecker&&) requires C2;
+MoveAssignmentChecker& operator=(MoveAssignmentChecker&&);
+};
+
+static_assert(__is_trivially_copyable(MoveAssignmentChecker<0>));
+// FIXME: DR1734.
+static_assert(__is_trivially_copyable(MoveAssignmentChecker<1>));
+static_assert(!__is_trivially_copyable(MoveAssignmentChecker<2>));

[PATCH] D129954: [CodeGen][inlineasm] assume the flag output of inline asm is boolean value

2022-07-17 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D129954#3658139 , @nikic wrote:

> Hm, might it be better to teach LLVM about this (in some 
> ConstantRange/KnownBits logic)? This doesn't really seem like something the 
> frontend should know about and encode, as that means each frontend has to add 
> this annotation by itself.

Agreed that teaching LLVM about his saves other frontends from doing the same 
thing. The information is inline asm semantic defined by GCC extension though, 
I think putting it in the frontend is a valid choice and makes the 
implementation easy.

I looked into where to put this in LLVM. It seems nontrivial: existing 
ConstantRanges are computed from binary-op/comparsion etc. Inferring range from 
an inline asm call is something passes (LazyValueInfo) need to learn, with some 
kinds of def-use chain walking. That said, I'm definitely new to ConstantRange 
analysis, it may well be that this is not that hard to implement. Could you 
please give some guidance?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129954

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


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-17 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny created this revision.
Herald added subscribers: usaxena95, kadircet.
Herald added a project: All.
SimplyDanny requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added projects: clang, clang-tools-extra.

Without the "found declaration" it is later not possible to know where the 
operator declaration
was brought into the scope calling it.

The initial motivation for this fix came from #55095. However, this also has an 
influence on
`clang -ast-dump` which now prints a `UsingShadow` attribute for operators only 
visible through
`using` statements. Also, clangd now correctly references the `using` statement 
instead of the
operator directly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129973

Files:
  clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp


Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -4675,6 +4675,9 @@
   EXPECT_TRUE(notMatches(
 "namespace a { void f(); } using a::f; void g() { a::f(); }",
 declRefExpr(throughUsingDecl(anything();
+  EXPECT_TRUE(matches(
+"struct S {}; namespace a { int operator+(S s1, S s2) { return 0; }; } 
using a::operator+; int g() { S a, b; return a + b; }",
+declRefExpr(throughUsingDecl(anything();
 }
 
 TEST(SingleDecl, IsSingleDecl) {
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -63,8 +63,10 @@
   // being used.
   if (FoundDecl != Fn && S.DiagnoseUseOfDecl(Fn, Loc))
 return ExprError();
-  DeclRefExpr *DRE = new (S.Context)
-  DeclRefExpr(S.Context, Fn, false, Fn->getType(), VK_LValue, Loc, 
LocInfo);
+  DeclRefExpr *DRE =
+  DeclRefExpr::Create(S.Context, Fn->getQualifierLoc(), Loc, Fn, false,
+  Loc, Fn->getType(),  VK_LValue,
+  FoundDecl);
   if (HadMultipleCandidates)
 DRE->setHadMultipleCandidates(true);
 
Index: clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
@@ -210,3 +210,14 @@
 // We used to report Q unsued, because we only checked the first template
 // argument.
 Bar *bar;
+
+namespace internal { 
+  struct S {};
+  int operator+(S s1, S s2) { return 0; };
+} 
+
+// Make sure this statement is not reported as unused.
+using internal::operator+; 
+using internal::S;
+
+int j() { return S() + S(); }


Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -4675,6 +4675,9 @@
   EXPECT_TRUE(notMatches(
 "namespace a { void f(); } using a::f; void g() { a::f(); }",
 declRefExpr(throughUsingDecl(anything();
+  EXPECT_TRUE(matches(
+"struct S {}; namespace a { int operator+(S s1, S s2) { return 0; }; } using a::operator+; int g() { S a, b; return a + b; }",
+declRefExpr(throughUsingDecl(anything();
 }
 
 TEST(SingleDecl, IsSingleDecl) {
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -63,8 +63,10 @@
   // being used.
   if (FoundDecl != Fn && S.DiagnoseUseOfDecl(Fn, Loc))
 return ExprError();
-  DeclRefExpr *DRE = new (S.Context)
-  DeclRefExpr(S.Context, Fn, false, Fn->getType(), VK_LValue, Loc, LocInfo);
+  DeclRefExpr *DRE =
+  DeclRefExpr::Create(S.Context, Fn->getQualifierLoc(), Loc, Fn, false,
+  Loc, Fn->getType(),  VK_LValue,
+  FoundDecl);
   if (HadMultipleCandidates)
 DRE->setHadMultipleCandidates(true);
 
Index: clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
@@ -210,3 +210,14 @@
 // We used to report Q unsued, because we only checked the first template
 // argument.
 Bar *bar;
+
+namespace internal { 
+  struct S {};
+  int operator+(S s1, S s2) { return 0; };
+} 
+
+// Make sure this statement is not reported as unused.
+using internal::operator+; 
+using internal::S;
+
+int j() { return S() + S(); }

[PATCH] D129971: [clangd][WIP] Add doxygen parsing for Hover

2022-07-17 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders abandoned this revision.
tom-anders added a comment.

Sorry, meant to make this a draft


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129971

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


[PATCH] D129971: [clangd][WIP] Add doxygen parsing for Hover

2022-07-17 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders created this revision.
Herald added subscribers: usaxena95, kadircet, arphaman, mgorny.
Herald added a project: All.
tom-anders requested review of this revision.
Herald added subscribers: cfe-commits, llvm-commits, MaskRay, ilya-biryukov.
Herald added projects: LLVM, clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129971

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeCompletionStrings.cpp
  clang-tools-extra/clangd/CodeCompletionStrings.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/SymbolDocumentation.cpp
  clang-tools-extra/clangd/SymbolDocumentation.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn

Index: llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn
@@ -113,6 +113,7 @@
 "SemanticHighlighting.cpp",
 "SemanticSelection.cpp",
 "SourceCode.cpp",
+"SymbolDocumentation.cpp"
 "TUScheduler.cpp",
 "TidyProvider.cpp",
 "URI.cpp",
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -914,7 +914,8 @@
   /*IncludeBriefComments*/ false);
   std::string Documentation =
   formatDocumentation(*CCS, getDocComment(Ctx, SymbolCompletion,
-  /*CommentsFromHeaders=*/true));
+  /*CommentsFromHeaders=*/true)
+.CommentText);
   if (!(S.Flags & Symbol::IndexedForCodeCompletion)) {
 if (Opts.StoreAllDocumentation)
   S.Documentation = Documentation;
Index: clang-tools-extra/clangd/SymbolDocumentation.h
===
--- /dev/null
+++ clang-tools-extra/clangd/SymbolDocumentation.h
@@ -0,0 +1,71 @@
+//===--- SymbolDocumentation.h ==-*- 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
+//
+//===--===//
+//
+// Class to parse doxygen comments into a flat structure for consumption
+// in e.g. Hover and Code Completion
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SYMBOLDOCUMENTATION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SYMBOLDOCUMENTATION_H
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Comment.h"
+#include "clang/AST/CommentVisitor.h"
+
+namespace clang {
+namespace clangd {
+
+struct ParameterDocumentation {
+  llvm::StringRef Name;
+  std::string Description;
+  llvm::Optional PassDirection;
+};
+
+struct ExceptionDocumentation {
+  llvm::StringRef Exception;
+  std::string Description;
+};
+
+struct SymbolDocumentation {
+  SymbolDocumentation(const RawComment , const ASTContext ,
+  const Preprocessor *PP, const Decl *D);
+
+  void visitFullComment(const comments::FullComment *FC);
+  void visitParamCommandComment(const comments::ParamCommandComment *P);
+
+  SymbolDocumentation() = default;
+  SymbolDocumentation(const std::string ) : CommentText(Doc) {}
+
+  bool empty() const { return CommentText.empty(); }
+
+  std::string Brief;
+
+  std::string Returns;
+
+  llvm::SmallVector Notes;
+  llvm::SmallVector Warnings;
+
+  /// \\param commands that match a parameter in the function declaration
+  std::map MatchingParameterDocs;
+
+  llvm::SmallVector UnmatchedParameterDocs;
+
+  llvm::SmallVector Throws;
+
+  /// All the paragraphs we don't have any special handling for, e.g. \details
+  std::string Description;
+
+  /// The full text of the doxygen comment
+  std::string CommentText;
+};
+
+} // namespace clangd
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_SYMBOLDOCUMENTATION_H
Index: clang-tools-extra/clangd/SymbolDocumentation.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/SymbolDocumentation.cpp
@@ -0,0 +1,149 @@
+//===--- SymbolDocumentation.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 

[PATCH] D129951: [clang] teaches Clang the special ADL rules for functions in std::ranges

2022-07-17 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added inline comments.



Comment at: clang/lib/Sema/SemaOverload.cpp:9438
   // FIXME: Pass in the explicit template arguments?
   ArgumentDependentLookup(Name, Loc, Args, Fns);
 

rsmith wrote:
> It would seem preferable to me to do the filtering in 
> `ArgumentDependentLookup` itself rather than here (but I don't feel strongly 
> about it).
Agreed. I tried to do it there, but was having issues getting it working. I'll 
give it a second go?



Comment at: clang/lib/Sema/SemaOverload.cpp:9455-9459
+// Functions in 'std::ranges' are hidden from ADL per [range.iter.ops]/2 
and
+// [algorithms.requirements]/2.
+if ((*I)->isInStdRangesNamespace() &&
+Name.getNameKind() == DeclarationName::NameKind::Identifier)
+  continue;

rsmith wrote:
> I worry that this might break some stdlib implementation that finds helper 
> functions via ADL in `std::ranges` somehow. Also, it seems desirable to make 
> this opt-in for the stdlib implementation and indeed for end-user functions 
> not in `std::ranges`.
> 
> Have you considered enabling this behavior with an attribute instead of by 
> detecting whether the function is in `std::ranges`?
You're the second person to have suggested this, and I daresay Aaron will too, 
based on our prior discussion about this. We'd chatted about `__disable_adl` 
specifically, so that anyone who uses it won't be affected by a silent change 
from Clang to GCC: they'd instead get a break. I would prefer an attribute too.

My main concern is that other stdlib implementers would object to adding yet 
another annotation to their function calls (based on my failure to get libc++ 
to be as aggressive as Microsoft/STL is with `[[nodiscard]]`).



Comment at: clang/lib/Sema/SemaOverload.cpp:12837-12841
+  // Functions in 'std::ranges' inhibit ADL per [range.iter.ops]/2 and
+  // [algorithms.requirements]/2.
+  if (!ULE->decls().empty() && ULE->decls_begin()->isInStdRangesNamespace() &&
+  ULE->getName().getNameKind() == DeclarationName::NameKind::Identifier)
+return;

rsmith wrote:
> What should happen if a `using` declaration names one of these things? Should 
> we care about the properties of the underlying declaration (eg, whether the 
> target of the using declaration is in this namespace / has the attribute), or 
> about the found decl (eg, whether the `using` declaration itself is in the 
> namespace / has the attribute)?
> 
> Depending on the answer, we may need to check all declarations in the 
> `UnresolvedLookupExpr`, not only the first one. For example, we could have an 
> overload set that contains both a user-declared function and a `using` 
> declaration that names a function in `std::ranges` here.
> When found by unqualified ([basic.lookup.unqual]) name lookup for the 
> postfix-expression in a function call ([expr.call]), they inhibit 
> argument-dependent name lookup.

My interpretation of this is that both using-declarations and -directives are 
impacted (regardless of what the code says right now). [basic.lookup.unqual] 
doesn't specifically say anything about using-declarations, but I think 
[p4](https://eel.is/c++draft/basic.lookup.unqual#4) implies that they're 
included.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129951

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


[PATCH] D103313: [RISCV][Clang] Add support for Zmmul extension

2022-07-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added inline comments.
This revision is now accepted and ready to land.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:80
 
+{"zmmul", RISCVExtensionVersion{0, 1}},
+

If it is ratified, is the version really 0.1?


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

https://reviews.llvm.org/D103313

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


[PATCH] D103313: [RISCV][Clang] Add support for Zmmul extension

2022-07-17 Thread ksyx via Phabricator via cfe-commits
ksyx updated this revision to Diff 445332.
ksyx added a comment.

Rebase and update use of M extension existence check to include Zmmul whenever 
needed.


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

https://reviews.llvm.org/D103313

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/test/Driver/riscv-arch.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoM.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/CodeGen/RISCV/zmmul.ll
  llvm/test/MC/RISCV/rv32i-invalid.s
  llvm/test/MC/RISCV/rv32zmmul-invaild.s
  llvm/test/MC/RISCV/rv32zmmul-valid.s
  llvm/test/MC/RISCV/rv64zmmul-invalid.s
  llvm/test/MC/RISCV/rv64zmmul-valid.s

Index: llvm/test/MC/RISCV/rv64zmmul-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zmmul-valid.s
@@ -0,0 +1,5 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+zmmul -riscv-no-aliases 2>&1 \
+# RUN:  | FileCheck -check-prefixes=CHECK-INST %s
+
+# CHECK-INST: mulw ra, sp, gp
+mulw ra, sp, gp
Index: llvm/test/MC/RISCV/rv64zmmul-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zmmul-invalid.s
@@ -0,0 +1,14 @@
+# RUN: not llvm-mc %s -triple=riscv64 -mattr=+zmmul -riscv-no-aliases 2>&1 \
+# RUN:  | FileCheck -check-prefixes=CHECK-ERROR %s
+
+# CHECK-ERROR: 5:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+divw tp, t0, t1
+
+# CHECK-ERROR: 8:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+divuw t2, s0, s2
+
+# CHECK-ERROR: 11:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+remw a0, a1, a2
+
+# CHECK-ERROR: 14:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+remuw a3, a4, a5
Index: llvm/test/MC/RISCV/rv32zmmul-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zmmul-valid.s
@@ -0,0 +1,14 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+zmmul -riscv-no-aliases 2>&1 \
+# RUN:  | FileCheck -check-prefixes=CHECK-INST %s
+
+# CHECK-INST: mul a4, ra, s0
+mul a4, ra, s0
+
+# CHECK-INST: mulh ra, zero, zero
+mulh x1, x0, x0
+
+# CHECK-INST: mulhsu t0, t2, t1
+mulhsu t0, t2, t1
+
+# CHECK-INST: mulhu a5, a4, a3
+mulhu a5, a4, a3
Index: llvm/test/MC/RISCV/rv32zmmul-invaild.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zmmul-invaild.s
@@ -0,0 +1,14 @@
+# RUN: not llvm-mc %s -triple=riscv32 -mattr=+zmmul -riscv-no-aliases 2>&1 \
+# RUN:  | FileCheck -check-prefixes=CHECK-ERROR %s
+
+# CHECK-ERROR: 5:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+div s0, s0, s0
+
+# CHECK-ERROR: 8:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+divu gp, a0, a1
+
+# CHECK-ERROR: 11:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+rem s2, s2, s8
+
+# CHECK-ERROR: 14:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+remu x18, x18, x24
Index: llvm/test/MC/RISCV/rv32i-invalid.s
===
--- llvm/test/MC/RISCV/rv32i-invalid.s
+++ llvm/test/MC/RISCV/rv32i-invalid.s
@@ -169,7 +169,7 @@
 xor s2, s2 # CHECK: :[[@LINE]]:1: error: too few operands for instruction
 
 # Instruction not in the base ISA
-mul a4, ra, s0 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+div a4, ra, s0 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
 amomaxu.w s5, s4, (s3) # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'A' (Atomic Instructions)
 fadd.s ft0, ft1, ft2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'F' (Single-Precision Floating-Point){{$}}
 fadd.h ft0, ft1, ft2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zfh' (Half-Precision Floating-Point)
Index: llvm/test/CodeGen/RISCV/zmmul.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/zmmul.ll
@@ -0,0 +1,41 @@
+; RUN: llc -mtriple=riscv32 -mattr=+zmmul -verify-machineinstrs < %s \
+; RUN:  | not FileCheck -check-prefix=CHECK-DIV %s
+; RUN: llc -mtriple=riscv64 -mattr=+zmmul -verify-machineinstrs < %s \
+; RUN:  | not FileCheck -check-prefix=CHECK-DIV %s
+; RUN: llc -mtriple=riscv32 -mattr=+zmmul -verify-machineinstrs < %s \
+; RUN:  | not FileCheck -check-prefix=CHECK-REM %s
+; RUN: llc -mtriple=riscv64 -mattr=+zmmul -verify-machineinstrs < %s \
+; RUN:  | not FileCheck -check-prefix=CHECK-REM %s
+
+; RUN: llc 

[PATCH] D129951: [clang] teaches Clang the special ADL rules for functions in std::ranges

2022-07-17 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaOverload.cpp:9438
   // FIXME: Pass in the explicit template arguments?
   ArgumentDependentLookup(Name, Loc, Args, Fns);
 

It would seem preferable to me to do the filtering in `ArgumentDependentLookup` 
itself rather than here (but I don't feel strongly about it).



Comment at: clang/lib/Sema/SemaOverload.cpp:9455-9459
+// Functions in 'std::ranges' are hidden from ADL per [range.iter.ops]/2 
and
+// [algorithms.requirements]/2.
+if ((*I)->isInStdRangesNamespace() &&
+Name.getNameKind() == DeclarationName::NameKind::Identifier)
+  continue;

I worry that this might break some stdlib implementation that finds helper 
functions via ADL in `std::ranges` somehow. Also, it seems desirable to make 
this opt-in for the stdlib implementation and indeed for end-user functions not 
in `std::ranges`.

Have you considered enabling this behavior with an attribute instead of by 
detecting whether the function is in `std::ranges`?



Comment at: clang/lib/Sema/SemaOverload.cpp:12837-12841
+  // Functions in 'std::ranges' inhibit ADL per [range.iter.ops]/2 and
+  // [algorithms.requirements]/2.
+  if (!ULE->decls().empty() && ULE->decls_begin()->isInStdRangesNamespace() &&
+  ULE->getName().getNameKind() == DeclarationName::NameKind::Identifier)
+return;

What should happen if a `using` declaration names one of these things? Should 
we care about the properties of the underlying declaration (eg, whether the 
target of the using declaration is in this namespace / has the attribute), or 
about the found decl (eg, whether the `using` declaration itself is in the 
namespace / has the attribute)?

Depending on the answer, we may need to check all declarations in the 
`UnresolvedLookupExpr`, not only the first one. For example, we could have an 
overload set that contains both a user-declared function and a `using` 
declaration that names a function in `std::ranges` here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129951

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


[PATCH] D129951: [clang] teaches Clang the special ADL rules for functions in std::ranges

2022-07-17 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

In D129951#3657923 , @cjdb wrote:

> ~~Looking at the output from Clang 14 , I'm 
> observing that a binary with 178 function templates is 13% the size of the 
> one with 89 function objects. When only one function object is used vs all 
> 178 function templates, the functions still win out, with the binary being 
> 80% the size.~~

I wrote this quite late at night and confused total lines of assembly with 
program size. That's not accurate at all.

There doesn't seem to be a difference between the two when the optimiser is 
enabled, but with:

- `-O0`: there's a binary size difference of 24kB.
- `-Og -g`: there's a binary size difference of 32kB.
- `-g`: there's a binary size difference of 59kB.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129951

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


[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-17 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov marked an inline comment as done.
mizvekov added inline comments.



Comment at: clang/lib/Sema/TypeLocBuilder.cpp:159
 
-  assert(Capacity - Index == TypeLoc::getFullDataSizeForType(T) &&
+  unsigned FDSz = TypeLoc::getFullDataSizeForType(T);
+  assert(Capacity - Index == FDSz &&

chapuni wrote:
> It causes a warning with -Asserts. May be rolled back.
Thanks! fixed in latest rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-17 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov edited the summary of this revision.
mizvekov updated this revision to Diff 445319.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

Files:
  clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
  clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp
  clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
  clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
  clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/DumpASTTests.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/copy-constructor-init.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/shared-ptr-array-mismatch.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison-32bits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
  clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp
  clang/bindings/python/tests/cindex/test_type.py
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/lib/ARCMigrate/ObjCMT.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTDiagnostic.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/FormatString.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/QualTypeNames.cpp
  clang/lib/AST/ScanfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Sema/TypeLocBuilder.cpp
  clang/lib/Sema/TypeLocBuilder.h
  clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/test/AST/ast-dump-APValue-anon-union.cpp
  clang/test/AST/ast-dump-APValue-struct.cpp
  clang/test/AST/ast-dump-APValue-union.cpp
  clang/test/AST/ast-dump-decl.cpp
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/AST/ast-dump-funcs.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
  clang/test/AST/ast-dump-overloaded-operators.cpp
  clang/test/AST/ast-dump-records-json.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/AST/ast-dump-stmt.cpp
  clang/test/AST/ast-dump-template-decls-json.cpp
  clang/test/AST/ast-dump-temporaries-json.cpp
  clang/test/AST/ast-dump-using-template.cpp
  clang/test/AST/ast-dump-using.cpp
  clang/test/AST/coroutine-locals-cleanup-exp-namespace.cpp
  clang/test/AST/coroutine-locals-cleanup.cpp
  clang/test/AST/float16.cpp
  clang/test/AST/sourceranges.cpp
  clang/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/method-call-path-notes.cpp.plist
  clang/test/Analysis/analyzer-display-progress.cpp
  clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
  clang/test/Analysis/blocks.mm
  clang/test/Analysis/bug_hash_test.cpp
  clang/test/Analysis/cast-value-notes.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/cfg-rich-constructors.cpp
  clang/test/Analysis/cfg-rich-constructors.mm
  clang/test/Analysis/cfg.cpp
  clang/test/Analysis/copy-elision.cpp
  clang/test/Analysis/cxx-uninitialized-object-inheritance.cpp
  clang/test/Analysis/dump_egraph.cpp
  clang/test/Analysis/exploded-graph-rewriter/dynamic_types.cpp
  clang/test/Analysis/initializers-cfg-output.cpp
  clang/test/Analysis/inlining/Inputs/expected-plists/path-notes.cpp.plist
  clang/test/Analysis/lambdas.cpp
  

[PATCH] D129573: [Clang] add a diagnostic note 'while loop outside functions' at global scope

2022-07-17 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/test/Parser/while-loop-outside-function.c:3-4
+
+while(1) {}; // expected-error {{expected identifier or '('}} \
+ // expected-note {{while loop outside of functions}}
+

How about just making the error be the same thing the note would say?





Comment at: clang/test/Parser/while-loop-outside-function.cpp:20
+};
\ No newline at end of file


Missing newline


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129573

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


[PATCH] D129940: [clang-format] Fix misannotation of colon in presence of requires clause

2022-07-17 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:820-833
+  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
+  ASSERT_EQ(ConstrainedTokens.size(),
+NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
+  << ConstrainedTokens;
+
+  for (auto I = 0u; I < NumberOfBaseTokens; ++I) {
+if (I < NumberOfTokensBeforeRequires) {

HazardyKnusperkeks wrote:
> curdeius wrote:
> > owenpan wrote:
> > > Can you make it a function or lambda?
> > :+1:
> Often thought about that. But as @MyDeveloperDay mentioned in different other 
> reviews, we would loose the line where the EXPECT failed, since it would 
> always be the same line.
> 
> One step to mitigate that would be to return a `bool`, then one would loose 
> the "subexpect", only knows which subtest failed.
> 
> But an idea I have right now would be to add a StringRef parameter which is 
> then fed into the expect/assert to identify the subtest.
You can then add a function taking a source location maybe (+ optionally a 
macro passing `__FILE__` and `__LINE__`). WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129940

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


[PATCH] D129954: [CodeGen][inlineasm] assume the flag output of inline asm is boolean value

2022-07-17 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

Hm, might it be better to teach LLVM about this (in some 
ConstantRange/KnownBits logic)? This doesn't really seem like something the 
frontend should know about and encode, as that means each frontend has to add 
this annotation by itself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129954

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


[PATCH] D129802: [DRAFT] Implementing new atomic orderings in LLVM and generate barriers for legacy __sync builtins. Support corresponding memory model in outline atomics as well.

2022-07-17 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

In D129802#3653544 , @efriedma wrote:

> If we do decide we need to do something here, I'd prefer to model this using 
> explicit fences in the IR, as opposed to a new atomic ordering.  Adding extra 
> atomic orderings just makes everything harder to reason about.

+1. I think the bar for adding new memory orderings should be incredibly high. 
Memory models are complicated enough without introducing esoteric orderings 
that aren't clearly specified.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129802

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


[PATCH] D129946: [clang-format] Mark constexpr lambdas as lambda

2022-07-17 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2130
 case tok::kw_noexcept:
+case tok::kw_constexpr:
   nextToken();

owenpan wrote:
> Maybe move it up so that it's grouped with `kw_const`?
Will do before submit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129946

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


[PATCH] D129940: [clang-format] Fix misannotation of colon in presence of requires clause

2022-07-17 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:820-833
+  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
+  ASSERT_EQ(ConstrainedTokens.size(),
+NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
+  << ConstrainedTokens;
+
+  for (auto I = 0u; I < NumberOfBaseTokens; ++I) {
+if (I < NumberOfTokensBeforeRequires) {

curdeius wrote:
> owenpan wrote:
> > Can you make it a function or lambda?
> :+1:
Often thought about that. But as @MyDeveloperDay mentioned in different other 
reviews, we would loose the line where the EXPECT failed, since it would always 
be the same line.

One step to mitigate that would be to return a `bool`, then one would loose the 
"subexpect", only knows which subtest failed.

But an idea I have right now would be to add a StringRef parameter which is 
then fed into the expect/assert to identify the subtest.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129940

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


[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-17 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D112374#3658059 , @kimgr wrote:

> Haha. Pun intended? :-)

Yes :-)

> As you noticed, it's not our tests that care about the AST, it's the tool 
> itself. IWYU has been around since 2010-11, so there's probably lots of code 
> in there to work around bugs and idiosyncrasies in the Clang AST that have 
> since been fixed. I've inherited the project, so I don't have much 
> information on how or why the implementation ended up the way it did.
>
> Anyway, thanks for the heads-up about `getAs` vs `dyn_cast`, that seems like 
> an easy transformation for us to do. Though I'm not sure where -- everywhere 
> a `Type*` is processed?
>
> Also, I suspect we have a few open-ended searches where we're looking for the 
> first desugared type in the tree, but I guess that's where `getCanonicalType` 
> would be used?

I think for IWYU getCanonicalType could be problematic. It would be fine for 
quickly testing what kind of node you have under all that sugar and such, but 
if for example you try to get a Decl represented by some canonical type, you 
would likely get a canonical decl, but it seems to me that would not be useful 
because you might need to know the exact (re)-declaration used, which has 
source location information and you could pin down to a specific file.

There is `getDesugaredType`, which will just pull off all top level sugar 
without really canonicalizing the whole thing.

If instead you want to search down a type for the first thing of interest, then 
you can in that case have a main switch case on the type class, or even perhaps 
keep an if else chain of dyn_casts, but on your default or else case you could 
just test that the current type node is sugar with `getSingleStepDesugaredType` 
on it, see if you get a different result and try again with it in that case.
That way this mechanism does not get poisoned by clang introducing some new 
type sugar, which could not even be relevant to IWYU.

> Thanks!

Thank you for your patience as well, and sorry for the trouble!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


[PATCH] D128861: [clang-tidy] add cppcoreguidelines-symmetric-binary-operator

2022-07-17 Thread Julian Schmidt via Phabricator via cfe-commits
5chmidti added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128861

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


[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-17 Thread Kim Gräsman via Phabricator via cfe-commits
kimgr added a comment.

In D112374#3657640 , @mizvekov wrote:

> In D112374#3657472 , @kimgr wrote:
>
>> I'm coming at this from pretty far away, so there's very likely lots of 
>> details that I'm overlooking. But it seems to me the mainline had only had 
>> an `ElaboratedType` node if there was elaboration, and not otherwise. And 
>> that makes a lot more sense to me than having 2 `ElaboratedType*` nodes _for 
>> every type in the AST_, just to express that "hey, by the way, this type had 
>> no elaboration".
>
> There are no 2 `ElaboratedType` nodes, there is only one. If you are seeing 
> something like an ElaboratedType wrapping directly over another 
> ElaboratedType, that would seem to be a bug.

I meant the `ElaboratedTypeLoc` + `ElaboratedType`, but yeah, those are 
parallel, not nested.

>> That sounds good at face value, but if you're planning to remove these nodes 
>> again, that would create enormous churn for out-of-tree tools to re-adjust 
>> to the new shape of the tree.
>>
>> I can't say what the best solution is, but this patch generates quite a lot 
>> of work for me, and I would really hope that catching up with the new AST 
>> does not generate even more work down the line.
>
> That part I don't understand why. Before this patch, clang can produce a 
> bunch of type nodes wrapped in an ElTy, or not. After this patch, we add 
> ElTys in more cases, but the basic situation remains the same.
>
> Why IWYU would even care about ElaboratedTypes at all? I would have expected 
> a `git grep ElaboratedType` on IWYU sources to have no matches.
>
> Can you elaborate on that?

Haha. Pun intended? :-)

> In general, I would not expect external tools to care about the shape of the 
> AST. I would expect the type API would be used in a way where we ignore a 
> type sugar node we have no reason to acknowledge.
> Ie you query if some type is a (possible sugar to) X, and you would either 
> get X or nothing. The type sugar over it would just be skipped over and you 
> would have no reason to know what was in there or what shape it had.
>
> Of course that was not what happened in practice. A lot of code used 
> `dyn_cast` where it should have used `getAs`. Just look at all the fixes in 
> this patch for examples.
> And fixing that, besides making that code compatible with this patch, also 
> fixed other bugs where it would not properly ignore other pre-existing type 
> sugar.

As you noticed, it's not our tests that care about the AST, it's the tool 
itself. IWYU has been around since 2010-11, so there's probably lots of code in 
there to work around bugs and idiosyncrasies in the Clang AST that have since 
been fixed. I've inherited the project, so I don't have much information on how 
or why the implementation ended up the way it did.

Anyway, thanks for the heads-up about `getAs` vs `dyn_cast`, that seems like an 
easy transformation for us to do. Though I'm not sure where -- everywhere a 
`Type*` is processed?

Also, I suspect we have a few open-ended searches where we're looking for the 
first desugared type in the tree, but I guess that's where `getCanonicalType` 
would be used?

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


[PATCH] D129926: [clang-format] Handle constructor invocations after new operator in C# correct

2022-07-17 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.

LGTM.




Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2864
 do {
+  // Handle constructor invocation
+  if (FormatTok->is(tok::l_paren))

Nit: comments should be full phrases, ending with full stops 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129926

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


[PATCH] D129940: [clang-format] Fix misannotation of colon in presence of requires clause

2022-07-17 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.

Ok for me if it's OK for Owen.




Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:820-833
+  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
+  ASSERT_EQ(ConstrainedTokens.size(),
+NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
+  << ConstrainedTokens;
+
+  for (auto I = 0u; I < NumberOfBaseTokens; ++I) {
+if (I < NumberOfTokensBeforeRequires) {

owenpan wrote:
> Can you make it a function or lambda?
:+1:


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129940

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


[PATCH] D129642: [Sema] Tweak diagnostic logic so suppress-in-hedaer logic works in tools too.

2022-07-17 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

nit: typo in commit message ("hedaer")


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129642

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


[PATCH] D129953: [PATCH] [clang-tidy] NFC: add preposition "of" to code annotation of ElseAfterReturnCheck

2022-07-17 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp:266
 if (IsLastInScope) {
-  // If the if statement is the last statement its enclosing statements
+  // If the if statement is the last statement of its enclosing statements
   // scope, we can pull the decl out of the if statement.

njames93 wrote:
> 
This is the middle of a sentence though -- the sentence continues on the next 
line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129953

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


[PATCH] D129953: [PATCH] [clang-tidy] NFC: add preposition "of" to code annotation of ElseAfterReturnCheck

2022-07-17 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D129953#3657925 , @zhouyizhou 
wrote:

> In D129953#3657920 , @njames93 
> wrote:
>
>> While you're here could you also put full stops( or periods ) at the end of 
>> the sentences.
>
> Thank Nathan for reviewing my patch
> I am here, and am very happy to make further enhancement ;-) But because my 
> native language is not English, I don't know where should I put the full 
> stops at . 
> Isn't  "If the if statement is the last statement of its enclosing statements 
> scope, we can pull the decl out of the if statement." constitute a complete 
> sentence?
>
> Thanks again
> Zhouyi

They are just used to end sentences, we typically try to put them at the end of 
every comment in LLVM.




Comment at: 
clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp:266
 if (IsLastInScope) {
-  // If the if statement is the last statement its enclosing statements
+  // If the if statement is the last statement of its enclosing statements
   // scope, we can pull the decl out of the if statement.





Comment at: 
clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp:302
 if (IsLastInScope) {
-  // If the if statement is the last statement its enclosing statements
+  // If the if statement is the last statement of its enclosing statements
   // scope, we can pull the decl out of the if statement.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129953

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


[PATCH] D129953: [PATCH] [clang-tidy] NFC: add preposition "of" to code annotation of ElseAfterReturnCheck

2022-07-17 Thread zhouyizhou via Phabricator via cfe-commits
zhouyizhou added a comment.

In D129953#3657920 , @njames93 wrote:

> While you're here could you also put full stops( or periods ) at the end of 
> the sentences.

Thank Nathan for reviewing my patch
I am here, and am very happy to make further enhancement ;-) But because my 
native language is not English, I don't know where should I put the full stops 
at . 
Isn't  "If the if statement is the last statement of its enclosing statements 
scope, we can pull the decl out of the if statement." constitute a complete 
sentence?

Thanks again
Zhouyi


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129953

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


[PATCH] D129951: [clang] teaches Clang the special ADL rules for functions in std::ranges

2022-07-17 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

Looking at the output from Clang 14 , I'm 
observing that a binary with 178 function templates is 13% the size of the one 
with 89 function objects. When only one function object is used vs all 178 
function templates, the functions still win out, with the binary being 80% the 
size.

The AST also becomes substantially larger.

I ran `time clang++-13 -c file.cpp -std=c++20 -Oz -DNDEBUG` locally, a hundred 
times, and got the following results:

  # Function objects
  real mean:0.07447
  real median:  0.074
  real stddev:  0.002267268191

  sys mean: 0.01664
  sys median:   0.016
  sys stddev:   0.005569614534

  user mean:0.05785
  user median:  0.057
  user stddev:  0.005848896987

  # Function templates
  real mean:0.06336
  real median:  0.063
  real stddev:  0.002076905235

  sys mean: 0.01701
  sys median:   0.017
  sys stddev:   0.005545942188

  user mean:0.04645
  user median:  0.047
  user stddev:  0.005678908346


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129951

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


[PATCH] D129953: [PATCH] [clang-tidy] NFC: add preposition "of" to code annotation of ElseAfterReturnCheck

2022-07-17 Thread Nathan James via Phabricator via cfe-commits
njames93 accepted this revision.
njames93 added a comment.
This revision is now accepted and ready to land.

While you're here could you also put full stops( or periods ) at the end of 
the sentences.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129953

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