[PATCH] D120621: [clang-format] Fix BreakBeforeBinaryOperators with TemplateCloser on the lhs

2022-02-27 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 411662.
HazardyKnusperkeks added a comment.

Formatted


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

https://reviews.llvm.org/D120621

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6440,6 +6440,43 @@
Style);
 }
 
+TEST_F(FormatTest, BreakBinaryOperatorsInPresenceOfTemplates) {
+  auto Style = getLLVMStyleWithColumns(45);
+  EXPECT_EQ(Style.BreakBeforeBinaryOperators, FormatStyle::BOS_None);
+  verifyFormat("bool b =\n"
+   "is_default_constructible_v> and\n"
+   "is_copy_constructible_v> and\n"
+   "is_move_constructible_v> and\n"
+   "is_copy_assignable_v> and\n"
+   "is_move_assignable_v> and\n"
+   "is_destructible_v> and\n"
+   "is_swappable_v> and\n"
+   "is_callable_v(T)>;",
+   Style);
+
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
+  verifyFormat("bool b = is_default_constructible_v>\n"
+   " and is_copy_constructible_v>\n"
+   " and is_move_constructible_v>\n"
+   " and is_copy_assignable_v>\n"
+   " and is_move_assignable_v>\n"
+   " and is_destructible_v>\n"
+   " and is_swappable_v>\n"
+   " and is_callable_v(T)>;",
+   Style);
+
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
+  verifyFormat("bool b = is_default_constructible_v>\n"
+   " and is_copy_constructible_v>\n"
+   " and is_move_constructible_v>\n"
+   " and is_copy_assignable_v>\n"
+   " and is_move_assignable_v>\n"
+   " and is_destructible_v>\n"
+   " and is_swappable_v>\n"
+   " and is_callable_v(T)>;",
+   Style);
+}
+
 TEST_F(FormatTest, ConstructorInitializers) {
   verifyFormat("Constructor() : Initializer(FitsOnTheLine) {}");
   verifyFormat("Constructor() : Inttializer(FitsOnTheLine) {}",
@@ -24052,6 +24089,40 @@
"  }\n"
"};");
 
+  auto Style = getLLVMStyle();
+
+  verifyFormat(
+  "template \n"
+  "  requires is_default_constructible_v> and\n"
+  "   is_copy_constructible_v> and\n"
+  "   is_move_constructible_v> and\n"
+  "   is_copy_assignable_v> and "
+  "is_move_assignable_v> and\n"
+  "   is_destructible_v> and is_swappable_v> and\n"
+  "   is_callable_v(T)> and\n"
+  "   is_same_v(declval()))> and\n"
+  "   is_same_v(declval()))> and\n"
+  "   is_same_v(declval()))>\n"
+  "struct S {};",
+  Style);
+
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
+  verifyFormat(
+  "template \n"
+  "  requires is_default_constructible_v>\n"
+  "   and is_copy_constructible_v>\n"
+  "   and is_move_constructible_v>\n"
+  "   and is_copy_assignable_v> and "
+  "is_move_assignable_v>\n"
+  "   and is_destructible_v> and is_swappable_v>\n"
+  "   and is_callable_v(T)>\n"
+  "   and is_same_v(declval()))>\n"
+  "   and is_same_v(declval()))>\n"
+  "   and is_same_v(declval()))>\n"
+  "struct S {};",
+  Style);
+
   // Not a clause, but we once hit an assert.
   verifyFormat("#if 0\n"
"#else\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -4410,6 +4410,14 @@
 return false;
   if (Left.is(TT_TemplateCloser) && Right.is(TT_TemplateOpener))
 return true;
+  if ((Left.is(tok::greater) && Right.is(tok::greater)) ||
+  (Left.is(tok::less) && Right.is(tok::less)))
+return false;
+  if (Right.is(TT_BinaryOperator) &&
+  Style.BreakBeforeBinaryOperators != FormatStyle::BOS_None &&
+  (Style.BreakBeforeBinaryOperators == FormatStyle::BOS_All ||
+   Right.getPrecedence() != prec::Assignment))
+return true;
   if (Left.isOneOf(TT_TemplateCloser, TT_UnaryOperator) ||
   Left.is(tok::kw_operator))
 return false;
@@ -4483,14 +4491,6 @@
   if (Right.is(TT_InheritanceComma) &&
   Style.BreakInheritanceList == FormatStyle::BILS_BeforeComma)
 return true;
-  if ((Left.is(tok::greater) && Right.is(tok::greater)) ||
-  (Left.is(tok::less) && Right.is(tok::less)))
-return false;
-  if (Right.is(TT_BinaryOperator) &&
-  Style.BreakBeforeBinaryOperators != FormatStyle::BOS_Non

[PATCH] D120511: [clang-format] Allow to set token types final

2022-02-27 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 411663.
HazardyKnusperkeks marked 2 inline comments as done.
HazardyKnusperkeks added a comment.

Renamed member function.


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

https://reviews.llvm.org/D120511

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp

Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -70,6 +70,14 @@
   EXPECT_EQ(Tokens.size(), 17u) << Tokens;
   EXPECT_TOKEN(Tokens[10], tok::r_paren, TT_TypeDeclarationParen);
   EXPECT_TOKEN(Tokens[11], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("void f() {\n"
+"  while (p < a && *p == 'a')\n"
+"p++;\n"
+"}");
+  EXPECT_EQ(Tokens.size(), 21u) << Tokens;
+  EXPECT_TOKEN(Tokens[10], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[11], tok::star, TT_UnaryOperator);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsClasses) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -500,7 +500,7 @@
   break;
 case tok::l_brace:
   if (NextLBracesType != TT_Unknown)
-FormatTok->setType(NextLBracesType);
+FormatTok->setFinalizedType(NextLBracesType);
   else if (FormatTok->Previous &&
FormatTok->Previous->ClosesRequiresClause) {
 // We need the 'default' case here to correctly parse a function
@@ -1240,7 +1240,7 @@
   nextToken();
   while (!eof()) {
 if (FormatTok->is(tok::colon)) {
-  FormatTok->setType(TT_ModulePartitionColon);
+  FormatTok->setFinalizedType(TT_ModulePartitionColon);
 }
 // Handle import  as we would an include statement.
 else if (FormatTok->is(tok::less)) {
@@ -1250,7 +1250,7 @@
 // literals.
 if (FormatTok->isNot(tok::comment) &&
 !FormatTok->TokenText.startswith("//"))
-  FormatTok->setType(TT_ImplicitStringLiteral);
+  FormatTok->setFinalizedType(TT_ImplicitStringLiteral);
 nextToken();
   }
 }
@@ -1325,11 +1325,11 @@
   case tok::kw_asm:
 nextToken();
 if (FormatTok->is(tok::l_brace)) {
-  FormatTok->setType(TT_InlineASMBrace);
+  FormatTok->setFinalizedType(TT_InlineASMBrace);
   nextToken();
   while (FormatTok && FormatTok->isNot(tok::eof)) {
 if (FormatTok->is(tok::r_brace)) {
-  FormatTok->setType(TT_InlineASMBrace);
+  FormatTok->setFinalizedType(TT_InlineASMBrace);
   nextToken();
   addUnwrappedLine();
   break;
@@ -1651,7 +1651,7 @@
   break;
 case tok::l_brace:
   if (NextLBracesType != TT_Unknown)
-FormatTok->setType(NextLBracesType);
+FormatTok->setFinalizedType(NextLBracesType);
   if (!tryToParsePropertyAccessor() && !tryToParseBracedList()) {
 // A block outside of parentheses must be the last part of a
 // structural element.
@@ -1668,7 +1668,7 @@
   addUnwrappedLine();
 }
 if (!Line->InPPDirective)
-  FormatTok->setType(TT_FunctionLBrace);
+  FormatTok->setFinalizedType(TT_FunctionLBrace);
 parseBlock();
 addUnwrappedLine();
 return;
@@ -1773,7 +1773,7 @@
 
 if (FollowedByNewline && (Text.size() >= 5 || FunctionLike) &&
 tokenCanStartNewLine(*FormatTok) && Text == Text.upper()) {
-  PreviousToken->setType(TT_FunctionLikeOrFreestandingMacro);
+  PreviousToken->setFinalizedType(TT_FunctionLikeOrFreestandingMacro);
   addUnwrappedLine();
   return;
 }
@@ -1997,7 +1997,7 @@
   // This might or might not actually be a lambda arrow (this could be an
   // ObjC method invocation followed by a dereferencing arrow). We might
   // reset this back to TT_Unknown in TokenAnnotator.
-  FormatTok->setType(TT_LambdaArrow);
+  FormatTok->setFinalizedType(TT_LambdaArrow);
   SeenArrow = true;
   nextToken();
   break;
@@ -2005,8 +2005,8 @@
   return true;
 }
   }
-  FormatTok->setType(TT_LambdaLBrace);
-  LSquare.setType(TT_LambdaLSquare);
+  FormatTok->setFinalizedType(TT_LambdaLBrace);
+  LSquare.setFinalizedType(TT_LambdaLSquare);
   parseChildBlock();
   return true;
 }
@@ -2038,7 +2038,7 @@
 
   // Consume * (generator function). Treat it like C++'s overloaded operators.
   if (FormatTok->is(tok::star)) {
-FormatTok->setType(TT_OverloadedOperator);
+FormatTok->setFinalizedType(TT_OverloadedOperator);
 nextToken();
   }
 
@@ -2246,7 +2246,7 @@
 }
 case tok::ampamp:
   if (AmpAmpTokenType != TT_Unknown)
- 

[PATCH] D120511: [clang-format] Allow to set token types final

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



Comment at: clang/lib/Format/FormatToken.h:382
+  }
+  bool typeIsFinalized() const { return TypeIsFinalized; }
 

owenpan wrote:
> I thought you didn't like using the same [[ 
> https://reviews.llvm.org/D116316#inline-1112220 | name ]] for both a variable 
> and function. :)
Naming a getter after the member you get should (nearly) always be done.

What I still stand to is having a local variable named after the function it is 
initialized from (this alone is fine), but then still calling the function in a 
loop. `IsPrecededByCommentOrPPDirective` is not the same as 
`precededByCommentOrPPDirective()` since the function relies on the changing 
token. I still find that very confusing, but for now I know that this code does 
not affect me while debugging, because I don't use the option.


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

https://reviews.llvm.org/D120511

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


[PATCH] D120511: [clang-format] Allow to set token types final

2022-02-27 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/FormatToken.h:382
+  }
+  bool typeIsFinalized() const { return TypeIsFinalized; }
 

HazardyKnusperkeks wrote:
> owenpan wrote:
> > I thought you didn't like using the same [[ 
> > https://reviews.llvm.org/D116316#inline-1112220 | name ]] for both a 
> > variable and function. :)
> Naming a getter after the member you get should (nearly) always be done.
> 
> What I still stand to is having a local variable named after the function it 
> is initialized from (this alone is fine), but then still calling the function 
> in a loop. `IsPrecededByCommentOrPPDirective` is not the same as 
> `precededByCommentOrPPDirective()` since the function relies on the changing 
> token. I still find that very confusing, but for now I know that this code 
> does not affect me while debugging, because I don't use the option.
Point taken.


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

https://reviews.llvm.org/D120511

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


[clang] 853ca54 - [C++20][Modules][6/8] Record direct module imports.

2022-02-27 Thread Iain Sandoe via cfe-commits

Author: Iain Sandoe
Date: 2022-02-27T10:07:11Z
New Revision: 853ca5472314e109b98e46f0985f27f79e17d2bd

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

LOG: [C++20][Modules][6/8] Record direct module imports.

This is a small cache to avoid having to check both Exports and
Imports.

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

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaModule.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 0b872c48482db..9937846e05658 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2219,6 +2219,9 @@ class Sema final {
   /// The global module fragment of the current translation unit.
   clang::Module *GlobalModuleFragment = nullptr;
 
+  /// The modules we imported directly.
+  llvm::SmallPtrSet DirectModuleImports;
+
   /// Namespace definitions that we will export when they finish.
   llvm::SmallPtrSet DeferredExportedNamespaces;
 
@@ -2246,6 +2249,10 @@ class Sema final {
 return Entity->getOwningModule();
   }
 
+  bool isModuleDirectlyImported(const Module *M) {
+return DirectModuleImports.contains(M);
+  }
+
   /// Make a merged definition of an existing hidden definition \p ND
   /// visible at the specified location.
   void makeMergedDefinitionVisible(NamedDecl *ND);

diff  --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index 0606b3a4edae8..a829693fafebc 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -514,6 +514,11 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
 assert(ThisModule && "was expecting a module if building one");
   }
 
+  // In some cases we need to know if an entity was present in a directly-
+  // imported module (as opposed to a transitive import).  This avoids
+  // searching both Imports and Exports.
+  DirectModuleImports.insert(Mod);
+
   return Import;
 }
 



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


[PATCH] D118589: [C++20][Modules][6/8] Record direct module imports.

2022-02-27 Thread Iain Sandoe via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG853ca5472314: [C++20][Modules][6/8] Record direct module 
imports. (authored by iains).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118589

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaModule.cpp


Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -514,6 +514,11 @@
 assert(ThisModule && "was expecting a module if building one");
   }
 
+  // In some cases we need to know if an entity was present in a directly-
+  // imported module (as opposed to a transitive import).  This avoids
+  // searching both Imports and Exports.
+  DirectModuleImports.insert(Mod);
+
   return Import;
 }
 
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -2219,6 +2219,9 @@
   /// The global module fragment of the current translation unit.
   clang::Module *GlobalModuleFragment = nullptr;
 
+  /// The modules we imported directly.
+  llvm::SmallPtrSet DirectModuleImports;
+
   /// Namespace definitions that we will export when they finish.
   llvm::SmallPtrSet DeferredExportedNamespaces;
 
@@ -2246,6 +2249,10 @@
 return Entity->getOwningModule();
   }
 
+  bool isModuleDirectlyImported(const Module *M) {
+return DirectModuleImports.contains(M);
+  }
+
   /// Make a merged definition of an existing hidden definition \p ND
   /// visible at the specified location.
   void makeMergedDefinitionVisible(NamedDecl *ND);


Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -514,6 +514,11 @@
 assert(ThisModule && "was expecting a module if building one");
   }
 
+  // In some cases we need to know if an entity was present in a directly-
+  // imported module (as opposed to a transitive import).  This avoids
+  // searching both Imports and Exports.
+  DirectModuleImports.insert(Mod);
+
   return Import;
 }
 
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -2219,6 +2219,9 @@
   /// The global module fragment of the current translation unit.
   clang::Module *GlobalModuleFragment = nullptr;
 
+  /// The modules we imported directly.
+  llvm::SmallPtrSet DirectModuleImports;
+
   /// Namespace definitions that we will export when they finish.
   llvm::SmallPtrSet DeferredExportedNamespaces;
 
@@ -2246,6 +2249,10 @@
 return Entity->getOwningModule();
   }
 
+  bool isModuleDirectlyImported(const Module *M) {
+return DirectModuleImports.contains(M);
+  }
+
   /// Make a merged definition of an existing hidden definition \p ND
   /// visible at the specified location.
   void makeMergedDefinitionVisible(NamedDecl *ND);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119477: Ignore FullExpr when traversing cast sub-expressions

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

I have a local branch with both D119476  and 
this patch.

- Rebased on latest main (853ca5472314e109b98e46f0985f27f79e17d2bd 
)
- Ran `ninja check-clang` and `ninja tools/clang/unittests/Tooling/ToolingTests 
&& tools/clang/unittests/Tooling/ToolingTests` without issue

I did some integration testing with D119095  
and could not find any conflict. More detail on that differential.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119477

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


[PATCH] D119476: Generalize and harmonize sub-expression traversal

2022-02-27 Thread Kim Gräsman via Phabricator via cfe-commits
kimgr updated this revision to Diff 411666.
kimgr added a comment.

Fix typo in comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119476

Files:
  clang/lib/AST/Expr.cpp


Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -1899,51 +1899,48 @@
 }
 
 namespace {
-  const Expr *skipImplicitTemporary(const Expr *E) {
-// Skip through reference binding to temporary.
-if (auto *Materialize = dyn_cast(E))
-  E = Materialize->getSubExpr();
+// Skip over implicit nodes produced as part of semantic analysis.
+// Designed for use with IgnoreExprNodes.
+Expr *ignoreImplicitSemaNodes(Expr *E) {
+  if (auto *Materialize = dyn_cast(E))
+return Materialize->getSubExpr();
 
-// Skip any temporary bindings; they're implicit.
-if (auto *Binder = dyn_cast(E))
-  E = Binder->getSubExpr();
+  if (auto *Binder = dyn_cast(E))
+return Binder->getSubExpr();
 
-return E;
-  }
+  return E;
 }
+} // namespace
 
 Expr *CastExpr::getSubExprAsWritten() {
   const Expr *SubExpr = nullptr;
-  const CastExpr *E = this;
-  do {
-SubExpr = skipImplicitTemporary(E->getSubExpr());
+
+  for (const CastExpr *E = this; E; E = dyn_cast(SubExpr)) {
+SubExpr = IgnoreExprNodes(E->getSubExpr(), ignoreImplicitSemaNodes);
 
 // Conversions by constructor and conversion functions have a
 // subexpression describing the call; strip it off.
-if (E->getCastKind() == CK_ConstructorConversion)
-  SubExpr =
-
skipImplicitTemporary(cast(SubExpr->IgnoreImplicit())->getArg(0));
-else if (E->getCastKind() == CK_UserDefinedConversion) {
+if (E->getCastKind() == CK_ConstructorConversion) {
+  SubExpr = IgnoreExprNodes(
+  cast(SubExpr->IgnoreImplicit())->getArg(0),
+  ignoreImplicitSemaNodes);
+} else if (E->getCastKind() == CK_UserDefinedConversion) {
   SubExpr = SubExpr->IgnoreImplicit();
-  assert((isa(SubExpr) ||
-  isa(SubExpr)) &&
+  assert((isa(SubExpr) || isa(SubExpr)) &&
  "Unexpected SubExpr for CK_UserDefinedConversion.");
   if (auto *MCE = dyn_cast(SubExpr))
 SubExpr = MCE->getImplicitObjectArgument();
 }
+  }
 
-// If the subexpression we're left with is an implicit cast, look
-// through that, too.
-  } while ((E = dyn_cast(SubExpr)));
-
-  return const_cast(SubExpr);
+  return const_cast(SubExpr);
 }
 
 NamedDecl *CastExpr::getConversionFunction() const {
   const Expr *SubExpr = nullptr;
 
   for (const CastExpr *E = this; E; E = dyn_cast(SubExpr)) {
-SubExpr = skipImplicitTemporary(E->getSubExpr());
+SubExpr = IgnoreExprNodes(E->getSubExpr(), ignoreImplicitSemaNodes);
 
 if (E->getCastKind() == CK_ConstructorConversion)
   return cast(SubExpr)->getConstructor();


Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -1899,51 +1899,48 @@
 }
 
 namespace {
-  const Expr *skipImplicitTemporary(const Expr *E) {
-// Skip through reference binding to temporary.
-if (auto *Materialize = dyn_cast(E))
-  E = Materialize->getSubExpr();
+// Skip over implicit nodes produced as part of semantic analysis.
+// Designed for use with IgnoreExprNodes.
+Expr *ignoreImplicitSemaNodes(Expr *E) {
+  if (auto *Materialize = dyn_cast(E))
+return Materialize->getSubExpr();
 
-// Skip any temporary bindings; they're implicit.
-if (auto *Binder = dyn_cast(E))
-  E = Binder->getSubExpr();
+  if (auto *Binder = dyn_cast(E))
+return Binder->getSubExpr();
 
-return E;
-  }
+  return E;
 }
+} // namespace
 
 Expr *CastExpr::getSubExprAsWritten() {
   const Expr *SubExpr = nullptr;
-  const CastExpr *E = this;
-  do {
-SubExpr = skipImplicitTemporary(E->getSubExpr());
+
+  for (const CastExpr *E = this; E; E = dyn_cast(SubExpr)) {
+SubExpr = IgnoreExprNodes(E->getSubExpr(), ignoreImplicitSemaNodes);
 
 // Conversions by constructor and conversion functions have a
 // subexpression describing the call; strip it off.
-if (E->getCastKind() == CK_ConstructorConversion)
-  SubExpr =
-skipImplicitTemporary(cast(SubExpr->IgnoreImplicit())->getArg(0));
-else if (E->getCastKind() == CK_UserDefinedConversion) {
+if (E->getCastKind() == CK_ConstructorConversion) {
+  SubExpr = IgnoreExprNodes(
+  cast(SubExpr->IgnoreImplicit())->getArg(0),
+  ignoreImplicitSemaNodes);
+} else if (E->getCastKind() == CK_UserDefinedConversion) {
   SubExpr = SubExpr->IgnoreImplicit();
-  assert((isa(SubExpr) ||
-  isa(SubExpr)) &&
+  assert((isa(SubExpr) || isa(SubExpr)) &&
  "Unexpected SubExpr for CK_UserDefinedConversion.");
   if (auto *MCE = dyn_cast(SubExpr))
 SubExpr = MCE->getImplicitObjec

[PATCH] D120398: [format] follow up: Use unsigned char as the base of all enums in FormatStyle

2022-02-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Is there a clang-tidy check for this? I mean if we are doing this because it 
helps reduce the size of FormatStyle and its recommended practice for small 
enums, then we should have a clang-tidy check that catches us on this. (no?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120398

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


[PATCH] D120398: [format] follow up: Use unsigned char as the base of all enums in FormatStyle

2022-02-27 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Looks innocent but I have a few questions.
What's the size difference that you observe?
Any runtime penalty? (Usually compilers choose a faster underlying type for 
enums, not smaller)
Also, is this change very relevant to clang-format? We should not copy 
FormatStyle a lot, no?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120398

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


[PATCH] D93758: [format][NFC] Use unsigned char as the base of all enums in FormatStyle

2022-02-27 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

This went totally over my head.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93758

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


[PATCH] D120398: [format] follow up: Use unsigned char as the base of all enums in FormatStyle

2022-02-27 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.

The decision is made in the header (so I think it will always be `int` until 
this doesn't fit). To decide what is faster the compiler would need to know all 
the usages. Which it can't.

We have multiple times bit fields in `clang-format` to reduce the object size. 
I think it's only consistent to decrease the `FormatStyle` size.

The only reason I didn't do it for the enums introduced by me is consistency.

In D120398#3347726 , @MyDeveloperDay 
wrote:

> Is there a clang-tidy check for this? I mean if we are doing this because it 
> helps reduce the size of FormatStyle and its recommended practice for small 
> enums, then we should have a clang-tidy check that catches us on this. (no?)

None that I'm aware of.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120398

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


[PATCH] D86559: [Sema, CodeGen] Allow [[likely]] and [[unlikely]] on labels

2022-02-27 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

What is the status of this patch?


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

https://reviews.llvm.org/D86559

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


[PATCH] D112774: [RISCV] Support k-ext clang intrinsics

2022-02-27 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 411675.
achieveartificialintelligence marked an inline comment as done.
achieveartificialintelligence added a comment.

Thanks for @craig.topper's detailed advice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112774

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkc.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkc.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zknd.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zkne.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zknh.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zksed.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zksh.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd-zkne.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zkne.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksed.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksh.c
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c

Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -31,6 +31,17 @@
 // CHECK-NOT: __riscv_zfh
 // CHECK-NOT: __riscv_v
 // CHECK-NOT: __riscv_vector
+// CHECK-NOT: __riscv_zbkc
+// CHECK-NOT: __riscv_zbkx
+// CHECK-NOT: __riscv_zbkb
+// CHECK-NOT: __riscv_zkne
+// CHECK-NOT: __riscv_zknd
+// CHECK-NOT: __riscv_zknh
+// CHECK-NOT: __riscv_zksh
+// CHECK-NOT: __riscv_zksed
+// CHECK-NOT: __riscv_zkr
+// CHECK-NOT: __riscv_zkt
+// CHECK-NOT: __riscv_zk
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32im -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-M-EXT %s
@@ -343,3 +354,58 @@
 // CHECK-ZVE32X-EXT: __riscv_v_min_vlen 32
 // CHECK-ZVE32X-EXT: __riscv_vector 1
 // CHECK-ZVE32X-EXT: __riscv_zve32x 100{{$}}
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izbkc1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZBKC-EXT %s
+// CHECK-ZBKC-EXT: __riscv_zbkc
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izbkx1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZBKX-EXT %s
+// CHECK-ZBKX-EXT: __riscv_zbkx
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izbkb1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZBKB-EXT %s
+// CHECK-ZBKB-EXT: __riscv_zbkb
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izknd1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKND-EXT %s
+// CHECK-ZKND-EXT: __riscv_zknd
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izkne1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKNE-EXT %s
+// CHECK-ZKNE-EXT: __riscv_zkne
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izknh1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKNH-EXT %s
+// CHECK-ZKNH-EXT: __riscv_zknh
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izksh1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKSH-EXT %s
+// CHECK-ZKSH-EXT: __riscv_zksh
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izksed1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKSED-EXT %s
+// CHECK-ZKSED-EXT: __riscv_zksed
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izkr1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKR-EXT %s
+// CHECK-ZKR-EXT: __riscv_zkr
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izkt1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKT-EXT %s
+// CHECK-ZKT-EXT: __riscv_zkt
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izk1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZK-EXT %s
+// CHECK-ZK-EXT: __riscv_zk
Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -414,3 +414,47 @@
 // RUN: %clang -target riscv32-unknown-elf -march=rv32iv1p0_zvl32b1p0 -### %s -c 2>&1 | \
 // RUN:   FileCheck -check-prefix=RV32-ZVL-GOODVERS %s
 // RV32-ZVL-GOODVERS: "-target-feature" "+zvl32b"
+
+// RUN: %clang -target riscv

[PATCH] D112774: [RISCV] Support k-ext clang intrinsics

2022-02-27 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 411676.
achieveartificialintelligence added a comment.

Fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112774

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkc.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkc.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zknd.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zkne.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zknh.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zksed.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zksh.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd-zkne.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zkne.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksed.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksh.c
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c

Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -31,6 +31,17 @@
 // CHECK-NOT: __riscv_zfh
 // CHECK-NOT: __riscv_v
 // CHECK-NOT: __riscv_vector
+// CHECK-NOT: __riscv_zbkc
+// CHECK-NOT: __riscv_zbkx
+// CHECK-NOT: __riscv_zbkb
+// CHECK-NOT: __riscv_zkne
+// CHECK-NOT: __riscv_zknd
+// CHECK-NOT: __riscv_zknh
+// CHECK-NOT: __riscv_zksh
+// CHECK-NOT: __riscv_zksed
+// CHECK-NOT: __riscv_zkr
+// CHECK-NOT: __riscv_zkt
+// CHECK-NOT: __riscv_zk
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32im -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-M-EXT %s
@@ -343,3 +354,58 @@
 // CHECK-ZVE32X-EXT: __riscv_v_min_vlen 32
 // CHECK-ZVE32X-EXT: __riscv_vector 1
 // CHECK-ZVE32X-EXT: __riscv_zve32x 100{{$}}
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izbkc1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZBKC-EXT %s
+// CHECK-ZBKC-EXT: __riscv_zbkc
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izbkx1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZBKX-EXT %s
+// CHECK-ZBKX-EXT: __riscv_zbkx
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izbkb1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZBKB-EXT %s
+// CHECK-ZBKB-EXT: __riscv_zbkb
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izknd1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKND-EXT %s
+// CHECK-ZKND-EXT: __riscv_zknd
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izkne1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKNE-EXT %s
+// CHECK-ZKNE-EXT: __riscv_zkne
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izknh1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKNH-EXT %s
+// CHECK-ZKNH-EXT: __riscv_zknh
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izksh1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKSH-EXT %s
+// CHECK-ZKSH-EXT: __riscv_zksh
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izksed1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKSED-EXT %s
+// CHECK-ZKSED-EXT: __riscv_zksed
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izkr1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKR-EXT %s
+// CHECK-ZKR-EXT: __riscv_zkr
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izkt1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKT-EXT %s
+// CHECK-ZKT-EXT: __riscv_zkt
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izk1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZK-EXT %s
+// CHECK-ZK-EXT: __riscv_zk
Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -414,3 +414,47 @@
 // RUN: %clang -target riscv32-unknown-elf -march=rv32iv1p0_zvl32b1p0 -### %s -c 2>&1 | \
 // RUN:   FileCheck -check-prefix=RV32-ZVL-GOODVERS %s
 // RV32-ZVL-GOODVERS: "-target-feature" "+zvl32b"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izbkc1p0 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=

[PATCH] D120398: [format] follow up: Use unsigned char as the base of all enums in FormatStyle

2022-02-27 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

> Any runtime penalty? (Usually compilers choose a faster underlying type for 
> enums, not smaller)



> The decision is made in the header (so I think it will always be `int` until 
> this doesn't fit). To decide what is faster the compiler would need to know 
> all the usages. Which it can't.

Yes, Clang chooses `int` by default. In fact, C++11 and later //mandate// that 
a new-style scoped enum `enum class Foo {` means the same thing as `enum class 
Foo : int {` — see https://timsong-cpp.github.io/cppwp/n3337/dcl.enum#5 . For 
unscoped old-style enums, Clang/GCC/MSVC all choose `int` by default, 
//unless// `-fshort-enums` is passed on the command line and/or the enum is 
annotated with `__attribute__((packed))`, in which case it chooses the smallest 
possible type. `-fshort-enums` and `__attribute__((packed))` have no effect on 
new-style scoped enums nor on enums with explicit underlying types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120398

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


[PATCH] D120629: [clang] Remove unused variable AllElementsInt. NFC.

2022-02-27 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone created this revision.
Quuxplusone added reviewers: rnk, rsmith, sammccall.
Quuxplusone added a project: clang.
Quuxplusone requested review of this revision.
Herald added a subscriber: cfe-commits.

This has been unused ever since it was committed in b8a501ccf1.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120629

Files:
  clang/lib/Sema/SemaDecl.cpp


Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -18474,9 +18474,6 @@
   unsigned NumNegativeBits = 0;
   unsigned NumPositiveBits = 0;
 
-  // Keep track of whether all elements have type int.
-  bool AllElementsInt = true;
-
   for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
 EnumConstantDecl *ECD =
   cast_or_null(Elements[i]);
@@ -18491,10 +18488,6 @@
 else
   NumNegativeBits = std::max(NumNegativeBits,
  (unsigned)InitVal.getMinSignedBits());
-
-// Keep track of whether every enum element has type int (very common).
-if (AllElementsInt)
-  AllElementsInt = ECD->getType() == Context.IntTy;
   }
 
   // Figure out the type that should be used for this enum.


Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -18474,9 +18474,6 @@
   unsigned NumNegativeBits = 0;
   unsigned NumPositiveBits = 0;
 
-  // Keep track of whether all elements have type int.
-  bool AllElementsInt = true;
-
   for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
 EnumConstantDecl *ECD =
   cast_or_null(Elements[i]);
@@ -18491,10 +18488,6 @@
 else
   NumNegativeBits = std::max(NumNegativeBits,
  (unsigned)InitVal.getMinSignedBits());
-
-// Keep track of whether every enum element has type int (very common).
-if (AllElementsInt)
-  AllElementsInt = ECD->getType() == Context.IntTy;
   }
 
   // Figure out the type that should be used for this enum.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120569: [clang] Improve laziness of resolving module map headers.

2022-02-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

Thanks, this LGTM. but I am afraid all users of modules/modulemaps might not be 
aware of the fact that a module might be "partially" resolved (or still 
unresolved after a resolve operation, ASTWriter is a good example of an aware 
user).

For example there's Module::isAvailable 

 that checks `MissingHeaders` in a module for unavailability. I am not sure if 
it's possible to get there without ever fully resolving a Module, but I 
couldn't prove otherwise either.
So this might cause surprising breakages or hide some diagnostics.

It would be great if you could test the change against LLVM or some other 
codebases with module enabled builds to see nothing crashes. Also we should 
probably be on the watch out after landing this for possible complaints from 
outside.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120569

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


[PATCH] D120631: [clang-format][docs] Fix incorrect 'clang-format 12' option markers

2022-02-27 Thread Krystian Kuzniarek via Phabricator via cfe-commits
kuzkry created this revision.
kuzkry added a reviewer: MyDeveloperDay.
kuzkry added a project: clang-format.
kuzkry requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Introduced by 23a5090c6 
, some 
style option markers indicated 'clang-format 12',
though their respective options were available in earlier releases.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120631

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h

Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -499,7 +499,7 @@
 
   /// If ``true``, horizontally align operands of binary and ternary
   /// expressions.
-  /// \version 12
+  /// \version 3.5
   OperandAlignmentStyle AlignOperands;
 
   /// If ``true``, aligns trailing comments.
@@ -562,7 +562,7 @@
   /// B
   ///   } myEnum;
   /// \endcode
-  /// \version 12
+  /// \version 11
   bool AllowShortEnumsOnASingleLine;
 
   /// Different styles for merging short blocks containing at most one
@@ -987,7 +987,7 @@
   ///   //^ inserted
   ///   ]
   /// \endcode
-  /// \version 12
+  /// \version 11
   TrailingCommaStyle InsertTrailingCommas;
 
   /// If ``false``, a function declaration's or function definition's
@@ -2355,7 +2355,7 @@
   /// \endcode
   ///
   /// For example: BOOST_PP_STRINGIZE
-  /// \version 12
+  /// \version 11
   std::vector WhitespaceSensitiveMacros;
 
   tooling::IncludeStyle IncludeStyle;
@@ -2518,7 +2518,7 @@
   };
 
   /// IndentExternBlockStyle is the type of indenting of extern blocks.
-  /// \version 12
+  /// \version 11
   IndentExternBlockStyle IndentExternBlock;
 
   /// Indent the requires clause in a template. This only applies when
@@ -2918,7 +2918,7 @@
   ///}]
   ///}
   /// \endcode
-  /// \version 12
+  /// \version 11
   bool ObjCBreakBeforeNestedBlockParam;
 
   /// Add a space in front of an Objective-C protocol list, i.e. use
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -603,7 +603,7 @@
 
 
 
-**AlignOperands** (``OperandAlignmentStyle``) :versionbadge:`clang-format 12`
+**AlignOperands** (``OperandAlignmentStyle``) :versionbadge:`clang-format 3.5`
   If ``true``, horizontally align operands of binary and ternary
   expressions.
 
@@ -746,7 +746,7 @@
   return;
 }
 
-**AllowShortEnumsOnASingleLine** (``Boolean``) :versionbadge:`clang-format 12`
+**AllowShortEnumsOnASingleLine** (``Boolean``) :versionbadge:`clang-format 11`
   Allow short enums on a single line.
 
   .. code-block:: c++
@@ -2603,7 +2603,7 @@
plop();  plop();
  }  }
 
-**IndentExternBlock** (``IndentExternBlockStyle``) :versionbadge:`clang-format 12`
+**IndentExternBlock** (``IndentExternBlockStyle``) :versionbadge:`clang-format 11`
   IndentExternBlockStyle is the type of indenting of extern blocks.
 
   Possible values:
@@ -2789,7 +2789,7 @@
   --i;  --i;
 while (i);} while (i);
 
-**InsertTrailingCommas** (``TrailingCommaStyle``) :versionbadge:`clang-format 12`
+**InsertTrailingCommas** (``TrailingCommaStyle``) :versionbadge:`clang-format 11`
   If set to ``TCS_Wrapped`` will insert trailing commas in container
   literals (arrays and objects) that wrap across multiple lines.
   It is currently only available for JavaScript
@@ -3147,7 +3147,7 @@
  [self onOperationDone];
  }];
 
-**ObjCBreakBeforeNestedBlockParam** (``Boolean``) :versionbadge:`clang-format 12`
+**ObjCBreakBeforeNestedBlockParam** (``Boolean``) :versionbadge:`clang-format 11`
   Break parameters list into lines when there is nested block
   parameters in a function call.
 
@@ -4355,7 +4355,7 @@
 
 
 
-**WhitespaceSensitiveMacros** (``List of Strings``) :versionbadge:`clang-format 12`
+**WhitespaceSensitiveMacros** (``List of Strings``) :versionbadge:`clang-format 11`
   A vector of macros which are whitespace-sensitive and should not
   be touched.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120631: [clang-format][docs] Fix incorrect 'clang-format 12' option markers

2022-02-27 Thread Krystian Kuzniarek via Phabricator via cfe-commits
kuzkry added a comment.

Here's a list of earliest commits where each option changed in this PR was 
introduced:

AlignOperands - introduced by 3219e43c9467e47be9b1a9e32b3ed42a50f6b280
AllowShortEnumsOnASingleLine - introduced by 
292058a5d6d708ec7d285a452d4350b33ba080dc 

IndentExternBlock - introduced by 6ef45b0426a8c7b9764e102fb1a49561a3a2c118 

InsertTrailingCommas - introduced by a324fcf1ae62d065b957e66a9d2f5c18b6259d27 

ObjCBreakBeforeNestedBlockParam - introduced by 
70c98671fa7b395a52829b91782393f4c2613562 

WhitespaceSensitiveMacros - introduced by 
292058a5d6d708ec7d285a452d4350b33ba080dc 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120631

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


[PATCH] D120290: [Clang][OpenMP] Add the codegen support for `atomic compare capture`

2022-02-27 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 411688.
tianshilei1992 marked an inline comment as done.
tianshilei1992 added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120290

Files:
  clang/include/clang/AST/StmtOpenMP.h
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/OpenMP/atomic_compare_codegen.cpp

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


[PATCH] D120159: [Clang] Implement __builtin_source_location.

2022-02-27 Thread James Y Knight via Phabricator via cfe-commits
jyknight updated this revision to Diff 411692.
jyknight added a comment.

Minor tweaks to comments and docs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120159

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/DeclNodes.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/CodeGenCXX/builtin-source-location.cpp
  clang/test/SemaCXX/source_location.cpp
  clang/test/SemaCXX/source_location_err.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -6466,6 +6466,7 @@
   case Decl::Binding:
   case Decl::MSProperty:
   case Decl::MSGuid:
+  case Decl::UnnamedGlobalConstant:
   case Decl::TemplateParamObject:
   case Decl::IndirectField:
   case Decl::ObjCIvar:
Index: clang/test/SemaCXX/source_location_err.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/source_location_err.cpp
@@ -0,0 +1,104 @@
+// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify -DTEST=1 %s
+// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify -DTEST=2 %s
+// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify -DTEST=3 %s
+// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify -DTEST=4 %s
+// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify -DTEST=5 %s
+
+#if TEST == 1
+auto test1a = __builtin_source_location(); // expected-error {{std::source_location::__impl was not found}}
+
+namespace std {
+inline namespace NS {
+  struct source_location;
+}
+}
+
+auto test1b = __builtin_source_location(); // expected-error {{std::source_location::__impl was not found}}
+
+namespace std {
+inline namespace NS {
+  struct source_location {
+struct __impl;
+  };
+}
+}
+auto test1c = __builtin_source_location(); // expected-error {{std::source_location::__impl was not found}}
+
+#elif TEST == 2
+auto test2a = __builtin_source_location(); // expected-error {{std::source_location::__impl was not found}}
+
+namespace std {
+inline namespace NS {
+struct source_location {
+  struct __impl { int x; };
+};
+}
+}
+auto test2b = __builtin_source_location(); // expected-error {{std::source_location::__impl must be standard-layout and have only two 'const char *' fields _M_file_name and _M_function_name, and two integral fields _M_line and _M_column.}}
+
+#elif TEST == 3
+namespace std {
+struct source_location {
+  struct __impl {
+char _M_line;
+const char *_M_file_name;
+char _M_column;
+const char *_M_function_name;
+int other_member;
+  };
+};
+}
+auto test3 = __builtin_source_location(); // expected-error {{std::source_location::__impl must be standard-layout and have only two 'const char *' fields _M_file_name and _M_function_name, and two integral fields _M_line and _M_column.}}
+
+#elif TEST == 4
+namespace std {
+struct source_location {
+  struct parent {};
+  struct __impl : public parent {
+char _M_line;
+const char *_M_file_name;
+char _M_column;
+const char *_M_function_name;
+  };
+};
+}
+auto test4 = __builtin_source_location(); // expected-error {{std::source_location::__impl must be standard-layout and have only two 'const char *' fields _M_file_name and _M_function_name, and two integral fields _M_line and _M_column.}}
+
+
+#elif TEST == 5
+namespace std {
+struct source_location {
+  struct __impl {
+signed char _M_line; // odd integral type to choose, but ok!
+const char *_M_file_name;
+signed char _M_column;
+const char *_M_function_name;
+static int other_member; // static members are OK
+  };
+};
+}
+
+// Verify that the address cannot be used as a non-type template argument.
+template 
+auto fn1() {return X;} // expected-note {{candidate template ignored: substitution failure: 

[PATCH] D118599: [C++20][Modules][8/8] Amend module visibility rules for partitions.

2022-02-27 Thread H. Vetinari via Phabricator via cfe-commits
h-vetinari added a comment.

A non-actionable comment out of curiosity for the work




Comment at: clang/test/Modules/cxx20-10-1-ex2.cpp:15-17
-// Not expected to work yet.
 //  %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu4.cpp \
 //   -fmodule-file=%t/B.pcm  -o %t/B_X2.pcm

Should these two tests now be switched on? Missing a `RUN: ` for that IIUC?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118599

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


[PATCH] D120504: [AST] RAV doesn't traverse explicitly instantiated function bodies by default

2022-02-27 Thread David Li via Phabricator via cfe-commits
davidxl added inline comments.



Comment at: clang/lib/CodeGen/CodeGenPGO.cpp:157
 
+  bool shouldVisitTemplateInstantiations() { return true; }
+

This one line change looks ok to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120504

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


[clang] bcbb037 - [Driver][OpenBSD] Enable unwind tables on all architectures

2022-02-27 Thread Brad Smith via cfe-commits

Author: Todd Mortimer
Date: 2022-02-27T19:43:49-05:00
New Revision: bcbb03754ef19a8682635ab83fe5283db27b94f5

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

LOG: [Driver][OpenBSD] Enable unwind tables on all architectures

Added: 


Modified: 
clang/lib/Driver/ToolChains/OpenBSD.h
clang/test/Driver/openbsd.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/OpenBSD.h 
b/clang/lib/Driver/ToolChains/OpenBSD.h
index 95c10cc62316..9d668711b91b 100644
--- a/clang/lib/Driver/ToolChains/OpenBSD.h
+++ b/clang/lib/Driver/ToolChains/OpenBSD.h
@@ -82,6 +82,10 @@ class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF {
   std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef 
Component,
 FileType Type = ToolChain::FT_Static) const 
override;
 
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override {
+return true;
+  }
+
   LangOptions::StackProtectorMode
   GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
 return LangOptions::SSPStrong;

diff  --git a/clang/test/Driver/openbsd.c b/clang/test/Driver/openbsd.c
index 04a46f2862e7..9a811c193232 100644
--- a/clang/test/Driver/openbsd.c
+++ b/clang/test/Driver/openbsd.c
@@ -118,3 +118,10 @@
 // RUN: %clang -target powerpc-unknown-openbsd -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-POWERPC-SECUREPLT %s
 // CHECK-POWERPC-SECUREPLT: "-target-feature" "+secure-plt"
+
+// Check that unwind tables are enabled
+// RUN: %clang -target arm-unknown-openbsd -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=UNWIND-TABLES %s
+// RUN: %clang -target mips64-unknown-openbsd -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=UNWIND-TABLES %s
+// UNWIND-TABLES: "-funwind-tables=2"



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


[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2022-02-27 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence added a comment.

Can you help test if this patch works fine now? @krasimir


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

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


[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2022-02-27 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 411719.
achieveartificialintelligence added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

Files:
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoD.td
  llvm/lib/Target/RISCV/RISCVInstrInfoF.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/zfinx-types.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32i-invalid.s
  llvm/test/MC/RISCV/rv32zdinx-invalid.s
  llvm/test/MC/RISCV/rv32zdinx-valid.s
  llvm/test/MC/RISCV/rv32zfinx-invalid.s
  llvm/test/MC/RISCV/rv32zfinx-valid.s
  llvm/test/MC/RISCV/rv32zhinx-invalid.s
  llvm/test/MC/RISCV/rv32zhinx-valid.s
  llvm/test/MC/RISCV/rv32zhinxmin-invalid.s
  llvm/test/MC/RISCV/rv32zhinxmin-valid.s
  llvm/test/MC/RISCV/rv64zdinx-invalid.s
  llvm/test/MC/RISCV/rv64zdinx-valid.s
  llvm/test/MC/RISCV/rv64zfinx-invalid.s
  llvm/test/MC/RISCV/rv64zfinx-valid.s
  llvm/test/MC/RISCV/rv64zhinx-invalid.s
  llvm/test/MC/RISCV/rv64zhinx-valid.s
  llvm/test/MC/RISCV/rv64zhinxmin-invalid.s
  llvm/test/MC/RISCV/rv64zhinxmin-valid.s
  llvm/test/MC/RISCV/rvzdinx-aliases-valid.s
  llvm/test/MC/RISCV/rvzfinx-aliases-valid.s
  llvm/test/MC/RISCV/rvzhinx-aliases-valid.s

Index: llvm/test/MC/RISCV/rvzhinx-aliases-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvzhinx-aliases-valid.s
@@ -0,0 +1,82 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+zhinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+zhinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+zhinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+zhinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+zhinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+zhinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+zhinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+zhinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+
+##===--===##
+## Assembler Pseudo Instructions (User-Level ISA, Version 2.2, Chapter 20)
+##===--===##
+
+# CHECK-INST: fsgnjx.h s1, s2, s2
+# CHECK-ALIAS: fabs.h s1, s2
+fabs.h s1, s2
+# CHECK-INST: fsgnjn.h s2, s3, s3
+# CHECK-ALIAS: fneg.h s2, s3
+fneg.h s2, s3
+
+# CHECK-INST: flt.h tp, s6, s5
+# CHECK-ALIAS: flt.h tp, s6, s5
+fgt.h x4, s5, s6
+# CHECK-INST: fle.h t2, s1, s0
+# CHECK-ALIAS: fle.h t2, s1, s0
+fge.h x7, x8, x9
+
+##===--===##
+## Aliases which omit the rounding mode.
+##===--===##
+
+# CHECK-INST: fmadd.h a0, a1, a2, a3, dyn
+# CHECK-ALIAS: fmadd.h a0, a1, a2, a3
+fmadd.h x10, x11, x12, x13
+# CHECK-INST: fmsub.h a4, a5, a6, a7, dyn
+# CHECK-ALIAS: fmsub.h a4, a5, a6, a7
+fmsub.h x14, x15, x16, x17
+# CHECK-INST: fnmsub.h s2, s3, s4, s5, dyn
+# CHECK-ALIAS: fnmsub.h s2, s3, s4, s5
+fnmsub.h x18, x19, x20, x21
+# CHECK-INST: fnmadd.h s6, s7, s8, s9, dyn
+# CHECK-ALIAS: fnmadd.h s6, s7, s8, s9
+fnmadd.h x22, x23, x24, x25
+# CHECK-INST: fadd.h s10, s11, t3, dyn
+# CHECK-ALIAS: fadd.h s10, s11, t3
+fadd.h x26, x27, x28
+# CHECK-INST: fsub.h t4, t5, t6, dyn
+# CHECK-ALIAS: fsub.h t4, t5, t6
+fsub.h x29, x30, x31
+# CHECK-INST: fmul.h s0, s1, s2, dyn
+# CHECK-ALIAS: fmul.h s0, s1, s2
+fmul.h s0, s1, s2
+# CHECK-INST: fdiv.h s3, s4, s5, dyn
+# CHECK-ALIAS: fdiv.h s3, s4, s5
+fdiv.h s3, s4, s5
+# CHECK-INST: fsqrt.h s6, s7, dyn
+# CHECK-ALIAS: fsqrt.h s6, s7
+fsqrt.h s6, s7
+# CHECK-INST: fcvt.w.h a0, s5, dyn
+# CHECK-ALIAS: fcvt.w.h a0, s5
+fcvt.w.h a0, s5
+# CHECK-INST: fcvt.wu.h a1, s6, dyn
+# CHECK-ALIAS: fcvt.wu.h a1, s6
+fcvt.wu.h a1, s6
+# CHECK-INST: fcvt.h.w t6, a4, dyn
+# CHECK-ALIAS: fcvt.h.w t6, a4
+fcvt.h.w t6, a4
+# CHECK-INST: fcvt.h.wu s0, a5, dyn
+# CHECK-ALIAS: fcvt.h.wu s0, a5
+fcvt.h.wu s0, a5
Index: llvm

[PATCH] D116439: [clang-tidy] Fix `readability-const-return-type` for pure virtual function.

2022-02-27 Thread gehry via Phabricator via cfe-commits
Sockke updated this revision to Diff 411722.
Sockke added a comment.

Added a release note.


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

https://reviews.llvm.org/D116439

Files:
  clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
@@ -271,3 +271,17 @@
 
 int **const * n_multiple_ptr();
 int *const & n_pointer_ref();
+
+class PVBase {
+public:
+  virtual const int getC() = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 
'const'-qualified at the top level, which may reduce code readability without 
improving const correctness
+  // CHECK-NOT-FIXES: virtual int getC() = 0;
+};
+
+class PVDerive : public PVBase {
+public:
+  const int getC() { return 1; }
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 
'const'-qualified at the top level, which may reduce code readability without 
improving const correctness
+  // CHECK-NOT-FIXES: int getC() { return 1; }
+};
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -116,6 +116,10 @@
   ` related to passing
   arguments that refer to program elements without a trivial identifier.
 
+- Fixed a crash in :doc:`readability-const-return-type
+  ` when a pure virtual 
function
+  overrided has a const return type. Removed the fix for a virtual function.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -97,7 +97,9 @@
   // Find all function definitions for which the return types are `const`
   // qualified.
   Finder->addMatcher(
-  functionDecl(returns(isConstQualified()), isDefinition()).bind("func"),
+  functionDecl(returns(isConstQualified()),
+   anyOf(isDefinition(), cxxMethodDecl(isPure(
+  .bind("func"),
   this);
 }
 
@@ -115,6 +117,12 @@
 << Def->getReturnType();
 if (CR.ConstRange.isValid())
   Diagnostic << CR.ConstRange;
+
+// Do not propose fixes for virtual function.
+const auto *Method = dyn_cast(Def);
+if (Method && Method->isVirtual())
+  return;
+
 for (auto &Hint : CR.Hints)
   Diagnostic << Hint;
   }


Index: clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
@@ -271,3 +271,17 @@
 
 int **const * n_multiple_ptr();
 int *const & n_pointer_ref();
+
+class PVBase {
+public:
+  virtual const int getC() = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 'const'-qualified at the top level, which may reduce code readability without improving const correctness
+  // CHECK-NOT-FIXES: virtual int getC() = 0;
+};
+
+class PVDerive : public PVBase {
+public:
+  const int getC() { return 1; }
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 'const'-qualified at the top level, which may reduce code readability without improving const correctness
+  // CHECK-NOT-FIXES: int getC() { return 1; }
+};
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -116,6 +116,10 @@
   ` related to passing
   arguments that refer to program elements without a trivial identifier.
 
+- Fixed a crash in :doc:`readability-const-return-type
+  ` when a pure virtual function
+  overrided has a const return type. Removed the fix for a virtual function.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -97,7 +97,9 @@
   // Find all function definitions for which the return types are `const`
   // qualified.
   Finder->addMatcher(
-  functionDecl(returns(isConstQualified()), isDefinition()).bind("func"),
+  functionDecl(returns(isConstQualified()),
+ 

[PATCH] D120639: [RISCV] Pass -mno-relax to assembler when -fno-integrated-as specified

2022-02-27 Thread luxufan via Phabricator via cfe-commits
StephenFan created this revision.
StephenFan added reviewers: asb, jrtc27, craig.topper.
Herald added subscribers: VincentWu, luke957, achieveartificialintelligence, 
vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, 
Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar.
StephenFan requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, eopXD.
Herald added a project: clang.

In the past, `clang --target=riscv64-unknown-linux-gnu -mno-relax -c hello.s` 
will assemble hello.s without relaxation, but `clang 
--target=riscv64-unknown-linux-gnu -mno-relax -fno-integrated-as -c hello.s` 
doesn't pass the `-mno-relax` option to assembler, and assemble with relaxation
This patch pass the -mno-relax option to assembler when -fno-integrated-as is 
specified.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120639

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/riscv-gnutools.c


Index: clang/test/Driver/riscv-gnutools.c
===
--- clang/test/Driver/riscv-gnutools.c
+++ clang/test/Driver/riscv-gnutools.c
@@ -16,9 +16,14 @@
 // RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree 
-fno-integrated-as %s -### -c -march=rv32g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32G-ILP32D %s
 
+// Check default when -mno-relax specified
+// RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree 
-mno-relax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32-NO-RELAX %s
+
 // CHECK-RV32IMAC-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" 
"rv32imac"
 // CHECK-RV32IMAFDC-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" 
"rv32imafdc"
 // CHECK-RV32G-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32g"
+// CHECK-RV32-NO-RELAX: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" 
"rv32imac" "-mno-relax"
 
 
 // 64-bit checks
@@ -35,6 +40,11 @@
 // RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree 
-fno-integrated-as %s -### -c -march=rv64g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64G-LP64D %s
 
+// Check default when -mno-relax specified
+// RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree 
-mno-relax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64-NO-RELAX %s
+
 // CHECK-RV64IMAC-LP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" 
"rv64imac"
 // CHECK-RV64IMAFDC-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" 
"rv64imafdc"
 // CHECK-RV64G-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64g"
+// CHECK-RV64-NO-RELAX: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" 
"rv64imac" "-mno-relax"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -761,6 +761,8 @@
 StringRef MArchName = riscv::getRISCVArch(Args, 
getToolChain().getTriple());
 CmdArgs.push_back("-march");
 CmdArgs.push_back(MArchName.data());
+if (Args.hasArg(options::OPT_mno_relax))
+  CmdArgs.push_back("-mno-relax");
 break;
   }
   case llvm::Triple::sparc:


Index: clang/test/Driver/riscv-gnutools.c
===
--- clang/test/Driver/riscv-gnutools.c
+++ clang/test/Driver/riscv-gnutools.c
@@ -16,9 +16,14 @@
 // RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree -fno-integrated-as %s -### -c -march=rv32g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32G-ILP32D %s
 
+// Check default when -mno-relax specified
+// RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree -mno-relax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32-NO-RELAX %s
+
 // CHECK-RV32IMAC-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32imac"
 // CHECK-RV32IMAFDC-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32imafdc"
 // CHECK-RV32G-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32g"
+// CHECK-RV32-NO-RELAX: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32imac" "-mno-relax"
 
 
 // 64-bit checks
@@ -35,6 +40,11 @@
 // RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree -fno-integrated-as %s -### -c -march=rv64g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64G-LP64D %s
 
+// Check default when -mno-relax specified
+// RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree -mno-relax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64-NO-RELAX %s
+
 // CHECK-RV64IMAC-LP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64imac"
 // CHECK-RV64IMAFDC-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64imafdc"
 // CHECK-RV64G-LP64D: "{{.*}}as{{(.

[PATCH] D120639: [RISCV] Pass -mno-relax to assembler when -fno-integrated-as specified

2022-02-27 Thread luxufan via Phabricator via cfe-commits
StephenFan updated this revision to Diff 411724.
StephenFan added a comment.

fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120639

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/riscv-gnutools.c


Index: clang/test/Driver/riscv-gnutools.c
===
--- clang/test/Driver/riscv-gnutools.c
+++ clang/test/Driver/riscv-gnutools.c
@@ -16,9 +16,14 @@
 // RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree 
-fno-integrated-as %s -### -c -march=rv32g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32G-ILP32D %s
 
+// Check default when -mno-relax and -fno-integrated-as specified
+// RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree 
-mno-relax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32-NO-RELAX %s
+
 // CHECK-RV32IMAC-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" 
"rv32imac"
 // CHECK-RV32IMAFDC-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" 
"rv32imafdc"
 // CHECK-RV32G-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32g"
+// CHECK-RV32-NO-RELAX: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" 
"rv32imac" "-mno-relax"
 
 
 // 64-bit checks
@@ -35,6 +40,11 @@
 // RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree 
-fno-integrated-as %s -### -c -march=rv64g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64G-LP64D %s
 
+// Check default when -mno-relax and -fno-integrated-as specified
+// RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree 
-mno-relax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64-NO-RELAX %s
+
 // CHECK-RV64IMAC-LP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" 
"rv64imac"
 // CHECK-RV64IMAFDC-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" 
"rv64imafdc"
 // CHECK-RV64G-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64g"
+// CHECK-RV64-NO-RELAX: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" 
"rv64imac" "-mno-relax"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -761,6 +761,8 @@
 StringRef MArchName = riscv::getRISCVArch(Args, 
getToolChain().getTriple());
 CmdArgs.push_back("-march");
 CmdArgs.push_back(MArchName.data());
+if (Args.hasArg(options::OPT_mno_relax))
+  CmdArgs.push_back("-mno-relax");
 break;
   }
   case llvm::Triple::sparc:


Index: clang/test/Driver/riscv-gnutools.c
===
--- clang/test/Driver/riscv-gnutools.c
+++ clang/test/Driver/riscv-gnutools.c
@@ -16,9 +16,14 @@
 // RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree -fno-integrated-as %s -### -c -march=rv32g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32G-ILP32D %s
 
+// Check default when -mno-relax and -fno-integrated-as specified
+// RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree -mno-relax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32-NO-RELAX %s
+
 // CHECK-RV32IMAC-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32imac"
 // CHECK-RV32IMAFDC-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32imafdc"
 // CHECK-RV32G-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32g"
+// CHECK-RV32-NO-RELAX: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32imac" "-mno-relax"
 
 
 // 64-bit checks
@@ -35,6 +40,11 @@
 // RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree -fno-integrated-as %s -### -c -march=rv64g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64G-LP64D %s
 
+// Check default when -mno-relax and -fno-integrated-as specified
+// RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree -mno-relax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64-NO-RELAX %s
+
 // CHECK-RV64IMAC-LP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64imac"
 // CHECK-RV64IMAFDC-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64imafdc"
 // CHECK-RV64G-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64g"
+// CHECK-RV64-NO-RELAX: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64imac" "-mno-relax"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -761,6 +761,8 @@
 StringRef MArchName = riscv::getRISCVArch(Args, getToolChain().getTriple());
 CmdArgs.push_back("-march");
 CmdArgs.push_back(MArchName.data());
+if (Args.hasArg(options::OPT_mno_relax))
+  CmdArgs.push_back("-mno-relax");
 break;
   }
   case llvm::Triple::sparc:
___

[PATCH] D116593: Fix `performance-unnecessary-value-param` for template specialization

2022-02-27 Thread gehry via Phabricator via cfe-commits
Sockke updated this revision to Diff 411729.
Sockke added a comment.

Removed the fix for a template.


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

https://reviews.llvm.org/D116593

Files:
  clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-value-param-delayed.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-value-param.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-value-param.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-value-param.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-value-param.cpp
@@ -109,7 +109,7 @@
 
 template  void templateWithNonTemplatizedParameter(const ExpensiveToCopyType S, T V) {
   // CHECK-MESSAGES: [[@LINE-1]]:90: warning: the const qualified parameter 'S'
-  // CHECK-FIXES: template  void templateWithNonTemplatizedParameter(const ExpensiveToCopyType& S, T V) {
+  // CHECK-NOT-FIXES: template  void templateWithNonTemplatizedParameter(const ExpensiveToCopyType& S, T V) {
 }
 
 void instantiated() {
@@ -381,3 +381,24 @@
   // CHECK-FIXES: void templateFunction(ExpensiveToCopyType E) {
   E.constReference();
 }
+
+template 
+T templateSpecializationFunction(ExpensiveToCopyType E) {
+  // CHECK-MESSAGES: [[@LINE-1]]:54: warning: the parameter 'E' is copied
+  // CHECK-NOT-FIXES: T templateSpecializationFunction(const ExpensiveToCopyType& E) {
+  return T();
+}
+
+template <>
+bool templateSpecializationFunction(ExpensiveToCopyType E) {
+  // CHECK-MESSAGES: [[@LINE-1]]:57: warning: the parameter 'E' is copied
+  // CHECK-NOT-FIXES: bool templateSpecializationFunction(const ExpensiveToCopyType& E) {
+  return true;
+}
+
+template <>
+int templateSpecializationFunction(ExpensiveToCopyType E) {
+  // CHECK-MESSAGES: [[@LINE-1]]:56: warning: the parameter 'E' is copied
+  // CHECK-NOT-FIXES: int templateSpecializationFunction(const ExpensiveToCopyType& E) {
+  return 0;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-value-param-delayed.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-value-param-delayed.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-value-param-delayed.cpp
@@ -69,7 +69,7 @@
 
 template  void templateWithNonTemplatizedParameter(const ExpensiveToCopyType S, T V) {
   // CHECK-MESSAGES: [[@LINE-1]]:90: warning: the const qualified parameter 'S'
-  // CHECK-FIXES: template  void templateWithNonTemplatizedParameter(const ExpensiveToCopyType& S, T V) {
+  // CHECK-NOT-FIXES: template  void templateWithNonTemplatizedParameter(const ExpensiveToCopyType& S, T V) {
 }
 
 void instantiated() {
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -116,6 +116,10 @@
   ` related to passing
   arguments that refer to program elements without a trivial identifier.
 
+- Fixed a crash in :doc:`performance-unnecessary-value-param
+  ` when the specialization
+  template has an unnecessary value paramter. Removed the fix for a template.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -51,18 +51,6 @@
   return Matches.empty();
 }
 
-bool isExplicitTemplateSpecialization(const FunctionDecl &Function) {
-  if (const auto *SpecializationInfo = Function.getTemplateSpecializationInfo())
-if (SpecializationInfo->getTemplateSpecializationKind() ==
-TSK_ExplicitSpecialization)
-  return true;
-  if (const auto *Method = llvm::dyn_cast(&Function))
-if (Method->getTemplatedKind() == FunctionDecl::TK_MemberSpecialization &&
-Method->getMemberSpecializationInfo()->isExplicitSpecialization())
-  return true;
-  return false;
-}
-
 } // namespace
 
 UnnecessaryValueParamCheck::UnnecessaryValueParamCheck(
@@ -146,11 +134,12 @@
   // 2. the function is virtual as it might break overrides
   // 3. the function is referenced outside of a call expression within the
   //compilation unit as the signature change could introduce build errors.
-  // 4. the function is an explicit template specialization.
+  // 4. the function is a primary template or an explicit template
+  // specialization.
   const auto *Method = llvm::dyn_cast(Function);
   if (Param->getBeginLoc().isMacroID() || (Method && Method->isVirtual()) ||
   isReferencedOutsideOfCallExpr(*Functi

[PATCH] D120639: [RISCV] Pass -mno-relax to assembler when -fno-integrated-as specified

2022-02-27 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:764
 CmdArgs.push_back(MArchName.data());
+if (Args.hasArg(options::OPT_mno_relax))
+  CmdArgs.push_back("-mno-relax");

I doubt this does the right thing for `-mrelax -mno-relax`? I imagine you want 
Args.hasFlag.



Comment at: clang/test/Driver/riscv-gnutools.c:19
 
+// Check default when -mno-relax and -fno-integrated-as specified
+// RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree 
-mno-relax -fno-integrated-as %s -### -c \

All of these tests are using -fno-integrated-as, calling it out specifically 
for this one is misleading


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120639

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


[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2022-02-27 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:10923-10924
 
-  return TargetLowering::getRegForInlineAsmConstraint(TRI, Constraint, VT);
+  std::pair Res;
+  Res = TargetLowering::getRegForInlineAsmConstraint(TRI, Constraint, VT);
+




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

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


[PATCH] D120639: [RISCV] Pass -mno-relax to assembler when -fno-integrated-as specified

2022-02-27 Thread luxufan via Phabricator via cfe-commits
StephenFan updated this revision to Diff 411730.
StephenFan added a comment.

Address @jrtc27 's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120639

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/riscv-gnutools.c


Index: clang/test/Driver/riscv-gnutools.c
===
--- clang/test/Driver/riscv-gnutools.c
+++ clang/test/Driver/riscv-gnutools.c
@@ -16,9 +16,14 @@
 // RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree 
-fno-integrated-as %s -### -c -march=rv32g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32G-ILP32D %s
 
+// Check default when -mno-relax specified
+// RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree 
-mno-relax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32-NO-RELAX %s
+
 // CHECK-RV32IMAC-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" 
"rv32imac"
 // CHECK-RV32IMAFDC-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" 
"rv32imafdc"
 // CHECK-RV32G-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32g"
+// CHECK-RV32-NO-RELAX: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" 
"rv32imac" "-mno-relax"
 
 
 // 64-bit checks
@@ -35,6 +40,11 @@
 // RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree 
-fno-integrated-as %s -### -c -march=rv64g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64G-LP64D %s
 
+// Check default when -mno-relax specified
+// RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree 
-mno-relax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64-NO-RELAX %s
+
 // CHECK-RV64IMAC-LP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" 
"rv64imac"
 // CHECK-RV64IMAFDC-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" 
"rv64imafdc"
 // CHECK-RV64G-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64g"
+// CHECK-RV64-NO-RELAX: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" 
"rv64imac" "-mno-relax"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -761,6 +761,8 @@
 StringRef MArchName = riscv::getRISCVArch(Args, 
getToolChain().getTriple());
 CmdArgs.push_back("-march");
 CmdArgs.push_back(MArchName.data());
+if (!Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax))
+  CmdArgs.push_back("-mno-relax");
 break;
   }
   case llvm::Triple::sparc:


Index: clang/test/Driver/riscv-gnutools.c
===
--- clang/test/Driver/riscv-gnutools.c
+++ clang/test/Driver/riscv-gnutools.c
@@ -16,9 +16,14 @@
 // RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree -fno-integrated-as %s -### -c -march=rv32g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32G-ILP32D %s
 
+// Check default when -mno-relax specified
+// RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree -mno-relax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32-NO-RELAX %s
+
 // CHECK-RV32IMAC-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32imac"
 // CHECK-RV32IMAFDC-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32imafdc"
 // CHECK-RV32G-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32g"
+// CHECK-RV32-NO-RELAX: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32imac" "-mno-relax"
 
 
 // 64-bit checks
@@ -35,6 +40,11 @@
 // RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree -fno-integrated-as %s -### -c -march=rv64g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64G-LP64D %s
 
+// Check default when -mno-relax specified
+// RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree -mno-relax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64-NO-RELAX %s
+
 // CHECK-RV64IMAC-LP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64imac"
 // CHECK-RV64IMAFDC-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64imafdc"
 // CHECK-RV64G-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64g"
+// CHECK-RV64-NO-RELAX: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64imac" "-mno-relax"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -761,6 +761,8 @@
 StringRef MArchName = riscv::getRISCVArch(Args, getToolChain().getTriple());
 CmdArgs.push_back("-march");
 CmdArgs.push_back(MArchName.data());
+if (!Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax))
+  CmdArgs.push_back("-mno-relax");
 break;
   }
   case llvm::Triple::sparc:
___
cfe-commits mailin

[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2022-02-27 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 411734.
achieveartificialintelligence marked an inline comment as done.
achieveartificialintelligence added a comment.

Address @jrtc27's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

Files:
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoD.td
  llvm/lib/Target/RISCV/RISCVInstrInfoF.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/zfinx-types.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32i-invalid.s
  llvm/test/MC/RISCV/rv32zdinx-invalid.s
  llvm/test/MC/RISCV/rv32zdinx-valid.s
  llvm/test/MC/RISCV/rv32zfinx-invalid.s
  llvm/test/MC/RISCV/rv32zfinx-valid.s
  llvm/test/MC/RISCV/rv32zhinx-invalid.s
  llvm/test/MC/RISCV/rv32zhinx-valid.s
  llvm/test/MC/RISCV/rv32zhinxmin-invalid.s
  llvm/test/MC/RISCV/rv32zhinxmin-valid.s
  llvm/test/MC/RISCV/rv64zdinx-invalid.s
  llvm/test/MC/RISCV/rv64zdinx-valid.s
  llvm/test/MC/RISCV/rv64zfinx-invalid.s
  llvm/test/MC/RISCV/rv64zfinx-valid.s
  llvm/test/MC/RISCV/rv64zhinx-invalid.s
  llvm/test/MC/RISCV/rv64zhinx-valid.s
  llvm/test/MC/RISCV/rv64zhinxmin-invalid.s
  llvm/test/MC/RISCV/rv64zhinxmin-valid.s
  llvm/test/MC/RISCV/rvzdinx-aliases-valid.s
  llvm/test/MC/RISCV/rvzfinx-aliases-valid.s
  llvm/test/MC/RISCV/rvzhinx-aliases-valid.s

Index: llvm/test/MC/RISCV/rvzhinx-aliases-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvzhinx-aliases-valid.s
@@ -0,0 +1,82 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+zhinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+zhinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+zhinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+zhinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+zhinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+zhinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+zhinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+zhinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+
+##===--===##
+## Assembler Pseudo Instructions (User-Level ISA, Version 2.2, Chapter 20)
+##===--===##
+
+# CHECK-INST: fsgnjx.h s1, s2, s2
+# CHECK-ALIAS: fabs.h s1, s2
+fabs.h s1, s2
+# CHECK-INST: fsgnjn.h s2, s3, s3
+# CHECK-ALIAS: fneg.h s2, s3
+fneg.h s2, s3
+
+# CHECK-INST: flt.h tp, s6, s5
+# CHECK-ALIAS: flt.h tp, s6, s5
+fgt.h x4, s5, s6
+# CHECK-INST: fle.h t2, s1, s0
+# CHECK-ALIAS: fle.h t2, s1, s0
+fge.h x7, x8, x9
+
+##===--===##
+## Aliases which omit the rounding mode.
+##===--===##
+
+# CHECK-INST: fmadd.h a0, a1, a2, a3, dyn
+# CHECK-ALIAS: fmadd.h a0, a1, a2, a3
+fmadd.h x10, x11, x12, x13
+# CHECK-INST: fmsub.h a4, a5, a6, a7, dyn
+# CHECK-ALIAS: fmsub.h a4, a5, a6, a7
+fmsub.h x14, x15, x16, x17
+# CHECK-INST: fnmsub.h s2, s3, s4, s5, dyn
+# CHECK-ALIAS: fnmsub.h s2, s3, s4, s5
+fnmsub.h x18, x19, x20, x21
+# CHECK-INST: fnmadd.h s6, s7, s8, s9, dyn
+# CHECK-ALIAS: fnmadd.h s6, s7, s8, s9
+fnmadd.h x22, x23, x24, x25
+# CHECK-INST: fadd.h s10, s11, t3, dyn
+# CHECK-ALIAS: fadd.h s10, s11, t3
+fadd.h x26, x27, x28
+# CHECK-INST: fsub.h t4, t5, t6, dyn
+# CHECK-ALIAS: fsub.h t4, t5, t6
+fsub.h x29, x30, x31
+# CHECK-INST: fmul.h s0, s1, s2, dyn
+# CHECK-ALIAS: fmul.h s0, s1, s2
+fmul.h s0, s1, s2
+# CHECK-INST: fdiv.h s3, s4, s5, dyn
+# CHECK-ALIAS: fdiv.h s3, s4, s5
+fdiv.h s3, s4, s5
+# CHECK-INST: fsqrt.h s6, s7, dyn
+# CHECK-ALIAS: fsqrt.h s6, s7
+fsqrt.h s6, s7
+# CHECK-INST: fcvt.w.h a0, s5, dyn
+# CHECK-ALIAS: fcvt.w.h a0, s5
+fcvt.w.h a0, s5
+# CHECK-INST: fcvt.wu.h a1, s6, dyn
+# CHECK-ALIAS: fcvt.wu.h a1, s6
+fcvt.wu.h a1, s6
+# CHECK-INST: fcvt.h.w t6, a4, dyn
+# CHECK-ALIAS: fcvt.h.w t6, a4
+fcvt.h.w t6, a4
+# CHECK-INST: 

[PATCH] D120644: [clang][tests] Fix ve-toolchain tests with CLANG_DEFAULT_UNWINDLIB

2022-02-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: kaz7, simoll, aaron.ballman.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Otherwise, the

`// DEF-SAME: "[[RESOURCE_DIR]]/lib/linux/libclang_rt.builtins-ve.a" "-lc"`

line ends up getting a `-lgcc_s` inserted in between and the output doesn't 
match anymore.
Also fix a `-stdlib=c++` now that I'm already looking at it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120644

Files:
  clang/test/Driver/ve-toolchain.c
  clang/test/Driver/ve-toolchain.cpp


Index: clang/test/Driver/ve-toolchain.cpp
===
--- clang/test/Driver/ve-toolchain.cpp
+++ clang/test/Driver/ve-toolchain.cpp
@@ -133,7 +133,8 @@
 // RUN: --sysroot %S/Inputs/basic_ve_tree \
 // RUN: -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
-// RUN: --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=DEF %s
+// RUN: --unwindlib=none \
+// RUN: --stdlib=libc++ %s 2>&1 | FileCheck -check-prefix=DEF %s
 
 // DEF:  clang{{.*}}" "-cc1"
 // DEF-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
Index: clang/test/Driver/ve-toolchain.c
===
--- clang/test/Driver/ve-toolchain.c
+++ clang/test/Driver/ve-toolchain.c
@@ -83,6 +83,7 @@
 // RUN: %clang -### -target ve-unknown-linux-gnu \
 // RUN: --sysroot %S/Inputs/basic_ve_tree \
 // RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
+// RUN: --unwindlib=none \
 // RUN: -fuse-ld=ld \
 // RUN: %s 2>&1 | FileCheck -check-prefix=DEF %s
 


Index: clang/test/Driver/ve-toolchain.cpp
===
--- clang/test/Driver/ve-toolchain.cpp
+++ clang/test/Driver/ve-toolchain.cpp
@@ -133,7 +133,8 @@
 // RUN: --sysroot %S/Inputs/basic_ve_tree \
 // RUN: -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
-// RUN: --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=DEF %s
+// RUN: --unwindlib=none \
+// RUN: --stdlib=libc++ %s 2>&1 | FileCheck -check-prefix=DEF %s
 
 // DEF:  clang{{.*}}" "-cc1"
 // DEF-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
Index: clang/test/Driver/ve-toolchain.c
===
--- clang/test/Driver/ve-toolchain.c
+++ clang/test/Driver/ve-toolchain.c
@@ -83,6 +83,7 @@
 // RUN: %clang -### -target ve-unknown-linux-gnu \
 // RUN: --sysroot %S/Inputs/basic_ve_tree \
 // RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
+// RUN: --unwindlib=none \
 // RUN: -fuse-ld=ld \
 // RUN: %s 2>&1 | FileCheck -check-prefix=DEF %s
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120498: [AST] Test RecursiveASTVisitor's current traversal of templates.

2022-02-27 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

will leave approval to hokein, but LGTM




Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:172
 
-  /// Return whether this visitor should recurse into
-  /// template instantiations.
+  /// Return whether we should traverse of AST nodes that were created by
+  /// template instantiation, rather than by written code.

nit: stray "of"



Comment at: clang/unittests/Tooling/RecursiveASTVisitorTests/Templates.cpp:283
+  VisitClassTemplateSpecializationDecl
+  VisitFieldDecl
+TraverseClassTemplateSpecializationDecl

Is this a FIXME (body is traversed is an instantiation declaration)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120498

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


[PATCH] D120644: [clang][tests] Fix ve-toolchain tests with CLANG_DEFAULT_UNWINDLIB

2022-02-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

The failing tests seem all omp related and not about this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120644

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


[PATCH] D118599: [C++20][Modules][8/8] Amend module visibility rules for partitions.

2022-02-27 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 411741.
iains added a comment.

rebased, fix missing RUN lines for two cases in a test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118599

Files:
  clang/lib/Sema/SemaLookup.cpp
  clang/test/Modules/cxx20-10-1-ex2.cpp


Index: clang/test/Modules/cxx20-10-1-ex2.cpp
===
--- clang/test/Modules/cxx20-10-1-ex2.cpp
+++ clang/test/Modules/cxx20-10-1-ex2.cpp
@@ -12,9 +12,8 @@
 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu3.cpp \
 // RUN:   -o %t/B_X1.pcm -verify
 
-// Not expected to work yet.
-//  %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu4.cpp \
-//   -fmodule-file=%t/B.pcm  -o %t/B_X2.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu4.cpp \
+// RUN:-fmodule-file=%t/B.pcm  -o %t/B_X2.pcm
 
 // RUN: %clang_cc1 -std=c++20 -emit-obj %t/std10-1-ex2-tu5.cpp \
 // RUN:  -fmodule-file=%t/B.pcm  -o %t/b_tu5.o
@@ -22,9 +21,8 @@
 // RUN: %clang_cc1 -std=c++20 -S %t/std10-1-ex2-tu6.cpp \
 // RUN:  -fmodule-file=%t/B.pcm  -o %t/b_tu6.s -verify
 
-// Not expected to work yet.
-//  %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu7.cpp \
-//   -fmodule-file=%t/B_X2.pcm  -o %t/B_X3.pcm -verify
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu7.cpp \
+// RUN: -fmodule-file=%t/B_X2.pcm  -o %t/B_X3.pcm -verify
 
 //--- std10-1-ex2-tu1.cpp
 module B:Y;
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -1687,8 +1687,8 @@
   Module *DeclModule = SemaRef.getOwningModule(D);
   assert(DeclModule && "hidden decl has no owning module");
 
-  // If the owning module is visible, the decl is visible.
   if (SemaRef.isModuleVisible(DeclModule, D->isModulePrivate()))
+// If the owning module is visible, the decl is visible.
 return true;
 
   // Determine whether a decl context is a file context for the purpose of
@@ -1762,6 +1762,22 @@
   if (ModulePrivate) {
 if (isInCurrentModule(M, getLangOpts()))
   return true;
+else if (M->Kind == Module::ModuleKind::ModulePartitionImplementation &&
+ isModuleDirectlyImported(M))
+  // Unless a partition implementation is directly imported it is not
+  // counted as visible for lookup, although the contained decls might
+  // still be reachable.  It's a partition, so it must be part of the
+  // current module to be a valid import.
+  return true;
+else if (getLangOpts().CPlusPlusModules && !ModuleScopes.empty() &&
+ ModuleScopes[0].Module->Kind ==
+ Module::ModuleKind::ModulePartitionImplementation &&
+ ModuleScopes[0].Module->getPrimaryModuleInterfaceName() ==
+ M->Name &&
+ isModuleDirectlyImported(M))
+  // We are building a module implementation partition and the TU imports
+  // the primary module interface unit.
+  return true;
   } else {
 if (VisibleModules.isVisible(M))
   return true;


Index: clang/test/Modules/cxx20-10-1-ex2.cpp
===
--- clang/test/Modules/cxx20-10-1-ex2.cpp
+++ clang/test/Modules/cxx20-10-1-ex2.cpp
@@ -12,9 +12,8 @@
 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu3.cpp \
 // RUN:   -o %t/B_X1.pcm -verify
 
-// Not expected to work yet.
-//  %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu4.cpp \
-//   -fmodule-file=%t/B.pcm  -o %t/B_X2.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu4.cpp \
+// RUN:-fmodule-file=%t/B.pcm  -o %t/B_X2.pcm
 
 // RUN: %clang_cc1 -std=c++20 -emit-obj %t/std10-1-ex2-tu5.cpp \
 // RUN:  -fmodule-file=%t/B.pcm  -o %t/b_tu5.o
@@ -22,9 +21,8 @@
 // RUN: %clang_cc1 -std=c++20 -S %t/std10-1-ex2-tu6.cpp \
 // RUN:  -fmodule-file=%t/B.pcm  -o %t/b_tu6.s -verify
 
-// Not expected to work yet.
-//  %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu7.cpp \
-//   -fmodule-file=%t/B_X2.pcm  -o %t/B_X3.pcm -verify
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu7.cpp \
+// RUN: -fmodule-file=%t/B_X2.pcm  -o %t/B_X3.pcm -verify
 
 //--- std10-1-ex2-tu1.cpp
 module B:Y;
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -1687,8 +1687,8 @@
   Module *DeclModule = SemaRef.getOwningModule(D);
   assert(DeclModule && "hidden decl has no owning module");
 
-  // If the owning module is visible, the decl is visible.
   if (SemaRef.isModuleVisible(DeclModule, D->isModulePrivate()))
+// If the owning module is visible, the decl is visible.
 return true;
 
   // Determine whether a decl context is a file context for the p

[PATCH] D118599: [C++20][Modules][8/8] Amend module visibility rules for partitions.

2022-02-27 Thread Iain Sandoe via Phabricator via cfe-commits
iains marked an inline comment as done.
iains added inline comments.



Comment at: clang/test/Modules/cxx20-10-1-ex2.cpp:15-17
-// Not expected to work yet.
 //  %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu4.cpp \
 //   -fmodule-file=%t/B.pcm  -o %t/B_X2.pcm

h-vetinari wrote:
> Should these two tests now be switched on? Missing a `RUN: ` for that IIUC?
good catch, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118599

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