[PATCH] D141497: [clang][Interp] Record initialization via conditional operator

2023-03-19 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


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

https://reviews.llvm.org/D141497

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


[PATCH] D141472: [clang][Interp] Add function pointers

2023-03-19 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


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

https://reviews.llvm.org/D141472

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


[PATCH] D144457: [clang][Interp] Handle global composite temporaries

2023-03-19 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144457

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


[PATCH] D144943: [clang][Interp] Implement bitcasts (WIP)

2023-03-19 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144943

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


[PATCH] D145841: [clang][Interp] Fix diagnostics for calling non-constexpr constructors

2023-03-19 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


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

https://reviews.llvm.org/D145841

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


[PATCH] D145860: [clang][Interp] Fix initializing fields after base class members

2023-03-19 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145860

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


[PATCH] D144522: [clang-tidy] Add readability-operators-representation check

2023-03-19 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability/operators-representation.rst:16
+To configure the check to enforce the traditional token representation, you can
+set the `BinaryOperators` and `OverloadedOperators` options to ``&&,||,!``,
+respectively. This will cause the check to warn on any occurrences of ``and``,

PiotrZSL wrote:
> carlosgalvezp wrote:
> > Is there any reason why this distinction is needed? The usage of the 
> > operator happens in client code - it's unlikely one would want different 
> > style depending on whether the operator is overloaded or not?
> > 
> > ```
> > bool x = some_bool and some_other_bool;
> > bool y = some_object && some_other_object;
> > ```
> Consider code like this:
> 
> ```
> template
> void archive(T&& a, std::optional& v)
> {
> a & v;
> }
> 
> and
> 
> bool test(unsigned value, unsigned mask)
> {
> return value & mask;
> }
> ```
> 
> Those are 2 different use-cases, probably you don't want to use bit_and, but 
> you could use bit_and for value & mask.
Good point, thanks for the clarification!



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability/operators-representation.rst:28-29
+
+Alternative Token Representation
+
+

carlosgalvezp wrote:
> PiotrZSL wrote:
> > carlosgalvezp wrote:
> > > Personally I find this to be a matter of style, and arguments could be 
> > > found for either style. As such I don't think this check should promote 
> > > the style preference of the author of the check.
> > > 
> > > It's like having a written discussion in the clang-format option 
> > > `ColumnLimit` explaining why N characters is a better choice than M 
> > > characters. In the end this is a decision each project should take, and 
> > > the check should not have a bias towards a preferred choice.
> > Following this way of thinking none of value is correct. Always will be 
> > group that is for it or against it. Initially this check had to be only to 
> > enforce alternative tokens but then made it configurable and change name of 
> > check. This check is for "readability" and alternative tokens are more 
> > readable. If someone don't like them, their choose, they can change config 
> > to their needs.
> FYI @njames93 , do you have an opinion on the matter as Code Owner?
> alternative tokens are more readable

I don't believe this is an objective, universal truth - I think it's very 
subjective, and you will find people who disagrees. 

Take for example the "readability-identifier-naming" check. There's many 
different conventions supported there, there's no "correct" one and "incorrect" 
one. Imagine if the author wrote a 100+ lines dissertation about why Hungarian 
notation is better than the others, and encourage people to choose that. 

> if someone don't like them, their choose, they can change config to their 
> needs.

Yes, this is exactly what I would expect from this check. My point is that this 
lengthy discussion here encouraging choosing one style over the other is out of 
place, cluttering the documentation with content that is not relevant to 
understand what the check does and how to use it. The check documentation 
should be neutral and just present the available options. This is consistent 
with all other checks. 

The purpose of this check is not to transform code into ATR style, but rather 
to ensure consistency in a project, whichever style is wanted. 



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability/operators-representation.rst:159
+Configuration can be mixed, for example: `and;||;not`.
+The default value is `and;or;not`.
+

It's unclear what the default value is for the other operators. From the code I 
see that ATR is the default - in that case I think the documentation should 
either a) provide the full list of defaults here, or b) simply mention "ATR 
style is the default". As a user I would prefer the former, so I know what 
keywords I am allowed to type in here, without having to go and consult 
cppreference.

Actually, now that I think about it, wouldn't it be better to implement this as 
an enum, similar to the readability-identifier-naming checks? Is there a use 
case for having `and;||;not`, i.e. a mix of style within the same category 
(e.g. BinaryOperators)?

In that case, it could look something like:

```
readability-operators-representation.BinaryOperatorsStyle = Traditional
readability-operators-representation.BinaryOperatorsStyle = Alternative
```

This would be easier to use from a user perspective, and IMHO would lead to a 
more consistent codebase, where one style or the other is chosen for all 
operators in each category.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144522

_

[PATCH] D146377: [clangd] Remove reundant use of getSpellingLoc()

2023-03-19 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added reviewers: hokein, kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
nridge requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

getFileLoc() is guaranteed to return a file loc, and getSpellingLoc()
on a file loc is a no-op.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146377

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/XRefs.cpp


Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1611,8 +1611,8 @@
   ASTContext &Ctx = ND.getASTContext();
   auto &SM = Ctx.getSourceManager();
   SourceLocation NameLoc = nameLocation(ND, Ctx.getSourceManager());
-  SourceLocation BeginLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getBeginLoc()));
-  SourceLocation EndLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getEndLoc()));
+  SourceLocation BeginLoc = SM.getFileLoc(ND.getBeginLoc());
+  SourceLocation EndLoc = SM.getFileLoc(ND.getEndLoc());
   const auto DeclRange =
   toHalfOpenFileRange(SM, Ctx.getLangOpts(), {BeginLoc, EndLoc});
   if (!DeclRange)
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -223,8 +223,8 @@
 std::optional declToSym(ASTContext &Ctx, const NamedDecl &ND) {
   auto &SM = Ctx.getSourceManager();
 
-  SourceLocation BeginLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getBeginLoc()));
-  SourceLocation EndLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getEndLoc()));
+  SourceLocation BeginLoc = SM.getFileLoc(ND.getBeginLoc());
+  SourceLocation EndLoc = SM.getFileLoc(ND.getEndLoc());
   const auto SymbolRange =
   toHalfOpenFileRange(SM, Ctx.getLangOpts(), {BeginLoc, EndLoc});
   if (!SymbolRange)


Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1611,8 +1611,8 @@
   ASTContext &Ctx = ND.getASTContext();
   auto &SM = Ctx.getSourceManager();
   SourceLocation NameLoc = nameLocation(ND, Ctx.getSourceManager());
-  SourceLocation BeginLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getBeginLoc()));
-  SourceLocation EndLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getEndLoc()));
+  SourceLocation BeginLoc = SM.getFileLoc(ND.getBeginLoc());
+  SourceLocation EndLoc = SM.getFileLoc(ND.getEndLoc());
   const auto DeclRange =
   toHalfOpenFileRange(SM, Ctx.getLangOpts(), {BeginLoc, EndLoc});
   if (!DeclRange)
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -223,8 +223,8 @@
 std::optional declToSym(ASTContext &Ctx, const NamedDecl &ND) {
   auto &SM = Ctx.getSourceManager();
 
-  SourceLocation BeginLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getBeginLoc()));
-  SourceLocation EndLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getEndLoc()));
+  SourceLocation BeginLoc = SM.getFileLoc(ND.getBeginLoc());
+  SourceLocation EndLoc = SM.getFileLoc(ND.getEndLoc());
   const auto SymbolRange =
   toHalfOpenFileRange(SM, Ctx.getLangOpts(), {BeginLoc, EndLoc});
   if (!SymbolRange)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146377: [clangd] Remove reundant use of getSpellingLoc()

2023-03-19 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

No functional changes intended, this redundancy is just something I noticed 
while I was learning about these functions during my review of D144074 
 and looking at other usages of them in 
clnagd.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146377

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


[PATCH] D145435: Choose style (file) from within code for use in IDEs

2023-03-19 Thread bers via Phabricator via cfe-commits
bersbersbers updated this revision to Diff 506357.
bersbersbers added a comment.

Fix unit tests, add unit tests


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

https://reviews.llvm.org/D145435

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/BreakableToken.cpp
  clang/lib/Format/BreakableToken.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/ConfigParseTest.cpp

Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -1262,6 +1262,22 @@
 "none", "", &FS);
   ASSERT_TRUE(static_cast(Style9));
   ASSERT_EQ(*Style9, SubSubStyle);
+
+  // Test 10.1: use style from style comment in code file.
+  ASSERT_TRUE(
+  FS.addFile("comment.cpp", 0, llvm::MemoryBuffer::getMemBuffer("")));
+  auto Style10 = getStyle("file", "comment.cpp", "LLVM",
+  "   // clang-format style=Google", &FS);
+  ASSERT_TRUE((bool)Style10);
+  ASSERT_EQ(*Style10, getGoogleStyle());
+
+  // Test 10.2: don't use commented style comment.
+  ASSERT_TRUE(
+  FS.addFile("comment.cpp", 0, llvm::MemoryBuffer::getMemBuffer("")));
+  Style10 = getStyle("file", "comment.cpp", "LLVM",
+ "// // clang-format style=Google", &FS);
+  ASSERT_TRUE((bool)Style10);
+  ASSERT_EQ(*Style10, getLLVMStyle());
 }
 
 TEST(ConfigParseTest, GetStyleOfSpecificFile) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -4292,6 +4292,10 @@
   if (CommentPragmasRegex.match(IndentContent))
 return false;
 
+  // If comment is a style comment, treat as separate section.
+  if (IndentContent.ltrim().startswith(clang::format::StyleComment))
+return false;
+
   // If Line starts with a line comment, then FormatTok continues the comment
   // section if its original column is greater or equal to the original start
   // column of the line.
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3741,6 +3741,29 @@
   if (!getPredefinedStyle(FallbackStyleName, Style.Language, &FallbackStyle))
 return make_string_error("Invalid fallback style \"" + FallbackStyleName);
 
+  if (StyleName == "file") {
+// Read style from first style comment at start of line in the code.
+std::string Prefix{std::string("// ") + StyleComment};
+size_t PrefixPos = StringRef::npos;
+while ((PrefixPos = Code.find(Prefix, PrefixPos + 1)) != StringRef::npos) {
+  // For each prefix, locate respective start of line (SoL) and check text
+  // between prefix and start of line for non-whitespace (comments not at
+  // start of line up to whitespace may be quoted, commented out, ...).
+  if (const size_t SoL = Code.substr(0, PrefixPos).find_last_of("\r\n") + 1;
+  !Code.substr(SoL, PrefixPos - SoL).ltrim().empty()) {
+continue;
+  }
+
+  // Use remainder of line as `StyleName` as if passed by `-style=...`;
+  // if no end of line (EoL) found, use remainder of file.
+  const size_t StylePos = PrefixPos + Prefix.size();
+  const size_t EoL = Code.find_first_of("\r\n", StylePos);
+  const size_t StyleLen = EoL - (EoL == StringRef::npos ? 0 : StylePos);
+  StyleName = Code.substr(StylePos, StyleLen);
+  break;
+}
+  }
+
   llvm::SmallVector, 1>
   ChildFormatTextToApply;
 
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -2192,7 +2192,7 @@
 }();
 if (!Style.ReflowComments ||
 CommentPragmasRegex.match(Current.TokenText.substr(2)) ||
-switchesFormatting(Current) || !RegularComments) {
+setsStyle(Current) || switchesFormatting(Current) || !RegularComments) {
   return nullptr;
 }
 return std::make_unique(
Index: clang/lib/Format/BreakableToken.h
===
--- clang/lib/Format/BreakableToken.h
+++ clang/lib/Format/BreakableToken.h
@@ -27,6 +27,10 @@
 namespace clang {
 namespace format {
 
+/// Checks if \p Token sets style, basically, // clang-format style=
+/// \p Token must be a line comment.
+bool setsStyle(const FormatToken &Token);
+
 /// Checks if \p Token switches formatting, like /* clang-format off */.
 /// \p Token must be a comment.
 bool switchesFormatting(const FormatToken &Token);
Index: clang/lib/Format/BreakableToken.cpp
==

[PATCH] D146278: [flang] add -flang-experimental-hlfir flag to flang-new

2023-03-19 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

You can either pass parameters to passes or use different pass pipelines for 
different optimisation levels (in MLIR territory).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146278

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


[PATCH] D146358: [clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables

2023-03-19 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 506358.
hazohelet added a comment.

Address comments from @shafik and @tbaeder


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

https://reviews.llvm.org/D146358

Files:
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Interp/Interp.cpp
  clang/test/AST/Interp/cxx20.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp

Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -761,7 +761,7 @@
 };
 
 S s1; // expected-error {{call to consteval function 'NamespaceScopeConsteval::S::S' is not a constant expression}} \
- expected-note {{subobject of type 'int' is not initialized}}
+ expected-note {{subobject 'Val' is not initialized}}
 
 template 
 struct T {
@@ -770,7 +770,7 @@
 };
 
 T t; // expected-error {{call to consteval function 'NamespaceScopeConsteval::T::T' is not a constant expression}} \
- expected-note {{subobject of type 'int' is not initialized}}
+ expected-note {{subobject 'Val' is not initialized}}
 
 } // namespace NamespaceScopeConsteval
 
Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -409,12 +409,12 @@
 b.a.x = 2;
 return b;
   }
-  constexpr B uninit = return_uninit(); // expected-error {{constant expression}} expected-note {{subobject of type 'int' is not initialized}}
+  constexpr B uninit = return_uninit(); // expected-error {{constant expression}} expected-note {{subobject 'y' is not initialized}}
   static_assert(return_uninit().a.x == 2);
   constexpr A return_uninit_struct() {
 B b = {.b = 1};
 b.a.x = 2;
-return b.a; // expected-note {{in call to 'A(b.a)'}} expected-note {{subobject of type 'int' is not initialized}}
+return b.a; // expected-note {{in call to 'A(b.a)'}} expected-note {{subobject 'y' is not initialized}}
   }
   // Note that this is rejected even though return_uninit() is accepted, and
   // return_uninit() copies the same stuff wrapped in a union.
@@ -558,7 +558,7 @@
 }
   };
   constinit X x1(true);
-  constinit X x2(false); // expected-error {{constant initializer}} expected-note {{constinit}} expected-note {{subobject of type 'int' is not initialized}}
+  constinit X x2(false); // expected-error {{constant initializer}} expected-note {{constinit}} expected-note {{subobject 'n' is not initialized}}
 
   struct Y {
 struct Z { int n; }; // expected-note {{here}}
@@ -577,7 +577,7 @@
   };
   // FIXME: This is working around clang not implementing DR2026. With that
   // fixed, we should be able to test this without the injected copy.
-  constexpr Y copy(Y y) { return y; } // expected-note {{in call to 'Y(y)'}} expected-note {{subobject of type 'int' is not initialized}}
+  constexpr Y copy(Y y) { return y; } // expected-note {{in call to 'Y(y)'}} expected-note {{subobject 'n' is not initialized}}
   constexpr Y y1 = copy(Y());
   static_assert(y1.z1.n == 1 && y1.z2.n == 2 && y1.z3.n == 3);
 
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
@@ -359,7 +359,7 @@
   // The constructor is still 'constexpr' here, but the result is not intended
   // to be a constant expression. The standard is not clear on how this should
   // work.
-  constexpr V v; // expected-error {{constant expression}} expected-note {{subobject of type 'int' is not initialized}}
+  constexpr V v; // expected-error {{constant expression}} expected-note {{subobject 'y' is not initialized}}
 
   constexpr int k = V().x; // FIXME: ok?
 }
Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -143,9 +143,9 @@
 constexpr A() {}
   };
   constexpr A a; // expected-error {{must be initialized by a constant expression}} \
- // expected-note {{subobject of type 'int' is not initialized}} \
+ // expected-note {{subobject 'a' is not initialized}} \
  // ref-error {{must be initialized by a constant expression}} \
- // ref-note {{subobject of type 'int' is not initialized}}
+ // ref-note {{subobject 'a' is not initialized}}
 
 
   class Base {
@@ -161,18 +161,18 @@
 constexpr Derived() : Base() {}   };
 
   constexpr Derived D; // expected-error {{must be initialized by a constant expression}} \
- 

[PATCH] D134827: [clangd] Avoid recursion on UnresolvedUsingValueDecl during semantic highlighting

2023-03-19 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 506359.
nridge added a comment.

add test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134827

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -942,7 +942,15 @@
   auto $LocalVariable_def[[s]] = $Operator[[new]] 
$Class[[Foo]]<$TemplateParameter[[T]]>();
   $Operator[[delete]] $LocalVariable[[s]];
 }
-  )cpp"};
+  )cpp",
+  // Recursive UsingValueDecl
+  R"cpp(
+template  class $Class_def[[X]] {
+  template  class $Class_def[[Y]] {
+using $Class[[Y]]<0>::$Unknown_dependentName[[xxx]];
+  };
+};
+)cpp"};
   for (const auto &TestCase : TestCases)
 // Mask off scope modifiers to keep the tests manageable.
 // They're tested separately.
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -156,7 +156,7 @@
 return HighlightingKind::Concept;
   if (const auto *UUVD = dyn_cast(D)) {
 auto Targets = Resolver->resolveUsingValueDecl(UUVD);
-if (!Targets.empty()) {
+if (!Targets.empty() && Targets[0] != UUVD) {
   return kindForDecl(Targets[0], Resolver);
 }
 return HighlightingKind::Unknown;


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -942,7 +942,15 @@
   auto $LocalVariable_def[[s]] = $Operator[[new]] $Class[[Foo]]<$TemplateParameter[[T]]>();
   $Operator[[delete]] $LocalVariable[[s]];
 }
-  )cpp"};
+  )cpp",
+  // Recursive UsingValueDecl
+  R"cpp(
+template  class $Class_def[[X]] {
+  template  class $Class_def[[Y]] {
+using $Class[[Y]]<0>::$Unknown_dependentName[[xxx]];
+  };
+};
+)cpp"};
   for (const auto &TestCase : TestCases)
 // Mask off scope modifiers to keep the tests manageable.
 // They're tested separately.
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -156,7 +156,7 @@
 return HighlightingKind::Concept;
   if (const auto *UUVD = dyn_cast(D)) {
 auto Targets = Resolver->resolveUsingValueDecl(UUVD);
-if (!Targets.empty()) {
+if (!Targets.empty() && Targets[0] != UUVD) {
   return kindForDecl(Targets[0], Resolver);
 }
 return HighlightingKind::Unknown;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134827: [clangd] Avoid recursion on UnresolvedUsingValueDecl during semantic highlighting

2023-03-19 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:143
 auto Targets = Resolver->resolveUsingValueDecl(UUVD);
-if (!Targets.empty()) {
+if (!Targets.empty() && Targets[0] != UUVD) {
   return kindForDecl(Targets[0], Resolver);

sammccall wrote:
> This looks good+safe.
> 
> I wonder if the check should be moved inside resolveUsingValueDecl - having 
> it resolve to itself seems unhelpful always.
> I wonder if the check should be moved inside resolveUsingValueDecl - having 
> it resolve to itself seems unhelpful always.

I haven't done this because, as mentioned earlier, I think a fix for the 
mutually-recursive case will need to build on logic here rather than inside 
resolveUsingValueDecl.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134827

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


[PATCH] D134827: [clangd] Avoid recursion on UnresolvedUsingValueDecl during semantic highlighting

2023-03-19 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

I will go ahead and merge this partial fix because it is an improvement over 
the current state.

@sammccall I'm still curious to know your thoughts on the approach for fixing 
the mutually-recursive case. Is there something more general than adding a 
recursion guard like this to semantic highlighting code that I'm overlooking?

> we may want a "seen decls" set (similar to `SeenTemplates` here 
> )
>  in the `kindForDecl()` recursion


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134827

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


[clang-tools-extra] 7138e75 - [clangd] Avoid recursion on UnresolvedUsingValueDecl during semantic highlighting

2023-03-19 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2023-03-19T04:30:33-04:00
New Revision: 7138e75d1bb5008b9278359dc83f05c668e104c2

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

LOG: [clangd] Avoid recursion on UnresolvedUsingValueDecl during semantic 
highlighting

Fixes https://github.com/clangd/clangd/issues/1313

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

Added: 


Modified: 
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 19f79f793420d..2122cb86c2834 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -156,7 +156,7 @@ std::optional kindForDecl(const NamedDecl 
*D,
 return HighlightingKind::Concept;
   if (const auto *UUVD = dyn_cast(D)) {
 auto Targets = Resolver->resolveUsingValueDecl(UUVD);
-if (!Targets.empty()) {
+if (!Targets.empty() && Targets[0] != UUVD) {
   return kindForDecl(Targets[0], Resolver);
 }
 return HighlightingKind::Unknown;

diff  --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp 
b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index cba318df3d2fe..9a3ab30eafabb 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -1045,7 +1045,15 @@ sizeof...($TemplateParameter[[Elements]]);
   auto $LocalVariable_def[[s]] = $Operator[[new]] 
$Class[[Foo]]$Bracket[[<]]$TemplateParameter[[T]]$Bracket[[>]]();
   $Operator[[delete]] $LocalVariable[[s]];
 }
-  )cpp"};
+  )cpp",
+  // Recursive UsingValueDecl
+  R"cpp(
+template  class $Class_def[[X]] {
+  template  class $Class_def[[Y]] {
+using $Class[[Y]]<0>::$Unknown_dependentName[[xxx]];
+  };
+};
+)cpp"};
   for (const auto &TestCase : TestCases)
 // Mask off scope modifiers to keep the tests manageable.
 // They're tested separately.



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


[PATCH] D134827: [clangd] Avoid recursion on UnresolvedUsingValueDecl during semantic highlighting

2023-03-19 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7138e75d1bb5: [clangd] Avoid recursion on 
UnresolvedUsingValueDecl during semantic… (authored by nridge).

Changed prior to commit:
  https://reviews.llvm.org/D134827?vs=506359&id=506360#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134827

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -1045,7 +1045,15 @@
   auto $LocalVariable_def[[s]] = $Operator[[new]] 
$Class[[Foo]]$Bracket[[<]]$TemplateParameter[[T]]$Bracket[[>]]();
   $Operator[[delete]] $LocalVariable[[s]];
 }
-  )cpp"};
+  )cpp",
+  // Recursive UsingValueDecl
+  R"cpp(
+template  class $Class_def[[X]] {
+  template  class $Class_def[[Y]] {
+using $Class[[Y]]<0>::$Unknown_dependentName[[xxx]];
+  };
+};
+)cpp"};
   for (const auto &TestCase : TestCases)
 // Mask off scope modifiers to keep the tests manageable.
 // They're tested separately.
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -156,7 +156,7 @@
 return HighlightingKind::Concept;
   if (const auto *UUVD = dyn_cast(D)) {
 auto Targets = Resolver->resolveUsingValueDecl(UUVD);
-if (!Targets.empty()) {
+if (!Targets.empty() && Targets[0] != UUVD) {
   return kindForDecl(Targets[0], Resolver);
 }
 return HighlightingKind::Unknown;


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -1045,7 +1045,15 @@
   auto $LocalVariable_def[[s]] = $Operator[[new]] $Class[[Foo]]$Bracket[[<]]$TemplateParameter[[T]]$Bracket[[>]]();
   $Operator[[delete]] $LocalVariable[[s]];
 }
-  )cpp"};
+  )cpp",
+  // Recursive UsingValueDecl
+  R"cpp(
+template  class $Class_def[[X]] {
+  template  class $Class_def[[Y]] {
+using $Class[[Y]]<0>::$Unknown_dependentName[[xxx]];
+  };
+};
+)cpp"};
   for (const auto &TestCase : TestCases)
 // Mask off scope modifiers to keep the tests manageable.
 // They're tested separately.
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -156,7 +156,7 @@
 return HighlightingKind::Concept;
   if (const auto *UUVD = dyn_cast(D)) {
 auto Targets = Resolver->resolveUsingValueDecl(UUVD);
-if (!Targets.empty()) {
+if (!Targets.empty() && Targets[0] != UUVD) {
   return kindForDecl(Targets[0], Resolver);
 }
 return HighlightingKind::Unknown;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134827: [clangd] Avoid recursion on UnresolvedUsingValueDecl during semantic highlighting

2023-03-19 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks tests: http://45.33.8.238/linux/102084/step_9.txt

Please take a look and revert for now if it takes a while to fix.

Did you not run tests before commiting?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134827

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


[PATCH] D70401: [RISCV] Complete RV32E/ilp32e implementation

2023-03-19 Thread Edmund Raile via Phabricator via cfe-commits
recallmenot added a comment.

Hi, I'm working on CH32V003 for rust and it uses RV32EC core.
I tried replacing my distros llvm and clang with a patched version of this like 
this:

  git clone https://aur.archlinux.org/llvm-git.git
  cd llvm-git
  mkdir src
  cd src
  git clone https://github.com/llvm/llvm-project.git
  cd llvm-project
  arc patch D70401
  cd ../..
  mv llvm-config.h src/
  makepkg -es
  sudo pacman -Rd --nodeps clang llvm
  makepkg -eid

but that bricked my xfce-wayland-manjaro DE (one screen black)
And in config.toml if I put

  [build]
  target = "riscv32i-unknown-none-elf"
  rustflags = [
"-C", "target-feature=+e,+c"
  ]

then build with cargo build
LLVM still complains it doesn't implement CodeGen for RV32E yet
What am I doing wrong?
Ended up reverting to repository llvm and clang, desktop now works again but 
CodeGen is obviously missing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70401

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


[PATCH] D134827: [clangd] Avoid recursion on UnresolvedUsingValueDecl during semantic highlighting

2023-03-19 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

My apologies. I did run tests locally but on a slightly older tree. I'll post a 
fix momentarily.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134827

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


[PATCH] D146042: [clang-format] Fix numerous issues with "LambdaBodyIndentation: OuterScope" option

2023-03-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

Looks like this patch doesn't put the opening brace at the outerscope for some 
of the examples from the linked github issues:

  $ cat .clang-format
  AllowShortLambdasOnASingleLine: None
  BraceWrapping:
BeforeLambdaBody: true
  BreakBeforeBraces: Custom
  LambdaBodyIndentation: OuterScope
  $ cat test.cpp
  (1,
 b(
[]
   {
 return 0;
   }));
  
  some_function(a_really_long_name, another_long_name, a_third_long_name,
[&](LineCallback line_callback)
  {
int a;
int b;
  });
  $ clang-format test.cpp
  (1, b(
  []
  {
return 0;
  }));
  
  some_function(a_really_long_name, another_long_name, a_third_long_name,
[&](LineCallback line_callback)
{
  int a;
  int b;
});
  $ 

Shouldn't the expected output be the same as the input?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146042

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


[clang-tools-extra] 9d042ed - [clangd] Fix test failure in SemanticHighlighting.GetsCorrectTokens

2023-03-19 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2023-03-19T04:43:24-04:00
New Revision: 9d042ed1a4f4eaf99eb8d349e5c489a60afb7e50

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

LOG: [clangd] Fix test failure in SemanticHighlighting.GetsCorrectTokens

Added: 


Modified: 
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp 
b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index 9a3ab30eafab..259efcf54a6b 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -1048,9 +1048,9 @@ sizeof...($TemplateParameter[[Elements]]);
   )cpp",
   // Recursive UsingValueDecl
   R"cpp(
-template  class $Class_def[[X]] {
-  template  class $Class_def[[Y]] {
-using $Class[[Y]]<0>::$Unknown_dependentName[[xxx]];
+template $Bracket[[<]]int$Bracket[[>]] class $Class_def[[X]] {
+  template $Bracket[[<]]int$Bracket[[>]] class $Class_def[[Y]] {
+using 
$Class[[Y]]$Bracket[[<]]0$Bracket[[>]]::$Unknown_dependentName[[xxx]];
   };
 };
 )cpp"};



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


[PATCH] D134827: [clangd] Avoid recursion on UnresolvedUsingValueDecl during semantic highlighting

2023-03-19 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Should be fixed in https://reviews.llvm.org/rG9d042ed1a4f4.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134827

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


[PATCH] D146101: [clang-format] Add DesignatedInitializerIndentWidth option.

2023-03-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D146101#4201842 , @jp4a50 wrote:

> I understand the added complexity and maintenance burden of a new option but 
> we do meet the 3 criteria listed in your link.
>
> - it is part of the KJ style guide which is used by the capn proto 
>  project which has over 100 
> maintainers
> - the style guide is publicly accessible here 
> 

The style guide doesn't mention indenting designated initializers with 2 spaces?

> - I'm willing to contribute and maintain patches :)
>
> I think it's also worth noting that the google style guide 
>  
> gives an example of designated initializers indented at 2 spaces (whereas 
> their "continuation indent" for wrapped function parameters is 4).

It's likely an error that the designated initializer example there shows 
2-space indents as clang-format uses the 4-space continuation indent width:

  clang-format -style=Google
  Point p = {
  .x = 1.0, .y = 2.0,
  // z will be 0.0
  };
  Point p = {
  .x = 1.0, .y = 2.0,
  // z will be 0.0
  };


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146101

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


[PATCH] D146284: [clang-format] Annotate noexcept, explicit specifiers as containing expressions

2023-03-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

Should we add tests to TokenAnnotatorTest.cpp?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146284

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


[PATCH] D146284: [clang-format] Annotate noexcept, explicit specifiers as containing expressions

2023-03-19 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel added a comment.

Yes, good point, I will do that


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146284

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


[PATCH] D146284: [clang-format] Annotate noexcept, explicit specifiers as containing expressions

2023-03-19 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel updated this revision to Diff 506370.
rymiel added a comment.

Annotator tests (copied from format tests)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146284

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


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -242,6 +242,17 @@
 "}");
   ASSERT_EQ(Tokens.size(), 12u) << Tokens;
   EXPECT_TOKEN(Tokens[7], tok::amp, TT_BinaryOperator);
+
+  Tokens =
+  annotate("template  void swap() noexcept(Bar && 
Foo);");
+  ASSERT_EQ(Tokens.size(), 23u) << Tokens;
+  EXPECT_TOKEN(Tokens[15], tok::ampamp, TT_BinaryOperator);
+
+  Tokens = annotate("template  struct S {\n"
+"  explicit(Bar && Foo) S(const S &);\n"
+"};");
+  ASSERT_EQ(Tokens.size(), 30u) << Tokens;
+  EXPECT_TOKEN(Tokens[14], tok::ampamp, TT_BinaryOperator);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11592,6 +11592,10 @@
   verifyFormat("template  class A {\n"
"  static_assert(B && C, \"Something is wrong\");\n"
"};");
+  verifyFormat("template  void swap() noexcept(Bar && 
Foo);");
+  verifyFormat("template  struct S {\n"
+   "  explicit(Bar && Foo) S(const S &);\n"
+   "};");
   verifyGoogleFormat("#define IF(a, b, c) if (a && (b == c))");
   verifyGoogleFormat("#define WHILE(a, b, c) while (a && (b == c))");
   verifyFormat("#define A(a, b) (a && b)");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -318,9 +318,10 @@
   // export type X = (...);
   Contexts.back().IsExpression = false;
 } else if (OpeningParen.Previous &&
-   (OpeningParen.Previous->isOneOf(tok::kw_static_assert,
-   tok::kw_while, tok::l_paren,
-   tok::comma, TT_BinaryOperator) 
||
+   (OpeningParen.Previous->isOneOf(
+tok::kw_static_assert, tok::kw_noexcept, tok::kw_explicit,
+tok::kw_while, tok::l_paren, tok::comma,
+TT_BinaryOperator) ||
 OpeningParen.Previous->isIf())) {
   // static_assert, if and while usually contain expressions.
   Contexts.back().IsExpression = true;


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -242,6 +242,17 @@
 "}");
   ASSERT_EQ(Tokens.size(), 12u) << Tokens;
   EXPECT_TOKEN(Tokens[7], tok::amp, TT_BinaryOperator);
+
+  Tokens =
+  annotate("template  void swap() noexcept(Bar && Foo);");
+  ASSERT_EQ(Tokens.size(), 23u) << Tokens;
+  EXPECT_TOKEN(Tokens[15], tok::ampamp, TT_BinaryOperator);
+
+  Tokens = annotate("template  struct S {\n"
+"  explicit(Bar && Foo) S(const S &);\n"
+"};");
+  ASSERT_EQ(Tokens.size(), 30u) << Tokens;
+  EXPECT_TOKEN(Tokens[14], tok::ampamp, TT_BinaryOperator);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11592,6 +11592,10 @@
   verifyFormat("template  class A {\n"
"  static_assert(B && C, \"Something is wrong\");\n"
"};");
+  verifyFormat("template  void swap() noexcept(Bar && Foo);");
+  verifyFormat("template  struct S {\n"
+   "  explicit(Bar && Foo) S(const S &);\n"
+   "};");
   verifyGoogleFormat("#define IF(a, b, c) if (a && (b == c))");
   verifyGoogleFormat("#define WHILE(a, b, c) while (a && (b == c))");
   verifyFormat("#define A(a, b) (a && b)");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -318,9 +318,10 @@
   // export type X = (...);
   Contexts.back().IsExpression = false;
 } else if (OpeningParen.Previous &&
-   (OpeningParen.Previous->isOneOf(tok::kw_static_assert,
-   tok::kw_while, tok::l_paren,
-   

[PATCH] D145435: Choose style (file) from within code for use in IDEs

2023-03-19 Thread bers via Phabricator via cfe-commits
bersbersbers added a comment.

That remaining failing unit test (`Flang.Driver::code-gen-rv64.f90`) appears to 
be independent of my diff, as it appears in other pipelines as well, compare 
https://buildkite.com/llvm-project/premerge-checks/builds/141883#0186f8c7-4ac2-43c4-a83d-d101ed0ebf65/6-13797


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

https://reviews.llvm.org/D145435

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


[PATCH] D144522: [clang-tidy] Add readability-operators-representation check

2023-03-19 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL planned changes to this revision.
PiotrZSL added a comment.

Update documentation, and config examples, add "Traditional Tokens 
Representation" section.




Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability/operators-representation.rst:159
+Configuration can be mixed, for example: `and;||;not`.
+The default value is `and;or;not`.
+

carlosgalvezp wrote:
> It's unclear what the default value is for the other operators. From the code 
> I see that ATR is the default - in that case I think the documentation should 
> either a) provide the full list of defaults here, or b) simply mention "ATR 
> style is the default". As a user I would prefer the former, so I know what 
> keywords I am allowed to type in here, without having to go and consult 
> cppreference.
> 
> Actually, now that I think about it, wouldn't it be better to implement this 
> as an enum, similar to the readability-identifier-naming checks? Is there a 
> use case for having `and;||;not`, i.e. a mix of style within the same 
> category (e.g. BinaryOperators)?
> 
> In that case, it could look something like:
> 
> ```
> readability-operators-representation.BinaryOperatorsStyle = Traditional
> readability-operators-representation.BinaryOperatorsStyle = Alternative
> ```
> 
> This would be easier to use from a user perspective, and IMHO would lead to a 
> more consistent codebase, where one style or the other is chosen for all 
> operators in each category.
I choose this style just because with single option you can define whatever you 
like.
You can easily be less or more strict, enforce for example alternative tokens 
for some, and enforce traditional for other.

Entire section "Alternative Token Representation" is here so you wouldn't need 
to go to cppreference, there is an mapping.

And note that default config don't enforce alternative tokens for all, just for 
3 most common.
Not everyone know about alternative token existence. And cppreference don't 
describe why they exist. This is why this description with examples were added, 
about pros and some cons. Not only engineers read checks documentations , 
quality/product managers do that also.
And most of checks descriptions basically don't provide any information that 
would answer a question: "Why I should enable this check, what I will gain".

I agree, that some additional paragraph about example configurations (less, 
more strict) and maybe some clarification about options could be added. And 
some clarification why options are split into two with example, I will think 
about this.

As for "Alternative Token Representation" if you wan't I can extract from it 
also "Traditional Token Representation" and put there pros and cons. And move 
mapping table in front of both of them.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144522

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


[PATCH] D141811: [clang-format] Allow trailing return types in macros

2023-03-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:7989-7990
 
+  verifyFormat("#define MAKE_DEF(NAME) 
"
+   "\\\n"
+   "  auto NAME() -> int { return 42; }");

I'd reduce `ColumnLimit` to 60 for example to get rid of the string 
concatenation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141811

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


[PATCH] D145886: [C++2x][Modules] Amend module purview constant linkage [P2788R0].

2023-03-19 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 506380.
iains added a comment.

rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145886

Files:
  clang/lib/AST/Decl.cpp
  clang/test/CXX/module/basic/basic.def.odr/p4.cppm
  clang/test/CXX/module/basic/basic.link/p3.cppm


Index: clang/test/CXX/module/basic/basic.link/p3.cppm
===
--- clang/test/CXX/module/basic/basic.link/p3.cppm
+++ clang/test/CXX/module/basic/basic.link/p3.cppm
@@ -3,7 +3,7 @@
 
 export module M;
 
-// CHECK-NOT: @_ZW1M1a ={{.*}}
+// CHECK: @_ZW1M1a ={{.*}} constant i32 1
 const int a = 1;
 // CHECK: @_ZW1M1b ={{.*}} constant i32 2
 export const int b = 2;
Index: clang/test/CXX/module/basic/basic.def.odr/p4.cppm
===
--- clang/test/CXX/module/basic/basic.def.odr/p4.cppm
+++ clang/test/CXX/module/basic/basic.def.odr/p4.cppm
@@ -5,9 +5,9 @@
 // RUN: %clang_cc1 -std=c++20 %t/Module.cppm -triple %itanium_abi_triple 
-emit-llvm -o - | FileCheck %t/Module.cppm --implicit-check-not unused
 //
 // RUN: %clang_cc1 -std=c++20 %t/Module.cppm -triple %itanium_abi_triple 
-emit-module-interface -o %t/Module.pcm
-// RUN: %clang_cc1 -std=c++20 %t/module.cpp -triple %itanium_abi_triple 
-fmodule-file=%t/Module.pcm -emit-llvm -o - | FileCheck %t/module.cpp 
--implicit-check-not=unused --implicit-check-not=global_module
+// RUN: %clang_cc1 -std=c++20 %t/module.cpp -triple %itanium_abi_triple 
-fmodule-file=Module=%t/Module.pcm -emit-llvm -o - | FileCheck %t/module.cpp 
--implicit-check-not=unused --implicit-check-not=global_module
 //
-// RUN: %clang_cc1 -std=c++20 %t/user.cpp -triple %itanium_abi_triple 
-fmodule-file=%t/Module.pcm -emit-llvm -o - | FileCheck %t/user.cpp 
--implicit-check-not=unused --implicit-check-not=global_module
+// RUN: %clang_cc1 -std=c++20 %t/user.cpp -triple %itanium_abi_triple 
-fmodule-file=Module=%t/Module.pcm -emit-llvm -o - | FileCheck %t/user.cpp 
--implicit-check-not=unused --implicit-check-not=global_module
 
 //--- Module.cppm
 // CHECK-DAG: @extern_var_global_module = external {{(dso_local )?}}global
@@ -30,7 +30,7 @@
 // permitted to run the initializer for this variable.
 // CHECK-DAG: @_ZW6Module25inline_var_module_linkage = linkonce_odr 
{{(dso_local )?}}global
 // CHECK-DAG: @_ZL25static_var_module_linkage = internal
-// CHECK-DAG: @_ZL24const_var_module_linkage = internal
+// CHECK-DAG: @_ZW6Module24const_var_module_linkage = {{(dso_local )?}}constant
 //
 // CHECK-DAG: @_ZW6Module25unused_var_module_linkage = {{(dso_local )?}}global 
i32 4
 
@@ -129,7 +129,7 @@
 // CHECK-DAG: @_ZW6Module25extern_var_module_linkage = external {{(dso_local 
)?}}global
 // CHECK-DAG: @_ZW6Module25inline_var_module_linkage = linkonce_odr 
{{(dso_local )?}}global
 // CHECK-DAG: @_ZL25static_var_module_linkage = internal {{(dso_local 
)?}}global i32 0,
-// CHECK-DAG: @_ZL24const_var_module_linkage = internal {{(dso_local 
)?}}constant i32 3,
+// CHECK-DAG: @_ZW6Module24const_var_module_linkage = available_externally 
{{(dso_local )?}}constant i32 3,
 
 module Module;
 
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -600,6 +600,12 @@
   llvm_unreachable("unexpected module ownership kind");
 }
 
+static bool isDeclaredInModuleInterfaceOrPartition(const NamedDecl *D) {
+  if (auto *M = D->getOwningModule())
+return M->isInterfaceOrPartition();
+  return false;
+}
+
 static LinkageInfo getInternalLinkageFor(const NamedDecl *D) {
   return LinkageInfo::internal();
 }
@@ -642,15 +648,15 @@
   if (const auto *Var = dyn_cast(D)) {
 // - a non-template variable of non-volatile const-qualified type, unless
 //   - it is explicitly declared extern, or
-//   - it is inline or exported, or
+//   - it is declared in the purview of a module interface unit
+// (outside the private-module-fragment, if any) or module partition, 
or
+//   - it is inline, or
 //   - it was previously declared and the prior declaration did not have
 // internal linkage
 // (There is no equivalent in C99.)
-if (Context.getLangOpts().CPlusPlus &&
-Var->getType().isConstQualified() &&
-!Var->getType().isVolatileQualified() &&
-!Var->isInline() &&
-!isExportedFromModuleInterfaceUnit(Var) &&
+if (Context.getLangOpts().CPlusPlus && Var->getType().isConstQualified() &&
+!Var->getType().isVolatileQualified() && !Var->isInline() &&
+!isDeclaredInModuleInterfaceOrPartition(Var) &&
 !isa(Var) &&
 !Var->getDescribedVarTemplate()) {
   const VarDecl *PrevVar = Var->getPreviousDecl();


Index: clang/test/CXX/module/basic/basic.link/p3.cppm
===
--- clang/test/CXX/module/basic/basic.link/p3.cpp

[PATCH] D146042: [clang-format] Fix numerous issues with "LambdaBodyIndentation: OuterScope" option

2023-03-19 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 added a comment.

In D146042#4204513 , @owenpan wrote:

> Looks like this patch doesn't put the opening brace at the outerscope for 
> some of the examples from the linked github issues:
>
>   $ cat .clang-format
>   AllowShortLambdasOnASingleLine: None
>   BraceWrapping:
> BeforeLambdaBody: true
>   BreakBeforeBraces: Custom
>   LambdaBodyIndentation: OuterScope
>   $ cat test.cpp
>   (1,
>b(
>   []
>{
>  return 0;
>}));
>   
>   some_function(a_really_long_name, another_long_name, a_third_long_name,
> [&](LineCallback line_callback)
>   {
> int a;
> int b;
>   });
>   $ clang-format test.cpp
>   (1, b(
>   []
>   {
> return 0;
>   }));
>   
>   some_function(a_really_long_name, another_long_name, a_third_long_name,
> [&](LineCallback line_callback)
> {
>   int a;
>   int b;
> });
>   $ 
>
> Shouldn't the expected output be the same as the input?

I'm confident that the patch will indent all those examples correctly when they 
are at block scope which is the only place those snippets will actually be 
valid code. I added an exception (see comment in ContinuationIndenter.cpp) to 
the code to disable `OuterScope`'s behaviour when the line's indentation level 
is 0 (i.e. statements at namespace scope) because otherwise you can end up with 
things like:

  Namespace::Foo::Foo(
Arg arg1, Arg arg2,
Arg arg3, Arg arg4)
: init1{arg1},
  init2{[arg2]() {
return arg2;
  }},
  init3{arg3},
  init4{arg4} {}

The main rationale behind the `OuterScope` style is that the lambda body will 
be indented similarly to the code block of an `if` statement (or `for` etc) 
inside function definitions/blocks, but this breaks down when you have 
something like an constructor initializer which lives outside of a code block. 
The way I've handled this case isn't particularly elegant, though, so I'd be 
happy to remove the relevant code from this diff as it's not necessary to fix 
the issues I've linked - it was an extra bit of behaviour that my team (authors 
of the original implementation of `OuterScope`) wanted.

FYI I will be away until next Monday now but thanks for the feedback so far.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146042

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


[PATCH] D146101: [clang-format] Add DesignatedInitializerIndentWidth option.

2023-03-19 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 added a comment.

> The style guide doesn't mention indenting designated initializers with 2 
> spaces?

That is a fair point. I will get it updated because the author and maintainer 
of that style guide is the one requesting this change since, in practice, 
codebases following this style guide indent designated initializers with 2 
spaces.

>> I think it's also worth noting that the google style guide gives an example 
>> of designated initializers indented at 2 spaces (whereas their "continuation 
>> indent" for wrapped function parameters is 4).
>
> It's likely an error that the designated initializer example there shows 
> 2-space indents as clang-format uses the 4-space continuation indent width:

This is possible, but isn't it also possible that they would prefer designated 
initializers to be indented at 2 spaces but don't have the option with 
clang-format currently?

The only general information supplied in the google style guide about 
indentation is as follows:

> - Default indentation is 2 spaces.
> - Wrapped parameters have a 4 space indent.

If we are taking a strict definition of parameters, the above suggests to me 
that designated initializers would fall under the default indentation of 2 
spaces.

As mentioned on my other diff, I'm away until next Monday now so won't be able 
to get back to further comments til then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146101

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


[PATCH] D146364: [Driver] Fix naming conflicts of getStatsFileName when using LTO

2023-03-19 Thread Yingwei Zheng via Phabricator via cfe-commits
dtcxzyw updated this revision to Diff 506387.
dtcxzyw removed subscribers: MaskRay, cfe-commits, inglorion.
dtcxzyw added a comment.

Fix test errors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146364

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


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1774,14 +1774,13 @@
 StringRef SaveStats = A->getValue();
 if (SaveStats == "obj" && Output.isFilename()) {
   StatsFile.assign(Output.getFilename());
-  llvm::sys::path::remove_filename(StatsFile);
-} else if (SaveStats != "cwd") {
+} else if (SaveStats == "cwd") {
+  StatsFile.assign(llvm::sys::path::filename(Input.getBaseInput()));
+} else {
   D.Diag(diag::err_drv_invalid_value) << A->getAsString(Args) << SaveStats;
   return {};
 }
 
-StringRef BaseName = llvm::sys::path::filename(Input.getBaseInput());
-llvm::sys::path::append(StatsFile, BaseName);
 llvm::sys::path::replace_extension(StatsFile, "stats");
   } else {
 assert(D.CCPrintInternalStats);


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1774,14 +1774,13 @@
 StringRef SaveStats = A->getValue();
 if (SaveStats == "obj" && Output.isFilename()) {
   StatsFile.assign(Output.getFilename());
-  llvm::sys::path::remove_filename(StatsFile);
-} else if (SaveStats != "cwd") {
+} else if (SaveStats == "cwd") {
+  StatsFile.assign(llvm::sys::path::filename(Input.getBaseInput()));
+} else {
   D.Diag(diag::err_drv_invalid_value) << A->getAsString(Args) << SaveStats;
   return {};
 }
 
-StringRef BaseName = llvm::sys::path::filename(Input.getBaseInput());
-llvm::sys::path::append(StatsFile, BaseName);
 llvm::sys::path::replace_extension(StatsFile, "stats");
   } else {
 assert(D.CCPrintInternalStats);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146368: [clang-tidy] Add readability-reference-to-constructed-temporary check

2023-03-19 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/ReferenceToConstructedTemporaryCheck.cpp:22
+  bool operator()(const internal::BoundNodesMap &Nodes) const {
+auto *Other = Nodes.getNode(ID).get();
+if (!Other)

`const auto *`.



Comment at: 
clang-tools-extra/clang-tidy/readability/ReferenceToConstructedTemporaryCheck.cpp:26
+
+auto Self = Node.get();
+if (!Self)

Ditto.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability/reference-to-constructed-temporary.cpp:31
+}
+

Excessive newline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146368

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


[PATCH] D145883: [Flang][RISCV] Emit target features for RISC-V

2023-03-19 Thread Maya Amrami via Phabricator via cfe-commits
mamrami added inline comments.



Comment at: flang/test/Driver/code-gen-rv64.f90:1
+! Test -emit-obj (RISC-V 64)
+

sunshaoce wrote:
> awarzynski wrote:
> > mamrami wrote:
> > > Hi :)
> > > It seems like the test fails: 
> > > https://buildkite.com/llvm-project/premerge-checks/builds/141302#0186e55e-199e-401d-ab9f-9f3d47ec87af
> > > I see it in my non related patch https://reviews.llvm.org/D146132
> > Sorry about that :(
> > 
> > ```
> >  line 3: llvm-readelf: command not found
> > ```
> > 
> > There are 3 options:
> > * revert
> > * add `llvm-readelf` here 
> > https://github.com/llvm/llvm-project/blob/main/flang/test/CMakeLists.txt#L61
> > * updated the test to use `llvm-objdump` instead
> > 
> > HTH.
> Thanks! I've submitted in https://reviews.llvm.org/D146204.
Hi again!
The test passed after the fix but it fails again:
https://buildkite.com/llvm-project/premerge-checks/builds/141905#0186fa14-2339-4c0c-9966-dea23592a86b



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145883

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


[PATCH] D145883: [Flang][RISCV] Emit target features for RISC-V

2023-03-19 Thread Shao-Ce SUN via Phabricator via cfe-commits
sunshaoce added a subscriber: DavidSpickett.
sunshaoce added inline comments.



Comment at: flang/test/Driver/code-gen-rv64.f90:1
+! Test -emit-obj (RISC-V 64)
+

mamrami wrote:
> sunshaoce wrote:
> > awarzynski wrote:
> > > mamrami wrote:
> > > > Hi :)
> > > > It seems like the test fails: 
> > > > https://buildkite.com/llvm-project/premerge-checks/builds/141302#0186e55e-199e-401d-ab9f-9f3d47ec87af
> > > > I see it in my non related patch https://reviews.llvm.org/D146132
> > > Sorry about that :(
> > > 
> > > ```
> > >  line 3: llvm-readelf: command not found
> > > ```
> > > 
> > > There are 3 options:
> > > * revert
> > > * add `llvm-readelf` here 
> > > https://github.com/llvm/llvm-project/blob/main/flang/test/CMakeLists.txt#L61
> > > * updated the test to use `llvm-objdump` instead
> > > 
> > > HTH.
> > Thanks! I've submitted in https://reviews.llvm.org/D146204.
> Hi again!
> The test passed after the fix but it fails again:
> https://buildkite.com/llvm-project/premerge-checks/builds/141905#0186fa14-2339-4c0c-9966-dea23592a86b
> 
I noticed this error before, but @DavidSpickett haven't fixed yet. I'll fix it 
now.
https://reviews.llvm.org/rG9f93b71f20ea


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145883

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


[PATCH] D145883: [Flang][RISCV] Emit target features for RISC-V

2023-03-19 Thread Maya Amrami via Phabricator via cfe-commits
mamrami added inline comments.



Comment at: flang/test/Driver/code-gen-rv64.f90:1
+! Test -emit-obj (RISC-V 64)
+

sunshaoce wrote:
> mamrami wrote:
> > sunshaoce wrote:
> > > awarzynski wrote:
> > > > mamrami wrote:
> > > > > Hi :)
> > > > > It seems like the test fails: 
> > > > > https://buildkite.com/llvm-project/premerge-checks/builds/141302#0186e55e-199e-401d-ab9f-9f3d47ec87af
> > > > > I see it in my non related patch https://reviews.llvm.org/D146132
> > > > Sorry about that :(
> > > > 
> > > > ```
> > > >  line 3: llvm-readelf: command not found
> > > > ```
> > > > 
> > > > There are 3 options:
> > > > * revert
> > > > * add `llvm-readelf` here 
> > > > https://github.com/llvm/llvm-project/blob/main/flang/test/CMakeLists.txt#L61
> > > > * updated the test to use `llvm-objdump` instead
> > > > 
> > > > HTH.
> > > Thanks! I've submitted in https://reviews.llvm.org/D146204.
> > Hi again!
> > The test passed after the fix but it fails again:
> > https://buildkite.com/llvm-project/premerge-checks/builds/141905#0186fa14-2339-4c0c-9966-dea23592a86b
> > 
> I noticed this error before, but @DavidSpickett haven't fixed yet. I'll fix 
> it now.
> https://reviews.llvm.org/rG9f93b71f20ea
thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145883

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


[PATCH] D144522: [clang-tidy] Add readability-operators-representation check

2023-03-19 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL updated this revision to Diff 506398.
PiotrZSL added a comment.

Update documentation, changed default check configuration.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144522

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/OperatorsRepresentationCheck.cpp
  clang-tools-extra/clang-tidy/readability/OperatorsRepresentationCheck.h
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability/operators-representation.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/operators-representation-to-alternative.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/operators-representation-to-traditional.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/operators-representation-to-traditional.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability/operators-representation-to-traditional.cpp
@@ -0,0 +1,177 @@
+// RUN: %check_clang_tidy %s readability-operators-representation %t -- -config="{CheckOptions: [\
+// RUN: {key: readability-operators-representation.BinaryOperators, value: '&&;&=;&;|;~;!;!=;||;|=;^;^='}, \
+// RUN: {key: readability-operators-representation.OverloadedOperators, value: '&&;&=;&;|;~;!;!=;||;|=;^;^='}]}" --
+
+void testAllTokensToAlternative(int a, int b) {
+int value = 0;
+
+value = a or b;
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'or' is an alternative token spelling, consider using a traditional token '||' for consistency [readability-operators-representation]
+// CHECK-FIXES: {{^}}value = a || b;{{$}}
+
+value = a and b;
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'and' is an alternative token spelling, consider using a traditional token '&&' for consistency [readability-operators-representation]
+// CHECK-FIXES: {{^}}value = a && b;{{$}}
+
+value = a bitor b;
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'bitor' is an alternative token spelling, consider using a traditional token '|' for consistency [readability-operators-representation]
+// CHECK-FIXES: {{^}}value = a | b;{{$}}
+
+value = a bitand b;
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'bitand' is an alternative token spelling, consider using a traditional token '&' for consistency [readability-operators-representation]
+// CHECK-FIXES: {{^}}value = a & b;{{$}}
+
+value = not a;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 'not' is an alternative token spelling, consider using a traditional token '!' for consistency [readability-operators-representation]
+// CHECK-FIXES: {{^}}value = ! a;{{$}}
+
+value = a xor b;
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'xor' is an alternative token spelling, consider using a traditional token '^' for consistency [readability-operators-representation]
+// CHECK-FIXES: {{^}}value = a ^ b;{{$}}
+
+value = compl b;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 'compl' is an alternative token spelling, consider using a traditional token '~' for consistency [readability-operators-representation]
+// CHECK-FIXES: {{^}}value = ~ b;{{$}}
+
+value and_eq b;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: 'and_eq' is an alternative token spelling, consider using a traditional token '&=' for consistency [readability-operators-representation]
+// CHECK-FIXES: {{^}}value &= b;{{$}}
+
+value or_eq b;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: 'or_eq' is an alternative token spelling, consider using a traditional token '|=' for consistency [readability-operators-representation]
+// CHECK-FIXES: {{^}}value |= b;{{$}}
+
+value = a not_eq b;
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'not_eq' is an alternative token spelling, consider using a traditional token '!=' for consistency [readability-operators-representation]
+// CHECK-FIXES: {{^}}value = a != b;{{$}}
+
+value xor_eq a;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: 'xor_eq' is an alternative token spelling, consider using a traditional token '^=' for consistency [readability-operators-representation]
+// CHECK-FIXES: {{^}}value ^= a;{{$}}
+}
+
+struct Class {
+bool operator!() const;
+Class operator~() const;
+bool operator&&(const Class&) const;
+Class operator&(const Class&) const;
+bool operator||(const Class&) const;
+Class operator|(const Class&) const;
+Class operator^(const Class&) const;
+Class& operator&=(const Class&) const;
+Class& operator|=(const Class&) const;
+Class& operator^=(const Class&) const;
+bool operator!=(const Class&) const;
+};
+
+void testAllTokensToAlternative(Class a, Class b) {
+int value = 0;
+Class clval;
+
+value = a or b;
+

[PATCH] D146368: [clang-tidy] Add readability-reference-to-constructed-temporary check

2023-03-19 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL updated this revision to Diff 506399.
PiotrZSL marked 3 inline comments as done.
PiotrZSL added a comment.

Review comment fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146368

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  
clang-tools-extra/clang-tidy/readability/ReferenceToConstructedTemporaryCheck.cpp
  
clang-tools-extra/clang-tidy/readability/ReferenceToConstructedTemporaryCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability/reference-to-constructed-temporary.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/reference-to-constructed-temporary.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/reference-to-constructed-temporary.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability/reference-to-constructed-temporary.cpp
@@ -0,0 +1,30 @@
+// RUN: %check_clang_tidy -std=c++11-or-later %s readability-reference-to-constructed-temporary %t
+
+struct WithConstructor
+{
+WithConstructor(int, int);
+};
+
+struct WithoutConstructor
+{
+int a, b;
+};
+
+void test()
+{
+// CHECK-MESSAGES: :[[@LINE+1]]:27: warning: reference variable 'tmp1' extends the lifetime of a just-constructed temporary object 'const WithConstructor', consider changing reference to value [readability-reference-to-constructed-temporary]
+   const WithConstructor& tmp1{1,2};
+
+// CHECK-MESSAGES: :[[@LINE+1]]:30: warning: reference variable 'tmp2' extends the lifetime of a just-constructed temporary object 'const WithoutConstructor', consider changing reference to value [readability-reference-to-constructed-temporary]
+   const WithoutConstructor& tmp2{1,2};
+
+
+// CHECK-MESSAGES: :[[@LINE+1]]:22: warning: reference variable 'tmp3' extends the lifetime of a just-constructed temporary object 'WithConstructor', consider changing reference to value [readability-reference-to-constructed-temporary]
+   WithConstructor&& tmp3{1,2};
+
+// CHECK-MESSAGES: :[[@LINE+1]]:25: warning: reference variable 'tmp4' extends the lifetime of a just-constructed temporary object 'WithoutConstructor', consider changing reference to value [readability-reference-to-constructed-temporary]
+   WithoutConstructor&& tmp4{1,2};
+
+   WithConstructor tmp5{1,2};
+   WithoutConstructor tmp6{1,2};
+}
Index: clang-tools-extra/docs/clang-tidy/checks/readability/reference-to-constructed-temporary.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/readability/reference-to-constructed-temporary.rst
@@ -0,0 +1,32 @@
+.. title:: clang-tidy - readability-reference-to-constructed-temporary
+
+readability-reference-to-constructed-temporary
+==
+
+Detects C++ code where a reference variable is used to extend the lifetime of
+a temporary object that has just been constructed.
+
+This construction is often the result of multiple code refactorings or a lack
+of developer knowledge, leading to confusion or subtle bugs. In most cases,
+what the developer really wanted to do is create a new variable rather than
+extending the lifetime of a temporary object.
+
+Examples of problematic code include:
+
+.. code-block:: c++
+
+   const std::string& value("hello");
+
+   struct Point { int x; int y; };
+   const Point& p = { 1, 2 };
+
+In the first example, a ``const std::string&`` reference variable ``str`` is
+assigned a temporary object created by the ``std::string("hello")``
+constructor. In the second example, a ``const Point&`` reference variable ``p``
+is assigned an object that is constructed from an initializer list ``{ 1, 2 }``.
+Both of these examples extend the lifetime of the temporary object to the
+lifetime of the reference variable, which can make it difficult to reason about
+and may lead to subtle bugs or misunderstanding.
+
+To avoid these issues, it is recommended to change the reference variable to a
+(``const``) value variable.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -363,6 +363,7 @@
`readability-redundant-smartptr-get `_, "Yes"
`readability-redundant-string-cstr `_, "Yes"
`readability-redundant-string-init `_, "Yes"
+   `readability-reference-to-constructed-temporary `_,
`readability-simplify-boolean-expr `_, "Yes"
`readability-simplify-subscript-expr `_, "Yes"
`readability-static-accessed-through-instance `_, "Yes"
Index: clang-tools-extra/docs/ReleaseNotes.rst

[clang] 62a16d5 - [C++2x][Modules] Amend module purview constant linkage [P2788R0].

2023-03-19 Thread Iain Sandoe via cfe-commits

Author: Iain Sandoe
Date: 2023-03-19T16:25:56Z
New Revision: 62a16d5e2069542351c164aa0e3b216dc8e153c4

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

LOG: [C++2x][Modules] Amend module purview constant linkage [P2788R0].

This paper has been applied to the working draft and is believed to be
a DR against C++20, so that the patch here makes the change unconditionally.

for:
```
export module A;

const int mod_cst = 10;
```
Before the change, mod_cst would have internal linkage; after the change it
has module linkage.

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

Added: 


Modified: 
clang/lib/AST/Decl.cpp
clang/test/CXX/module/basic/basic.def.odr/p4.cppm
clang/test/CXX/module/basic/basic.link/p3.cppm

Removed: 




diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 484a4a294aa5e..56042e5fd252f 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -600,6 +600,12 @@ static bool isExportedFromModuleInterfaceUnit(const 
NamedDecl *D) {
   llvm_unreachable("unexpected module ownership kind");
 }
 
+static bool isDeclaredInModuleInterfaceOrPartition(const NamedDecl *D) {
+  if (auto *M = D->getOwningModule())
+return M->isInterfaceOrPartition();
+  return false;
+}
+
 static LinkageInfo getInternalLinkageFor(const NamedDecl *D) {
   return LinkageInfo::internal();
 }
@@ -642,15 +648,15 @@ LinkageComputer::getLVForNamespaceScopeDecl(const 
NamedDecl *D,
   if (const auto *Var = dyn_cast(D)) {
 // - a non-template variable of non-volatile const-qualified type, unless
 //   - it is explicitly declared extern, or
-//   - it is inline or exported, or
+//   - it is declared in the purview of a module interface unit
+// (outside the private-module-fragment, if any) or module partition, 
or
+//   - it is inline, or
 //   - it was previously declared and the prior declaration did not have
 // internal linkage
 // (There is no equivalent in C99.)
-if (Context.getLangOpts().CPlusPlus &&
-Var->getType().isConstQualified() &&
-!Var->getType().isVolatileQualified() &&
-!Var->isInline() &&
-!isExportedFromModuleInterfaceUnit(Var) &&
+if (Context.getLangOpts().CPlusPlus && Var->getType().isConstQualified() &&
+!Var->getType().isVolatileQualified() && !Var->isInline() &&
+!isDeclaredInModuleInterfaceOrPartition(Var) &&
 !isa(Var) &&
 !Var->getDescribedVarTemplate()) {
   const VarDecl *PrevVar = Var->getPreviousDecl();

diff  --git a/clang/test/CXX/module/basic/basic.def.odr/p4.cppm 
b/clang/test/CXX/module/basic/basic.def.odr/p4.cppm
index b8f24d3ed5c8a..1542e532c635a 100644
--- a/clang/test/CXX/module/basic/basic.def.odr/p4.cppm
+++ b/clang/test/CXX/module/basic/basic.def.odr/p4.cppm
@@ -5,9 +5,9 @@
 // RUN: %clang_cc1 -std=c++20 %t/Module.cppm -triple %itanium_abi_triple 
-emit-llvm -o - | FileCheck %t/Module.cppm --implicit-check-not unused
 //
 // RUN: %clang_cc1 -std=c++20 %t/Module.cppm -triple %itanium_abi_triple 
-emit-module-interface -o %t/Module.pcm
-// RUN: %clang_cc1 -std=c++20 %t/module.cpp -triple %itanium_abi_triple 
-fmodule-file=%t/Module.pcm -emit-llvm -o - | FileCheck %t/module.cpp 
--implicit-check-not=unused --implicit-check-not=global_module
+// RUN: %clang_cc1 -std=c++20 %t/module.cpp -triple %itanium_abi_triple 
-fmodule-file=Module=%t/Module.pcm -emit-llvm -o - | FileCheck %t/module.cpp 
--implicit-check-not=unused --implicit-check-not=global_module
 //
-// RUN: %clang_cc1 -std=c++20 %t/user.cpp -triple %itanium_abi_triple 
-fmodule-file=%t/Module.pcm -emit-llvm -o - | FileCheck %t/user.cpp 
--implicit-check-not=unused --implicit-check-not=global_module
+// RUN: %clang_cc1 -std=c++20 %t/user.cpp -triple %itanium_abi_triple 
-fmodule-file=Module=%t/Module.pcm -emit-llvm -o - | FileCheck %t/user.cpp 
--implicit-check-not=unused --implicit-check-not=global_module
 
 //--- Module.cppm
 // CHECK-DAG: @extern_var_global_module = external {{(dso_local )?}}global
@@ -30,7 +30,7 @@
 // permitted to run the initializer for this variable.
 // CHECK-DAG: @_ZW6Module25inline_var_module_linkage = linkonce_odr 
{{(dso_local )?}}global
 // CHECK-DAG: @_ZL25static_var_module_linkage = internal
-// CHECK-DAG: @_ZL24const_var_module_linkage = internal
+// CHECK-DAG: @_ZW6Module24const_var_module_linkage = {{(dso_local )?}}constant
 //
 // CHECK-DAG: @_ZW6Module25unused_var_module_linkage = {{(dso_local )?}}global 
i32 4
 
@@ -129,7 +129,7 @@ void f(a::b, a::c) {}
 // CHECK-DAG: @_ZW6Module25extern_var_module_linkage = external {{(dso_local 
)?}}global
 // CHECK-DAG: @_ZW6Module25inline_var_module_linkage = linkonce_odr 
{{(dso_local )?}}global
 // CHECK-DAG: @_ZL25static_var_module_linkage = internal {{(dso_local 
)?}}g

[PATCH] D145886: [C++2x][Modules] Amend module purview constant linkage [P2788R0].

2023-03-19 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 rG62a16d5e2069: [C++2x][Modules] Amend module purview constant 
linkage [P2788R0]. (authored by iains).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145886

Files:
  clang/lib/AST/Decl.cpp
  clang/test/CXX/module/basic/basic.def.odr/p4.cppm
  clang/test/CXX/module/basic/basic.link/p3.cppm


Index: clang/test/CXX/module/basic/basic.link/p3.cppm
===
--- clang/test/CXX/module/basic/basic.link/p3.cppm
+++ clang/test/CXX/module/basic/basic.link/p3.cppm
@@ -3,7 +3,7 @@
 
 export module M;
 
-// CHECK-NOT: @_ZW1M1a ={{.*}}
+// CHECK: @_ZW1M1a ={{.*}} constant i32 1
 const int a = 1;
 // CHECK: @_ZW1M1b ={{.*}} constant i32 2
 export const int b = 2;
Index: clang/test/CXX/module/basic/basic.def.odr/p4.cppm
===
--- clang/test/CXX/module/basic/basic.def.odr/p4.cppm
+++ clang/test/CXX/module/basic/basic.def.odr/p4.cppm
@@ -5,9 +5,9 @@
 // RUN: %clang_cc1 -std=c++20 %t/Module.cppm -triple %itanium_abi_triple 
-emit-llvm -o - | FileCheck %t/Module.cppm --implicit-check-not unused
 //
 // RUN: %clang_cc1 -std=c++20 %t/Module.cppm -triple %itanium_abi_triple 
-emit-module-interface -o %t/Module.pcm
-// RUN: %clang_cc1 -std=c++20 %t/module.cpp -triple %itanium_abi_triple 
-fmodule-file=%t/Module.pcm -emit-llvm -o - | FileCheck %t/module.cpp 
--implicit-check-not=unused --implicit-check-not=global_module
+// RUN: %clang_cc1 -std=c++20 %t/module.cpp -triple %itanium_abi_triple 
-fmodule-file=Module=%t/Module.pcm -emit-llvm -o - | FileCheck %t/module.cpp 
--implicit-check-not=unused --implicit-check-not=global_module
 //
-// RUN: %clang_cc1 -std=c++20 %t/user.cpp -triple %itanium_abi_triple 
-fmodule-file=%t/Module.pcm -emit-llvm -o - | FileCheck %t/user.cpp 
--implicit-check-not=unused --implicit-check-not=global_module
+// RUN: %clang_cc1 -std=c++20 %t/user.cpp -triple %itanium_abi_triple 
-fmodule-file=Module=%t/Module.pcm -emit-llvm -o - | FileCheck %t/user.cpp 
--implicit-check-not=unused --implicit-check-not=global_module
 
 //--- Module.cppm
 // CHECK-DAG: @extern_var_global_module = external {{(dso_local )?}}global
@@ -30,7 +30,7 @@
 // permitted to run the initializer for this variable.
 // CHECK-DAG: @_ZW6Module25inline_var_module_linkage = linkonce_odr 
{{(dso_local )?}}global
 // CHECK-DAG: @_ZL25static_var_module_linkage = internal
-// CHECK-DAG: @_ZL24const_var_module_linkage = internal
+// CHECK-DAG: @_ZW6Module24const_var_module_linkage = {{(dso_local )?}}constant
 //
 // CHECK-DAG: @_ZW6Module25unused_var_module_linkage = {{(dso_local )?}}global 
i32 4
 
@@ -129,7 +129,7 @@
 // CHECK-DAG: @_ZW6Module25extern_var_module_linkage = external {{(dso_local 
)?}}global
 // CHECK-DAG: @_ZW6Module25inline_var_module_linkage = linkonce_odr 
{{(dso_local )?}}global
 // CHECK-DAG: @_ZL25static_var_module_linkage = internal {{(dso_local 
)?}}global i32 0,
-// CHECK-DAG: @_ZL24const_var_module_linkage = internal {{(dso_local 
)?}}constant i32 3,
+// CHECK-DAG: @_ZW6Module24const_var_module_linkage = available_externally 
{{(dso_local )?}}constant i32 3,
 
 module Module;
 
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -600,6 +600,12 @@
   llvm_unreachable("unexpected module ownership kind");
 }
 
+static bool isDeclaredInModuleInterfaceOrPartition(const NamedDecl *D) {
+  if (auto *M = D->getOwningModule())
+return M->isInterfaceOrPartition();
+  return false;
+}
+
 static LinkageInfo getInternalLinkageFor(const NamedDecl *D) {
   return LinkageInfo::internal();
 }
@@ -642,15 +648,15 @@
   if (const auto *Var = dyn_cast(D)) {
 // - a non-template variable of non-volatile const-qualified type, unless
 //   - it is explicitly declared extern, or
-//   - it is inline or exported, or
+//   - it is declared in the purview of a module interface unit
+// (outside the private-module-fragment, if any) or module partition, 
or
+//   - it is inline, or
 //   - it was previously declared and the prior declaration did not have
 // internal linkage
 // (There is no equivalent in C99.)
-if (Context.getLangOpts().CPlusPlus &&
-Var->getType().isConstQualified() &&
-!Var->getType().isVolatileQualified() &&
-!Var->isInline() &&
-!isExportedFromModuleInterfaceUnit(Var) &&
+if (Context.getLangOpts().CPlusPlus && Var->getType().isConstQualified() &&
+!Var->getType().isVolatileQualified() && !Var->isInline() &&
+!isDeclaredInModuleInterfaceOrPartition(Var) &&
 !isa(Var) &&
 !Var->getDescribedVarTemplate()) {
   const VarDecl *PrevVar = Var->getPreviousDecl();

[PATCH] D146385: [clang][ExtractAPI] Complete declaration fragments for TagDecl types defined in a typedef

2023-03-19 Thread R4444 via Phabricator via cfe-commits
Ruturaj4 created this revision.
Ruturaj4 added a reviewer: dang.
Herald added a reviewer: ributzka.
Herald added a project: All.
Ruturaj4 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

enums and structs declared inside typedefs have incorrect declaration 
fragments, where the typedef keyword and other syntax is missing.

For the following struct:

typedef struct Test {

  int hello;

} Test;
The produced declaration is:

"declarationFragments": [

  {
"kind": "keyword",
"spelling": "struct"
  },
  {
"kind": "text",
"spelling": " "
  },
  {
"kind": "identifier",
"spelling": "Test"
  }

],
instead the declaration fragments should represent the following

typedef struct Test {

  …

} Test;

This patch removes the condition in SymbolGraphSerializer.cpp file and 
completes declaration fragments


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146385

Files:
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp


Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -801,11 +801,7 @@
 const TypedefRecord &Record) {
   // Typedefs of anonymous types have their entries unified with the underlying
   // type.
-  bool ShouldDrop = Record.UnderlyingType.Name.empty();
-  // enums declared with `NS_OPTION` have a named enum and a named typedef, 
with
-  // the same name
-  ShouldDrop |= (Record.UnderlyingType.Name == Record.Name);
-  if (ShouldDrop)
+  if (Record.UnderlyingType.Name.empty())
 return;
 
   auto Typedef = serializeAPIRecord(Record);


Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -801,11 +801,7 @@
 const TypedefRecord &Record) {
   // Typedefs of anonymous types have their entries unified with the underlying
   // type.
-  bool ShouldDrop = Record.UnderlyingType.Name.empty();
-  // enums declared with `NS_OPTION` have a named enum and a named typedef, with
-  // the same name
-  ShouldDrop |= (Record.UnderlyingType.Name == Record.Name);
-  if (ShouldDrop)
+  if (Record.UnderlyingType.Name.empty())
 return;
 
   auto Typedef = serializeAPIRecord(Record);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146386: [MS ABI] Fix mangling references to declarations.

2023-03-19 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a created this revision.
bolshakov-a added reviewers: erichkeane, rnk.
Herald added a project: All.
bolshakov-a requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Several issues have been discovered and (hopefully) fixed here:

- Reference NTTPs should be mangled in the same manner as pointer ones.

- Pointer fields of class type NTTPs should be treated in the same

manner as reference ones.

- Pointer-to-member fields of class type NTTPs should be treated

differently compared to pointer-to-member NTTPs. Tests on
pointer-to-member-function NTTP class fields added.

Reference NTTP mangling was done back in 2013
in e8fdc06e0dab2e7b98339425dbe369e27e2092a3, and Microsoft might change
mangling algorithm since then. But class type NTTPs are introduced only
in C++20, and the test was written in b637148ecb62b900872b34eedd78b923bb43c378 
.
It is strange if the MS ABI had been realy changed, because Microsoft
claims that they maintain ABI stability since VS 2015. I've tested both
on v142 and v143 MSVC toolsets, and they show the same behavior
on the test cases which are changed in this PR. But
pointer-to-member-function NTTP class field mangling has been actually
changed, because it was erroneous in v142, leading to name collisions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146386

Files:
  clang/lib/AST/MicrosoftMangle.cpp
  clang/test/CodeGenCXX/mangle-class-nttp.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp

Index: clang/test/CodeGenCXX/mangle-ms-templates.cpp
===
--- clang/test/CodeGenCXX/mangle-ms-templates.cpp
+++ clang/test/CodeGenCXX/mangle-ms-templates.cpp
@@ -272,7 +272,7 @@
 };
 extern const record inst;
 void recref(type1) {}
-// CHECK: "?recref@@YAXU?$type1@$E?inst@@3Urecord@@B@@@Z"
+// CHECK: "?recref@@YAXU?$type1@$1?inst@@3Urecord@@B@@@Z"
 
 struct _GUID {};
 struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid;
@@ -286,7 +286,7 @@
 void fun(UUIDType1 a) {}
 // CHECK: "?fun@@YAXU?$UUIDType1@Uuuid@@$1?_GUID_12345678_1234_1234_1234_1234567890ab@@3U__s_GUID@@B@@@Z"
 void fun(UUIDType2 b) {}
-// CHECK: "?fun@@YAXU?$UUIDType2@Uuuid@@$E?_GUID_12345678_1234_1234_1234_1234567890ab@@3U__s_GUID@@B@@@Z"
+// CHECK: "?fun@@YAXU?$UUIDType2@Uuuid@@$1?_GUID_12345678_1234_1234_1234_1234567890ab@@3U__s_GUID@@B@@@Z"
 
 template  struct TypeWithFriendDefinition {
   friend void FunctionDefinedWithInjectedName(TypeWithFriendDefinition) {}
Index: clang/test/CodeGenCXX/mangle-class-nttp.cpp
===
--- clang/test/CodeGenCXX/mangle-class-nttp.cpp
+++ clang/test/CodeGenCXX/mangle-class-nttp.cpp
@@ -15,7 +15,7 @@
 
 int n = 0;
 // CHECK: define weak_odr void @_Z1fIXtl1BadL_Z1nvv(
-// MSABI: define {{.*}} @"??$f@$2UB@@PEBH1?n@@3HAH0AYAXXZ"
+// MSABI: define {{.*}} @"??$f@$2UB@@PEBHE?n@@3HAH0AYAXXZ"
 template void f();
 // CHECK: define weak_odr void @_Z1fIXtl1BLPKi0ELi1vv(
 // MSABI: define {{.*}} @"??$f@$2UB@@PEBH0A@H00@@@YAXXZ"
@@ -86,13 +86,13 @@
 struct D { const int Derived::*p; int k; };
 template void f() {}
 // CHECK: define weak_odr void @_Z1fIXtl1DLM7DerivedKi0ELi1vv
-// MSABI: define {{.*}} @"??$f@$2UD@@PERDerived@@H0?0H00@@@YAXXZ"
+// MSABI: define {{.*}} @"??$f@$2UD@@PERDerived@@HNH00@@@YAXXZ"
 template void f();
 // CHECK: define weak_odr void @_Z1fIXtl1DEEEvv
-// MSABI: define {{.*}} @"??$f@$2UD@@PERDerived@@H0?0H0AYAXXZ"
+// MSABI: define {{.*}} @"??$f@$2UD@@PERDerived@@HNH0AYAXXZ"
 template void f();
 // CHECK: define weak_odr void @_Z1fIXtl1DadL_ZN7Derived1zEvv
-// MSABI: define {{.*}} @"??$f@$2UD@@PERDerived@@H0BA@H0AYAXXZ"
+// MSABI: define {{.*}} @"??$f@$2UD@@PERDerived@@H82@z@@H0AYAXXZ"
 template void f();
 #ifndef _WIN32
 // CHECK: define weak_odr void @_Z1fIXtl1DmcM7DerivedKiadL_ZN1A1aEEvv
@@ -112,7 +112,45 @@
 template void f();
 #endif
 
-// FIXME: Pointers to member functions.
+struct DerivedVirtually : virtual A, Nested { int z; };
+struct D2 { const int DerivedVirtually::*p; int k; };
+template void f() {}
+// CHECK: define weak_odr void @_Z1fIXtl2D2LM16DerivedVirtuallyKi0ELi1vv
+// MSABI: define {{.*}} @"??$f@$2UD2@@PERDerivedVirtually@@HFA@?0H00@@@YAXXZ"
+template void f();
+// CHECK: define weak_odr void @_Z1fIXtl2D2EEEvv
+// MSABI: define {{.*}} @"??$f@$2UD2@@PERDerivedVirtually@@HFA@?0H0AYAXXZ"
+template void f();
+// CHECK: define weak_odr void @_Z1fIXtl2D2adL_ZN16DerivedVirtually1zEvv
+// MSABI: define {{.*}} @"??$f@$2UD2@@PERDerivedVirtually@@HFBA@A@H0AYAXXZ"
+template void f();
+
+// Pointers to member functions.
+// Test struct templates instead of function templates so as to cover
+// the separate code which handles nullptr in their pointer-to-member arguments.
+struct Derived2 : A, Nested { void f(); virtual void g(); };
+st

[PATCH] D145843: [clangd] Add option to always insert headers with <> instead of ""

2023-03-19 Thread Andrew Kaster via Phabricator via cfe-commits
ADKaster updated this revision to Diff 506409.
ADKaster added a comment.

Change from a boolean parameter to an enum.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145843

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/Headers.cpp
  clang-tools-extra/clangd/Headers.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
  clang-tools-extra/clangd/unittests/HeadersTests.cpp

Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -108,7 +108,8 @@
 
 IncludeInserter Inserter(MainFile, /*Code=*/"", format::getLLVMStyle(),
  CDB.getCompileCommand(MainFile)->Directory,
- &Clang->getPreprocessor().getHeaderSearchInfo());
+ &Clang->getPreprocessor().getHeaderSearchInfo(),
+ IncludeDelimiter);
 for (const auto &Inc : Inclusions)
   Inserter.addExisting(Inc);
 auto Inserted = ToHeaderFile(Preferred);
@@ -128,7 +129,8 @@
 
 IncludeInserter Inserter(MainFile, /*Code=*/"", format::getLLVMStyle(),
  CDB.getCompileCommand(MainFile)->Directory,
- &Clang->getPreprocessor().getHeaderSearchInfo());
+ &Clang->getPreprocessor().getHeaderSearchInfo(),
+ IncludeDelimiter);
 auto Edit = Inserter.insert(VerbatimHeader, Directive);
 Action.EndSourceFile();
 return Edit;
@@ -139,6 +141,8 @@
   std::string MainFile = testPath("main.cpp");
   std::string Subdir = testPath("sub");
   std::string SearchDirArg = (llvm::Twine("-I") + Subdir).str();
+  Config::IncludeDelimiterPolicy IncludeDelimiter =
+  Config::IncludeDelimiterPolicy::Auto;
   IgnoringDiagConsumer IgnoreDiags;
   std::unique_ptr Clang;
 };
@@ -309,6 +313,9 @@
   std::string Path = testPath("sub/bar.h");
   FS.Files[Path] = "";
   EXPECT_EQ(calculate(Path), "\"bar.h\"");
+
+  IncludeDelimiter = Config::IncludeDelimiterPolicy::AlwaysBrackets;
+  EXPECT_EQ(calculate(Path), "");
 }
 
 TEST_F(HeadersTest, DoNotInsertIfInSameFile) {
@@ -331,6 +338,17 @@
   EXPECT_EQ(calculate(BarHeader), "\"sub/bar.h\"");
 }
 
+TEST_F(HeadersTest, ShortenIncludesInSearchPathBracketed) {
+  IncludeDelimiter = Config::IncludeDelimiterPolicy::AlwaysBrackets;
+  std::string BarHeader = testPath("sub/bar.h");
+  EXPECT_EQ(calculate(BarHeader), "");
+
+  SearchDirArg = (llvm::Twine("-I") + Subdir + "/..").str();
+  CDB.ExtraClangFlags = {SearchDirArg.c_str()};
+  BarHeader = testPath("sub/bar.h");
+  EXPECT_EQ(calculate(BarHeader), "");
+}
+
 TEST_F(HeadersTest, ShortenedIncludeNotInSearchPath) {
   std::string BarHeader =
   llvm::sys::path::convert_to_slash(testPath("sub-2/bar.h"));
@@ -343,6 +361,10 @@
 
   std::string BazHeader = testPath("sub/baz.h");
   EXPECT_EQ(calculate(BarHeader, BazHeader), "\"baz.h\"");
+
+  IncludeDelimiter = Config::IncludeDelimiterPolicy::AlwaysBrackets;
+  std::string BiffHeader = testPath("sub/biff.h");
+  EXPECT_EQ(calculate(BarHeader, BiffHeader), "");
 }
 
 TEST_F(HeadersTest, DontInsertDuplicatePreferred) {
@@ -374,8 +396,10 @@
 
 TEST(Headers, NoHeaderSearchInfo) {
   std::string MainFile = testPath("main.cpp");
-  IncludeInserter Inserter(MainFile, /*Code=*/"", format::getLLVMStyle(),
-   /*BuildDir=*/"", /*HeaderSearchInfo=*/nullptr);
+  IncludeInserter Inserter(
+  MainFile, /*Code=*/"", format::getLLVMStyle(),
+  /*BuildDir=*/"", /*HeaderSearchInfo=*/nullptr,
+  /*IncludeDelimiter*/ Config::IncludeDelimiterPolicy::Auto);
 
   auto HeaderPath = testPath("sub/bar.h");
   auto Inserting = HeaderFile{HeaderPath, /*Verbatim=*/false};
Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -265,13 +265,15 @@
   CapturedDiags Diags;
   Annotations YAML(R"yaml(
 Style:
-  FullyQualifiedNamespaces: [foo, bar])yaml");
+  FullyQualifiedNamespaces: [foo, bar]
+  IncludeDelimiter: AlwaysBrackets)yaml");
   auto Results =
   Fragment::parseYAML(YAML.code(), "config.yaml", Diags.callback());
   ASSERT_THAT(Diags.Diagnostics, IsEmpty());
   ASSERT_EQ(Results.size(), 1u);
   EXPECT_THAT(Results[0].Style.FullyQualifiedNamespaces,
   ElementsAre(val("foo"), val("bar")));
+  EXPECT_EQ("AlwaysBrackets", **Result

[PATCH] D145843: [clangd] Add option to always insert headers with <> instead of ""

2023-03-19 Thread Andrew Kaster via Phabricator via cfe-commits
ADKaster added inline comments.



Comment at: clang-tools-extra/clangd/Headers.cpp:353
+  if (IsSystem ||
+  IncludeDelimiter == Config::IncludeDelimiterPolicy::AlwaysBrackets)
 Suggested = "<" + Suggested + ">";

I couldn't tell looking at other code in clangd whether it would be preferred 
to fetch the value from `Config::current()` here every time, or if having the 
option saved as a member variable of the IncludeInserter is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145843

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


[PATCH] D146386: [MS ABI] Fix mangling references to declarations.

2023-03-19 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 506413.
bolshakov-a added a comment.

Rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146386

Files:
  clang/lib/AST/MicrosoftMangle.cpp
  clang/test/CodeGenCXX/mangle-class-nttp.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp

Index: clang/test/CodeGenCXX/mangle-ms-templates.cpp
===
--- clang/test/CodeGenCXX/mangle-ms-templates.cpp
+++ clang/test/CodeGenCXX/mangle-ms-templates.cpp
@@ -272,7 +272,7 @@
 };
 extern const record inst;
 void recref(type1) {}
-// CHECK: "?recref@@YAXU?$type1@$E?inst@@3Urecord@@B@@@Z"
+// CHECK: "?recref@@YAXU?$type1@$1?inst@@3Urecord@@B@@@Z"
 
 struct _GUID {};
 struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid;
@@ -286,7 +286,7 @@
 void fun(UUIDType1 a) {}
 // CHECK: "?fun@@YAXU?$UUIDType1@Uuuid@@$1?_GUID_12345678_1234_1234_1234_1234567890ab@@3U__s_GUID@@B@@@Z"
 void fun(UUIDType2 b) {}
-// CHECK: "?fun@@YAXU?$UUIDType2@Uuuid@@$E?_GUID_12345678_1234_1234_1234_1234567890ab@@3U__s_GUID@@B@@@Z"
+// CHECK: "?fun@@YAXU?$UUIDType2@Uuuid@@$1?_GUID_12345678_1234_1234_1234_1234567890ab@@3U__s_GUID@@B@@@Z"
 
 template  struct TypeWithFriendDefinition {
   friend void FunctionDefinedWithInjectedName(TypeWithFriendDefinition) {}
Index: clang/test/CodeGenCXX/mangle-class-nttp.cpp
===
--- clang/test/CodeGenCXX/mangle-class-nttp.cpp
+++ clang/test/CodeGenCXX/mangle-class-nttp.cpp
@@ -15,7 +15,7 @@
 
 int n = 0;
 // CHECK: define weak_odr void @_Z1fIXtl1BadL_Z1nvv(
-// MSABI: define {{.*}} @"??$f@$2UB@@PEBH1?n@@3HAH0AYAXXZ"
+// MSABI: define {{.*}} @"??$f@$2UB@@PEBHE?n@@3HAH0AYAXXZ"
 template void f();
 // CHECK: define weak_odr void @_Z1fIXtl1BLPKi0ELi1vv(
 // MSABI: define {{.*}} @"??$f@$2UB@@PEBH0A@H00@@@YAXXZ"
@@ -86,13 +86,13 @@
 struct D { const int Derived::*p; int k; };
 template void f() {}
 // CHECK: define weak_odr void @_Z1fIXtl1DLM7DerivedKi0ELi1vv
-// MSABI: define {{.*}} @"??$f@$2UD@@PERDerived@@H0?0H00@@@YAXXZ"
+// MSABI: define {{.*}} @"??$f@$2UD@@PERDerived@@HNH00@@@YAXXZ"
 template void f();
 // CHECK: define weak_odr void @_Z1fIXtl1DEEEvv
-// MSABI: define {{.*}} @"??$f@$2UD@@PERDerived@@H0?0H0AYAXXZ"
+// MSABI: define {{.*}} @"??$f@$2UD@@PERDerived@@HNH0AYAXXZ"
 template void f();
 // CHECK: define weak_odr void @_Z1fIXtl1DadL_ZN7Derived1zEvv
-// MSABI: define {{.*}} @"??$f@$2UD@@PERDerived@@H0BA@H0AYAXXZ"
+// MSABI: define {{.*}} @"??$f@$2UD@@PERDerived@@H82@z@@H0AYAXXZ"
 template void f();
 #ifndef _WIN32
 // CHECK: define weak_odr void @_Z1fIXtl1DmcM7DerivedKiadL_ZN1A1aEEvv
@@ -112,7 +112,45 @@
 template void f();
 #endif
 
-// FIXME: Pointers to member functions.
+struct DerivedVirtually : virtual A, Nested { int z; };
+struct D2 { const int DerivedVirtually::*p; int k; };
+template void f() {}
+// CHECK: define weak_odr void @_Z1fIXtl2D2LM16DerivedVirtuallyKi0ELi1vv
+// MSABI: define {{.*}} @"??$f@$2UD2@@PERDerivedVirtually@@HFA@?0H00@@@YAXXZ"
+template void f();
+// CHECK: define weak_odr void @_Z1fIXtl2D2EEEvv
+// MSABI: define {{.*}} @"??$f@$2UD2@@PERDerivedVirtually@@HFA@?0H0AYAXXZ"
+template void f();
+// CHECK: define weak_odr void @_Z1fIXtl2D2adL_ZN16DerivedVirtually1zEvv
+// MSABI: define {{.*}} @"??$f@$2UD2@@PERDerivedVirtually@@HFBA@A@H0AYAXXZ"
+template void f();
+
+// Pointers to member functions.
+// Test struct templates instead of function templates so as to cover
+// the separate code which handles nullptr in their pointer-to-member arguments.
+struct Derived2 : A, Nested { void f(); virtual void g(); };
+struct D3 { void (Derived2::*p)(); };
+template  struct S1 { static void fn() {} };
+// CHECK: define weak_odr void @_ZN2S1IXtl2D3adL_ZN8Derived21fEv2fnEv
+// MSABI: define {{.*}} @"?fn@?$S1@$2UD3@@P8Derived2@@EAAXXZE?f@2@QEAAXXZ@@@SAXXZ"
+template void S1::fn();
+// CHECK: define weak_odr void @_ZN2S1IXtl2D3adL_ZN8Derived21gEv2fnEv
+// MSABI: define {{.*}} @"?fn@?$S1@$2UD3@@P8Derived2@@EAAXXZE??_92@$BA@AA@@@SAXXZ"
+template void S1::fn();
+// CHECK: define weak_odr void @_ZN2S1IXtl2D3EEE2fnEv
+// MSABI: define {{.*}} @"?fn@?$S1@$2UD3@@P8Derived2@@EAAXXZHASAXXZ"
+template void S1::fn();
+
+struct NoInheritance { void f(); };
+struct D4 { void (NoInheritance::*p)(); };
+template  struct S2 { static void fn() {} };
+// CHECK: define weak_odr void @_ZN2S2IXtl2D4adL_ZN13NoInheritance1fEv2fnEv
+// MSABI: define {{.*}} @"?fn@?$S2@$2UD4@@P8NoInheritance@@EAAXXZE?f@2@QEAAXXZ@@@SAXXZ"
+template void S2::fn();
+// CHECK: define weak_odr void @_ZN2S2IXtl2D4EEE2fnEv
+// MSABI: define {{.*}} @"?fn@?$S2@$2UD4@@P8NoInheritance@@EAAXXZN@@@SAXXZ"
+template void S2::fn();
+
 
 union E {
   int n;
@@ -204,8 +242,6 @@
 template void f();
 
 // Empty and nearly-empty unions.
-// Some of the MSVC manglings here a

[PATCH] D146393: [Clang] Support free positioning of labels inside compound statements in C

2023-03-19 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron created this revision.
Izaron added reviewers: aaron.ballman, cor3ntin.
Herald added a project: All.
Izaron requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Implements part of paper P2324R2
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2508.pdf
Fixes https://github.com/llvm/llvm-project/issues/61507


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146393

Files:
  clang/lib/Parse/ParseStmt.cpp
  clang/test/OpenMP/allocate_messages.cpp
  clang/test/OpenMP/threadprivate_messages.cpp
  clang/test/Parser/c2x-label.c


Index: clang/test/Parser/c2x-label.c
===
--- clang/test/Parser/c2x-label.c
+++ clang/test/Parser/c2x-label.c
@@ -2,10 +2,11 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c2x -Wpre-c2x-compat -verify=c2x %s
 
 void test_label_in_func() {
-int x;
 label1:
+int x;
+label2:
 x = 1;
-label2: label3: label4:
+label3: label4: label5:
 } // c17-warning {{label at end of compound statement is a C2x extension}} \
  c2x-warning {{label at end of compound statement is incompatible with C 
standards before C2x}}
 
Index: clang/test/OpenMP/threadprivate_messages.cpp
===
--- clang/test/OpenMP/threadprivate_messages.cpp
+++ clang/test/OpenMP/threadprivate_messages.cpp
@@ -138,7 +138,7 @@
   }
 #pragma omp threadprivate(d3)
 label:
-#pragma omp threadprivate(d4) // expected-error {{'#pragma omp threadprivate' 
cannot be an immediate substatement}}
+#pragma omp threadprivate(d4)
 
 #pragma omp threadprivate(a) // expected-error {{'#pragma omp threadprivate' 
must appear in the scope of the 'a' variable declaration}}
   return (y);
Index: clang/test/OpenMP/allocate_messages.cpp
===
--- clang/test/OpenMP/allocate_messages.cpp
+++ clang/test/OpenMP/allocate_messages.cpp
@@ -141,7 +141,7 @@
   }
 #pragma omp allocate(d3)
 label:
-#pragma omp allocate(d4) // expected-error {{'#pragma omp allocate' cannot be 
an immediate substatement}}
+#pragma omp allocate(d4)
 
 #pragma omp allocate(a) // expected-error {{'#pragma omp allocate' must appear 
in the scope of the 'a' variable declaration}}
   return (y);
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -692,10 +692,6 @@
   assert(Tok.is(tok::identifier) && Tok.getIdentifierInfo() &&
  "Not an identifier!");
 
-  // The substatement is always a 'statement', not a 'declaration', but is
-  // otherwise in the same context as the labeled-statement.
-  StmtCtx &= ~ParsedStmtContext::AllowDeclarationsInC;
-
   Token IdentTok = Tok;  // Save the whole token.
   ConsumeToken();  // eat the identifier.
 


Index: clang/test/Parser/c2x-label.c
===
--- clang/test/Parser/c2x-label.c
+++ clang/test/Parser/c2x-label.c
@@ -2,10 +2,11 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c2x -Wpre-c2x-compat -verify=c2x %s
 
 void test_label_in_func() {
-int x;
 label1:
+int x;
+label2:
 x = 1;
-label2: label3: label4:
+label3: label4: label5:
 } // c17-warning {{label at end of compound statement is a C2x extension}} \
  c2x-warning {{label at end of compound statement is incompatible with C standards before C2x}}
 
Index: clang/test/OpenMP/threadprivate_messages.cpp
===
--- clang/test/OpenMP/threadprivate_messages.cpp
+++ clang/test/OpenMP/threadprivate_messages.cpp
@@ -138,7 +138,7 @@
   }
 #pragma omp threadprivate(d3)
 label:
-#pragma omp threadprivate(d4) // expected-error {{'#pragma omp threadprivate' cannot be an immediate substatement}}
+#pragma omp threadprivate(d4)
 
 #pragma omp threadprivate(a) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'a' variable declaration}}
   return (y);
Index: clang/test/OpenMP/allocate_messages.cpp
===
--- clang/test/OpenMP/allocate_messages.cpp
+++ clang/test/OpenMP/allocate_messages.cpp
@@ -141,7 +141,7 @@
   }
 #pragma omp allocate(d3)
 label:
-#pragma omp allocate(d4) // expected-error {{'#pragma omp allocate' cannot be an immediate substatement}}
+#pragma omp allocate(d4)
 
 #pragma omp allocate(a) // expected-error {{'#pragma omp allocate' must appear in the scope of the 'a' variable declaration}}
   return (y);
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -692,10 +692,6 @@
   assert(Tok.is(tok::identifier) && Tok.getIdentifierInfo() &&
  "Not an identifier!");
 
-  // The substatement is always a 'statement', not a 'declaration', but is
-  // otherwise in th

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-19 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added inline comments.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:1670
+  case TemplateArgument::UncommonValue:
+if (ValueDecl *D = getAsArrayToPointerDecayedDecl(
+TA.getUncommonValueType(), TA.getAsUncommonValue())) {

erichkeane wrote:
> bolshakov-a wrote:
> > erichkeane wrote:
> > > Has microsoft implemented this yet?  Can we see what they chose to do and 
> > > make sure we match them? 
> > Experimentally, I've made me sure that MSVC produces the same mangled names 
> > for the cases provided in the `mangle-ms-templates` test as in the test. 
> > But there are problems with references to subobjects: some cases are 
> > explicitly unsupported in `mangleTemplateArgValue`, and some cases produce 
> > a magled name different from what MSVC does. Should it be fixed in this PR, 
> > or may be delayed?
> We need to end up doing our best to match the microsoft mangling if at all 
> possible, since they own the ABI.  I DEFINITELY would want any followup patch 
> to be promised for Clang17 (that is, we don't release Clang17 with this patch 
> and NOT that patch), so I'd expect said patch to be available for review 
> before this gets committed.
> 
> As far as whether it needs to happen in THIS patch, we can perhaps decide 
> based on the severity of the break, if you can provide examples (or, if it is 
> split into a separate patch, we can use the tests there).
I've addressed some issues already present on the main branch in 
[D146386](https://reviews.llvm.org/D146386). I could try to fix remaining 
issues in this PR afrer landing that one.



Comment at: clang/lib/AST/TemplateBase.cpp:244
+  else if (const ValueDecl *VD = getAsSimpleValueDeclRef(Ctx, Type, V))
+// FIXME: The Declaration form should expose a const ValueDecl*.
+initFromDeclaration(const_cast(VD), Type, IsDefaulted);

erichkeane wrote:
> Why can this not happen now?
Adding `const` to the `TemplateArgument::DA::D` type and to the 
`TemplateArgument::getAsDecl()` return type would lead to many changes 
unrelated to this PR.



Comment at: clang/lib/Index/USRGeneration.cpp:1032
+  case TemplateArgument::UncommonValue:
+// FIXME: Visit value.
+break;

bnbarham wrote:
> bolshakov-a wrote:
> > bnbarham wrote:
> > > bolshakov-a wrote:
> > > > bnbarham wrote:
> > > > > akyrtzi wrote:
> > > > > > erichkeane wrote:
> > > > > > > bolshakov-a wrote:
> > > > > > > > aaron.ballman wrote:
> > > > > > > > > Any particular reason this isn't being handled now?
> > > > > > > > I need some guidance here. Which characters are allowed in the 
> > > > > > > > USR? Could the mangling algorithm from 
> > > > > > > > `CXXNameMangler::mangleValueInTemplateArg` be moved into some 
> > > > > > > > common place and reused here?
> > > > > > > I have no idea what is valid here.  BUT @akyrtzi and @gribozavr 
> > > > > > > (or @gribozavr2 ?) seem to be the ones that touch these files the 
> > > > > > > most?
> > > > > > Adding @bnbarham to review the `Index` changes.
> > > > > Just visiting the underlying type seems reasonable, ie. 
> > > > > `VisitType(Arg.getUncommonValueType());`. If it needed to be 
> > > > > differentiated between a `TemplateArgument::Type` you could add a 
> > > > > prefix character (eg. `U`), but that doesn't seem needed to me.
> > > > Doesn't the holded value be added so as to distinguish e.g. `Tpl<1.5>` 
> > > > from `Tpl<2.5>`?
> > > Ah I see, yeah, we would. And there's no USR generation for APValue 
> > > currently, which I assume is why your original question came up.
> > > 
> > > In general a USR just wants to uniquely identify an entity across 
> > > compilations and isn't as restricted as the mangled name. For basically 
> > > everything but `LValue` it seems like you'd be fine to print the value 
> > > (for eg. int, float, etc), visit the underlying type (array, vector), or 
> > > the visit the underlying decl (struct, union, member pointer). That's 
> > > almost true for `LValue` as well, just with the extra parts that are also 
> > > added to the ODR hash.
> > > 
> > > Alternatively, you could also just print the hash from `Profile` with the 
> > > same handling as ODR hash. Worst case we'd accidentally merge 
> > > specializations, but if that's good enough for the ODR hash it's probably 
> > > good enough here as well.
> > > it seems like you'd be fine to print the value (for eg. int, float, etc)
> > 
> > I'm in doubt about the dot inside a floating point value representation. 
> > Minus sign is allowed, as I can see for `TemplateArgument::Integral` case.
> As long as there's a prefix for APValue and its kind, the dot is fine (eg. 
> maybe `@AP@` and then `f` for float, `i` for integer, etc).
Thank you! I've decided to go the simplest way, i. e. to use `ODRHash` here. 
Should I write a test case (or some test cases), or they could become fragile 
due to possible `ODRHash` implementation changes? I'v

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-19 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 506426.
bolshakov-a added a comment.

Rename `UncommonValue` to `StructuralValue` and add "TODO" about it.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7311,6 +7311,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2";>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1";>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. delcared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1";>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3";>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::StructuralValue:
+if (Expr *E = TAL.getSourceStructuralValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:

[PATCH] D146393: [Clang] Support free positioning of labels inside compound statements in C

2023-03-19 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron added a comment.

A big TODO: rename `ext_c_label_end_of_compound_statement` to something like 
`ext_c_label_free_positioning`. Since we found out it is more complete than 
just the end of statements.




Comment at: clang/lib/Parse/ParseStmt.cpp:695-697
-  // The substatement is always a 'statement', not a 'declaration', but is
-  // otherwise in the same context as the labeled-statement.
-  StmtCtx &= ~ParsedStmtContext::AllowDeclarationsInC;

Place in code where it matters: 
https://github.com/llvm/llvm-project/blob/84870c4abbacfb97ca025c9219b724f381611380/clang/lib/Parse/ParseStmt.cpp#L237



Comment at: clang/test/OpenMP/threadprivate_messages.cpp:141
 label:
-#pragma omp threadprivate(d4) // expected-error {{'#pragma omp threadprivate' 
cannot be an immediate substatement}}
+#pragma omp threadprivate(d4)
 

TODO: find out if this is okay? (I've got no idea what it does)



Comment at: clang/test/Parser/c2x-label.c:5-6
 void test_label_in_func() {
-int x;
 label1:
+int x;
+label2:

TODO: make sure a warning is printed. I couldn't find correct conditions for 
the warning, I tried and it produced false positive warnings in some other 
tests =(

P.S. Its C++'s counterpart: 
https://github.com/llvm/llvm-project/blob/main/clang/test/Parser/cxx2b-label.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146393

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-19 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 506428.
bolshakov-a added a comment.

Add USR generation and a couple of minor fixes.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7311,6 +7311,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2";>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1";>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1";>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3";>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::StructuralValue:
+if (Expr *E = TAL.getSourceStructuralValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TA

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-19 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 506429.
bolshakov-a added a comment.

Finalize renaming.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7311,6 +7311,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::StructuralValue:
+return eTemplateArgumentKindStructuralValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindStructuralValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2";>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1";>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1";>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3";>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::StructuralValue:
+if (Expr *E = TAL.getSourceStructuralValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSourceNullPtrExpre

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-19 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 506430.
bolshakov-a added a comment.

Finalize renaming one more time.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7311,6 +7311,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::StructuralValue:
+return eTemplateArgumentKindStructuralValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindStructuralValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2";>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1";>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1";>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3";>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::StructuralValue:
+if (Expr *E = TAL.getSourceStructuralValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSour

[clang] b688b58 - [clang-format] Fix non-case colons in Verilog case lines

2023-03-19 Thread via cfe-commits

Author: sstwcw
Date: 2023-03-19T21:41:14Z
New Revision: b688b58f83ceb48dbe185be95372e45de1d51401

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

LOG: [clang-format] Fix non-case colons in Verilog case lines

Back in D128714, we should have replaced the old rule about colons when
we added the new one.  Because we didn't, all colons got mistaken as
case colons as long as the line began with `case` or `default`.  Now we
remove the rule that we forgot to remove.

Reviewed By: MyDeveloperDay, rymiel

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestVerilog.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 8613f51cd8a04..12beeba7c70cc 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4426,8 +4426,6 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine &Line,
  Line.First->isOneOf(tok::kw_default, tok::kw_case))) {
   return Style.SpaceBeforeCaseColon;
 }
-if (Line.First->isOneOf(tok::kw_default, tok::kw_case))
-  return Style.SpaceBeforeCaseColon;
 const FormatToken *Next = Right.getNextNonComment();
 if (!Next || Next->is(tok::semi))
   return false;

diff  --git a/clang/unittests/Format/FormatTestVerilog.cpp 
b/clang/unittests/Format/FormatTestVerilog.cpp
index aae62668c4b84..a4d6b540bd831 100644
--- a/clang/unittests/Format/FormatTestVerilog.cpp
+++ b/clang/unittests/Format/FormatTestVerilog.cpp
@@ -250,6 +250,39 @@ TEST_F(FormatTestVerilog, Case) {
"  end\n"
"endcase",
Style);
+  // Other colons should not be mistaken as case colons.
+  Style = getLLVMStyle(FormatStyle::LK_Verilog);
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_None;
+  verifyFormat("case (x[1:0])\n"
+   "endcase",
+   Style);
+  verifyFormat("default:\n"
+   "  x[1:0] = x[1:0];",
+   Style);
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_Both;
+  verifyFormat("case (x[1 : 0])\n"
+   "endcase",
+   Style);
+  verifyFormat("default:\n"
+   "  x[1 : 0] = x[1 : 0];",
+   Style);
+  Style = getLLVMStyle(FormatStyle::LK_Verilog);
+  Style.SpacesInContainerLiterals = true;
+  verifyFormat("case ('{x : x, default : 9})\n"
+   "endcase",
+   Style);
+  verifyFormat("x = '{x : x, default : 9};\n", Style);
+  verifyFormat("default:\n"
+   "  x = '{x : x, default : 9};\n",
+   Style);
+  Style.SpacesInContainerLiterals = false;
+  verifyFormat("case ('{x: x, default: 9})\n"
+   "endcase",
+   Style);
+  verifyFormat("x = '{x: x, default: 9};\n", Style);
+  verifyFormat("default:\n"
+   "  x = '{x: x, default: 9};\n",
+   Style);
 }
 
 TEST_F(FormatTestVerilog, Coverage) {



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


[PATCH] D145888: [clang-format] Fix non-case colons in Verilog case lines

2023-03-19 Thread sstwcw 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 rGb688b58f83ce: [clang-format] Fix non-case colons in Verilog 
case lines (authored by sstwcw).

Changed prior to commit:
  https://reviews.llvm.org/D145888?vs=504481&id=506431#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145888

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


Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -250,6 +250,39 @@
"  end\n"
"endcase",
Style);
+  // Other colons should not be mistaken as case colons.
+  Style = getLLVMStyle(FormatStyle::LK_Verilog);
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_None;
+  verifyFormat("case (x[1:0])\n"
+   "endcase",
+   Style);
+  verifyFormat("default:\n"
+   "  x[1:0] = x[1:0];",
+   Style);
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_Both;
+  verifyFormat("case (x[1 : 0])\n"
+   "endcase",
+   Style);
+  verifyFormat("default:\n"
+   "  x[1 : 0] = x[1 : 0];",
+   Style);
+  Style = getLLVMStyle(FormatStyle::LK_Verilog);
+  Style.SpacesInContainerLiterals = true;
+  verifyFormat("case ('{x : x, default : 9})\n"
+   "endcase",
+   Style);
+  verifyFormat("x = '{x : x, default : 9};\n", Style);
+  verifyFormat("default:\n"
+   "  x = '{x : x, default : 9};\n",
+   Style);
+  Style.SpacesInContainerLiterals = false;
+  verifyFormat("case ('{x: x, default: 9})\n"
+   "endcase",
+   Style);
+  verifyFormat("x = '{x: x, default: 9};\n", Style);
+  verifyFormat("default:\n"
+   "  x = '{x: x, default: 9};\n",
+   Style);
 }
 
 TEST_F(FormatTestVerilog, Coverage) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -4426,8 +4426,6 @@
  Line.First->isOneOf(tok::kw_default, tok::kw_case))) {
   return Style.SpaceBeforeCaseColon;
 }
-if (Line.First->isOneOf(tok::kw_default, tok::kw_case))
-  return Style.SpaceBeforeCaseColon;
 const FormatToken *Next = Right.getNextNonComment();
 if (!Next || Next->is(tok::semi))
   return false;


Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -250,6 +250,39 @@
"  end\n"
"endcase",
Style);
+  // Other colons should not be mistaken as case colons.
+  Style = getLLVMStyle(FormatStyle::LK_Verilog);
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_None;
+  verifyFormat("case (x[1:0])\n"
+   "endcase",
+   Style);
+  verifyFormat("default:\n"
+   "  x[1:0] = x[1:0];",
+   Style);
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_Both;
+  verifyFormat("case (x[1 : 0])\n"
+   "endcase",
+   Style);
+  verifyFormat("default:\n"
+   "  x[1 : 0] = x[1 : 0];",
+   Style);
+  Style = getLLVMStyle(FormatStyle::LK_Verilog);
+  Style.SpacesInContainerLiterals = true;
+  verifyFormat("case ('{x : x, default : 9})\n"
+   "endcase",
+   Style);
+  verifyFormat("x = '{x : x, default : 9};\n", Style);
+  verifyFormat("default:\n"
+   "  x = '{x : x, default : 9};\n",
+   Style);
+  Style.SpacesInContainerLiterals = false;
+  verifyFormat("case ('{x: x, default: 9})\n"
+   "endcase",
+   Style);
+  verifyFormat("x = '{x: x, default: 9};\n", Style);
+  verifyFormat("default:\n"
+   "  x = '{x: x, default: 9};\n",
+   Style);
 }
 
 TEST_F(FormatTestVerilog, Coverage) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -4426,8 +4426,6 @@
  Line.First->isOneOf(tok::kw_default, tok::kw_case))) {
   return Style.SpaceBeforeCaseColon;
 }
-if (Line.First->isOneOf(tok::kw_default, tok::kw_case))
-  return Style.SpaceBeforeCaseColon;
 const FormatToken *Next = Right.getNextNonComment();
 if (!Next || Next->is(tok::semi))
   return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136315: [clang][Darwin] Try to guess the SDK root with xcrun when unspecified

2023-03-19 Thread Caleb Zulawski via Phabricator via cfe-commits
calebzulawski updated this revision to Diff 506434.
calebzulawski added a comment.

Corrected docs and updated upstream


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136315

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-sdk-detect.c
  clang/test/Driver/lit.local.cfg

Index: clang/test/Driver/lit.local.cfg
===
--- clang/test/Driver/lit.local.cfg
+++ clang/test/Driver/lit.local.cfg
@@ -1,4 +1,5 @@
 from lit.llvm import llvm_config
+import subprocess
 
 config.suffixes = ['.c', '.cpp', '.cppm', '.h', '.m', '.mm', '.S', '.s', '.f90', '.F90', '.f95',
'.cu', '.rs', '.cl', '.clcpp', '.hip', '.hipi', '.hlsl']
@@ -24,3 +25,9 @@
 
 if config.ppc_linux_default_ieeelongdouble:
   config.available_features.add('ppc_linux_default_ieeelongdouble')
+
+if os.path.exists('/usr/bin/xcrun') and sys.platform == 'darwin':
+if subprocess.run(['/usr/bin/xcrun', '--sdk', 'macosx', '--show-sdk-path']).returncode == 0:
+config.available_features.add('macos-sdk')
+if subprocess.run(['/usr/bin/xcrun', '--sdk', 'iphoneos', '--show-sdk-path']).returncode == 0:
+config.available_features.add('ios-sdk')
Index: clang/test/Driver/darwin-sdk-detect.c
===
--- /dev/null
+++ clang/test/Driver/darwin-sdk-detect.c
@@ -0,0 +1,20 @@
+// REQUIRES: system-darwin, ios-sdk, macos-sdk
+
+// Check that we default to running `xcrun --show-sdk-path` if there is no
+// SDKROOT defined in the environment.
+//
+// RUN: env -u SDKROOT %clang --infer-sdkroot-from-xcrun -target x86_64-apple-macos -c %s -### 2> %t.log
+// RUN: FileCheck --check-prefix=CHECK-XC < %t.log %s
+//
+// CHECK-XC: clang
+// CHECK-XC: "-cc1"
+// CHECK-XC: "-isysroot" "{{.*MacOSX[0-9\.]*\.sdk}}"
+
+// Check once again that we default to running `xcrun`, this time with another target.
+//
+// RUN: env -u SDKROOT %clang --infer-sdkroot-from-xcrun -target arm64-apple-ios -c %s -### 2> %t.log
+// RUN: FileCheck --check-prefix=CHECK-XC-IOS < %t.log %s
+//
+// CHECK-XC-IOS: clang
+// CHECK-XC-IOS: "-cc1"
+// CHECK-XC-IOS: "-isysroot" "{{.*iPhoneOS[0-9\.]*\.sdk}}"
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -18,15 +18,22 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/ProfileData/InstrProf.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/TargetParser/TargetParser.h"
 #include  // ::getenv
+#include   // std::unique_ptr
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
@@ -2098,21 +2105,89 @@
 void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
   const OptTable &Opts = getDriver().getOpts();
 
-  // Support allowing the SDKROOT environment variable used by xcrun and other
-  // Xcode tools to define the default sysroot, by making it the default for
-  // isysroot.
+  // On Apple platforms, standard headers and libraries are not provided with
+  // the base system (e.g. in /usr/{include,lib}). Instead, they are provided
+  // in various SDKs for the different Apple platforms. Clang needs to know
+  // where that SDK lives, and there are a couple ways this can be achieved:
+  //
+  // (1) If `-isysroot ` is passed explicitly, use that.
   if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
 // Warn if the path does not exist.
 if (!getVFS().exists(A->getValue()))
   getDriver().Diag(clang::diag::warn_missing_sysroot) << A->getValue();
-  } else {
-if (char *env = ::getenv("SDKROOT")) {
-  // We only use this value as the default if it is an absolute path,
-  // exists, and it is not the root path.
-  if (llvm::sys::path::is_absolute(env) && getVFS().exists(env) &&
-  StringRef(env) != "/") {
-Args.append(Args.MakeSeparateArg(
-nullptr, Opts.getOption(options::OPT_isysroot), env));
+  }
+
+  // (2) If the SDKROOT environment variable is defined and points to a valid
+  // path, use that. $SDKROOT is set by `xcrun` and other Xcode tools, so
+  // running `xcrun clang` will work by going through this path.
+  else if (char *env = ::getenv("SDKROOT")) {
+// We only use this value as the default if

[PATCH] D146396: [clang-tidy] Use checks dependences for Analyzer checks

2023-03-19 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL created this revision.
Herald added subscribers: carlosgalvezp, manas, ASDenysPetrov, dkrupp, 
donat.nagy, Szelethus, a.sidorin, baloghadamsoftware, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
PiotrZSL requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Before this change all checks from 'core' group were
enabled when any analyzer check were enabled.
Now only checks dependences are enabled.
Unfortunately even if this gives more flexibility to
user, Clang Static Analyzer got some hidden checks
that are somehow enabled by default there, but not in
Clang-Tidy.

Issues:
 https://github.com/llvm/llvm-project/issues/61520
 https://github.com/llvm/llvm-project/issues/59588
 https://github.com/llvm/llvm-project/issues/59589


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146396

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/infrastructure/enable-analyzer-checks.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/enable-analyzer-checks.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/enable-analyzer-checks.cpp
@@ -0,0 +1,10 @@
+// REQUIRES: static-analyzer
+
+// Check if enabling once check will enable only dependences
+// RUN: clang-tidy -checks=-*,clang-analyzer-core.CallAndMessage -list-checks | grep 'clang-analyzer-core.CallAndMessageModeling'
+// RUN: clang-tidy -checks=-*,clang-analyzer-core.CallAndMessage -list-checks | wc -l | grep -x '4'
+
+// Check if disabling dependency does nothing if check is enabled
+// RUN: clang-tidy -checks=-*,clang-analyzer-core.CallAndMessage,-clang-analyzer-core.clang-analyzer-core.CallAndMessageModeling \
+// RUN: -list-checks | grep 'clang-analyzer-core.CallAndMessageModeling'
+
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -98,6 +98,9 @@
   `ImplementationFileExtensions`, replacing the check-local options of the
   same name.
 
+- Clang Static Analyzer checks can now be individually enabled or disabled.
+  Use `--checks="clang-analyzer-core.*"` to preserve the previous behavior.
+
 New checks
 ^^
 
Index: clang-tools-extra/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -349,37 +349,52 @@
   }
 }
 
-typedef std::vector> CheckersList;
+using CheckersList = std::vector>;
+using CheckersSet = std::set>;
+
+static void
+addAnalyzerCheckAndDependencies(CheckersSet &Checks,
+llvm::StringRef AnalyzerCheckFullName) {
+  if (!Checks.emplace(AnalyzerCheckFullName.str(), true).second)
+return;
+
+#define GET_CHECKER_WEAK_DEPENDENCIES
+#define GET_CHECKER_DEPENDENCIES
+#define CHECKER_DEPENDENCY(Parent, Child)  \
+  if (Parent == AnalyzerCheckFullName) \
+addAnalyzerCheckAndDependencies(Checks, Child);
+#define CHECKER_WEAK_DEPENDENCY(Parent, Child) \
+  if (Parent == AnalyzerCheckFullName) \
+addAnalyzerCheckAndDependencies(Checks, Child);
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
+#undef CHECKER_WEAK_DEPENDENCY
+#undef CHECKER_DEPENDENCY
+#undef GET_CHECKER_DEPENDENCIES
+#undef GET_CHECKER_WEAK_DEPENDENCIES
+}
 
 static CheckersList getAnalyzerCheckersAndPackages(ClangTidyContext &Context,
bool IncludeExperimental) {
-  CheckersList List;
-
-  const auto &RegisteredCheckers =
-  AnalyzerOptions::getRegisteredCheckers(IncludeExperimental);
-  bool AnalyzerChecksEnabled = false;
-  for (StringRef CheckName : RegisteredCheckers) {
-std::string ClangTidyCheckName((AnalyzerCheckNamePrefix + CheckName).str());
-AnalyzerChecksEnabled |= Context.isCheckEnabled(ClangTidyCheckName);
+  CheckersSet Checks;
+
+#define GET_CHECKERS
+#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN) \
+  {\
+llvm::StringRef AnalyzerCheckFullName(FULLNAME);   \
+if (!AnalyzerCheckFullName.startswith("debug.") && \
+(IncludeExperimental ||\
+ !AnalyzerCheckFullName.startswith("alpha."))) {   \
+  std::string ClangTidyCheckName(  \
+  (AnalyzerCheckNamePrefix + AnalyzerCheckFullName).str());\
+  if (Context.isCheckEnabled(ClangTidyCheckName

[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-19 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 506439.
francii added a comment.

Allow user-specified -L and -l options


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145899

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,18 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -r does not link object files or libraries
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-r \
+// RUN:   | FileCheck --check-prefixes=CHECK-RELOCATABLE %s
+
+// CHECK-RELOCATABLE: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-RELOCATABLE: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-RELOCATABLE-NOT: "-l{{.*}}"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -235,47 +235,49 @@
   // Add directory to library search path.
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
-  if (getToolChain().ShouldLinkCXXStdlib(Args))
-getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
-
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
-
-// Add OpenMP runtime if -fopenmp is specified.
-if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
- options::OPT_fno_openmp, false)) {
-  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
-  case Driver::OMPRT_OMP:
-CmdArgs.push_back("-lomp");
-break;
-  case Driver::OMPRT_IOMP5:
-CmdArgs.push_back("-liomp5");
-break;
-  case Driver::OMPRT_GOMP:
-CmdArgs.push_back("-lgomp");
-break;
-  case Driver::OMPRT_Unknown:
-// Already diagnosed.
-break;
+  if (!Args.hasArg(options::OPT_r)) {
+ToolChain.addProfileRTLibs(Args, CmdArgs);
+
+if (getToolChain().ShouldLinkCXXStdlib(Args))
+  getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+
+if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+
+  // Add OpenMP runtime if -fopenmp is specified.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false)) {
+switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+  CmdArgs.push_back("-lomp");
+  break;
+case Driver::OMPRT_IOMP5:
+  CmdArgs.push_back("-liomp5");
+  break;
+case Driver::OMPRT_GOMP:
+  CmdArgs.push_back("-lgomp");
+  break;
+case Driver::OMPRT_Unknown:
+  // Already diagnosed.
+  break;
+}
   }
-}
 
-// Support POSIX threads if "-pthreads" or "-pthread" is present.
-if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
-  CmdArgs.push_back("-lpthreads");
+  // Support POSIX threads if "-pthreads" or "-pthread" is present.
+  if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
+CmdArgs.push_back("-lpthreads");
 
-if (D.CCCIsCXX())
-  CmdArgs.push_back("-lm");
+  if (D.CCCIsCXX())
+CmdArgs.push_back("-lm");
 
-CmdArgs.push_back("-lc");
+  CmdArgs.push_back("-lc");
 
-if (Args.hasArgNoClaim(options::OPT_p, options::OPT_pg)) {
-  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
-   "/lib/profiled"));
-  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
-   "/usr/lib/profiled"));
+  if (Args.hasArgNoClaim(options::OPT_p, options::OPT_pg)) {
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/lib/profiled"));
+CmdArgs.push_back(Args.MakeA

[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

2023-03-19 Thread Michael Francis via Phabricator via cfe-commits
francii created this revision.
Herald added a project: All.
francii requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

`-K` is a linker option on AIX, that is used to align the header, text, data, 
and loader sections of the output file so
that each section begins on a page boundary.

This patch creates the `-K` option in clang.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146399

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,10 @@
 }
   }
 
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_K); A && 
!TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3405,6 +3405,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real 
file system. "
"Additionally, pass this overlay file to the linker if it supports 
it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput,NoArgumentUnused]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,10 @@
 }
   }
 
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_K); A && !TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3405,6 +3405,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real file system. "
"Additionally, pass this overlay file to the linker if it supports it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput,NoArgumentUnused]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

2023-03-19 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 506447.
francii added a comment.

nit: spacing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146399

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,10 @@
 }
   }
 
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_K); A && 
!TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3405,6 +3405,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real 
file system. "
"Additionally, pass this overlay file to the linker if it supports 
it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput, NoArgumentUnused]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,10 @@
 }
   }
 
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_K); A && !TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3405,6 +3405,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real file system. "
"Additionally, pass this overlay file to the linker if it supports it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput, NoArgumentUnused]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146187: [docs] Update the status for coroutines

2023-03-19 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

> Ugh, that does sort of change the calculus for whether we do or don't claim 
> support on Windows. If removing the definition of that macro on Windows 
> causes significant code breakage, that would be a reason we should leave it 
> defined. But do we have evidence of that?

Ah, yes. This is what I want to say. Simply, if we remove the definition for 
`__cpp_impl_coroutines`, the coroutine header in MS/STL and libstdc++ can't 
work anymore. For libstdc++, all the coroutine things are only defined if 
`__cpp_impl_coroutines ` is defined 
(https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/std/coroutine#L58-L69).
 And this is the same for MS/STL: 
https://github.com/microsoft/STL/blob/5116678ea11245b232a6e43824aad25fb60b9c6e/stl/inc/yvals_core.h#L1587-L1589
 and 
https://github.com/microsoft/STL/blob/be29af22c049774ae93f2c33e4eb5d801e12216c/stl/inc/coroutine#L17-L39.
 So I can image that many uses of coroutines in Windows may get useless after 
we undefined the `__cpp_impl_coroutines` macros.


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

https://reviews.llvm.org/D146187

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


[PATCH] D146401: [clang-format] Don't squash Verilog escaped identifiers

2023-03-19 Thread sstwcw via Phabricator via cfe-commits
sstwcw created this revision.
sstwcw added reviewers: HazardyKnusperkeks, MyDeveloperDay, owenpan, rymiel.
Herald added a project: All.
sstwcw requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

An escaped identifier always needs a space following it so the parser
can tell it apart from the next token.

The unit tests are changed to use `FormatTestBase.h` because we need the
2-argument version of `verifyFormat`.  We also added the `messUp`
virtual function because Verilog needs a different version of it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146401

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestBase.h
  clang/unittests/Format/FormatTestVerilog.cpp

Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -6,47 +6,26 @@
 //
 //===--===//
 
-#include "FormatTestUtils.h"
-#include "clang/Format/Format.h"
-#include "llvm/Support/Debug.h"
-#include "gtest/gtest.h"
+#include "FormatTestBase.h"
 
 #define DEBUG_TYPE "format-test"
 
 namespace clang {
 namespace format {
-
-class FormatTestVerilog : public ::testing::Test {
+namespace test {
+namespace {
+class FormatTestVerilog : public test::FormatTestBase {
 protected:
-  static std::string format(llvm::StringRef Code, unsigned Offset,
-unsigned Length, const FormatStyle &Style) {
-LLVM_DEBUG(llvm::errs() << "---\n");
-LLVM_DEBUG(llvm::errs() << Code << "\n\n");
-std::vector Ranges(1, tooling::Range(Offset, Length));
-tooling::Replacements Replaces = reformat(Style, Code, Ranges);
-auto Result = applyAllReplacements(Code, Replaces);
-EXPECT_TRUE(static_cast(Result));
-LLVM_DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
-return *Result;
-  }
-
-  static std::string
-  format(llvm::StringRef Code,
- const FormatStyle &Style = getLLVMStyle(FormatStyle::LK_Verilog)) {
-return format(Code, 0, Code.size(), Style);
+  virtual FormatStyle getDefaultStyle() const override {
+return getLLVMStyle(FormatStyle::LK_Verilog);
   }
-
-  static void verifyFormat(
-  llvm::StringRef Code,
-  const FormatStyle &Style = getLLVMStyle(FormatStyle::LK_Verilog)) {
-EXPECT_EQ(Code.str(), format(Code, Style)) << "Expected code is not stable";
-EXPECT_EQ(Code.str(),
-  format(test::messUp(Code, /*HandleHash=*/false), Style));
+  virtual std::string messUp(llvm::StringRef Code) const override {
+return test::messUp(Code, /*HandleHash=*/false);
   }
 };
 
 TEST_F(FormatTestVerilog, Align) {
-  FormatStyle Style = getLLVMStyle(FormatStyle::LK_Verilog);
+  FormatStyle Style = getDefaultStyle();
   Style.AlignConsecutiveAssignments.Enabled = true;
   verifyFormat("x<= x;\n"
"sfdbddfbdfbb <= x;\n"
@@ -225,7 +204,7 @@
"instruction3(ir);\n"
"endcase");
   // Test indention options.
-  auto Style = getLLVMStyle(FormatStyle::LK_Verilog);
+  auto Style = getDefaultStyle();
   Style.IndentCaseLabels = false;
   verifyFormat("case (data)\n"
"16'd0:\n"
@@ -251,7 +230,7 @@
"endcase",
Style);
   // Other colons should not be mistaken as case colons.
-  Style = getLLVMStyle(FormatStyle::LK_Verilog);
+  Style = getDefaultStyle();
   Style.BitFieldColonSpacing = FormatStyle::BFCS_None;
   verifyFormat("case (x[1:0])\n"
"endcase",
@@ -266,7 +245,7 @@
   verifyFormat("default:\n"
"  x[1 : 0] = x[1 : 0];",
Style);
-  Style = getLLVMStyle(FormatStyle::LK_Verilog);
+  Style = getDefaultStyle();
   Style.SpacesInContainerLiterals = true;
   verifyFormat("case ('{x : x, default : 9})\n"
"endcase",
@@ -338,8 +317,8 @@
   verifyFormat("#1.5s;");
   // The following expression should be on the same line.
   verifyFormat("#1 x = x;");
-  EXPECT_EQ("#1 x = x;", format("#1\n"
-"x = x;"));
+  verifyFormat("#1 x = x;", "#1\n"
+"x = x;");
 }
 
 TEST_F(FormatTestVerilog, Headers) {
@@ -469,7 +448,7 @@
" b);\n"
"endmodule");
   // With a concatenation in the names.
-  auto Style = getLLVMStyle(FormatStyle::LK_Verilog);
+  auto Style = getDefaultStyle();
   Style.ColumnLimit = 40;
   verifyFormat("`define X(x)   \\\n"
"  module test  \\\n"
@@ -560,6 +539,28 @@
"endfunction : x");
 }
 
+TEST_F(FormatTestVerilog, Identifiers) {
+  // Escaped identifiers should not be split.
+  verifyFormat("\\busa+index");
+  verifyFormat("\\-clock");
+  verifyFormat("\\***error-condition***");
+  verifyFormat("\\net1\\/net2");
+  ver

[PATCH] D146402: [clang-format] Handle Verilog assign statements

2023-03-19 Thread sstwcw via Phabricator via cfe-commits
sstwcw created this revision.
sstwcw added reviewers: HazardyKnusperkeks, MyDeveloperDay, owenpan, rymiel.
Herald added a project: All.
sstwcw requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146402

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


Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -97,6 +97,23 @@
Style);
 }
 
+TEST_F(FormatTestVerilog, Assign) {
+  verifyFormat("assign mynet = enable;");
+  verifyFormat("assign (strong1, pull0) #1 mynet = enable;");
+  verifyFormat("assign #1 mynet = enable;");
+  verifyFormat("assign mynet = enable;");
+  // Test that assignments are on separate lines.
+  verifyFormat("assign mynet = enable,\n"
+   "   mynet1 = enable1;");
+  // Test that `<=` and `,` don't confuse it.
+  verifyFormat("assign mynet = enable1 <= enable2;");
+  verifyFormat("assign mynet = enable1 <= enable2,\n"
+   "   mynet1 = enable3;");
+  verifyFormat("assign mynet = enable,\n"
+   "   mynet1 = enable2 <= enable3;");
+  verifyFormat("assign mynet = enable(enable1, enable2);");
+}
+
 TEST_F(FormatTestVerilog, BasedLiteral) {
   verifyFormat("x = '0;");
   verifyFormat("x = '1;");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1284,8 +1284,11 @@
 Tok->setType(TT_InheritanceComma);
 break;
   default:
-if (Contexts.back().FirstStartOfName &&
-(Contexts.size() == 1 || startsWithInitStatement(Line))) {
+if (Style.isVerilog() && Contexts.size() == 1 &&
+Line.startsWith(Keywords.kw_assign)) {
+  Tok->setFinalizedType(TT_VerilogAssignComma);
+} else if (Contexts.back().FirstStartOfName &&
+   (Contexts.size() == 1 || startsWithInitStatement(Line))) {
   Contexts.back().FirstStartOfName->PartOfMultiVariableDeclStmt = true;
   Line.IsMultiVariableDeclStmt = true;
 }
@@ -4689,6 +4692,9 @@
   return true;
 }
   } else if (Style.isVerilog()) {
+// Break between assignments.
+if (Left.is(TT_VerilogAssignComma))
+  return true;
 // Break between ports of different types.
 if (Left.is(TT_VerilogTypeComma))
   return true;
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -144,6 +144,8 @@
   TYPE(UnaryOperator)  
\
   TYPE(UnionLBrace)
\
   TYPE(UntouchableMacroFunc)   
\
+  /* Like in 'assign x = 0, y = 1;' . */   
\
+  TYPE(VerilogAssignComma) 
\
   /* like in begin : block */  
\
   TYPE(VerilogBlockLabelColon) 
\
   /* The square bracket for the dimension part of the type name.   
\


Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -97,6 +97,23 @@
Style);
 }
 
+TEST_F(FormatTestVerilog, Assign) {
+  verifyFormat("assign mynet = enable;");
+  verifyFormat("assign (strong1, pull0) #1 mynet = enable;");
+  verifyFormat("assign #1 mynet = enable;");
+  verifyFormat("assign mynet = enable;");
+  // Test that assignments are on separate lines.
+  verifyFormat("assign mynet = enable,\n"
+   "   mynet1 = enable1;");
+  // Test that `<=` and `,` don't confuse it.
+  verifyFormat("assign mynet = enable1 <= enable2;");
+  verifyFormat("assign mynet = enable1 <= enable2,\n"
+   "   mynet1 = enable3;");
+  verifyFormat("assign mynet = enable,\n"
+   "   mynet1 = enable2 <= enable3;");
+  verifyFormat("assign mynet = enable(enable1, enable2);");
+}
+
 TEST_F(FormatTestVerilog, BasedLiteral) {
   verifyFormat("x = '0;");
   verifyFormat("x = '1;");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1284,8 +1284,11 @@
 Tok->setType(TT_InheritanceComma);
 break;
   default:
-if (Contexts.back().FirstStartOfName &&
- 

[PATCH] D146403: [clang-format] More work on space around operators in Verilog

2023-03-19 Thread sstwcw via Phabricator via cfe-commits
sstwcw created this revision.
sstwcw added reviewers: HazardyKnusperkeks, MyDeveloperDay, owenpan, rymiel.
Herald added a project: All.
sstwcw requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

before:

  (opcode *>o1) = 6.1;
  a inside{b, c};
  x = { >> {j}};

after:

  (opcode *> o1) = 6.1;
  a inside {b, c};
  x = {>>{j}};


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146403

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

Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -657,6 +657,14 @@
   verifyFormat("x = ++x;");
   verifyFormat("x = --x;");
 
+  // Test that `*` and `*>` are binary.
+  verifyFormat("x = x * x;");
+  verifyFormat("x = (x * x);");
+  verifyFormat("(opcode *> o1) = 6.1;");
+  verifyFormat("(C, D *> Q) = 18;");
+  // The wildcard import is not a binary operator.
+  verifyFormat("import p::*;");
+
   // Test that operators don't get split.
   verifyFormat("x = x++;");
   verifyFormat("x = x--;");
@@ -697,6 +705,13 @@
   EXPECT_EQ("x = x < -x;", format("x=x<-x;"));
   EXPECT_EQ("x = x << -x;", format("x=x<<-x;"));
   EXPECT_EQ("x = x <<< -x;", format("x=x<<<-x;"));
+
+  // Test that operators that are C++ identifiers get treated as operators.
+  verifyFormat("solve s before d;");   // before
+  verifyFormat("binsof(i) intersect {0};");// intersect
+  verifyFormat("req dist {1};");   // dist
+  verifyFormat("a inside {b, c};");// inside
+  verifyFormat("bus.randomize() with { atype == low; };"); // with
 }
 
 TEST_F(FormatTestVerilog, Preprocessor) {
@@ -849,6 +864,26 @@
"endprimitive");
 }
 
+TEST_F(FormatTestVerilog, Streaming) {
+  verifyFormat("x = {>>{j}};");
+  verifyFormat("x = {>>byte{j}};");
+  verifyFormat("x = {<<{j}};");
+  verifyFormat("x = {<>4{6'b11_0101}};");
+  verifyFormat("x = {<<2{{<<{4'b1101;");
+  verifyFormat("bit [96 : 1] y = {>>{a, b, c}};");
+  verifyFormat("int j = {>>{a, b, c}};");
+  verifyFormat("{>>{a, b, c}} = 23'b1;");
+  verifyFormat("{>>{a, b, c}} = x;");
+  verifyFormat("{>>{j}} = x;");
+  verifyFormat("{>>byte{j}} = x;");
+  verifyFormat("{<<{j}} = x;");
+  verifyFormat("{<` in module path declarations in
+  // specify blocks because merged tokens take the type of the first one by
+  // default.
+  if (Tok.is(tok::star))
+return TT_BinaryOperator;
+  if (determineUnaryOperatorByUsage(Tok))
+return TT_UnaryOperator;
+  return TT_BinaryOperator;
+}
+
 const FormatToken *PrevToken = Tok.getPreviousNonComment();
 if (!PrevToken)
   return TT_UnaryOperator;
@@ -3984,7 +3996,12 @@
 return !Left.isOneOf(tok::l_paren, tok::l_square, tok::at) &&
(Left.isNot(tok::colon) || Left.isNot(TT_ObjCMethodExpr));
   }
-  if ((Left.isOneOf(tok::identifier, tok::greater, tok::r_square,
+  // No space between the variable name and the initializer list.
+  // A a1{1};
+  // Verilog doesn't have such syntax, but it has word operators that are C++
+  // identifiers like `a inside {b, c}`. So the rule is not applicable.
+  if (!Style.isVerilog() &&
+  (Left.isOneOf(tok::identifier, tok::greater, tok::r_square,
 tok::r_paren) ||
Left.isSimpleTypeSpecifier()) &&
   Right.is(tok::l_brace) && Right.getNextNonComment() &&
@@ -4370,12 +4387,24 @@
  Keywords.isWordLike(Left))) {
   return false;
 }
+// Don't add spaces in imports like `import foo::*;`.
+if ((Right.is(tok::star) && Left.is(tok::coloncolon)) ||
+(Left.is(tok::star) && Right.is(tok::semi))) {
+  return false;
+}
 // Add space in attribute like `(* ASYNC_REG = "TRUE" *)`.
 if (Left.endsSequence(tok::star, tok::l_paren) && Right.is(tok::identifier))
   return true;
 // Add space before drive strength like in `wire (strong1, pull0)`.
 if (Right.is(tok::l_paren) && Right.is(TT_VerilogStrength))
   return true;
+// Don't add space in a streaming concatenation like `{>>{j}}`.
+if ((Left.is(tok::l_brace) &&
+ Right.isOneOf(tok::lessless, tok::greatergreater)) ||
+(Left.endsSequence(tok::lessless, tok::l_brace) ||
+ Left.endsSequence(tok::greatergreater, tok::l_brace))) {
+  return false;
+}
   }
   if (Left.is(TT_ImplicitStringLiteral))
 return Right.hasWhitespaceBefore();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143974: [clangd] Inactive regions support via dedicated protocol

2023-03-19 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

The issue addressed by this patch is attracting a steady stream of user 
interest (two recent examples are https://github.com/clangd/clangd/issues/1545 
and https://github.com/clangd/vscode-clangd/issues/469).

A review would be appreciated :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143974

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


[PATCH] D146403: [clang-format] More work on space around operators in Verilog

2023-03-19 Thread sstwcw via Phabricator via cfe-commits
sstwcw updated this revision to Diff 506457.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146403

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

Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -657,6 +657,14 @@
   verifyFormat("x = ++x;");
   verifyFormat("x = --x;");
 
+  // Test that `*` and `*>` are binary.
+  verifyFormat("x = x * x;");
+  verifyFormat("x = (x * x);");
+  verifyFormat("(opcode *> o1) = 6.1;");
+  verifyFormat("(C, D *> Q) = 18;");
+  // The wildcard import is not a binary operator.
+  verifyFormat("import p::*;");
+
   // Test that operators don't get split.
   verifyFormat("x = x++;");
   verifyFormat("x = x--;");
@@ -697,6 +705,13 @@
   EXPECT_EQ("x = x < -x;", format("x=x<-x;"));
   EXPECT_EQ("x = x << -x;", format("x=x<<-x;"));
   EXPECT_EQ("x = x <<< -x;", format("x=x<<<-x;"));
+
+  // Test that operators that are C++ identifiers get treated as operators.
+  verifyFormat("solve s before d;");   // before
+  verifyFormat("binsof(i) intersect {0};");// intersect
+  verifyFormat("req dist {1};");   // dist
+  verifyFormat("a inside {b, c};");// inside
+  verifyFormat("bus.randomize() with { atype == low; };"); // with
 }
 
 TEST_F(FormatTestVerilog, Preprocessor) {
@@ -849,6 +864,26 @@
"endprimitive");
 }
 
+TEST_F(FormatTestVerilog, Streaming) {
+  verifyFormat("x = {>>{j}};");
+  verifyFormat("x = {>>byte{j}};");
+  verifyFormat("x = {<<{j}};");
+  verifyFormat("x = {<>4{6'b11_0101}};");
+  verifyFormat("x = {<<2{{<<{4'b1101;");
+  verifyFormat("bit [96 : 1] y = {>>{a, b, c}};");
+  verifyFormat("int j = {>>{a, b, c}};");
+  verifyFormat("{>>{a, b, c}} = 23'b1;");
+  verifyFormat("{>>{a, b, c}} = x;");
+  verifyFormat("{>>{j}} = x;");
+  verifyFormat("{>>byte{j}} = x;");
+  verifyFormat("{<<{j}} = x;");
+  verifyFormat("{<` in module path declarations in
+  // specify blocks because merged tokens take the type of the first one by
+  // default.
+  if (Tok.is(tok::star))
+return TT_BinaryOperator;
+  return determineUnaryOperatorByUsage(Tok) ? TT_UnaryOperator
+: TT_BinaryOperator;
+}
+
 const FormatToken *PrevToken = Tok.getPreviousNonComment();
 if (!PrevToken)
   return TT_UnaryOperator;
@@ -3984,7 +3995,12 @@
 return !Left.isOneOf(tok::l_paren, tok::l_square, tok::at) &&
(Left.isNot(tok::colon) || Left.isNot(TT_ObjCMethodExpr));
   }
-  if ((Left.isOneOf(tok::identifier, tok::greater, tok::r_square,
+  // No space between the variable name and the initializer list.
+  // A a1{1};
+  // Verilog doesn't have such syntax, but it has word operators that are C++
+  // identifiers like `a inside {b, c}`. So the rule is not applicable.
+  if (!Style.isVerilog() &&
+  (Left.isOneOf(tok::identifier, tok::greater, tok::r_square,
 tok::r_paren) ||
Left.isSimpleTypeSpecifier()) &&
   Right.is(tok::l_brace) && Right.getNextNonComment() &&
@@ -4370,12 +4386,24 @@
  Keywords.isWordLike(Left))) {
   return false;
 }
+// Don't add spaces in imports like `import foo::*;`.
+if ((Right.is(tok::star) && Left.is(tok::coloncolon)) ||
+(Left.is(tok::star) && Right.is(tok::semi))) {
+  return false;
+}
 // Add space in attribute like `(* ASYNC_REG = "TRUE" *)`.
 if (Left.endsSequence(tok::star, tok::l_paren) && Right.is(tok::identifier))
   return true;
 // Add space before drive strength like in `wire (strong1, pull0)`.
 if (Right.is(tok::l_paren) && Right.is(TT_VerilogStrength))
   return true;
+// Don't add space in a streaming concatenation like `{>>{j}}`.
+if ((Left.is(tok::l_brace) &&
+ Right.isOneOf(tok::lessless, tok::greatergreater)) ||
+(Left.endsSequence(tok::lessless, tok::l_brace) ||
+ Left.endsSequence(tok::greatergreater, tok::l_brace))) {
+  return false;
+}
   }
   if (Left.is(TT_ImplicitStringLiteral))
 return Right.hasWhitespaceBefore();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70401: [RISCV] Complete RV32E/ilp32e implementation

2023-03-19 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead added a comment.

In D70401#4204511 , @recallmenot wrote:

> Hi, I'm working on CH32V003 for rust and it uses RV32EC core.
> I tried replacing my distros llvm and clang with a patched version of this 
> like this:
>
>   git clone https://aur.archlinux.org/llvm-git.git
>   cd llvm-git
>   mkdir src
>   cd src
>   git clone https://github.com/llvm/llvm-project.git
>   cd llvm-project
>   arc patch D70401
>   cd ../..
>   mv llvm-config.h src/
>   makepkg -es
>   sudo pacman -Rd --nodeps clang llvm
>   makepkg -eid
>
> but that bricked my xfce-wayland-manjaro DE (one screen black)
> And in config.toml if I put
>
>   [build]
>   target = "riscv32i-unknown-none-elf"
>   rustflags = [
>   "-C", "target-feature=+e,+c"
>   ]
>
> then build with cargo build
> LLVM still complains it doesn't implement CodeGen for RV32E yet
> What am I doing wrong?
> Ended up reverting to repository llvm and clang, desktop now works again but 
> CodeGen is obviously missing.

I don't see any obvious problem here.
I am not familiar with rust. Is `riscv32i-unknown-none-elf` a valid target for 
`rustc`, it should be something like `riscv32-unknown-elf` in LLVM I think. And 
is `target-feature=+e,+c` the right way to specify features?
Can you please provide the whole command/arguments passed to LLVM?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70401

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


[clang] d2639ff - [NFC] [C++20] [Modules] Add test for #pragma once

2023-03-19 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-03-20T11:37:09+08:00
New Revision: d26392673c39885400c45c317afd4e2c9f8d

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

LOG: [NFC] [C++20] [Modules] Add test for #pragma once

Close https://github.com/llvm/llvm-project/issues/38554
Close https://github.com/llvm/llvm-project/issues/58532

It looks like we can workaround the '#pragma once' problem automatically
after we force the lazily loading for named modules. Add a test to show
this.

Added: 
clang/test/Modules/pr38554.cppm
clang/test/Modules/pr58532.cppm

Modified: 


Removed: 




diff  --git a/clang/test/Modules/pr38554.cppm b/clang/test/Modules/pr38554.cppm
new file mode 100644
index 0..0193e5b0e0611
--- /dev/null
+++ b/clang/test/Modules/pr38554.cppm
@@ -0,0 +1,21 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %t/c.cppm
+
+//--- a.hpp
+#pragma once
+using a = int;
+
+//--- b.hpp
+#pragma once
+#include "a.hpp"
+a b;
+
+//--- c.cppm
+// expected-no-diagnostics
+module;
+#include "b.hpp"
+export module c;
+export using ::a;

diff  --git a/clang/test/Modules/pr58532.cppm b/clang/test/Modules/pr58532.cppm
new file mode 100644
index 0..cf530b4ac2ccc
--- /dev/null
+++ b/clang/test/Modules/pr58532.cppm
@@ -0,0 +1,34 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/interface.cppm -emit-module-interface \
+// RUN: -o %t/m.pcm
+// RUN: %clang_cc1 -std=c++20 %t/implementation.cpp -fmodule-file=m=%t/m.pcm \
+// RUN: -fsyntax-only -verify
+
+//--- invisible.h
+#pragma once // This breaks things.
+const int kInvisibleSymbol = 0;
+struct invisible_struct
+{};
+#define INVISIBLE_DEFINE
+
+//--- visible.h
+#include "invisible.h"
+const int kSadlyUndeclaredSymbol = kInvisibleSymbol;
+using unfortunately_still_invisible_struct = invisible_struct;
+#ifndef INVISIBLE_DEFINE
+#error "Still not defined."
+#endif
+
+//--- interface.cppm
+module;
+#include "visible.h"
+export module m;
+
+//--- implementation.cpp
+// expected-no-diagnostics
+module;
+#include "visible.h"
+module m;



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


[PATCH] D146188: [Clang][DOC] Add documentation in for __builtin_flt_rounds and __builtin_set_flt_rounds

2023-03-19 Thread xiongji90 via Phabricator via cfe-commits
xiongji90 updated this revision to Diff 506460.

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

https://reviews.llvm.org/D146188

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -3246,7 +3246,7 @@
 
double __builtin_canonicalize(double);
float __builtin_canonicalizef(float);
-   long double__builtin_canonicalizel(long double);
+   long double __builtin_canonicalizel(long double);
 
 Returns the platform specific canonical encoding of a floating point
 number. This canonicalization is useful for implementing certain
@@ -3254,6 +3254,39 @@
 `_ for
 more information on the semantics.
 
+``__builtin_flt_rounds``
+--
+
+.. code-block:: c
+
+   int __builtin_flt_rounds();
+
+Returns the current rounding mode. Encoding of the returned values is
+same as the result of FLT_ROUNDS, specified by C standard:
+0  - toward zero
+1  - to nearest, ties to even
+2  - toward positive infinity
+3  - toward negative infinity
+4  - to nearest, ties away from zero
+The effect of passing some other value to this builtin is 
implementation-defined.
+
+``__builtin_set_flt_rounds``
+--
+
+.. code-block:: c
+
+   void __builtin_set_flt_rounds(int);
+
+Sets the current rounding mode. Encoding of the returned values is
+same as the result of FLT_ROUNDS, specified by C standard:
+0  - toward zero
+1  - to nearest, ties to even
+2  - toward positive infinity
+3  - toward negative infinity
+4  - to nearest, ties away from zero
+This builtin is restrcted to work on x86 and arm targets currently. When 
support
+for the builtin is added for new targets, the manual should be updated 
accordingly.
+
 String builtins
 ---
 


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -3246,7 +3246,7 @@
 
double __builtin_canonicalize(double);
float __builtin_canonicalizef(float);
-   long double__builtin_canonicalizel(long double);
+   long double __builtin_canonicalizel(long double);
 
 Returns the platform specific canonical encoding of a floating point
 number. This canonicalization is useful for implementing certain
@@ -3254,6 +3254,39 @@
 `_ for
 more information on the semantics.
 
+``__builtin_flt_rounds``
+--
+
+.. code-block:: c
+
+   int __builtin_flt_rounds();
+
+Returns the current rounding mode. Encoding of the returned values is
+same as the result of FLT_ROUNDS, specified by C standard:
+0  - toward zero
+1  - to nearest, ties to even
+2  - toward positive infinity
+3  - toward negative infinity
+4  - to nearest, ties away from zero
+The effect of passing some other value to this builtin is implementation-defined.
+
+``__builtin_set_flt_rounds``
+--
+
+.. code-block:: c
+
+   void __builtin_set_flt_rounds(int);
+
+Sets the current rounding mode. Encoding of the returned values is
+same as the result of FLT_ROUNDS, specified by C standard:
+0  - toward zero
+1  - to nearest, ties to even
+2  - toward positive infinity
+3  - toward negative infinity
+4  - to nearest, ties away from zero
+This builtin is restrcted to work on x86 and arm targets currently. When support
+for the builtin is added for new targets, the manual should be updated accordingly.
+
 String builtins
 ---
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146188: [Clang][DOC] Add documentation in for __builtin_flt_rounds and __builtin_set_flt_rounds

2023-03-19 Thread xiongji90 via Phabricator via cfe-commits
xiongji90 added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:3295
+support this builtin. Since this builtin changes default floating-point
+environment, ``#pragma STDC FENV_ACCESS ON`` is required.
+

rjmccall wrote:
> sepavloff wrote:
> > Not necessary. Options `-ffp-model=strict` or `-frounding-math` also can be 
> > used. I would remove this statement.
> It is appropriate to at least say that not all modes permit changing the 
> default floating-point environment and cross-reference the appropriate place 
> in the Clang documentation where we talk about that in more detail.  If we 
> don't have such a place already, this is the time to add it.
Hi, @rjmccall and @sepavloff 
I removed the statement that requiring to add "#pragma stdc fenv access", I 
checked the doc that there has not been any description about default fp 
environment, do you mean we need to add such description first and 
cross-reference it here?
Thanks very much.


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

https://reviews.llvm.org/D146188

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


[PATCH] D146354: [clang][ExtractAPI] Add semicolons for enum, typedef, struct declaration fragments

2023-03-19 Thread NagaChaitanya Vellanki via Phabricator via cfe-commits
chaitanyav added a comment.

The debian build is failing because of this 
https://github.com/google/llvm-premerge-checks/issues/436

The windows build is failing because of 
https://github.com/llvm/llvm-project/issues/61519, i see that the fix 
(https://reviews.llvm.org/rGd233c7b814071e8b9345b1c25411272ec7446c8d) for this 
is already on main but i cannot trigger a new build for my changes.

Please advice on how to trigger a new build that will run on latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146354

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


[PATCH] D146188: [Clang][DOC] Add documentation in for __builtin_flt_rounds and __builtin_set_flt_rounds

2023-03-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:3271
+4  - to nearest, ties away from zero
+The effect of passing some other value to this builtin is 
implementation-defined.
+

This comment belongs with the other builtin.  I would suggest just combining 
these two into one section, though, like:

```
``__builtin_flt_rounds`` and ``__builtin_set_flt_rounds``
-
```

That way you don't have to describe the options twice.

Make sure you clarify that the target restrictions only applies to 
`__builtin_set_flt_rounds`.



Comment at: clang/docs/LanguageExtensions.rst:3280
+
+Sets the current rounding mode. Encoding of the returned values is
+same as the result of FLT_ROUNDS, specified by C standard:





Comment at: clang/docs/LanguageExtensions.rst:3287
+4  - to nearest, ties away from zero
+This builtin is restrcted to work on x86 and arm targets currently. When 
support
+for the builtin is added for new targets, the manual should be updated 
accordingly.




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

https://reviews.llvm.org/D146188

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


[PATCH] D146188: [Clang][DOC] Add documentation in for __builtin_flt_rounds and __builtin_set_flt_rounds

2023-03-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:3288
+This builtin is restrcted to work on x86 and arm targets currently. When 
support
+for the builtin is added for new targets, the manual should be updated 
accordingly.
+

This meta-commentary about when to update the manual should not go into the 
manual.

I'm going to insist that we talk about ``#pragma STDC FENV_ACCESS`` here.  It 
would be inappropriate not to, given that it's undefined behavior to use this 
without also using the pragma or one of those flags.  We should not be 
documenting features with non-obvious UB without warning.

How about:

```
By default, these builtins may not be used.  The floating point rounding mode 
is part of the floating point environment, and it is undefined behavior to read 
or modify the floating point environment, or to run code under a non-default 
floating point environment, unless that code is compiled under a special mode.  
Clang supports three well-defined ways to control the rounding mode of floating 
point operations:

- The standard pragma ``#pragma STDC FENV_ROUND `` can change the 
rounding mode to a specific value for the operations covered by the pragma.  
This does not permit dynamic access to the rounding mode, but in many cases it 
is sufficient to achieve the desired effect, and it is more optimizable than 
the alternatives below.

- The standard pragma ``#pragma STDC FENV_ROUND FE_DYNAMIC`` allows dynamic 
access to the floating point rounding mode (including by these builtins) in 
code covered by the pragma.  The command line option ``-frounding-math`` 
behaves as if the translation unit began with this pragma.  This pragma does 
not allow changes to the floating point exceptions mode and so may be more 
optimizable than the next alternative.

- The standard pragma ``#pragma STDC FENV_ACCESS ON`` allows dynamic access to 
the entire floating point environment (including by these builtins) in code 
covered by the pragma.  The command line option ``-ffp-model=strict`` behaves 
as if the translation unit began with this pragma.

Code that modifies the floating point rounding mode dynamically must take care 
to reset it to the default mode before returning control to code that is not 
compiled under one of these last two pragmas.  See the C standard for more 
information about these pragmas.
```

Serge, please fact-check all that.


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

https://reviews.llvm.org/D146188

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


[PATCH] D146188: [Clang][DOC] Add documentation in for __builtin_flt_rounds and __builtin_set_flt_rounds

2023-03-19 Thread xiongji90 via Phabricator via cfe-commits
xiongji90 updated this revision to Diff 506472.
xiongji90 added a comment.

Combine description of __builtin_flt_rounds and __builtin_set_flt_rounds


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146188

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -272,6 +272,7 @@
 - Add ``__builtin_elementwise_log2`` builtin for floating point types only.
 - Add ``__builtin_elementwise_exp`` builtin for floating point types only.
 - Add ``__builtin_elementwise_exp2`` builtin for floating point types only.
+- Add ``__builtin_set_flt_rounds`` builtin for X86, x86_64, Arm and AArch64 
only.
 
 AST Matchers
 
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -3246,7 +3246,7 @@
 
double __builtin_canonicalize(double);
float __builtin_canonicalizef(float);
-   long double__builtin_canonicalizel(long double);
+   long double __builtin_canonicalizel(long double);
 
 Returns the platform specific canonical encoding of a floating point
 number. This canonicalization is useful for implementing certain
@@ -3254,6 +3254,25 @@
 `_ for
 more information on the semantics.
 
+``__builtin_flt_rounds`` and ``__builtin_set_flt_rounds``
+-
+
+.. code-block:: c
+
+   int __builtin_flt_rounds();
+   void __builtin_set_flt_rounds(int);
+
+Returns and sets current rounding mode. Encoding of the returned values and
+input parameter is same as the result of FLT_ROUNDS, specified by C standard:
+0  - toward zero
+1  - to nearest, ties to even
+2  - toward positive infinity
+3  - toward negative infinity
+4  - to nearest, ties away from zero
+The effect of passing some other value to ``__builtin_flt_rounds`` is
+implementation-defined. ``__builtin_set_flt_rounds`` is restricted to work on
+X86 and Arm targets currently.
+
 String builtins
 ---
 


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -272,6 +272,7 @@
 - Add ``__builtin_elementwise_log2`` builtin for floating point types only.
 - Add ``__builtin_elementwise_exp`` builtin for floating point types only.
 - Add ``__builtin_elementwise_exp2`` builtin for floating point types only.
+- Add ``__builtin_set_flt_rounds`` builtin for X86, x86_64, Arm and AArch64 only.
 
 AST Matchers
 
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -3246,7 +3246,7 @@
 
double __builtin_canonicalize(double);
float __builtin_canonicalizef(float);
-   long double__builtin_canonicalizel(long double);
+   long double __builtin_canonicalizel(long double);
 
 Returns the platform specific canonical encoding of a floating point
 number. This canonicalization is useful for implementing certain
@@ -3254,6 +3254,25 @@
 `_ for
 more information on the semantics.
 
+``__builtin_flt_rounds`` and ``__builtin_set_flt_rounds``
+-
+
+.. code-block:: c
+
+   int __builtin_flt_rounds();
+   void __builtin_set_flt_rounds(int);
+
+Returns and sets current rounding mode. Encoding of the returned values and
+input parameter is same as the result of FLT_ROUNDS, specified by C standard:
+0  - toward zero
+1  - to nearest, ties to even
+2  - toward positive infinity
+3  - toward negative infinity
+4  - to nearest, ties away from zero
+The effect of passing some other value to ``__builtin_flt_rounds`` is
+implementation-defined. ``__builtin_set_flt_rounds`` is restricted to work on
+X86 and Arm targets currently.
+
 String builtins
 ---
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146188: [Clang][DOC] Add documentation in for __builtin_flt_rounds and __builtin_set_flt_rounds

2023-03-19 Thread xiongji90 via Phabricator via cfe-commits
xiongji90 updated this revision to Diff 506475.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146188

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -272,6 +272,7 @@
 - Add ``__builtin_elementwise_log2`` builtin for floating point types only.
 - Add ``__builtin_elementwise_exp`` builtin for floating point types only.
 - Add ``__builtin_elementwise_exp2`` builtin for floating point types only.
+- Add ``__builtin_set_flt_rounds`` builtin for X86, x86_64, Arm and AArch64 
only.
 
 AST Matchers
 
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -3246,7 +3246,7 @@
 
double __builtin_canonicalize(double);
float __builtin_canonicalizef(float);
-   long double__builtin_canonicalizel(long double);
+   long double __builtin_canonicalizel(long double);
 
 Returns the platform specific canonical encoding of a floating point
 number. This canonicalization is useful for implementing certain
@@ -3254,6 +3254,26 @@
 `_ for
 more information on the semantics.
 
+``__builtin_flt_rounds`` and ``__builtin_set_flt_rounds``
+-
+
+.. code-block:: c
+
+   int __builtin_flt_rounds();
+   void __builtin_set_flt_rounds(int);
+
+Returns and sets current floating point rounding mode. The encoding of returned
+values and input parameters is same as the result of FLT_ROUNDS, specified by C
+standard:
+0  - toward zero
+1  - to nearest, ties to even
+2  - toward positive infinity
+3  - toward negative infinity
+4  - to nearest, ties away from zero
+The effect of passing some other value to ``__builtin_flt_rounds`` is
+implementation-defined. ``__builtin_set_flt_rounds`` is currently only 
supported to
+work on x86, x86_64, Arm and AArch64 targets currently.
+
 String builtins
 ---
 


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -272,6 +272,7 @@
 - Add ``__builtin_elementwise_log2`` builtin for floating point types only.
 - Add ``__builtin_elementwise_exp`` builtin for floating point types only.
 - Add ``__builtin_elementwise_exp2`` builtin for floating point types only.
+- Add ``__builtin_set_flt_rounds`` builtin for X86, x86_64, Arm and AArch64 only.
 
 AST Matchers
 
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -3246,7 +3246,7 @@
 
double __builtin_canonicalize(double);
float __builtin_canonicalizef(float);
-   long double__builtin_canonicalizel(long double);
+   long double __builtin_canonicalizel(long double);
 
 Returns the platform specific canonical encoding of a floating point
 number. This canonicalization is useful for implementing certain
@@ -3254,6 +3254,26 @@
 `_ for
 more information on the semantics.
 
+``__builtin_flt_rounds`` and ``__builtin_set_flt_rounds``
+-
+
+.. code-block:: c
+
+   int __builtin_flt_rounds();
+   void __builtin_set_flt_rounds(int);
+
+Returns and sets current floating point rounding mode. The encoding of returned
+values and input parameters is same as the result of FLT_ROUNDS, specified by C
+standard:
+0  - toward zero
+1  - to nearest, ties to even
+2  - toward positive infinity
+3  - toward negative infinity
+4  - to nearest, ties away from zero
+The effect of passing some other value to ``__builtin_flt_rounds`` is
+implementation-defined. ``__builtin_set_flt_rounds`` is currently only supported to
+work on x86, x86_64, Arm and AArch64 targets currently.
+
 String builtins
 ---
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143755: [clang-format] Add a space between an overloaded operator and '>'

2023-03-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Hi @owenpan, this seems to be crashing for:

  struct Foo { operator enum foo{} };

with stack trace:

  $ ~/repos/llvm/build/bin/clang-format format_crash.cc --dry-run
  clang-format: 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Format/TokenAnnotator.cpp:1229:
 bool clang::format::(anonymous namespace)::AnnotatingParser::consumeToken(): 
Assertion `CurrentToken' failed.
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace.
  Stack dump:
  0.  Program arguments: 
/usr/local/google/home/kadircet/repos/llvm/build/bin/clang-format 
format_crash.cc --dry-run
   #0 0x00397687 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
/usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/Unix/Signals.inc:567:13
   #1 0x0039583e llvm::sys::RunSignalHandlers() 
/usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/Signals.cpp:105:18
   #2 0x00397faa SignalHandler(int) 
/usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/Unix/Signals.inc:412:1
   #3 0x7f49d145af90 (/lib/x86_64-linux-gnu/libc.so.6+0x3bf90)
   #4 0x7f49d14a9ccc __pthread_kill_implementation 
./nptl/pthread_kill.c:44:76
   #5 0x7f49d145aef2 raise ./signal/../sysdeps/posix/raise.c:27:6
   #6 0x7f49d1445472 abort ./stdlib/abort.c:81:7
   #7 0x7f49d1445395 _nl_load_domain ./intl/loadmsgcat.c:1177:9
   #8 0x7f49d1453df2 (/lib/x86_64-linux-gnu/libc.so.6+0x34df2)
   #9 0x0043a7c1 parseBrace 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Format/TokenAnnotator.cpp:867:9
  #10 0x0043a7c1 clang::format::(anonymous 
namespace)::AnnotatingParser::consumeToken() 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Format/TokenAnnotator.cpp:1170:12
  #11 0x0042e1f8 clang::format::(anonymous 
namespace)::AnnotatingParser::parseLine() 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Format/TokenAnnotator.cpp:1558:11
  #12 0x0042dc37 
clang::format::TokenAnnotator::annotate(clang::format::AnnotatedLine&) 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Format/TokenAnnotator.cpp:2837:13
  #13 0x0041b910 clang::format::TokenAnalyzer::process(bool) 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Format/TokenAnalyzer.cpp:0:19
  #14 0x003d0576 ~TokenAnalyzer 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Format/TokenAnalyzer.h:88:7
  #15 0x003d0576 operator() 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Format/Format.cpp:3492:9
  #16 0x003d0576 __invoke_impl, (lambda at 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Format/Format.cpp:3491:27) 
&, const clang::format::Environment &> 
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/invoke.h:61:14
  #17 0x003d0576 __invoke_r, (lambda at 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Format/Format.cpp:3491:27) 
&, const clang::format::Environment &> 
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/invoke.h:114:9
  #18 0x003d0576 
std::_Function_handler 
(clang::format::Environment const&), 
clang::format::internal::reformat(clang::format::FormatStyle const&, 
llvm::StringRef, llvm::ArrayRef, unsigned int, unsigned 
int, unsigned int, llvm::StringRef, 
clang::format::FormattingAttemptStatus*)::$_8>::_M_invoke(std::_Any_data 
const&, clang::format::Environment const&) 
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_function.h:290:9
  #19 0x003b8a18 _M_is_engaged 
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/optional:471:58
  #20 0x003b8a18 operator bool 
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/optional:985:22
  #21 0x003b8a18 
clang::format::internal::reformat(clang::format::FormatStyle const&, 
llvm::StringRef, llvm::ArrayRef, unsigned int, unsigned 
int, unsigned int, llvm::StringRef, clang::format::FormattingAttemptStatus*) 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Format/Format.cpp:3533:9
  #22 0x003b9c73 _Rb_tree_impl 
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_tree.h:687:12
  #23 0x003b9c73 _Rb_tree 
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_tree.h:954:7
  #24 0x003b9c73 set 
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_set.h:231:7
  #25 0x003b9c73 Replacements 
/usr/local/google/home/kadircet/repos/llvm/clang/include/clang/Tooling/Core/Replacement.h:212:7
  #26 0x003b9c73 clang::format::reformat(clang::format::FormatStyle 
const&, llvm::StringRef, llvm::ArrayRef, 
llvm::StringRef, clang::format::FormattingAttemptStatus*) 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Format/Format.cpp:3557:10
  #27 0x0033da7f clang::format::format(llvm::StringRef) 
/usr/local/google/home/kadircet/repos/llvm/clang/tools/clang-format/ClangForma