[PATCH] D116637: [Clang][Sema][OpenMP] Sema support for `atomic compare`

2022-02-05 Thread Caroline Tice via Phabricator via cfe-commits
cmtice added a comment.

When building/running 
third_party/llvm/llvm-project/clang/test/OpenMP/atomic_messages.c and 
third_party/llvm/llvm-project/clang/test/OpenMP/atomic_ast_print.cpp, we get 
use-of-uninitialized-variable error messages:

SUMMARY: MemorySanitizer: use-of-uninitialized-value 
third_party/llvm/llvm-project/clang/lib/Sema/SemaOpenMP.cpp:11214:40 in 
(anonymous namespace)::OpenMPAtomicCompareChecker::checkType((anonymous 
namespace)::OpenMPAtomicCompareChecker::ErrorInfoTy&) 
const::$_57::operator()(clang::Expr const*, llvm::omp::OMPAtomicCompareOp, 
bool) const
Exiting

You should probably look into this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116637

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


[PATCH] D113319: [clang-format] Improve require and concept handling

2022-02-05 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks marked 22 inline comments as done.
HazardyKnusperkeks added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:3516-3518
+The clause tries to stick to the template declaration in case of class
+templates or between template and function declarations. In case of
+after the function declaration it tries to stick to this.

curdeius wrote:
> Just a suggestion, I'm not a writer. I'd just like to see something clear and 
> comprehensible.
I'm happy to reword the stuff. :)



Comment at: clang/lib/Format/ContinuationIndenter.cpp:1499-1500
+  if (State.NextToken->ClosesRequiresClause && Style.IndentRequiresClause) {
+// Remove the indentation of the requires clauses (which is not in Indent,
+// but in LastSpace).
+State.Stack.back().LastSpace -= Style.IndentWidth;

curdeius wrote:
> And why it is not in `Indent`?
This one I tackled a month ago...
If I remember correctly this is because the indentation is not from an 
increased ``Level`` of the line, but because the position comes out of 
``getNewLineColumn``.
The Level would only work if I would generate different UnwrappedLines 
depending on the clause style, which currently I don't.
The ``Indent`` is correctly reduced, but ``LastSpace`` stayed.



Comment at: clang/lib/Format/TokenAnnotator.cpp:3900-3908
+  if (Right.is(TT_RequiresClause)) {
+switch (Style.RequiresClausePosition) {
+case FormatStyle::RCPS_OwnLine:
+case FormatStyle::RCPS_ToFollowing:
+  return true;
+default:
+  break;

curdeius wrote:
> The body of seems to be the exact same code as below in lines 3920-3926.
> Maybe you can refactor to something like this?
> Name of the lambda in my suggestion is maybe incorrect though.
Here is not about indentation, it is about breaking the line. And the 
difference is ``WithFollowing`` vs. ``WithPreceding``.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:731
+bool CanContainBracedList,
+TokenType NextLBracesType) {
   assert(FormatTok->isOneOf(tok::l_brace, TT_MacroBlockBegin) &&

curdeius wrote:
> Why plural?
Because it applies to all braces found within this block (not nested).



Comment at: clang/unittests/Format/FormatTest.cpp:3819-3822
+  verifyFormat("template \n"
+   "constexpr void foo\n"
+   "  requires(I == 42)\n"
+   "{}\n"

curdeius wrote:
> Do you test what was here previously with `RequiresClausePosition: 
> SingleLine` (or whichever relevant option)?
I don't understand the question.

Before we had no real handling of requires, which did something like a 
combination of ``SingleLine`` and ``WithFollowing``.

I could have left the string in the test unchanged, but would have to set the 
style to ``SingleLine``.

I thought it would be acceptable to change the test, since we basically only 
now defined a default for LLVMStyle.



Comment at: clang/unittests/Format/FormatTest.cpp:23249-23252
+  verifyFormat("template \n"
+   "concept C = [] -> bool { return true; }() && requires(T t) { "
+   "t.bar(); } &&\n"
+   "  sizeof(T) <= 8;");

curdeius wrote:
> How about adding a test case with the exact same concept body but surrounded 
> with parens (e.g. using `decltype(...)`)?
> The one below looks *almost* the same, but uses `std::true_type` and 
> `::value` and so it's harder to transpose to what this test should look like.
Where should the parens go?
The misformatting is that `sizeof` is indented below `bool`, not below the 
`l_square`.



Comment at: clang/unittests/Format/FormatTest.cpp:23417
+  "  requires Bar && Foo;\n"
+  "  requires((trait && Baz) || (T2 && Foo));\n"
+  "};",

curdeius wrote:
> curdeius wrote:
> > Hmm, no space after `requires` here?
> > It looks strange.
> > My preference would be not to put a space before a parameter list (as in 
> > `requires(T t)`), but put a space before of a constraint expression.
> > It seems to be the style used in 
> > https://en.cppreference.com/w/cpp/language/constraints.
> > Unless there are options that modify this behaviour?
> Oh, I've just seen a comment below on basically the same topic.
Yeah, the change for that is D113369 which I will update shortly.

We can gladly discuss the defaults there.


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

https://reviews.llvm.org/D113319

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


[PATCH] D113319: [clang-format] Improve require and concept handling

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

- Incorporated review notes
- Rebased


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

https://reviews.llvm.org/D113319

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  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
@@ -14,6 +14,14 @@
 
 namespace clang {
 namespace format {
+
+// Not really the equality, but everything we need.
+static bool operator==(const FormatToken &LHS,
+   const FormatToken &RHS) noexcept {
+  return LHS.Tok.getKind() == RHS.Tok.getKind() &&
+ LHS.getType() == RHS.getType();
+}
+
 namespace {
 
 class TokenAnnotatorTest : public ::testing::Test {
@@ -97,6 +105,261 @@
   EXPECT_TOKEN(Tokens[4], tok::l_brace, TT_Unknown);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsRequiresClausesAndConcepts) {
+  auto Tokens = annotate("template \n"
+ "concept C = (Foo && Bar) && (Bar && Baz);");
+
+  ASSERT_EQ(Tokens.size(), 21u) << Tokens;
+  EXPECT_TOKEN(Tokens[10], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[13], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[16], tok::ampamp, TT_BinaryOperator);
+
+  Tokens = annotate("template \n"
+"concept C = requires(T t) {\n"
+"  { t.foo() };\n"
+"} && Bar && Baz;");
+  ASSERT_EQ(Tokens.size(), 35u) << Tokens;
+  EXPECT_TOKEN(Tokens[23], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[28], tok::ampamp, TT_BinaryOperator);
+
+  Tokens = annotate("template\n"
+"requires C1 && (C21 || C22 && C2e) && C3\n"
+"struct Foo;");
+  ASSERT_EQ(Tokens.size(), 36u) << Tokens;
+  EXPECT_TOKEN(Tokens[6], tok::identifier, TT_Unknown);
+  EXPECT_EQ(Tokens[6]->FakeLParens.size(), 1u);
+  EXPECT_TOKEN(Tokens[10], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[16], tok::pipepipe, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[21], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[27], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[31], tok::greater, TT_TemplateCloser);
+  EXPECT_EQ(Tokens[31]->FakeRParens, 1u);
+  EXPECT_TRUE(Tokens[31]->ClosesRequiresClause);
+
+  Tokens =
+  annotate("template\n"
+   "requires (C1 && (C21 || C22 && C2e) && C3)\n"
+   "struct Foo;");
+  ASSERT_EQ(Tokens.size(), 38u) << Tokens;
+  EXPECT_TOKEN(Tokens[7], tok::identifier, TT_Unknown);
+  EXPECT_EQ(Tokens[7]->FakeLParens.size(), 1u);
+  EXPECT_TOKEN(Tokens[11], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[17], tok::pipepipe, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[22], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[28], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[32], tok::greater, TT_TemplateCloser);
+  EXPECT_EQ(Tokens[32]->FakeRParens, 1u);
+  EXPECT_TOKEN(Tokens[33], tok::r_paren, TT_Unknown);
+  EXPECT_TRUE(Tokens[33]->ClosesRequiresClause);
+}
+
+TEST_F(TokenAnnotatorTest, RequiresDoesNotChangeParsingOfTheRest) {
+  auto NumberOfAdditionalRequiresClauseTokens = 5u;
+  auto NumberOfTokensBeforeRequires = 5u;
+
+  auto BaseTokens = annotate("template\n"
+ "T Pi = 3.14;");
+  auto ConstrainedTokens = annotate("template\n"
+"  requires Foo\n"
+"T Pi = 3.14;");
+
+  auto NumberOfBaseTokens = 11u;
+
+  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
+  ASSERT_EQ(ConstrainedTokens.size(),
+NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
+  << ConstrainedTokens;
+
+  for (auto I = 0u; I < NumberOfBaseTokens; ++I)
+if (I < NumberOfTokensBeforeRequires)
+  EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I;
+else
+  EXPECT_EQ(*BaseTokens[I],
+*ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens])
+  << I;
+
+  BaseTokens = annotate("template\n"
+"struct Bar;");
+  ConstrainedTokens = annotate("template\n"
+   "  requires Foo\n"
+   "struct Bar;");
+  NumberOfBaseTokens = 9u;
+
+  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
+  ASSERT_EQ(ConstrainedTokens.size(),
+NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
+  

[PATCH] D119004: [NFC][analyzer] Allow CallDescriptions to be matched with CallExprs

2022-02-05 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Now that I remember, the ever so slightly different overloads of 
`ProgramState::getSVal` is a prime example I think. I always percieved that I 
have the means to invoke several of them at any point, but I never really knew 
which one. Though, to be fair, they were not documented particularly well (at 
least as I remember it).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119004

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


[clang] 74b1c4c - [clang] added alloc allign attr to memalign

2022-02-05 Thread Dávid Bolvanský via cfe-commits

Author: Dávid Bolvanský
Date: 2022-02-05T11:46:56+01:00
New Revision: 74b1c4c36740fe94953ef648e40df7dd9e9a9c7d

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

LOG: [clang] added alloc allign attr to memalign

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/CodeGen/alloc-fns-alignment.c

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index a86947aa5fbfc..f2871d82b0409 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -15315,6 +15315,7 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) 
{
 
 // Add known guaranteed alignment for allocation functions.
 switch (BuiltinID) {
+case Builtin::BImemalign:
 case Builtin::BIaligned_alloc:
   if (!FD->hasAttr())
 FD->addAttr(AllocAlignAttr::CreateImplicit(Context, ParamIdx(1, FD),
@@ -15322,7 +15323,6 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) 
{
   LLVM_FALLTHROUGH;
 case Builtin::BIcalloc:
 case Builtin::BImalloc:
-case Builtin::BImemalign:
 case Builtin::BIrealloc:
 case Builtin::BIstrdup:
 case Builtin::BIstrndup: {

diff  --git a/clang/test/CodeGen/alloc-fns-alignment.c 
b/clang/test/CodeGen/alloc-fns-alignment.c
index 8ab0610accf03..29d6e9e4fb380 100644
--- a/clang/test/CodeGen/alloc-fns-alignment.c
+++ b/clang/test/CodeGen/alloc-fns-alignment.c
@@ -6,6 +6,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-calloc  
-emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-CALLOC
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-realloc 
-emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-REALLOC
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-aligned_alloc 
-emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-ALIGNED_ALLOC
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-memalign 
-emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-MEMALIGN
 
 typedef __SIZE_TYPE__ size_t;
 
@@ -13,6 +14,7 @@ void *malloc(size_t);
 void *calloc(size_t, size_t);
 void *realloc(void *, size_t);
 void *aligned_alloc(size_t, size_t);
+void *memalign(size_t, size_t);
 
 void *malloc_test(size_t n) {
   return malloc(n);
@@ -30,6 +32,10 @@ void *aligned_alloc_variable_test(size_t n, size_t a) {
   return aligned_alloc(a, n);
 }
 
+void *memalign_variable_test(size_t n, size_t a) {
+  return memalign(a, n);
+}
+
 void *aligned_alloc_constant_test(size_t n) {
   return aligned_alloc(8, n);
 }
@@ -38,6 +44,10 @@ void *aligned_alloc_large_constant_test(size_t n) {
   return aligned_alloc(4096, n);
 }
 
+void *memalign_large_constant_test(size_t n) {
+  return memalign(4096, n);
+}
+
 // CHECK-LABEL: @malloc_test
 // ALIGN16: align 16 i8* @malloc
 
@@ -51,12 +61,19 @@ void *aligned_alloc_large_constant_test(size_t n) {
 // ALIGN16:  %[[ALLOCATED:.*]] = call align 16 i8* 
@aligned_alloc({{i32|i64}} noundef %[[ALIGN:.*]], {{i32|i64}} noundef 
%[[NBYTES:.*]])
 // ALIGN16-NEXT: call void @llvm.assume(i1 true) [ "align"(i8* %[[ALLOCATED]], 
{{i32|i64}} %[[ALIGN]]) ]
 
+// CHECK-LABEL: @memalign_variable_test
+// ALIGN16:  %[[ALLOCATED:.*]] = call align 16 i8* @memalign({{i32|i64}} 
noundef %[[ALIGN:.*]], {{i32|i64}} noundef %[[NBYTES:.*]])
+// ALIGN16-NEXT: call void @llvm.assume(i1 true) [ "align"(i8* %[[ALLOCATED]], 
{{i32|i64}} %[[ALIGN]]) ]
+
 // CHECK-LABEL: @aligned_alloc_constant_test
 // ALIGN16: align 16 i8* @aligned_alloc
 
 // CHECK-LABEL: @aligned_alloc_large_constant_test
 // ALIGN16: align 4096 i8* @aligned_alloc
 
+// CHECK-LABEL: @memalign_large_constant_test
+// ALIGN16: align 4096 i8* @memalign
+
 // CHECK-LABEL: @malloc_test
 // ALIGN8: align 8 i8* @malloc
 
@@ -69,13 +86,20 @@ void *aligned_alloc_large_constant_test(size_t n) {
 // CHECK-LABEL: @aligned_alloc_variable_test
 // ALIGN8: align 8 i8* @aligned_alloc
 
+// CHECK-LABEL: @memalign_variable_test
+// ALIGN8: align 8 i8* @memalign
+
 // CHECK-LABEL: @aligned_alloc_constant_test
 // ALIGN8: align 8 i8* @aligned_alloc
 
 // CHECK-LABEL: @aligned_alloc_large_constant_test
 // ALIGN8: align 4096 i8* @aligned_alloc
 
+// CHECK-LABEL: @memalign_large_constant_test
+// ALIGN8: align 4096 i8* @memalign
+
 // NOBUILTIN-MALLOC: declare i8* @malloc
 // NOBUILTIN-CALLOC: declare i8* @calloc
 // NOBUILTIN-REALLOC: declare i8* @realloc
 // NOBUILTIN-ALIGNED_ALLOC: declare i8* @aligned_alloc
+// NOBUILTIN-MEMALIGN: declare i8* @memalign



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


[PATCH] D113319: [clang-format] Improve require and concept handling

2022-02-05 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

@HazardyKnusperkeks I think this is tremendous, I think this looks and feels 
like a much more thorough approach to formatting concepts. Thank you so much 
for taking this on and for adding SO many unit tests that gives us lots of good 
examples, I'm probably not doing as an in-depth review as others because my own 
team aren't able to use a compiler on all platforms that allow us to use 
concepts and so my skill level around them isn't as great because I don't use 
them day to day.  But I'm going to give this a LGTM and when the others are 
happy I'm more than happy.

My personal opinion is when reviews get this big, and we are making forward 
progress then I'm ok to "BANK!" what we have. My fear for large reviews is if 
we get a regression in some other behaviour and we have to say "What changed" 
and the response is "Everything Changed" then finding out why becomes so much 
harder. So from my perspective, I'd like to see this landed and any additional 
issues worked out in separate reviews.


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

https://reviews.llvm.org/D113319

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


[PATCH] D118991: [clang-format][docs] Fix incorrect 'clang-format 14' configuration options markers

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

Thank you for looking into this, I'm more than happy for us to change the 
values to their more accurate first releases, but can I ask how you went about 
making those assumptions? For me initially I simply looks at the commit in the 
blame then tracked that to what branches it was in. I always knew it would be 
inaccurate.

What was your technique for doing this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118991

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


[PATCH] D118991: [clang-format][docs] Fix incorrect 'clang-format 14' configuration options markers

2022-02-05 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

Thank you for this. LGTM  (I double-checked a few and they all look good to me!)




Comment at: clang/docs/ClangFormatStyleOptions.rst:2212
 
-**EmptyLineAfterAccessModifier** (``EmptyLineAfterAccessModifierStyle``) 
:versionbadge:`clang-format 14`
+**EmptyLineAfterAccessModifier** (``EmptyLineAfterAccessModifierStyle``) 
:versionbadge:`clang-format 13`
   Defines when to put an empty line after access modifiers.

agreed its here
https://releases.llvm.org/13.0.0/tools/clang/docs/ClangFormatStyleOptions.html



Comment at: clang/docs/ClangFormatStyleOptions.rst:2378
 
-**IfMacros** (``List of Strings``) :versionbadge:`clang-format 14`
+**IfMacros** (``List of Strings``) :versionbadge:`clang-format 13`
   A vector of macros that should be interpreted as conditionals

Agreed
https://releases.llvm.org/13.0.0/tools/clang/docs/ClangFormatStyleOptions.html



Comment at: clang/docs/ClangFormatStyleOptions.rst:3130
 
-**PPIndentWidth** (``Integer``) :versionbadge:`clang-format 14`
+**PPIndentWidth** (``Integer``) :versionbadge:`clang-format 13`
   The number of columns to use for indentation of preprocessor statements.

Agreed,   https://reviews.llvm.org/D103286

{F21991078}



Comment at: clang/docs/ClangFormatStyleOptions.rst:3374
 
-**ReferenceAlignment** (``ReferenceAlignmentStyle``) 
:versionbadge:`clang-format 14`
+**ReferenceAlignment** (``ReferenceAlignmentStyle``) 
:versionbadge:`clang-format 13`
   Reference alignment style (overrides ``PointerAlignment`` for

Agreed https://reviews.llvm.org/D104096

{F21991083}



Comment at: clang/docs/ClangFormatStyleOptions.rst:3538
 
-**ShortNamespaceLines** (``Unsigned``) :versionbadge:`clang-format 14`
+**ShortNamespaceLines** (``Unsigned``) :versionbadge:`clang-format 13`
   The maximal number of unwrapped lines that a short namespace spans.

Agreed https://reviews.llvm.org/D87587

{F21991090}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118991

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


[PATCH] D118991: [clang-format][docs] Fix incorrect 'clang-format 14' configuration options markers

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

Hey @MyDeveloperDay,

Thank you for your positive feedback :)

You asked about my technique. Well, I did it empirically. There is a really 
splendid repository on GitHub by muttleyxd, i.e. 
https://github.com/muttleyxd/clang-tools-static-binaries. What muttleyxd did is 
he automated the task of compiling all major versions of clang tools (including 
clang-format) and he released it in form of static binaries to avoid problems 
with dependencies (they are really small though). Btw. I recommend you to at 
least save this as a bookmark in your web browser.

Having downloaded clang-format in versions 3.9 and from 4.0 to 13.0, I simply 
manually ran those binaries and looked for "unknown key" errors. I did that 
only for all options marked with "clang-format 14" tag, i.e.:
EmptyLineAfterAccessModifier
IfMacros
PPIndentWidth
PackConstructorInitializers
PenaltyBreakOpenParenthesis
QualifierAlignment
QualifierOrder
ReferenceAlignment
RemoveBracesLLVM
SeparateDefinitionBlocks
ShortNamespaceLines
SpaceBeforeParensOptions
SpacesInAngles
SpacesInLineCommentPrefix

The only problem I got was SpacesInAngles, which I actually checked using your 
technique, i.e. git-based rather than empirical one. I had to make it like that 
cause it was already available before 3.9, which is the earliest in muttleyxd's 
repository.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118991

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


[PATCH] D113319: [clang-format] Improve require and concept handling

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

I can just say: ship it!

Thanks for all the work!




Comment at: clang/lib/Format/ContinuationIndenter.cpp:1499-1500
+  if (State.NextToken->ClosesRequiresClause && Style.IndentRequiresClause) {
+// Remove the indentation of the requires clauses (which is not in Indent,
+// but in LastSpace).
+State.Stack.back().LastSpace -= Style.IndentWidth;

HazardyKnusperkeks wrote:
> curdeius wrote:
> > And why it is not in `Indent`?
> This one I tackled a month ago...
> If I remember correctly this is because the indentation is not from an 
> increased ``Level`` of the line, but because the position comes out of 
> ``getNewLineColumn``.
> The Level would only work if I would generate different UnwrappedLines 
> depending on the clause style, which currently I don't.
> The ``Indent`` is correctly reduced, but ``LastSpace`` stayed.
Ok. Roger.



Comment at: clang/lib/Format/TokenAnnotator.cpp:3900-3908
+  if (Right.is(TT_RequiresClause)) {
+switch (Style.RequiresClausePosition) {
+case FormatStyle::RCPS_OwnLine:
+case FormatStyle::RCPS_ToFollowing:
+  return true;
+default:
+  break;

HazardyKnusperkeks wrote:
> curdeius wrote:
> > The body of seems to be the exact same code as below in lines 3920-3926.
> > Maybe you can refactor to something like this?
> > Name of the lambda in my suggestion is maybe incorrect though.
> Here is not about indentation, it is about breaking the line. And the 
> difference is ``WithFollowing`` vs. ``WithPreceding``.
That's what I meant saying that the name might be  incorrect.



Comment at: clang/unittests/Format/FormatTest.cpp:3819-3822
+  verifyFormat("template \n"
+   "constexpr void foo\n"
+   "  requires(I == 42)\n"
+   "{}\n"

HazardyKnusperkeks wrote:
> curdeius wrote:
> > Do you test what was here previously with `RequiresClausePosition: 
> > SingleLine` (or whichever relevant option)?
> I don't understand the question.
> 
> Before we had no real handling of requires, which did something like a 
> combination of ``SingleLine`` and ``WithFollowing``.
> 
> I could have left the string in the test unchanged, but would have to set the 
> style to ``SingleLine``.
> 
> I thought it would be acceptable to change the test, since we basically only 
> now defined a default for LLVMStyle.
Fair enough.



Comment at: clang/unittests/Format/FormatTest.cpp:23249-23252
+  verifyFormat("template \n"
+   "concept C = [] -> bool { return true; }() && requires(T t) { "
+   "t.bar(); } &&\n"
+   "  sizeof(T) <= 8;");

HazardyKnusperkeks wrote:
> curdeius wrote:
> > How about adding a test case with the exact same concept body but 
> > surrounded with parens (e.g. using `decltype(...)`)?
> > The one below looks *almost* the same, but uses `std::true_type` and 
> > `::value` and so it's harder to transpose to what this test should look 
> > like.
> Where should the parens go?
> The misformatting is that `sizeof` is indented below `bool`, not below the 
> `l_square`.
Oh, right.


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

https://reviews.llvm.org/D113319

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


[PATCH] D116637: [Clang][Sema][OpenMP] Sema support for `atomic compare`

2022-02-05 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

In D116637#3298635 , @cmtice wrote:

> When building/running 
> third_party/llvm/llvm-project/clang/test/OpenMP/atomic_messages.c and 
> third_party/llvm/llvm-project/clang/test/OpenMP/atomic_ast_print.cpp, we get 
> use-of-uninitialized-variable error messages:
>
> SUMMARY: MemorySanitizer: use-of-uninitialized-value 
> third_party/llvm/llvm-project/clang/lib/Sema/SemaOpenMP.cpp:11214:40 in 
> (anonymous namespace)::OpenMPAtomicCompareChecker::checkType((anonymous 
> namespace)::OpenMPAtomicCompareChecker::ErrorInfoTy&) 
> const::$_57::operator()(clang::Expr const*, llvm::omp::OMPAtomicCompareOp, 
> bool) const
> Exiting
>
> You should probably look into this.

Thanks! It has been fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116637

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


[PATCH] D117091: [Clang] Add attributes alloc_size and alloc_align to mm_malloc

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

ping


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

https://reviews.llvm.org/D117091

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


[clang] 7119f76 - [clang] added allocsize attribute to allocation functions

2022-02-05 Thread Dávid Bolvanský via cfe-commits

Author: Dávid Bolvanský
Date: 2022-02-05T14:26:35+01:00
New Revision: 7119f76c47797391fddcfcb60f29e70a2b424713

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

LOG: [clang] added allocsize attribute to allocation functions

Added: 
clang/test/CodeGen/allocs-fns-allocsize.c

Modified: 
clang/lib/Sema/SemaDecl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index f2871d82b0409..fce33991c4aa4 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -15340,6 +15340,26 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl 
*FD) {
 default:
   break;
 }
+
+// Add allocsize attribute for allocation functions.
+switch (BuiltinID) {
+case Builtin::BIcalloc:
+  FD->addAttr(AllocSizeAttr::CreateImplicit(
+  Context, ParamIdx(1, FD), ParamIdx(2, FD), FD->getLocation()));
+  break;
+case Builtin::BImemalign:
+case Builtin::BIaligned_alloc:
+case Builtin::BIrealloc:
+  FD->addAttr(AllocSizeAttr::CreateImplicit(Context, ParamIdx(2, FD),
+ParamIdx(), 
FD->getLocation()));
+  break;
+case Builtin::BImalloc:
+  FD->addAttr(AllocSizeAttr::CreateImplicit(Context, ParamIdx(1, FD),
+ParamIdx(), 
FD->getLocation()));
+  break;
+default:
+  break;
+}
   }
 
   AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction(FD);

diff  --git a/clang/test/CodeGen/allocs-fns-allocsize.c 
b/clang/test/CodeGen/allocs-fns-allocsize.c
new file mode 100644
index 0..27133b252372e
--- /dev/null
+++ b/clang/test/CodeGen/allocs-fns-allocsize.c
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm < %s | 
FileCheck %s
+
+typedef __SIZE_TYPE__ size_t;
+
+void *malloc(size_t);
+void *calloc(size_t, size_t);
+void *realloc(void *, size_t);
+void *aligned_alloc(size_t, size_t);
+void *memalign(size_t, size_t);
+
+void *malloc_test(size_t n) {
+  return malloc(n);
+}
+
+void *calloc_test(size_t e, size_t n) {
+  return calloc(e, n);
+}
+
+void *realloc_test(void *p, size_t n) {
+  return realloc(p, n);
+}
+
+void *aligned_alloc_test(size_t n, size_t a) {
+  return aligned_alloc(a, n);
+}
+
+void *memalign_test(size_t n, size_t a) {
+  return memalign(a, n);
+}
+
+// CHECK: @malloc(i64 noundef) #1
+// CHECK: @calloc(i64 noundef, i64 noundef) #2
+// CHECK: @realloc(i8* noundef, i64 noundef) #3
+// CHECK: @aligned_alloc(i64 noundef, i64 noundef) #3
+// CHECK: @memalign(i64 noundef, i64 noundef) #3
+
+// CHECK: attributes #1 = { allocsize(0)
+// CHECK: attributes #2 = { allocsize(0,1)
+// CHECK: attributes #3 = { allocsize(1)



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


[PATCH] D119051: Fix pod-packed functionality to use the C++11 definition of pod-ness

2022-02-05 Thread Bhramar Vatsa via Phabricator via cfe-commits
Bhramar.vatsa added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1892
+  bool FieldPacked =
+  (Packed && (!FieldClass || D->getType().isCXX11PODType(Context) ||
+  Context.getLangOpts().getClangABICompat() <=

Maybe irrespective of the field's type itself, only important thing is just if 
it is a POD type or not?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119051

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


[PATCH] D84225: [CFE] Add nomerge function attribute to inline assembly.

2022-02-05 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang/lib/Sema/SemaStmtAttr.cpp:186
   void VisitCallExpr(const CallExpr *E) { FoundCallExpr = true; }
+  void VisitAsmStmt(const AsmStmt *S) { FoundCallExpr = true; }
 

This is totally wrong, just big hack to smuggle it here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84225

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


[PATCH] D117972: [PowerPC] Fix SSE translation on FreeBSD

2022-02-05 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added a comment.

In D117972#3287553 , @pkubaj wrote:

> Since I'm not a LLVM committer, can you commit it and merge to 14 branch?

Sure. Sorry for late response, I'm on vacation these days.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117972

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


[PATCH] D113319: [clang-format] Improve require and concept handling

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

- Fixed use of a variable which slipped in from another change.
- Rebased.


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

https://reviews.llvm.org/D113319

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  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
@@ -14,6 +14,14 @@
 
 namespace clang {
 namespace format {
+
+// Not really the equality, but everything we need.
+static bool operator==(const FormatToken &LHS,
+   const FormatToken &RHS) noexcept {
+  return LHS.Tok.getKind() == RHS.Tok.getKind() &&
+ LHS.getType() == RHS.getType();
+}
+
 namespace {
 
 class TokenAnnotatorTest : public ::testing::Test {
@@ -97,6 +105,261 @@
   EXPECT_TOKEN(Tokens[4], tok::l_brace, TT_Unknown);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsRequiresClausesAndConcepts) {
+  auto Tokens = annotate("template \n"
+ "concept C = (Foo && Bar) && (Bar && Baz);");
+
+  ASSERT_EQ(Tokens.size(), 21u) << Tokens;
+  EXPECT_TOKEN(Tokens[10], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[13], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[16], tok::ampamp, TT_BinaryOperator);
+
+  Tokens = annotate("template \n"
+"concept C = requires(T t) {\n"
+"  { t.foo() };\n"
+"} && Bar && Baz;");
+  ASSERT_EQ(Tokens.size(), 35u) << Tokens;
+  EXPECT_TOKEN(Tokens[23], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[28], tok::ampamp, TT_BinaryOperator);
+
+  Tokens = annotate("template\n"
+"requires C1 && (C21 || C22 && C2e) && C3\n"
+"struct Foo;");
+  ASSERT_EQ(Tokens.size(), 36u) << Tokens;
+  EXPECT_TOKEN(Tokens[6], tok::identifier, TT_Unknown);
+  EXPECT_EQ(Tokens[6]->FakeLParens.size(), 1u);
+  EXPECT_TOKEN(Tokens[10], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[16], tok::pipepipe, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[21], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[27], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[31], tok::greater, TT_TemplateCloser);
+  EXPECT_EQ(Tokens[31]->FakeRParens, 1u);
+  EXPECT_TRUE(Tokens[31]->ClosesRequiresClause);
+
+  Tokens =
+  annotate("template\n"
+   "requires (C1 && (C21 || C22 && C2e) && C3)\n"
+   "struct Foo;");
+  ASSERT_EQ(Tokens.size(), 38u) << Tokens;
+  EXPECT_TOKEN(Tokens[7], tok::identifier, TT_Unknown);
+  EXPECT_EQ(Tokens[7]->FakeLParens.size(), 1u);
+  EXPECT_TOKEN(Tokens[11], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[17], tok::pipepipe, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[22], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[28], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[32], tok::greater, TT_TemplateCloser);
+  EXPECT_EQ(Tokens[32]->FakeRParens, 1u);
+  EXPECT_TOKEN(Tokens[33], tok::r_paren, TT_Unknown);
+  EXPECT_TRUE(Tokens[33]->ClosesRequiresClause);
+}
+
+TEST_F(TokenAnnotatorTest, RequiresDoesNotChangeParsingOfTheRest) {
+  auto NumberOfAdditionalRequiresClauseTokens = 5u;
+  auto NumberOfTokensBeforeRequires = 5u;
+
+  auto BaseTokens = annotate("template\n"
+ "T Pi = 3.14;");
+  auto ConstrainedTokens = annotate("template\n"
+"  requires Foo\n"
+"T Pi = 3.14;");
+
+  auto NumberOfBaseTokens = 11u;
+
+  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
+  ASSERT_EQ(ConstrainedTokens.size(),
+NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
+  << ConstrainedTokens;
+
+  for (auto I = 0u; I < NumberOfBaseTokens; ++I)
+if (I < NumberOfTokensBeforeRequires)
+  EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I;
+else
+  EXPECT_EQ(*BaseTokens[I],
+*ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens])
+  << I;
+
+  BaseTokens = annotate("template\n"
+"struct Bar;");
+  ConstrainedTokens = annotate("template\n"
+   "  requires Foo\n"
+   "struct Bar;");
+  NumberOfBaseTokens = 9u;
+
+  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
+  ASSERT_EQ(ConstrainedTokens.size(),
+NumberOfBaseTokens + Number

[clang] f2f4080 - [PowerPC] Fix SSE translation on FreeBSD

2022-02-05 Thread Qiu Chaofan via cfe-commits

Author: Piotr Kubaj
Date: 2022-02-06T01:20:31+08:00
New Revision: f2f4080c10f4319adf75c660425911cd4e0e1843

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

LOG: [PowerPC] Fix SSE translation on FreeBSD

This patch drops throws specifier in posix_memalign declaration because
that's different between glibc and other libc, and Clang has a hack.

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

Added: 


Modified: 
clang/lib/Headers/ppc_wrappers/mm_malloc.h

Removed: 




diff  --git a/clang/lib/Headers/ppc_wrappers/mm_malloc.h 
b/clang/lib/Headers/ppc_wrappers/mm_malloc.h
index 86cf1a0f76180..b6bf22f928879 100644
--- a/clang/lib/Headers/ppc_wrappers/mm_malloc.h
+++ b/clang/lib/Headers/ppc_wrappers/mm_malloc.h
@@ -19,7 +19,7 @@
 #ifndef __cplusplus
 extern int posix_memalign (void **, size_t, size_t);
 #else
-extern "C" int posix_memalign (void **, size_t, size_t) throw ();
+extern "C" int posix_memalign (void **, size_t, size_t);
 #endif
 
 static __inline void *



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


[PATCH] D117972: [PowerPC] Fix SSE translation on FreeBSD

2022-02-05 Thread 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 rGf2f4080c10f4: [PowerPC] Fix SSE translation on FreeBSD 
(authored by pkubaj, committed by Qiu Chaofan ).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117972

Files:
  clang/lib/Headers/ppc_wrappers/mm_malloc.h


Index: clang/lib/Headers/ppc_wrappers/mm_malloc.h
===
--- clang/lib/Headers/ppc_wrappers/mm_malloc.h
+++ clang/lib/Headers/ppc_wrappers/mm_malloc.h
@@ -19,7 +19,7 @@
 #ifndef __cplusplus
 extern int posix_memalign (void **, size_t, size_t);
 #else
-extern "C" int posix_memalign (void **, size_t, size_t) throw ();
+extern "C" int posix_memalign (void **, size_t, size_t);
 #endif
 
 static __inline void *


Index: clang/lib/Headers/ppc_wrappers/mm_malloc.h
===
--- clang/lib/Headers/ppc_wrappers/mm_malloc.h
+++ clang/lib/Headers/ppc_wrappers/mm_malloc.h
@@ -19,7 +19,7 @@
 #ifndef __cplusplus
 extern int posix_memalign (void **, size_t, size_t);
 #else
-extern "C" int posix_memalign (void **, size_t, size_t) throw ();
+extern "C" int posix_memalign (void **, size_t, size_t);
 #endif
 
 static __inline void *
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118991: [clang-format][docs] Fix incorrect 'clang-format 14' configuration options markers

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

Do you need someone to land this for you? if so we need your "name 
"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118991

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


[PATCH] D118991: [clang-format][docs] Fix incorrect 'clang-format 14' configuration options markers

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

In D118991#3298823 , @MyDeveloperDay 
wrote:

> Do you need someone to land this for you? if so we need your "name 
> "

Yes, I need someone to do that. Could you do this for me, please? It's 
"Krystian Kuzniarek ". Thanks in advance.

P.S. I plan to continue with similar work in decreasing order of clang-format 
versions so firstly for "clang-format 13", secondly for 12, then 11, etc. If I 
find some more inaccuracies, I will prepare new Phabricator reviews for you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118991

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


LLVM build master will be restarted at 1PM PST

2022-02-05 Thread Galina Kistanova via cfe-commits
 Hello,

LLVM build master will be restarted at 1pm PST today.

Thanks

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


[libunwind] 527654d - [libunwind] Attempt to fix broken sphinx doc link

2022-02-05 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-02-05T21:05:01Z
New Revision: 527654dcebf83052ec05c087b98dd16c2313e9f9

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

LOG: [libunwind] Attempt to fix broken sphinx doc link

bbce75e352be0637305a1b59ac5eca7175bceece replaced `LLVM Bugzilla` with `LLVM 
bug tracker`

Added: 


Modified: 
libunwind/docs/index.rst

Removed: 




diff  --git a/libunwind/docs/index.rst b/libunwind/docs/index.rst
index 3597e757f59b5..99ee86c755f41 100644
--- a/libunwind/docs/index.rst
+++ b/libunwind/docs/index.rst
@@ -77,7 +77,7 @@ and `Getting started with LLVM 
`__.
 **Bug Reports**
 
 If you think you've found a bug in libunwind, please report it using
-the `LLVM Bugzilla`_. If you're not sure, you
+the `LLVM bug tracker`_. If you're not sure, you
 can post a message to the `cfe-dev mailing list`_ or on IRC.
 Please include "libunwind" in your subject.
 



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


[libunwind] 2b9554b - [libunwind] [sparc] Add SPARCv9 support

2022-02-05 Thread Fangrui Song via cfe-commits

Author: Koakuma
Date: 2022-02-05T13:08:26-08:00
New Revision: 2b9554b8850192bdd86c02eb671de1d866df8d87

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

LOG: [libunwind] [sparc] Add SPARCv9 support

Adds libunwind support for SPARCv9 (aka sparc64). This is a rebase of 
@kettenis' patch D32450, which I created (with his permission) because the 
original review has become inactive.
The changes are of a cosmetic nature to make it fit better with the new code 
style, and to reuse the existing SPARCv8 code, whenever possible.

Please let me know if I posted this on the wrong place. Also, the summary of 
the original review is reproduced below:

> This adds unwinder support for 64-bit SPARC (aka SPARCv9). The implementation 
> was done on OpenBSD/sparc64, so it takes StackGhost into account:
>
> https://www.usenix.org/legacy/publications/library/proceedings/sec01/full_papers/frantzen/frantzen_html/index.html
>
> Since StackGhost xor's return addresses with a random cookie before storing 
> them on the stack, the unwinder has to do some extra work to recover those. 
> This is done by introducing a new kRegisterInCFADecrypt "location" type that 
> is used to implement the DW_CFA_GNU_window_save opcode. That implementation 
> is SPARC-specific, but should work for 32-bit SPARC as well. 
> DW_CFA_GNU_window_save is only ever generated on SPARC as far as I know.

Co-authored-by: Mark Kettenis
Reviewed By: #libunwind, thesamesam, MaskRay, Arfrever

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

Added: 


Modified: 
libunwind/include/__libunwind_config.h
libunwind/src/DwarfInstructions.hpp
libunwind/src/DwarfParser.hpp
libunwind/src/Registers.hpp
libunwind/src/UnwindCursor.hpp
libunwind/src/UnwindRegistersRestore.S
libunwind/src/UnwindRegistersSave.S
libunwind/src/libunwind.cpp

Removed: 




diff  --git a/libunwind/include/__libunwind_config.h 
b/libunwind/include/__libunwind_config.h
index 67527d9da4042..e87bcf40034f3 100644
--- a/libunwind/include/__libunwind_config.h
+++ b/libunwind/include/__libunwind_config.h
@@ -23,6 +23,7 @@
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_OR1K  32
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS  65
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC 31
+#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC64   31
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_HEXAGON   34
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_RISCV 64
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_VE143
@@ -125,6 +126,12 @@
 #error "Unsupported MIPS ABI and/or environment"
 #  endif
 #  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS
+#elif defined(__sparc__) && defined(__arch64__)
+#define _LIBUNWIND_TARGET_SPARC64 1
+#define _LIBUNWIND_HIGHEST_DWARF_REGISTER  
\
+  _LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC64
+#define _LIBUNWIND_CONTEXT_SIZE 33
+#define _LIBUNWIND_CURSOR_SIZE 45
 # elif defined(__sparc__)
   #define _LIBUNWIND_TARGET_SPARC 1
   #define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC
@@ -165,6 +172,7 @@
 # define _LIBUNWIND_TARGET_MIPS_O32 1
 # define _LIBUNWIND_TARGET_MIPS_NEWABI 1
 # define _LIBUNWIND_TARGET_SPARC 1
+# define _LIBUNWIND_TARGET_SPARC64 1
 # define _LIBUNWIND_TARGET_HEXAGON 1
 # define _LIBUNWIND_TARGET_RISCV 1
 # define _LIBUNWIND_TARGET_VE 1

diff  --git a/libunwind/src/DwarfInstructions.hpp 
b/libunwind/src/DwarfInstructions.hpp
index 1c50941680b33..c1a241c55ce66 100644
--- a/libunwind/src/DwarfInstructions.hpp
+++ b/libunwind/src/DwarfInstructions.hpp
@@ -74,6 +74,13 @@ class DwarfInstructions {
   }
 };
 
+template 
+auto getSparcWCookie(const R &r, int) -> decltype(r.getWCookie()) {
+  return r.getWCookie();
+}
+template  uint64_t getSparcWCookie(const R &, long) {
+  return 0;
+}
 
 template 
 typename A::pint_t DwarfInstructions::getSavedRegister(
@@ -83,6 +90,10 @@ typename A::pint_t DwarfInstructions::getSavedRegister(
   case CFI_Parser::kRegisterInCFA:
 return (pint_t)addressSpace.getRegister(cfa + (pint_t)savedReg.value);
 
+  case CFI_Parser::kRegisterInCFADecrypt: // sparc64 specific
+return addressSpace.getP(cfa + (pint_t)savedReg.value) ^
+   getSparcWCookie(registers, 0);
+
   case CFI_Parser::kRegisterAtExpression:
 return (pint_t)addressSpace.getRegister(evaluateExpression(
 (pint_t)savedReg.value, addressSpace, registers, cfa));
@@ -124,6 +135,7 @@ double DwarfInstructions::getSavedFloatRegister(
   case CFI_Parser::kRegisterIsExpression:
   case CFI_Parser::kRegisterUnused:
   case CFI_Parser::kRegisterOffsetFromCFA:
+  case CFI_Parser::kRegisterInCFADecrypt:
 // FIX ME
 break;
   }
@@ -148,6 +160,7 @@ v128 DwarfInstructions::getSavedVectorRegister(
  

[PATCH] D118876: [HIPSPV] Fix literals are mapped to Generic address space

2022-02-05 Thread Yaxun Liu 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 rG171da443d598: [HIPSPV] Fix literals are mapped to Generic 
address space (authored by yaxunl).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118876

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenHIP/hipspv-addr-spaces.cpp


Index: clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
===
--- clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
+++ clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
@@ -22,6 +22,9 @@
   int* pi;
 } foo;
 
+// Check literals are placed in address space 1 (CrossWorkGroup/__global).
+// CHECK: @.str ={{.*}} unnamed_addr addrspace(1) constant
+
 // CHECK: define{{.*}} spir_func noundef i32 addrspace(4)* @_Z3barPi(i32 
addrspace(4)*
 __device__ int* bar(int *x) {
   return x;
@@ -44,3 +47,8 @@
   // CHECK: ret i32 addrspace(4)* addrspacecast (i32 addrspace(3)* @s to i32 
addrspace(4)*
   return &s;
 }
+
+// CHECK: define{{.*}} spir_func noundef i8 addrspace(4)* @_Z3quzv()
+__device__ const char* quz() {
+  return "abc";
+}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4381,6 +4381,14 @@
 return LangAS::opencl_constant;
   if (LangOpts.SYCLIsDevice)
 return LangAS::sycl_global;
+  if (LangOpts.HIP && LangOpts.CUDAIsDevice && getTriple().isSPIRV())
+// For HIPSPV map literals to cuda_device (maps to CrossWorkGroup in 
SPIR-V)
+// instead of default AS (maps to Generic in SPIR-V). Otherwise, we end up
+// with OpVariable instructions with Generic storage class which is not
+// allowed (SPIR-V V1.6 s3.42.8). Also, mapping literals to SPIR-V
+// UniformConstant storage class is not viable as pointers to it may not be
+// casted to Generic pointers which are used to model HIP's "flat" 
pointers.
+return LangAS::cuda_device;
   if (auto AS = getTarget().getConstantAddressSpace())
 return AS.getValue();
   return LangAS::Default;


Index: clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
===
--- clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
+++ clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
@@ -22,6 +22,9 @@
   int* pi;
 } foo;
 
+// Check literals are placed in address space 1 (CrossWorkGroup/__global).
+// CHECK: @.str ={{.*}} unnamed_addr addrspace(1) constant
+
 // CHECK: define{{.*}} spir_func noundef i32 addrspace(4)* @_Z3barPi(i32 addrspace(4)*
 __device__ int* bar(int *x) {
   return x;
@@ -44,3 +47,8 @@
   // CHECK: ret i32 addrspace(4)* addrspacecast (i32 addrspace(3)* @s to i32 addrspace(4)*
   return &s;
 }
+
+// CHECK: define{{.*}} spir_func noundef i8 addrspace(4)* @_Z3quzv()
+__device__ const char* quz() {
+  return "abc";
+}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4381,6 +4381,14 @@
 return LangAS::opencl_constant;
   if (LangOpts.SYCLIsDevice)
 return LangAS::sycl_global;
+  if (LangOpts.HIP && LangOpts.CUDAIsDevice && getTriple().isSPIRV())
+// For HIPSPV map literals to cuda_device (maps to CrossWorkGroup in SPIR-V)
+// instead of default AS (maps to Generic in SPIR-V). Otherwise, we end up
+// with OpVariable instructions with Generic storage class which is not
+// allowed (SPIR-V V1.6 s3.42.8). Also, mapping literals to SPIR-V
+// UniformConstant storage class is not viable as pointers to it may not be
+// casted to Generic pointers which are used to model HIP's "flat" pointers.
+return LangAS::cuda_device;
   if (auto AS = getTarget().getConstantAddressSpace())
 return AS.getValue();
   return LangAS::Default;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119063: [SemaCXX] Properly scope ArgumentPackSubstitutionIndex when expanding base types

2022-02-05 Thread Michael Colavita via Phabricator via cfe-commits
colavitam created this revision.
colavitam added reviewers: mizvekov, rsmith.
Herald added a subscriber: arphaman.
colavitam requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Resolve the crash in issue #53609. The ArgumentPackSubstitutionIndex
from expanding base types containing parameter packs should not persist
when we check the resulting types. Checking the types may lead to
template substitution in the base type, where the index will no longer
be valid.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119063

Files:
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/SemaCXX/template-base-class-pack-expansion.cpp


Index: clang/test/SemaCXX/template-base-class-pack-expansion.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/template-base-class-pack-expansion.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+// Don't crash (#53609).
+
+template  struct a;
+
+template  struct b;
+template 
+struct b...> {};
+
+template  struct c: b...  {};
+
+c d;
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2530,12 +2530,13 @@
   // If we should expand this pack expansion now, do so.
   if (ShouldExpand) {
 for (unsigned I = 0; I != *NumExpansions; ++I) {
+  {
 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, I);
 
-  TypeSourceInfo *BaseTypeLoc = SubstType(Base.getTypeSourceInfo(),
-  TemplateArgs,
-  Base.getSourceRange().getBegin(),
-  DeclarationName());
+BaseTypeLoc =
+SubstType(Base.getTypeSourceInfo(), TemplateArgs,
+  Base.getSourceRange().getBegin(), DeclarationName());
+  }
   if (!BaseTypeLoc) {
 Invalid = true;
 continue;


Index: clang/test/SemaCXX/template-base-class-pack-expansion.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/template-base-class-pack-expansion.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+// Don't crash (#53609).
+
+template  struct a;
+
+template  struct b;
+template 
+struct b...> {};
+
+template  struct c: b...  {};
+
+c d;
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2530,12 +2530,13 @@
   // If we should expand this pack expansion now, do so.
   if (ShouldExpand) {
 for (unsigned I = 0; I != *NumExpansions; ++I) {
+  {
 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, I);
 
-  TypeSourceInfo *BaseTypeLoc = SubstType(Base.getTypeSourceInfo(),
-  TemplateArgs,
-  Base.getSourceRange().getBegin(),
-  DeclarationName());
+BaseTypeLoc =
+SubstType(Base.getTypeSourceInfo(), TemplateArgs,
+  Base.getSourceRange().getBegin(), DeclarationName());
+  }
   if (!BaseTypeLoc) {
 Invalid = true;
 continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119063: [SemaCXX] Properly scope ArgumentPackSubstitutionIndex when expanding base types

2022-02-05 Thread Michael Colavita via Phabricator via cfe-commits
colavitam updated this revision to Diff 406213.
colavitam added a comment.

Fix comments for new test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119063

Files:
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/SemaCXX/template-base-class-pack-expansion.cpp


Index: clang/test/SemaCXX/template-base-class-pack-expansion.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/template-base-class-pack-expansion.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+// Don't crash (#53609).
+
+// expected-no-diagnostics
+
+template  struct a;
+
+template  struct b;
+template 
+struct b...> {};
+
+template  struct c: b...  {};
+
+c d;
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2530,12 +2530,13 @@
   // If we should expand this pack expansion now, do so.
   if (ShouldExpand) {
 for (unsigned I = 0; I != *NumExpansions; ++I) {
+  {
 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, I);
 
-  TypeSourceInfo *BaseTypeLoc = SubstType(Base.getTypeSourceInfo(),
-  TemplateArgs,
-  Base.getSourceRange().getBegin(),
-  DeclarationName());
+BaseTypeLoc =
+SubstType(Base.getTypeSourceInfo(), TemplateArgs,
+  Base.getSourceRange().getBegin(), DeclarationName());
+  }
   if (!BaseTypeLoc) {
 Invalid = true;
 continue;


Index: clang/test/SemaCXX/template-base-class-pack-expansion.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/template-base-class-pack-expansion.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+// Don't crash (#53609).
+
+// expected-no-diagnostics
+
+template  struct a;
+
+template  struct b;
+template 
+struct b...> {};
+
+template  struct c: b...  {};
+
+c d;
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2530,12 +2530,13 @@
   // If we should expand this pack expansion now, do so.
   if (ShouldExpand) {
 for (unsigned I = 0; I != *NumExpansions; ++I) {
+  {
 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, I);
 
-  TypeSourceInfo *BaseTypeLoc = SubstType(Base.getTypeSourceInfo(),
-  TemplateArgs,
-  Base.getSourceRange().getBegin(),
-  DeclarationName());
+BaseTypeLoc =
+SubstType(Base.getTypeSourceInfo(), TemplateArgs,
+  Base.getSourceRange().getBegin(), DeclarationName());
+  }
   if (!BaseTypeLoc) {
 Invalid = true;
 continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 171da44 - [HIPSPV] Fix literals are mapped to Generic address space

2022-02-05 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2022-02-05T17:26:52-05:00
New Revision: 171da443d598662371f4101f0ba92c0138011ff6

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

LOG: [HIPSPV] Fix literals are mapped to Generic address space

This issue is an oversight in D108621.

Literals in HIP are emitted as global constant variables with default
address space which maps to Generic address space for HIPSPV. In
SPIR-V such variables translate to OpVariable instructions with
Generic storage class which are not legal. Fix by mapping literals
to CrossWorkGroup address space.

The literals are not mapped to UniformConstant because the “flat”
pointers in HIP may reference them and “flat” pointers are modeled
as Generic pointers in SPIR-V. In SPIR-V/OpenCL UniformConstant
pointers may not be casted to Generic.

Patch by: Henry Linjamäki

Reviewed by: Yaxun Liu

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenHIP/hipspv-addr-spaces.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 5ffb954642a6b..a8f0892f0e8f4 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4381,6 +4381,14 @@ LangAS CodeGenModule::GetGlobalConstantAddressSpace() 
const {
 return LangAS::opencl_constant;
   if (LangOpts.SYCLIsDevice)
 return LangAS::sycl_global;
+  if (LangOpts.HIP && LangOpts.CUDAIsDevice && getTriple().isSPIRV())
+// For HIPSPV map literals to cuda_device (maps to CrossWorkGroup in 
SPIR-V)
+// instead of default AS (maps to Generic in SPIR-V). Otherwise, we end up
+// with OpVariable instructions with Generic storage class which is not
+// allowed (SPIR-V V1.6 s3.42.8). Also, mapping literals to SPIR-V
+// UniformConstant storage class is not viable as pointers to it may not be
+// casted to Generic pointers which are used to model HIP's "flat" 
pointers.
+return LangAS::cuda_device;
   if (auto AS = getTarget().getConstantAddressSpace())
 return AS.getValue();
   return LangAS::Default;

diff  --git a/clang/test/CodeGenHIP/hipspv-addr-spaces.cpp 
b/clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
index 8f56f2104ecbd..bde360eec8cd9 100644
--- a/clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
+++ b/clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
@@ -22,6 +22,9 @@ __device__ struct foo_t {
   int* pi;
 } foo;
 
+// Check literals are placed in address space 1 (CrossWorkGroup/__global).
+// CHECK: @.str ={{.*}} unnamed_addr addrspace(1) constant
+
 // CHECK: define{{.*}} spir_func noundef i32 addrspace(4)* @_Z3barPi(i32 
addrspace(4)*
 __device__ int* bar(int *x) {
   return x;
@@ -44,3 +47,8 @@ __device__ int* baz_s() {
   // CHECK: ret i32 addrspace(4)* addrspacecast (i32 addrspace(3)* @s to i32 
addrspace(4)*
   return &s;
 }
+
+// CHECK: define{{.*}} spir_func noundef i8 addrspace(4)* @_Z3quzv()
+__device__ const char* quz() {
+  return "abc";
+}



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


[PATCH] D118711: [hack] Build a tree of preprocessing directives

2022-02-05 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood updated this revision to Diff 406220.
LegalizeAdulthood added a comment.

- Use LLVM RTTI for PP node types
- Add routines to dump PP nodes


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

https://reviews.llvm.org/D118711

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
  clang-tools-extra/clang-tidy/utils/CMakeLists.txt
  clang-tools-extra/clang-tidy/utils/PPTree.cpp
  clang-tools-extra/clang-tidy/utils/PPTree.h

Index: clang-tools-extra/clang-tidy/utils/PPTree.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/utils/PPTree.h
@@ -0,0 +1,376 @@
+//===-- PPTree.h - clang-tidy -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PPTREE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PPTREE_H
+
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Token.h"
+#include 
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+class PPDirective {
+public:
+  enum DirectiveKind {
+DK_Inclusion,
+DK_Ident,
+DK_Pragma,
+DK_PragmaComment,
+DK_PragmaMark,
+DK_PragmaDetectMismatch,
+DK_PragmaDebug,
+DK_PragmaMessage,
+DK_MacroDefined,
+DK_MacroUndefined,
+DK_If,
+DK_Else,
+DK_ElseIf,
+DK_IfDef,
+DK_IfNotDef,
+DK_ElseIfDef,
+DK_ElseIfNotDef,
+DK_EndIf,
+  };
+
+  virtual ~PPDirective() = default;
+
+  DirectiveKind getKind() const { return Kind; }
+
+protected:
+  PPDirective(DirectiveKind Kind) : Kind(Kind) {}
+
+private:
+  DirectiveKind Kind;
+};
+
+using PPDirectiveStorage = std::vector;
+
+class PPDirectiveList {
+public:
+  void add(PPDirective *Dir) { Directives.emplace_back(Dir); }
+
+  ~PPDirectiveList() {
+for (PPDirective *Dir : Directives)
+  delete Dir;
+Directives.clear();
+  }
+
+  PPDirectiveStorage::iterator begin() { return Directives.begin(); }
+  PPDirectiveStorage::iterator end() { return Directives.end(); }
+
+  PPDirectiveStorage::const_iterator begin() const {
+return Directives.begin();
+  }
+  PPDirectiveStorage::const_iterator end() const { return Directives.end(); }
+
+  size_t size() const { return Directives.size(); }
+
+private:
+  PPDirectiveStorage Directives;
+};
+
+class PPInclusion : public PPDirective {
+public:
+  PPInclusion(SourceLocation HashLoc, Token IncludeTok, StringRef FileName,
+  bool IsAngled, CharSourceRange FilenameRange,
+  const FileEntry *File, StringRef SearchPath,
+  StringRef RelativePath, const Module *Imported,
+  SrcMgr::CharacteristicKind FileType)
+  : PPDirective(DK_Inclusion), HashLoc(HashLoc), IncludeTok(IncludeTok),
+FileName(FileName.str()), IsAngled(IsAngled),
+FilenameRange(FilenameRange), File(File), SearchPath(SearchPath.str()),
+RelativePath(RelativePath.str()), Imported(Imported),
+FileType(FileType) {}
+
+  static bool classof(const PPDirective *D) { return D->getKind() == DK_Inclusion; }
+
+  SourceLocation HashLoc;
+  Token IncludeTok;
+  std::string FileName;
+  bool IsAngled;
+  CharSourceRange FilenameRange;
+  const FileEntry *File;
+  std::string SearchPath;
+  std::string RelativePath;
+  const Module *Imported;
+  SrcMgr::CharacteristicKind FileType;
+};
+
+class PPIdent : public PPDirective {
+public:
+  PPIdent(SourceLocation Loc, StringRef Str)
+  : PPDirective(DK_Ident), Loc(Loc), Str(Str.str()) {}
+
+  static bool classof(const PPDirective *D) { return D->getKind() == DK_Ident; }
+
+  SourceLocation Loc;
+  std::string Str;
+};
+
+class PPPragma : public PPDirective {
+public:
+  PPPragma(SourceLocation Loc, PragmaIntroducerKind Introducer)
+  : PPDirective(DK_Pragma), Loc(Loc), Introducer(Introducer) {}
+
+  static bool classof(const PPDirective *D) {
+return D->getKind() == DK_Pragma;
+  }
+
+  SourceLocation Loc;
+  PragmaIntroducerKind Introducer;
+};
+
+class PPPragmaComment : public PPDirective {
+public:
+  PPPragmaComment(SourceLocation Loc, const IdentifierInfo *Kind, StringRef Str)
+  : PPDirective(DK_PragmaComment), Loc(Loc), Kind(Kind), Str(Str.str()) {}
+
+  static bool classof(const PPDirective *D) {
+return D->getKind() == DK_PragmaComment;
+  }
+
+  SourceLocation Loc;
+  const IdentifierInfo *Kind;
+  std::string Str;
+};
+
+class PPPragmaMark : public PPDirective {
+public:
+  PPPragmaMark(SourceLocation Loc, StringRef Trivia)
+  : PPDirective(DK_PragmaMark), Loc(Loc), Trivia(Trivia.str()) {}
+
+  static bool classof(const PPDirective *D) {
+return D->getKind(

[PATCH] D119026: [HIP] Emit amdgpu_code_object_version module flag

2022-02-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:575
+// times 100.
+if (getTarget().getTargetOpts().CodeObjectVersion != "none") {
+  unsigned CodeObjVer;

tra wrote:
> yaxunl wrote:
> > tra wrote:
> > > When will it ever be set to `none`? Does the new option parser enforce 
> > > the default & version values specified in the tablegen?
> > > If so, then it should never be `none`.
> > > If the `Values` specified for the option are not enforced, then the 
> > > condition will be true if user specifies any invalid value other than 
> > > `none`.
> > > 
> > Normal HIP programs should only use `-mcode-object-version={2|3|4|5}`. 
> > clang driver enforces that.
> > 
> > ROCm device library need to be compiled with `-Xclang 
> > -mcode-object-version=none` so that the module flag is not emitted. Since 
> > this use case is not for common users,  `-mcode-object-version=none` can 
> > only be used with -cc1.
> I'm surprised that cc1 does not check option validity. It does check them at 
> the driver level: https://godbolt.org/z/9T6n47es9
> 
> Assuming that's intentional, and there are no checks in cc1, then we should 
> probably remove the now-useless `Values` from the option tablegen and add a 
> test to verify what happens with invalid values.
> 
> 
I will use MarshallingInfoEnum, which will check the values. Will add a test 
for invalid values.


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

https://reviews.llvm.org/D119026

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


[PATCH] D119026: [HIP] Emit amdgpu_code_object_version module flag

2022-02-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 406221.
yaxunl marked an inline comment as done.
yaxunl added a comment.

marshalling the arg as enum. fix test failures for -cc1as. temporarily disable 
it except v5.


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

https://reviews.llvm.org/D119026

Files:
  clang/include/clang/Basic/TargetOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenCUDA/amdgpu-asan-printf.cu
  clang/test/CodeGenCUDA/amdgpu-asan.cu
  clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
  clang/test/Driver/hip-code-object-version.hip

Index: clang/test/Driver/hip-code-object-version.hip
===
--- clang/test/Driver/hip-code-object-version.hip
+++ clang/test/Driver/hip-code-object-version.hip
@@ -34,6 +34,7 @@
 // RUN:   %s 2>&1 | FileCheck -check-prefix=V3 %s
 
 // V3-WARN: warning: argument '-mcode-object-v3' is deprecated, use '-mcode-object-version=3' instead [-Wdeprecated]
+// V3: "-mcode-object-version=3"
 // V3: "-mllvm" "--amdhsa-code-object-version=3"
 // V3: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
 
@@ -44,6 +45,7 @@
 // RUN:   --offload-arch=gfx906 -nogpulib \
 // RUN:   %s 2>&1 | FileCheck -check-prefix=V4 %s
 
+// V4: "-mcode-object-version=4"
 // V4: "-mllvm" "--amdhsa-code-object-version=4"
 // V4: "-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx906"
 
@@ -54,6 +56,7 @@
 // RUN:   --offload-arch=gfx906 -nogpulib \
 // RUN:   %s 2>&1 | FileCheck -check-prefix=V5 %s
 
+// V5: "-mcode-object-version=5"
 // V5: "-mllvm" "--amdhsa-code-object-version=5"
 // V5: "-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx906"
 
Index: clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
@@ -0,0 +1,26 @@
+// Create module flag for code object version.
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -o - %s | FileCheck %s -check-prefix=NONE
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -mcode-object-version=2 -o - %s | FileCheck -check-prefix=NONE %s
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -mcode-object-version=3 -o - %s | FileCheck -check-prefix=NONE %s
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -mcode-object-version=4 -o - %s | FileCheck -check-prefix=NONE %s
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -mcode-object-version=5 -o - %s | FileCheck -check-prefix=V5 %s
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -mcode-object-version=none -o - %s | FileCheck %s -check-prefix=NONE
+
+// RUN: not %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -mcode-object-version=4.1 -o - %s 2>&1| FileCheck %s -check-prefix=INV
+
+// V5: !{{.*}} = !{i32 1, !"amdgpu_code_object_version", i32 500}
+// NONE-NOT: !{{.*}} = !{i32 1, !"amdgpu_code_object_version",
+// INV: error: invalid value '4.1' in '-mcode-object-version=4.1'
Index: clang/test/CodeGenCUDA/amdgpu-asan.cu
===
--- clang/test/CodeGenCUDA/amdgpu-asan.cu
+++ clang/test/CodeGenCUDA/amdgpu-asan.cu
@@ -27,8 +27,7 @@
 // ASAN-DAG: @llvm.compiler.used = {{.*}}@__amdgpu_device_library_preserve_asan_functions_ptr
 // ASAN-DAG: define weak void @__asan_report_load1(i64 %{{.*}})
 
-// MFCHECK: !llvm.module.flags = !{![[FLAG1:[0-9]+]], ![[FLAG2:[0-9]+]]}
-// MFCHECK: ![[FLAG1]] = !{i32 4, !"amdgpu_hostcall", i32 1}
+// MFCHECK: !{{.*}} = !{i32 4, !"amdgpu_hostcall", i32 1}
 
 // CHECK-NOT: @__amdgpu_device_library_preserve_asan_functions
 // CHECK-NOT: @__asan_report_load1
Index: clang/test/CodeGenCUDA/amdgpu-asan-printf.cu
===
--- clang/test/CodeGenCUDA/amdgpu-asan-printf.cu
+++ clang/test/CodeGenCUDA/amdgpu-asan-printf.cu
@@ -2,8 +2,7 @@
 // RUN:   -fcuda-is-device -target-cpu gfx906 -fsanitize=address \
 // RUN:   -O3 -x hip | FileCheck -check-prefixes=MFCHECK %s
 
-// MFCHECK: !llvm.module.flags = !{![[FLAG1:[0-9]+]], ![[FLAG2:[0-9]+]]}
-// MFCHECK: ![[FLAG1]] = !{i32 4, !"amdgpu_hostcall", i32 1}
+// MFCHECK: !{{.*}} = !{i32 4, !"amdgpu_hostcall", i32 1}
 
 // Test to check hostcall module flag metadata is generated correctly
 // when a program has printf call and compiled with -fsanitize=address.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1150,7 +1150,8 @@
 }
 static void handleAMDGPUCodeObjectVersionOptions(const Driver &D

[PATCH] D119067: [clang-format] Fix DefinitionBlockSeparator extra empty lines

2022-02-05 Thread ksyx via Phabricator via cfe-commits
ksyx created this revision.
ksyx added reviewers: MyDeveloperDay, curdeius, HazardyKnusperkeks.
ksyx added a project: clang-format.
ksyx requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This commit fixes https://github.com/llvm/llvm-project/issues/53229, in
which keywords like class and struct in a line ending with left brace or
whose next line is left brace only, will be falsely recognized as
definition line, causing extra empty lines inserted surrounding blocks
with no need to be formatted.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119067

Files:
  clang/lib/Format/DefinitionBlockSeparator.cpp
  clang/unittests/Format/DefinitionBlockSeparatorTest.cpp

Index: clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
===
--- clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
+++ clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
@@ -302,6 +302,9 @@
   "\n"
   "int bar2(int j, int k) {\n"
   "  int r = j / k;\n"
+  "  if (struct S = getS()) {\n"
+  "// if condition\n"
+  "  }\n"
   "  return r;\n"
   "}\n"
   "\n"
@@ -355,6 +358,9 @@
 "\n"
 "int bar2(int j, int k) {\n"
 "  int r = j / k;\n"
+"  if (struct S = getS()) {\n"
+"// if condition\n"
+"  }\n"
 "  return r;\n"
 "}\n"
 "\n"
@@ -412,6 +418,10 @@
"int bar2(int j, int k)\n"
"{\n"
"  int r = j / k;\n"
+   "  if (struct S = getS())\n"
+   "  {\n"
+   "// if condition\n"
+   "  }\n"
"  return r;\n"
"}\n"
"\n"
@@ -465,6 +475,9 @@
 "\n"
 "int bar2(int j, int k) {\n"
 "  int r = j / k;\n"
+"  if (struct S = getS()) {\n"
+"// if condition\n"
+"  }\n"
 "  return r;\n"
 "}\n"
 "\n"
Index: clang/lib/Format/DefinitionBlockSeparator.cpp
===
--- clang/lib/Format/DefinitionBlockSeparator.cpp
+++ clang/lib/Format/DefinitionBlockSeparator.cpp
@@ -35,18 +35,31 @@
   const bool IsNeverStyle =
   Style.SeparateDefinitionBlocks == FormatStyle::SDS_Never;
   const AdditionalKeywords &ExtraKeywords = Tokens.getKeywords();
-  auto LikelyDefinition = [this, ExtraKeywords](const AnnotatedLine *Line,
-bool ExcludeEnum = false) {
+  auto GetBracketLevelChange = [](const FormatToken *Tok) {
+if (Tok->isOneOf(tok::l_brace, tok::l_paren, tok::l_square))
+  return 1;
+else if (Tok->isOneOf(tok::r_brace, tok::r_paren, tok::r_square))
+  return -1;
+else
+  return 0;
+  };
+  auto LikelyDefinition = [&](const AnnotatedLine *Line,
+  bool ExcludeEnum = false) {
 if ((Line->MightBeFunctionDecl && Line->mightBeFunctionDefinition()) ||
 Line->startsWithNamespace())
   return true;
 FormatToken *CurrentToken = Line->First;
+int BracketLevel = 0;
 while (CurrentToken) {
-  if (CurrentToken->isOneOf(tok::kw_class, tok::kw_struct) ||
-  (Style.isJavaScript() && CurrentToken->is(ExtraKeywords.kw_function)))
-return true;
-  if (!ExcludeEnum && CurrentToken->is(tok::kw_enum))
-return true;
+  if (BracketLevel == 0) {
+if ((CurrentToken->isOneOf(tok::kw_class, tok::kw_struct) ||
+ (Style.isJavaScript() &&
+  CurrentToken->is(ExtraKeywords.kw_function
+  return true;
+if (!ExcludeEnum && CurrentToken->is(tok::kw_enum))
+  return true;
+  }
+  BracketLevel += GetBracketLevelChange(CurrentToken);
   CurrentToken = CurrentToken->Next;
 }
 return false;
@@ -104,11 +117,15 @@
 const auto HasEnumOnLine = [&]() {
   FormatToken *CurrentToken = CurrentLine->First;
   bool FoundEnumKeyword = false;
+  int BracketLevel = 0;
   while (CurrentToken) {
-if (CurrentToken->is(tok::kw_enum))
-  FoundEnumKeyword = true;
-else if (FoundEnumKeyword && CurrentToken->is(tok::l_brace))
-  return true;
+if (BracketLevel == 0) {
+  if (CurrentToken->is(tok::kw_enum))
+FoundEnumKeyword = true;
+  else if (FoundEnumKeyword && CurrentToken->is(tok::l_brace))
+return true;
+}
+BracketLevel += Get

[clang] 6cd0015 - [clang-format][docs] Fix incorrect 'clang-format 14' option markers

2022-02-05 Thread via cfe-commits

Author: Krystian Kuzniarek
Date: 2022-02-05T20:04:39-08:00
New Revision: 6cd0015e7827dd429844a18b7c8306e1d98044e4

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

LOG: [clang-format][docs] Fix incorrect 'clang-format 14' option markers

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

Note: Even though the value type of 'SpacesInAngles' option changed,
this option has been already present since version 3.4.

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

Added: 


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

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index bc1c2944c3961..d610c19faf2b6 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -2209,7 +2209,7 @@ the configuration (without a prefix: ``Auto``).
 **DisableFormat** (``Boolean``) :versionbadge:`clang-format 3.7`
   Disables formatting completely.
 
-**EmptyLineAfterAccessModifier** (``EmptyLineAfterAccessModifierStyle``) 
:versionbadge:`clang-format 14`
+**EmptyLineAfterAccessModifier** (``EmptyLineAfterAccessModifierStyle``) 
:versionbadge:`clang-format 13`
   Defines when to put an empty line after access modifiers.
   ``EmptyLineBeforeAccessModifier`` configuration handles the number of
   empty lines between two access modifiers.
@@ -2375,7 +2375,7 @@ the configuration (without a prefix: ``Auto``).
 
   For example: BOOST_FOREACH.
 
-**IfMacros** (``List of Strings``) :versionbadge:`clang-format 14`
+**IfMacros** (``List of Strings``) :versionbadge:`clang-format 13`
   A vector of macros that should be interpreted as conditionals
   instead of as function calls.
 
@@ -3127,7 +3127,7 @@ the configuration (without a prefix: ``Auto``).
   Add a space in front of an Objective-C protocol list, i.e. use
   ``Foo `` instead of ``Foo``.
 
-**PPIndentWidth** (``Integer``) :versionbadge:`clang-format 14`
+**PPIndentWidth** (``Integer``) :versionbadge:`clang-format 13`
   The number of columns to use for indentation of preprocessor statements.
   When set to -1 (default) ``IndentWidth`` is used also for preprocessor
   statements.
@@ -3371,7 +3371,7 @@ the configuration (without a prefix: ``Auto``).
   BasedOnStyle: llvm
   CanonicalDelimiter: 'cc'
 
-**ReferenceAlignment** (``ReferenceAlignmentStyle``) 
:versionbadge:`clang-format 14`
+**ReferenceAlignment** (``ReferenceAlignmentStyle``) 
:versionbadge:`clang-format 13`
   Reference alignment style (overrides ``PointerAlignment`` for
   references).
 
@@ -3535,7 +3535,7 @@ the configuration (without a prefix: ``Auto``).
 
 
 
-**ShortNamespaceLines** (``Unsigned``) :versionbadge:`clang-format 14`
+**ShortNamespaceLines** (``Unsigned``) :versionbadge:`clang-format 13`
   The maximal number of unwrapped lines that a short namespace spans.
   Defaults to 1.
 
@@ -3969,7 +3969,7 @@ the configuration (without a prefix: ``Auto``).
} // foo
  }
 
-**SpacesInAngles** (``SpacesInAnglesStyle``) :versionbadge:`clang-format 14`
+**SpacesInAngles** (``SpacesInAnglesStyle``) :versionbadge:`clang-format 3.4`
   The SpacesInAnglesStyle to use for template argument lists.
 
   Possible values:
@@ -4024,7 +4024,7 @@ the configuration (without a prefix: ``Auto``).
  var arr = [ 1, 2, 3 ]; vs. var arr = [1, 2, 3];
  f({a : 1, b : 2, c : 3});  f({a: 1, b: 2, c: 3});
 
-**SpacesInLineCommentPrefix** (``SpacesInLineComment``) 
:versionbadge:`clang-format 14`
+**SpacesInLineCommentPrefix** (``SpacesInLineComment``) 
:versionbadge:`clang-format 13`
   How many spaces are allowed at the start of a line comment. To disable the
   maximum set it to ``-1``, apart from that the maximum takes precedence
   over the minimum.

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 326e85305c8e7..ee90a64f04df0 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2110,7 +2110,7 @@ struct FormatStyle {
   /// Defines when to put an empty line after access modifiers.
   /// ``EmptyLineBeforeAccessModifier`` configuration handles the number of
   /// empty lines between two access modifiers.
-  /// \version 14
+  /// \version 13
   EmptyLineAfterAccessModifierStyle EmptyLineAfterAccessModifier;
 
   /// Different styles for empty line before access modifiers.
@@ -2285,7 +2285,7 @@ struct FormatStyle {
   ///
   /// For example: `KJ_IF_MAYBE
   /// 
`_
-  /// \version 14
+  /// \version 13
   std::vector IfMacros;
 
   /// \brief

[PATCH] D118991: [clang-format][docs] Fix incorrect 'clang-format 14' configuration options markers

2022-02-05 Thread Owen Pan 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 rG6cd0015e7827: [clang-format][docs] Fix incorrect 
'clang-format 14' option markers (authored by kuzkry, committed by 
owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118991

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

Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -2110,7 +2110,7 @@
   /// Defines when to put an empty line after access modifiers.
   /// ``EmptyLineBeforeAccessModifier`` configuration handles the number of
   /// empty lines between two access modifiers.
-  /// \version 14
+  /// \version 13
   EmptyLineAfterAccessModifierStyle EmptyLineAfterAccessModifier;
 
   /// Different styles for empty line before access modifiers.
@@ -2285,7 +2285,7 @@
   ///
   /// For example: `KJ_IF_MAYBE
   /// `_
-  /// \version 14
+  /// \version 13
   std::vector IfMacros;
 
   /// \brief A vector of macros that should be interpreted as type declarations
@@ -2956,7 +2956,7 @@
   ///# define BAR
   ///#endif
   /// \endcode
-  /// \version 14
+  /// \version 13
   int PPIndentWidth;
 
   /// See documentation of ``RawStringFormats``.
@@ -3042,7 +3042,7 @@
 
   /// \brief Reference alignment style (overrides ``PointerAlignment`` for
   /// references).
-  /// \version 14
+  /// \version 13
   ReferenceAlignmentStyle ReferenceAlignment;
 
   // clang-format off
@@ -3193,7 +3193,7 @@
   ///  int bar;   int bar;
   ///} // namespace b   } // namespace b
   /// \endcode
-  /// \version 14
+  /// \version 13
   unsigned ShortNamespaceLines;
 
   /// Include sorting options.
@@ -3610,7 +3610,7 @@
 SIAS_Leave
   };
   /// The SpacesInAnglesStyle to use for template argument lists.
-  /// \version 14
+  /// \version 3.4
   SpacesInAnglesStyle SpacesInAngles;
 
   /// If ``true``, spaces will be inserted around if/for/switch/while
@@ -3678,7 +3678,7 @@
   ///   ///  - Foo/// - Foo
   ///   ///- Bar  ///   - Bar
   /// \endcode
-  /// \version 14
+  /// \version 13
   SpacesInLineComment SpacesInLineCommentPrefix;
 
   /// If ``true``, spaces will be inserted after ``(`` and before ``)``.
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -2209,7 +2209,7 @@
 **DisableFormat** (``Boolean``) :versionbadge:`clang-format 3.7`
   Disables formatting completely.
 
-**EmptyLineAfterAccessModifier** (``EmptyLineAfterAccessModifierStyle``) :versionbadge:`clang-format 14`
+**EmptyLineAfterAccessModifier** (``EmptyLineAfterAccessModifierStyle``) :versionbadge:`clang-format 13`
   Defines when to put an empty line after access modifiers.
   ``EmptyLineBeforeAccessModifier`` configuration handles the number of
   empty lines between two access modifiers.
@@ -2375,7 +2375,7 @@
 
   For example: BOOST_FOREACH.
 
-**IfMacros** (``List of Strings``) :versionbadge:`clang-format 14`
+**IfMacros** (``List of Strings``) :versionbadge:`clang-format 13`
   A vector of macros that should be interpreted as conditionals
   instead of as function calls.
 
@@ -3127,7 +3127,7 @@
   Add a space in front of an Objective-C protocol list, i.e. use
   ``Foo `` instead of ``Foo``.
 
-**PPIndentWidth** (``Integer``) :versionbadge:`clang-format 14`
+**PPIndentWidth** (``Integer``) :versionbadge:`clang-format 13`
   The number of columns to use for indentation of preprocessor statements.
   When set to -1 (default) ``IndentWidth`` is used also for preprocessor
   statements.
@@ -3371,7 +3371,7 @@
   BasedOnStyle: llvm
   CanonicalDelimiter: 'cc'
 
-**ReferenceAlignment** (``ReferenceAlignmentStyle``) :versionbadge:`clang-format 14`
+**ReferenceAlignment** (``ReferenceAlignmentStyle``) :versionbadge:`clang-format 13`
   Reference alignment style (overrides ``PointerAlignment`` for
   references).
 
@@ -3535,7 +3535,7 @@
 
 
 
-**ShortNamespaceLines** (``Unsigned``) :versionbadge:`clang-format 14`
+**ShortNamespaceLines** (``Unsigned``) :versionbadge:`clang-format 13`
   The maximal number of unwrapped lines that a short namespace spans.
   Defaults to 1.
 
@@ -3969,7 +3969,7 @@
} // foo
  }
 
-**SpacesInAngles** (``SpacesInAnglesStyle``) :versionbadge:`clang-format 14`
+**SpacesInAngles** (``SpacesInAnglesStyle``) :versionbadge:`clang-format 3.4`
   The SpacesInAnglesStyle to use for template argument lists.
 
   Possible values:
@@ -4024,7 +4024,7 @@