[PATCH] D116326: [CodeCompletion] Signature help for aggregate initialization.

2022-01-03 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 added inline comments.



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:3699
+  unsigned ChunkIndex = 0;
+  auto AddChunk = [&](std::string Placeholder) {
+if (ChunkIndex > 0)

nit: const ref.



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:6018
+//   after `S{.b=1,`  we want to suggest c to continue
+//   after `S{.b=1, 2,`   we continue with d (this is legal C and ext in C++)
+//

Can you also add detail for out-of-order designated initialisation.
`S{.c=1, .b=2,`  (valid C, invalid C++, ext in C++)
IIUC the current version would continue with `c` here. (reasoning: promoting 
in-order designated initialisation ?)



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:6056
+  // (Probing getParamDecl() directly would be quadratic in number of fields).
+  unsigned AggregateSize = Aggregate.getNumParams();
+  unsigned DesignatedIndex = 0;

nit: move closer to usage below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116326

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


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

2022-01-03 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 397206.
achieveartificialintelligence added a comment.

Use `DAGOperand` instead of `RegisterOperand`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

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

Index: llvm/test/MC/RISCV/rvzhinx-aliases-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvzhinx-aliases-valid.s
@@ -0,0 +1,49 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zhinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zhinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zhinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zhinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zhinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zhinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zhinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zhinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+
+##===--===##
+## Aliases which omit the rounding mode.
+##===--===##
+
+# CHECK-INST: fmadd.h a0, a1, a2, a3, dyn
+# CHECK-ALIAS: fmadd.h a0, a1, a2, a3
+fmadd.h x10, x11, x12, x13
+# CHECK-INST: fmsub.h a4, a5, a6, a7, dyn
+# CHECK-ALIAS: fmsub.h a4, a5, a6, a7
+fmsub.h x14, x15, x16, x17
+# CHECK-INST: fnmsub.h s2, s3, s4, s5, dyn
+# CHECK-ALIAS: fnmsub.h s2, s3, s4, s5
+fnmsub.h x18, x19, x20, x21
+# CHECK-INST: fnmadd.h s6, s7, s8, s9, dyn
+# CHECK-ALIAS: fnmadd.h s6, s7, s8, s9
+fnmadd.h x22, x23, x24, x25
+# CHECK-INST: fadd.h s10, s11, t3, dyn
+# CHECK-ALIAS: fadd.h s10, s11, t3
+fadd.h x26, x27, x28
+# CHECK-INST: fsub.h t4, t5, t6, dyn
+# CHECK-ALIAS: fsub.h t4, t5, t6
+fsub.h x29, x30, x31
+# CHECK-INST: fmul.h s0, s1, s2, dyn
+# CHECK-ALIAS: fmul.h s0, s1, s2
+fmul.h s0, s1, s2
+# CHECK-INST: fdiv.h s3, s4, s5, dyn
+# CHECK-ALIAS: fdiv.h s3, s4, s5
+fdiv.h s3, s4, s5
Index: llvm/test/MC/RISCV/rvzfinx-aliases-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvzfinx-aliases-valid.s
@@ -0,0 +1,49 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zfinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zfinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zfinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zfinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zfinx %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zfinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zfinx %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zfinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zfinx %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zfinx -M no-aliases - \
+# RUN: | FileCh

[PATCH] D116553: [clang-format] Fix incorrect formatting of lambdas inside brace initialisation

2022-01-03 Thread Marek Kurdej 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 rGe2b6e21f19da: [clang-format] Fix incorrect formatting of 
lambdas inside brace initialisation (authored by curdeius).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116553

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -20232,6 +20232,11 @@
"};");
   verifyFormat("[]() -> Void {};");
   verifyFormat("[a, b]() -> Tuple { return {}; };");
+  verifyFormat("SomeFunction({[]() -> int[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> int *[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> int (*)[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> ns::type { return {}; }});");
+  verifyFormat("return int{[x = x]() { return x; }()};");
 
   // Lambdas with explicit template argument lists.
   verifyFormat(
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1786,6 +1786,9 @@
 case tok::l_paren:
   parseParens();
   break;
+case tok::l_square:
+  parseSquare();
+  break;
 case tok::amp:
 case tok::star:
 case tok::kw_const:


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -20232,6 +20232,11 @@
"};");
   verifyFormat("[]() -> Void {};");
   verifyFormat("[a, b]() -> Tuple { return {}; };");
+  verifyFormat("SomeFunction({[]() -> int[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> int *[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> int (*)[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> ns::type { return {}; }});");
+  verifyFormat("return int{[x = x]() { return x; }()};");
 
   // Lambdas with explicit template argument lists.
   verifyFormat(
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1786,6 +1786,9 @@
 case tok::l_paren:
   parseParens();
   break;
+case tok::l_square:
+  parseSquare();
+  break;
 case tok::amp:
 case tok::star:
 case tok::kw_const:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e2b6e21 - [clang-format] Fix incorrect formatting of lambdas inside brace initialisation

2022-01-03 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2022-01-04T08:28:12+01:00
New Revision: e2b6e21f19da6fe0da9349264e43286f0441b4ca

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

LOG: [clang-format] Fix incorrect formatting of lambdas inside brace 
initialisation

Fixes https://github.com/llvm/llvm-project/issues/27146.
Fixes https://github.com/llvm/llvm-project/issues/52943.

Before:

```
namespace ns {

void foo() {
  std::variant v;
  std::visit(overloaded{[](auto &&) -> int (*)[] { return nullptr; }}, v);
}

} // namespace ns

int break_me() {
  int x = 42;
  return int{[x = x]() {
return x;
  }()};
}
```

got formatted as:
```
namespace ns {

void foo() {
  std::variant v;
  std::visit(overloaded{[](auto &&) -> int (*)[] { return nullptr;
}
} // namespace ns
, v);
}

} // namespace ns

int break_me() {
  int x = 42;
  return int{[x = x](){return x;
}
()
}
;
}
```

Reviewed By: HazardyKnusperkeks, owenpan

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 0579acf36391c..17187b7996aae 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1786,6 +1786,9 @@ bool UnwrappedLineParser::tryToParseLambda() {
 case tok::l_paren:
   parseParens();
   break;
+case tok::l_square:
+  parseSquare();
+  break;
 case tok::amp:
 case tok::star:
 case tok::kw_const:

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 49635f3f15eae..71f07412a3b69 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -20232,6 +20232,11 @@ TEST_F(FormatTest, FormatsLambdas) {
"};");
   verifyFormat("[]() -> Void {};");
   verifyFormat("[a, b]() -> Tuple { return {}; };");
+  verifyFormat("SomeFunction({[]() -> int[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> int *[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> int (*)[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> ns::type { return {}; }});");
+  verifyFormat("return int{[x = x]() { return x; }()};");
 
   // Lambdas with explicit template argument lists.
   verifyFormat(



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


[PATCH] D116577: [clang-tidy] Added "boost-use-range-based-for-loop" check

2022-01-03 Thread Denis Mikhailov via Phabricator via cfe-commits
denzor200 created this revision.
Herald added subscribers: carlosgalvezp, xazax.hun, mgorny.
denzor200 requested review of this revision.
Herald added a project: clang-tools-extra.

Added a check for converting ``BOOST_FOREACH(..., ...)`` loops to use the new 
range-based loops in C++11.
This check have some limitations, see documentation for details.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116577

Files:
  clang-tools-extra/clang-tidy/boost/BoostTidyModule.cpp
  clang-tools-extra/clang-tidy/boost/CMakeLists.txt
  clang-tools-extra/clang-tidy/boost/UseRangeBasedForLoopCheck.cpp
  clang-tools-extra/clang-tidy/boost/UseRangeBasedForLoopCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/boost-use-range-based-for-loop.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/boost-use-range-based-for-loop.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/boost-use-range-based-for-loop.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/boost-use-range-based-for-loop.cpp
@@ -0,0 +1,41 @@
+// RUN: %check_clang_tidy %s boost-use-range-based-for-loop %t
+
+namespace std {
+template 
+class list {};
+}
+
+#define BOOST_FOREACH(VAR, COL) while(true)
+#define BOOST_REVERSE_FOREACH(VAR, COL) while(true)
+
+void test_range_based_for_loop()
+{
+  std::list list_int;
+  BOOST_FOREACH( int i, list_int ) {
+// do something with i
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead of BOOST_FOREACH [boost-use-range-based-for-loop]
+  // CHECK-FIXES: for(int i : list_int ) {
+
+  short array_short[] = {1,2,3};
+  BOOST_FOREACH(int
+val, array_short) {
+/// The short was implicitly converted to an int
+  }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based
+  // CHECK-FIXES: for(int val : array_short) {
+}
+
+#define foreach_ BOOST_FOREACH
+#define foreach_r_   BOOST_REVERSE_FOREACH
+
+void test_range_based_for_loop_prettier()
+{
+  std::list list_int;
+  foreach_( int i, list_int ) {
+// do something with i
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based 
+  // CHECK-FIXES: for(int i : list_int ) {
+}
+
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
@@ -51,6 +51,7 @@
`android-cloexec-pipe2 `_,
`android-cloexec-socket `_,
`android-comparison-in-temp-failure-retry `_,
+   `boost-use-range-based-for-loop `_, "Yes"
`boost-use-to-string `_, "Yes"
`bugprone-argument-comment `_, "Yes"
`bugprone-assert-side-effect `_,
Index: clang-tools-extra/docs/clang-tidy/checks/boost-use-range-based-for-loop.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/boost-use-range-based-for-loop.rst
@@ -0,0 +1,65 @@
+.. title:: clang-tidy - boost-use-range-based-for-loop
+
+boost-use-range-based-for-loop
+==
+
+This check converts ``BOOST_FOREACH(..., ...)`` loops to use the new range-based loops in C++11.
+
+Two kinds of loops can be converted correctly:
+
+-  Loops over arrays.
+-  Loops over STL containers.
+
+.. code-block:: c++
+
+std::list list_int( /*...*/ );
+BOOST_FOREACH( int i, list_int )
+{
+// do something with i
+}
+
+// Will be changed to
+std::list list_int( /*...*/ );
+for( int i: list_int )
+{
+// do something with i
+}
+
+Known Limitations
+-
+* Client code that use ``BOOST_FOREACH`` with "``std::pair`` of iterators" or with "Null-terminated strings (``char`` and ``wchar_t``)" or some other sequence types (everything that is not declared in the list "convertible correctly" above) will produce broken code (compilation error).
+
+.. code-block:: c++
+
+const char* cstr = "Hello world";
+BOOST_FOREACH( char c, cstr )
+{
+// do something with c
+}
+
+// Will be changed to
+const char* cstr = "Hello world";
+for( char c: cstr ) // won't compile
+{
+// do something with c
+}
+
+* First argument of the ``BOOST_FOREACH`` macro must be only new identifier definition, all other will produce a compilation error after migration.
+
+.. code-block:: c++
+
+std::list list_int( /*...*/ );
+int i;
+BOOST_FOREACH( i, list_int )
+{
+// do something with i
+}
+
+// Will be changed to
+std::list list_int( /*...*/ );
+int i;
+for( i: list_int ) // won't compile
+{
+// do something with i
+}
+
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/doc

[PATCH] D116563: [clang-format][NFC] Put all state change into the for statement

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

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116563

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


[PATCH] D116557: [clang-format] Fix SeparateDefinitionBlocks docs and ...

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

LGTM.


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

https://reviews.llvm.org/D116557

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


[PATCH] D116562: [clang-format][NFC] Right.Previous is Left

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

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116562

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


[PATCH] D116561: [clang-format][NFC] Use Prev instead of Current->Previous

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

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116561

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


[PATCH] D116560: [clang-format][NFC] TokenAnnotator: Use range based for

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

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116560

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


[PATCH] D116559: [clang-format][NFC] Early return in TokenAnnotator::next

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

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116559

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


[PATCH] D116558: [clang-format][NFC] Don't pass member by argument

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

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116558

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


[clang] 304d30b - [clang] Fix warning about unused variable [NFC]

2022-01-03 Thread Mikael Holmen via cfe-commits

Author: Mikael Holmen
Date: 2022-01-04T07:28:16+01:00
New Revision: 304d30bc594bf99bba9ee780007ac78755a9ff7a

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

LOG: [clang] Fix warning about unused variable [NFC]

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 3a4e9153689e2..d4afefcb24a98 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1929,7 +1929,7 @@ void Clang::AddMIPSTargetArgs(const ArgList &Args,
 }
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_mfix4300)) {
+  if (Args.getLastArg(options::OPT_mfix4300)) {
 CmdArgs.push_back("-mllvm");
 CmdArgs.push_back("-mfix4300");
   }



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


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

2022-01-03 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoF.td:217
+let Predicates = [HasStdExtF] in {
+def : FPFMADynFrmAlias;
+def : FPFMADynFrmAlias;

craig.topper wrote:
> Why do the aliases not apply to Zfinx?
Because the first argument is `FPFMA_rrr_frm Inst`, if we use multiclass here, 
it'll be `FFPFMA_rrr_frm Inst, FFPFMA_rrr_frm Inst_INX`. I don't know is there 
a better way?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

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


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

2022-01-03 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoF.td:217
+let Predicates = [HasStdExtF] in {
+def : FPFMADynFrmAlias;
+def : FPFMADynFrmAlias;

Why do the aliases not apply to Zfinx?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

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


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

2022-01-03 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoF.td:124
 class FPFMA_rrr_frm funct2, string opcodestr,
-RegisterClass rty>
+RegisterOperand rty>
 : RVInstR4Frmhttps://reviews.llvm.org/D93298/new/

https://reviews.llvm.org/D93298

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


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

2022-01-03 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 397193.
achieveartificialintelligence added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

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

Index: llvm/test/MC/RISCV/rvzhinx-aliases-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvzhinx-aliases-valid.s
@@ -0,0 +1,49 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zhinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zhinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zhinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zhinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zhinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zhinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zhinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zhinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+
+##===--===##
+## Aliases which omit the rounding mode.
+##===--===##
+
+# CHECK-INST: fmadd.h a0, a1, a2, a3, dyn
+# CHECK-ALIAS: fmadd.h a0, a1, a2, a3
+fmadd.h x10, x11, x12, x13
+# CHECK-INST: fmsub.h a4, a5, a6, a7, dyn
+# CHECK-ALIAS: fmsub.h a4, a5, a6, a7
+fmsub.h x14, x15, x16, x17
+# CHECK-INST: fnmsub.h s2, s3, s4, s5, dyn
+# CHECK-ALIAS: fnmsub.h s2, s3, s4, s5
+fnmsub.h x18, x19, x20, x21
+# CHECK-INST: fnmadd.h s6, s7, s8, s9, dyn
+# CHECK-ALIAS: fnmadd.h s6, s7, s8, s9
+fnmadd.h x22, x23, x24, x25
+# CHECK-INST: fadd.h s10, s11, t3, dyn
+# CHECK-ALIAS: fadd.h s10, s11, t3
+fadd.h x26, x27, x28
+# CHECK-INST: fsub.h t4, t5, t6, dyn
+# CHECK-ALIAS: fsub.h t4, t5, t6
+fsub.h x29, x30, x31
+# CHECK-INST: fmul.h s0, s1, s2, dyn
+# CHECK-ALIAS: fmul.h s0, s1, s2
+fmul.h s0, s1, s2
+# CHECK-INST: fdiv.h s3, s4, s5, dyn
+# CHECK-ALIAS: fdiv.h s3, s4, s5
+fdiv.h s3, s4, s5
Index: llvm/test/MC/RISCV/rvzfinx-aliases-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvzfinx-aliases-valid.s
@@ -0,0 +1,49 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zfinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zfinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zfinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zfinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zfinx %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zfinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zfinx %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zfinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zfinx %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zfinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN:

[PATCH] D116527: [clang-format] Fix indentation for array variables with alignment of consecutive assignments and declarations.

2022-01-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

Unless the test cases are wrong, they should not be changed. The original test 
case looked correct to me as it was doing a continuation indent between `type{` 
and `}`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116527

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


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

2022-01-03 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 397191.
achieveartificialintelligence added a comment.

Address @craig.topper 's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

Files:
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoD.td
  llvm/lib/Target/RISCV/RISCVInstrInfoF.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32i-invalid.s

Index: llvm/test/MC/RISCV/rv32i-invalid.s
===
--- llvm/test/MC/RISCV/rv32i-invalid.s
+++ llvm/test/MC/RISCV/rv32i-invalid.s
@@ -1,4 +1,4 @@
-# RUN: not llvm-mc -triple riscv32 < %s 2>&1 | FileCheck %s
+# RUN: not llvm-mc -triple riscv32 %s 2>&1 | FileCheck %s
 
 # Out of range immediates
 ## fencearg
@@ -173,6 +173,9 @@
 amomaxu.w s5, s4, (s3) # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'A' (Atomic Instructions)
 fadd.s ft0, ft1, ft2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'F' (Single-Precision Floating-Point)
 fadd.h ft0, ft1, ft2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zfh' (Half-Precision Floating-Point)
+fadd.s a0, a1, a2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zfinx' (Float in Integer)
+fadd.d a0, a2, a4 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zdinx' (Double in Integer)
+fadd.h a0, a1, a2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zhinx' (Half Float in Integer)
 
 # Using floating point registers when integer registers are expected
 addi a2, ft0, 24 # CHECK: :[[@LINE]]:10: error: invalid operand for instruction
Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -74,5 +74,17 @@
 .attribute arch, "rv32ifzfh0p1"
 # CHECK: attribute  5, "rv32i2p0_f2p0_zfh0p1_zfhmin0p1"
 
+.attribute arch, "rv32izfinx1p0"
+# CHECK: attribute  5, "rv32i2p0_zfinx1p0"
+
+.attribute arch, "rv32izdinx1p0"
+# CHECK: attribute  5, "rv32i2p0_zdinx1p0"
+
+.attribute arch, "rv32izhinxmin1p0"
+# CHECK: attribute  5, "rv32i2p0_zhinxmin1p0"
+
+.attribute arch, "rv32izhinx1p0"
+# CHECK: attribute  5, "rv32i2p0_zhinx1p0"
+
 .attribute arch, "rv32iv0p10zvlsseg0p10"
 # CHECK: attribute  5, "rv32i2p0_v0p10_zvlsseg0p10"
Index: llvm/lib/Target/RISCV/RISCVSubtarget.h
===
--- llvm/lib/Target/RISCV/RISCVSubtarget.h
+++ llvm/lib/Target/RISCV/RISCVSubtarget.h
@@ -53,6 +53,10 @@
   bool HasStdExtZvlsseg = false;
   bool HasStdExtZfhmin = false;
   bool HasStdExtZfh = false;
+  bool HasStdExtZfinx = false;
+  bool HasStdExtZdinx = false;
+  bool HasStdExtZhinxmin = false;
+  bool HasStdExtZhinx = false;
   bool HasRV64 = false;
   bool IsRV32E = false;
   bool EnableLinkerRelax = false;
@@ -119,6 +123,10 @@
   bool hasStdExtZvlsseg() const { return HasStdExtZvlsseg; }
   bool hasStdExtZfhmin() const { return HasStdExtZfhmin; }
   bool hasStdExtZfh() const { return HasStdExtZfh; }
+  bool hasStdExtZfinx() const { return HasStdExtZfinx; }
+  bool hasStdExtZdinx() const { return HasStdExtZdinx; }
+  bool hasStdExtZhinxmin() const { return HasStdExtZhinxmin; }
+  bool hasStdExtZhinx() const { return HasStdExtZhinx; }
   bool is64Bit() const { return HasRV64; }
   bool isRV32E() const { return IsRV32E; }
   bool enableLinkerRelax() const { return EnableLinkerRelax; }
Index: llvm/lib/Target/RISCV/RISCVRegisterInfo.td
===
--- llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+++ llvm/lib/Target/RISCV/RISCVRegisterInfo.td
@@ -66,6 +66,7 @@
 def sub_vrm1_6 : ComposedSubRegIndex;
 def sub_vrm1_7 : ComposedSubRegIndex;
 
+def sub_32_hi  : SubRegIndex<32, 32>;
 } // Namespace = "RISCV"
 
 // Integer registers
@@ -557,6 +558,63 @@
   let Size = 64;
 }
 
+let RegAltNameIndices = [ABIRegAltName] in {
+  foreach Index = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22,
+   24, 26, 28, 30] in {
+defvar Reg = !cast("X"#Index);
+def X#Index#_PD : RISCVRegWithSubRegs("X"#Index),
+!cast("X"#!add(Index, 1))],
+   Reg.AltNames> {
+  let SubRegIndices = [sub_32, sub_32_hi];
+}
+  }
+}
+
+def GPRF16 : RegisterClass<"RISCV", [f16], 16, (add
+(sequence "X%u", 10, 17),
+(sequence "X%u", 5, 7),
+(sequence "X%u", 28, 31),
+(sequence "X%u", 8, 9),
+(sequence "X%u", 18, 27),
+(sequence "X%u", 0, 4)
+)> {
+  let RegInfos = XLenRI;
+}
+
+

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

2022-01-03 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp:170
+
+static DecodeStatus DecodeGPRF32RegisterClass(MCInst &Inst, uint64_t RegNo,
+  uint64_t Address,

Can we make use of `let DecoderMethod =` on RegisterClass to avoid these 
aliases?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

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


[PATCH] D116325: [X86] Add missing CET intrinsics support

2022-01-03 Thread Freddy, Ye 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 rG0bab74280570: [X86] Add missing CET intrinsics support 
(authored by FreddyYe).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116325

Files:
  clang/lib/Headers/cetintrin.h
  clang/test/CodeGen/X86/cetintrin.c


Index: clang/test/CodeGen/X86/cetintrin.c
===
--- clang/test/CodeGen/X86/cetintrin.c
+++ clang/test/CodeGen/X86/cetintrin.c
@@ -37,6 +37,12 @@
   return _rdsspd(a);
 }
 
+unsigned int test_rdsspd_i32() {
+  // CHECK-LABEL: @test_rdsspd_i32
+  // CHECK:   call i32 @llvm.x86.rdsspd(i32 %{{[a-z0-9.]+}})
+  return _rdsspd_i32();
+}
+
 #ifdef __x86_64__
 unsigned long long test_rdsspq(unsigned long long a) {
   // X86_64-LABEL: @test_rdsspq
@@ -44,6 +50,12 @@
   return _rdsspq(a);
 }
 
+unsigned long long test_rdsspq_i64() {
+  // X86_64-LABEL: @test_rdsspq_i64
+  // X86_64:   call i64 @llvm.x86.rdsspq(i64 %{{[a-z0-9.]+}})
+  return _rdsspq_i64();
+}
+
 unsigned long long test_get_ssp(void) {
   // X86_64-LABEL: @test_get_ssp
   // X86_64:   call i64 @llvm.x86.rdsspq(i64 0)
Index: clang/lib/Headers/cetintrin.h
===
--- clang/lib/Headers/cetintrin.h
+++ clang/lib/Headers/cetintrin.h
@@ -42,10 +42,20 @@
   return __builtin_ia32_rdsspd(__a);
 }
 
+static __inline__ unsigned int __DEFAULT_FN_ATTRS _rdsspd_i32() {
+  unsigned int t;
+  return __builtin_ia32_rdsspd(t);
+}
+
 #ifdef __x86_64__
 static __inline__ unsigned long long __DEFAULT_FN_ATTRS _rdsspq(unsigned long 
long __a) {
   return __builtin_ia32_rdsspq(__a);
 }
+
+static __inline__ unsigned long long __DEFAULT_FN_ATTRS _rdsspq_i64() {
+  unsigned long long t;
+  return __builtin_ia32_rdsspq(t);
+}
 #endif /* __x86_64__ */
 
 #ifdef __x86_64__


Index: clang/test/CodeGen/X86/cetintrin.c
===
--- clang/test/CodeGen/X86/cetintrin.c
+++ clang/test/CodeGen/X86/cetintrin.c
@@ -37,6 +37,12 @@
   return _rdsspd(a);
 }
 
+unsigned int test_rdsspd_i32() {
+  // CHECK-LABEL: @test_rdsspd_i32
+  // CHECK:   call i32 @llvm.x86.rdsspd(i32 %{{[a-z0-9.]+}})
+  return _rdsspd_i32();
+}
+
 #ifdef __x86_64__
 unsigned long long test_rdsspq(unsigned long long a) {
   // X86_64-LABEL: @test_rdsspq
@@ -44,6 +50,12 @@
   return _rdsspq(a);
 }
 
+unsigned long long test_rdsspq_i64() {
+  // X86_64-LABEL: @test_rdsspq_i64
+  // X86_64:   call i64 @llvm.x86.rdsspq(i64 %{{[a-z0-9.]+}})
+  return _rdsspq_i64();
+}
+
 unsigned long long test_get_ssp(void) {
   // X86_64-LABEL: @test_get_ssp
   // X86_64:   call i64 @llvm.x86.rdsspq(i64 0)
Index: clang/lib/Headers/cetintrin.h
===
--- clang/lib/Headers/cetintrin.h
+++ clang/lib/Headers/cetintrin.h
@@ -42,10 +42,20 @@
   return __builtin_ia32_rdsspd(__a);
 }
 
+static __inline__ unsigned int __DEFAULT_FN_ATTRS _rdsspd_i32() {
+  unsigned int t;
+  return __builtin_ia32_rdsspd(t);
+}
+
 #ifdef __x86_64__
 static __inline__ unsigned long long __DEFAULT_FN_ATTRS _rdsspq(unsigned long long __a) {
   return __builtin_ia32_rdsspq(__a);
 }
+
+static __inline__ unsigned long long __DEFAULT_FN_ATTRS _rdsspq_i64() {
+  unsigned long long t;
+  return __builtin_ia32_rdsspq(t);
+}
 #endif /* __x86_64__ */
 
 #ifdef __x86_64__
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0bab742 - [X86] Add missing CET intrinsics support

2022-01-03 Thread Freddy Ye via cfe-commits

Author: Freddy Ye
Date: 2022-01-04T11:40:40+08:00
New Revision: 0bab7428057048d94774a91c329ae902fcffc170

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

LOG: [X86] Add missing CET intrinsics support

These two intrinsics are documented o SDM and intrinsic guide.

Reviewed By: pengfei

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

Added: 


Modified: 
clang/lib/Headers/cetintrin.h
clang/test/CodeGen/X86/cetintrin.c

Removed: 




diff  --git a/clang/lib/Headers/cetintrin.h b/clang/lib/Headers/cetintrin.h
index 4290e9d7355b9..019cab0261e7f 100644
--- a/clang/lib/Headers/cetintrin.h
+++ b/clang/lib/Headers/cetintrin.h
@@ -42,10 +42,20 @@ static __inline__ unsigned int __DEFAULT_FN_ATTRS 
_rdsspd(unsigned int __a) {
   return __builtin_ia32_rdsspd(__a);
 }
 
+static __inline__ unsigned int __DEFAULT_FN_ATTRS _rdsspd_i32() {
+  unsigned int t;
+  return __builtin_ia32_rdsspd(t);
+}
+
 #ifdef __x86_64__
 static __inline__ unsigned long long __DEFAULT_FN_ATTRS _rdsspq(unsigned long 
long __a) {
   return __builtin_ia32_rdsspq(__a);
 }
+
+static __inline__ unsigned long long __DEFAULT_FN_ATTRS _rdsspq_i64() {
+  unsigned long long t;
+  return __builtin_ia32_rdsspq(t);
+}
 #endif /* __x86_64__ */
 
 #ifdef __x86_64__

diff  --git a/clang/test/CodeGen/X86/cetintrin.c 
b/clang/test/CodeGen/X86/cetintrin.c
index f70d1c80e1cfe..dc55745ec4508 100644
--- a/clang/test/CodeGen/X86/cetintrin.c
+++ b/clang/test/CodeGen/X86/cetintrin.c
@@ -37,6 +37,12 @@ unsigned int test_rdsspd(unsigned int a) {
   return _rdsspd(a);
 }
 
+unsigned int test_rdsspd_i32() {
+  // CHECK-LABEL: @test_rdsspd_i32
+  // CHECK:   call i32 @llvm.x86.rdsspd(i32 %{{[a-z0-9.]+}})
+  return _rdsspd_i32();
+}
+
 #ifdef __x86_64__
 unsigned long long test_rdsspq(unsigned long long a) {
   // X86_64-LABEL: @test_rdsspq
@@ -44,6 +50,12 @@ unsigned long long test_rdsspq(unsigned long long a) {
   return _rdsspq(a);
 }
 
+unsigned long long test_rdsspq_i64() {
+  // X86_64-LABEL: @test_rdsspq_i64
+  // X86_64:   call i64 @llvm.x86.rdsspq(i64 %{{[a-z0-9.]+}})
+  return _rdsspq_i64();
+}
+
 unsigned long long test_get_ssp(void) {
   // X86_64-LABEL: @test_get_ssp
   // X86_64:   call i64 @llvm.x86.rdsspq(i64 0)



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


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

2022-01-03 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a subscriber: khchen.
craig.topper added inline comments.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:290
 
+if (ExtName == "zdinx")
+  Features.push_back("+zfinx");

@kito-cheng or @khchen is the right way to do this? Or should it be in 
updateImplication? Where do we have Zfhmin imply f or d imply f today?



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoD.td:34
+  let Name = "GPRPF64AsFPR";
+  let ParserMethod = "parseGPRAsFPR";
+}

Can you add `let RenderMethod = "addRegOperands";` here. That should let you 
remove `addGPRAsFPROperands` from RISCVAsmParser.cpp. Similar for the other 
AsmOperandClasses.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

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


[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2022-01-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 397184.
owenpan added a comment.

- Fixed a bug found by applying the patch on the entire `clang` source tree.
- Added an exception: the braces are not removed if the right one is followed 
by a comment on the same line.
- Updated an existing test case and added a new one.


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

https://reviews.llvm.org/D116316

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -18682,6 +18682,7 @@
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
   CHECK_PARSE_BOOL(Cpp11BracedListStyle);
   CHECK_PARSE_BOOL(ReflowComments);
+  CHECK_PARSE_BOOL(RemoveBracesLLVM);
   CHECK_PARSE_BOOL(SortUsingDeclarations);
   CHECK_PARSE_BOOL(SpacesInParentheses);
   CHECK_PARSE_BOOL(SpacesInSquareBrackets);
@@ -23020,6 +23021,316 @@
Style);
 }
 
+TEST_F(FormatTest, RemoveBraces) {
+  FormatStyle Style = getLLVMStyle();
+  Style.RemoveBracesLLVM = true;
+
+  // The following eight test cases are fully-braced versions of the examples at
+  // "llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-
+  // statement-bodies-of-if-else-loop-statements".
+
+  // 1. Omit the braces, since the body is simple and clearly associated with
+  // the if.
+  EXPECT_EQ("if (isa(D))\n"
+"  handleFunctionDecl(D);\n"
+"else if (isa(D))\n"
+"  handleVarDecl(D);",
+format("if (isa(D)) {\n"
+   "  handleFunctionDecl(D);\n"
+   "} else if (isa(D)) {\n"
+   "  handleVarDecl(D);\n"
+   "}",
+   Style));
+
+  // 2. Here we document the condition itself and not the body.
+  verifyFormat("if (isa(D)) {\n"
+   "  // It is necessary that we explain the situation with this\n"
+   "  // surprisingly long comment, so it would be unclear\n"
+   "  // without the braces whether the following statement is in\n"
+   "  // the scope of the `if`.\n"
+   "  // Because the condition is documented, we can't really\n"
+   "  // hoist this comment that applies to the body above the\n"
+   "  // if.\n"
+   "  handleOtherDecl(D);\n"
+   "}",
+   Style);
+
+  // 3. Use braces on the outer `if` to avoid a potential dangling else
+  // situation.
+  EXPECT_EQ("if (isa(D)) {\n"
+"  for (auto *A : D.attrs())\n"
+"if (shouldProcessAttr(A))\n"
+"  handleAttr(A);\n"
+"}",
+format("if (isa(D)) {\n"
+   "  for (auto *A : D.attrs()) {\n"
+   "if (shouldProcessAttr(A)) {\n"
+   "  handleAttr(A);\n"
+   "}\n"
+   "  }\n"
+   "}",
+   Style));
+
+  // 4. Use braces for the `if` block to keep it uniform with the else block.
+  verifyFormat("if (isa(D)) {\n"
+   "  handleFunctionDecl(D);\n"
+   "} else {\n"
+   "  // In this else case, it is necessary that we explain the\n"
+   "  // situation with this surprisingly long comment, so it\n"
+   "  // would be unclear without the braces whether the\n"
+   "  // following statement is in the scope of the `if`.\n"
+   "  handleOtherDecl(D);\n"
+   "}",
+   Style);
+
+  // 5. This should also omit braces.  The `for` loop contains only a single
+  // statement, so it shouldn't have braces.  The `if` also only contains a
+  // single simple statement (the for loop), so it also should omit braces.
+  EXPECT_EQ("if (isa(D))\n"
+"  for (auto *A : D.attrs())\n"
+"handleAttr(A);",
+format("if (isa(D)) {\n"
+   "  for (auto *A : D.attrs()) {\n"
+   "handleAttr(A);\n"
+   "  }\n"
+   "}",
+   Style));
+
+  // 6. Use braces for the outer `if` since the nested `for` is braced.
+  verifyFormat("if (isa(D)) {\n"
+   "  for (auto *A : D.attrs()) {\n"
+   "// In this for loop body, it is necessary that we explain\n"
+   "// the situation with this surprisingly long comment,\n"
+   "// forcing braces on the `for` block.\n"
+   "handleAttr(A);\n"
+   "  }\n"
+   "}",
+   Style);
+
+  // 7. Use braces on the outer block b

[PATCH] D109244: [clang] Allow the OpenBSD driver to link the libclang_rt.profile library.

2022-01-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Without testing `libclang_rt.profile{{.*}}.a` in clang/test/Driver, such 
functionality may regress.
If I am to refactor `addProfileRTLibs`, I may not notice the untested feature.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109244

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


[PATCH] D112903: [C++20] [Module] Fix bug47116 and implement [module.interface]/p6

2022-01-03 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

@aaron.ballman @urnathan gentle ping~


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

https://reviews.llvm.org/D112903

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


[PATCH] D115610: [C++20] [Modules] Don't create multiple global module fragment

2022-01-03 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

@rsmith gentle ping~


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115610

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


[PATCH] D115867: [C++20] [Coroutines] Warning for always_inline coroutine

2022-01-03 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

@Quuxplusone do you feel good with the current message?


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

https://reviews.llvm.org/D115867

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


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

2022-01-03 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

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


[PATCH] D114995: clang-tidy: improve the 'modernize-use-default-member-init'

2022-01-03 Thread Oleg Smolsky via Phabricator via cfe-commits
oleg.smolsky added a comment.

In D114995#3218022 , @aaron.ballman 
wrote:

> In D114995#3218004 , @oleg.smolsky 
> wrote:
>
>> @aaron.ballman could you commit this change please? I've never had commit 
>> rights... Thanks!
>
> Sure can! Is `Oleg Smolsky ` the correct attribution 
> for the patch, or would you like me to use a different name or email address?

Thanks Aaron! Yes, everything here looks right.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114995

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


[PATCH] D116020: [clang][#52782] Bail on incomplete parameter type in stdcall name mangling

2022-01-03 Thread Markus Böck via Phabricator via cfe-commits
zero9178 added a comment.

In D116020#3218453 , @majnemer wrote:

> I wonder if we should have different behavior for MSVC targets.
>
> If I do:
>
>   class Incomplete;
>   extern "C" int __stdcall Fn(int, Incomplete, long long);
>   auto fnptr = &Fn;
>
> MSVC generates:
>
>   EXTRN   _Fn@12:PROC
>
> It appears that they skip over incomplete types.
>
> Should the behavior for incomplete types depend on the target?

That's actually a good point! I originally failed to get MSVC to generate a 
symbol for just the function declaration and thought it might just be 
irrelevant for MSVC. I didn't think of just using the function as you did lol. 
In the case of MinGW it always gets through the mangled as debug info is 
generated for the whole class, including just the method declaration.

I experimented a bit with your code and found a few interesting things:
clang actually refuses taking the address of a stdcall function if it has an 
incomplete type parameter:

  clang-cl test.cpp test2.cpp --target=i686-pc-windows-msvc
  test.cpp(3,15): error: parameter '' must have a complete type to use function 
'Fn' with the stdcall calling convention
  auto fnptr = &Fn;
^
  test.cpp(1,7): note: forward declaration of 'Incomplete'
  class Incomplete;
^
  1 error generated.

Meanwhile cl will compile but fail to link with another object file that calls 
`fnptr`:

  test.obj : error LNK2001: unresolved external symbol _Fn@12
Hint on symbols that are defined and could potentially match:
  _Fn@16
  test.exe : fatal error LNK1120: 1 unresolved externals

As both of them error out one way I am guessing it simply doesn't matter how 
the incomplete stdcall gets mangled. One cannot create calls to the function 
while the parameter type is incomplete and therefore no references to it are 
created.

How DWARF debuggers handle the "wrong" declarations in the debug info I have no 
clue about however. Given that GCC works the same however I am guessing gdb 
handles it correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116020

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


[PATCH] D114077: [clangd] Basic IncludeCleaner support for c/c++ standard library

2022-01-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D114077#3218446 , @thakis wrote:

> Still broken on windows: http://45.33.8.238/win/51764/step_4.txt

I think the builder is stuck, that build is some hours old and doesn't have the 
fix in it.
(Which leaves the possibility that i broke the bot somehow, I'm poking at some 
other bots trying to see if any of them are more broken than normal...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114077

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


[PATCH] D115456: Implement on-demand TLS initialization for Microsoft CXX ABI

2022-01-03 Thread David Majnemer via Phabricator via cfe-commits
majnemer accepted this revision.
majnemer added a comment.
This revision is now accepted and ready to land.

Looks great! Please give others some time to review it as it is a holiday 
season...


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

https://reviews.llvm.org/D115456

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


[PATCH] D116557: [clang-format] Fix SeparateDefinitionBlocks docs and ...

2022-01-03 Thread ksyx via Phabricator via cfe-commits
ksyx accepted this revision.
ksyx added a comment.
This revision is now accepted and ready to land.

Thanks for the fix!


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

https://reviews.llvm.org/D116557

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


[PATCH] D116020: [clang][#52782] Bail on incomplete parameter type in stdcall name mangling

2022-01-03 Thread David Majnemer via Phabricator via cfe-commits
majnemer added a comment.

I wonder if we should have different behavior for MSVC targets.

If I do:

  class Incomplete;
  extern "C" int __stdcall Fn(int, Incomplete, long long);
  auto fnptr = &Fn;

MSVC generates:

  EXTRN   _Fn@12:PROC

It appears that they skip over incomplete types.

Should the behavior for incomplete types depend on the target?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116020

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


[PATCH] D114077: [clangd] Basic IncludeCleaner support for c/c++ standard library

2022-01-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Still broken on windows: http://45.33.8.238/win/51764/step_4.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114077

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


[PATCH] D116020: [clang][#52782] Bail on incomplete parameter type in stdcall name mangling

2022-01-03 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

LGTM, the change seems sensible to me. But I’d prefer if you could hold off 
pushing it for another couple days, as others who might want to comment might 
not be following during the holiday season.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116020

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


[PATCH] D116557: [clang-format] Fix SeparateDefinitionBlocks docs and ...

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

In D116557#3218328 , @ksyx wrote:

> Thanks for the fix :)

No Problem.




Comment at: clang/docs/ReleaseNotes.rst:300
 
 - Option ``SeparateDefinitionBlocks`` has been added to insert or remove empty
   lines between definition blocks including functions, classes, structs, enums,

ksyx wrote:
> The change is documented here to group with added options?
My bad, have overlooked that.


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

https://reviews.llvm.org/D116557

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


[PATCH] D116557: [clang-format] Fix SeparateDefinitionBlocks docs and ...

2022-01-03 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 397148.

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

https://reviews.llvm.org/D116557

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
@@ -3054,6 +3054,7 @@
   bool ReflowComments;
   // clang-format on
 
+  /// \brief The style if definition blocks should be separated.
   enum SeparateDefinitionStyle {
 /// Leave definition blocks as they are.
 SDS_Leave,
@@ -3853,6 +3854,7 @@
QualifierOrder == R.QualifierOrder &&
RawStringFormats == R.RawStringFormats &&
ReferenceAlignment == R.ReferenceAlignment &&
+   SeparateDefinitionBlocks == R.SeparateDefinitionBlocks &&
ShortNamespaceLines == R.ShortNamespaceLines &&
SortIncludes == R.SortIncludes &&
SortJavaStaticImport == R.SortJavaStaticImport &&
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -3192,15 +3192,15 @@
 **PenaltyBreakFirstLessLess** (``Unsigned``) :versionbadge:`clang-format 3.7`
   The penalty for breaking before the first ``<<``.
 
+**PenaltyBreakOpenParenthesis** (``Unsigned``) :versionbadge:`clang-format 14`
+  The penalty for breaking after ``(``.
+
 **PenaltyBreakString** (``Unsigned``) :versionbadge:`clang-format 3.7`
   The penalty for each line break introduced inside a string literal.
 
 **PenaltyBreakTemplateDeclaration** (``Unsigned``) :versionbadge:`clang-format 
7`
   The penalty for breaking after template declaration.
 
-**PenaltyBreakOpenParenthesis** (``Unsigned``) :versionbadge:`clang-format 14`
-  The penalty for breaking after ``(``.
-
 **PenaltyExcessCharacter** (``Unsigned``) :versionbadge:`clang-format 3.7`
   The penalty for each character outside of the column limit.
 
@@ -3403,19 +3403,8 @@
   * information */
 
 **SeparateDefinitionBlocks** (``SeparateDefinitionStyle``) 
:versionbadge:`clang-format 14`
-  Specifies the use of empty lines to separate definition blocks, including 
classes,
-  structs, enums, and functions.
-
-  Possible values:
-
-  * ``SDS_Leave`` (in configuration: ``Leave``)
-Leave definition blocks as they are.
-
-  * ``SDS_Always`` (in configuration: ``Always``)
-Insert an empty line between definition blocks.
-
-  * ``SDS_Never`` (in configuration: ``Never``)
-Remove any empty line between definition blocks.
+  Specifies the use of empty lines to separate definition blocks, including
+  classes, structs, enums, and functions.
 
   .. code-block:: c++
 
@@ -3461,6 +3450,19 @@
  class C {};
  }
 
+  Possible values:
+
+  * ``SDS_Leave`` (in configuration: ``Leave``)
+Leave definition blocks as they are.
+
+  * ``SDS_Always`` (in configuration: ``Always``)
+Insert an empty line between definition blocks.
+
+  * ``SDS_Never`` (in configuration: ``Never``)
+Remove any empty line between definition blocks.
+
+
+
 **ShortNamespaceLines** (``Unsigned``) :versionbadge:`clang-format 14`
   The maximal number of unwrapped lines that a short namespace spans.
   Defaults to 1.


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -3054,6 +3054,7 @@
   bool ReflowComments;
   // clang-format on
 
+  /// \brief The style if definition blocks should be separated.
   enum SeparateDefinitionStyle {
 /// Leave definition blocks as they are.
 SDS_Leave,
@@ -3853,6 +3854,7 @@
QualifierOrder == R.QualifierOrder &&
RawStringFormats == R.RawStringFormats &&
ReferenceAlignment == R.ReferenceAlignment &&
+   SeparateDefinitionBlocks == R.SeparateDefinitionBlocks &&
ShortNamespaceLines == R.ShortNamespaceLines &&
SortIncludes == R.SortIncludes &&
SortJavaStaticImport == R.SortJavaStaticImport &&
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -3192,15 +3192,15 @@
 **PenaltyBreakFirstLessLess** (``Unsigned``) :versionbadge:`clang-format 3.7`
   The penalty for breaking before the first ``<<``.
 
+**PenaltyBreakOpenParenthesis** (``Unsigned``) :versionbadge:`clang-format 14`
+  The penalty for breaking after ``(``.
+
 **PenaltyBreakString** (``Unsigned``) :versionbadge:`clang-format 3.7`
   The penalty for each line break introduced inside a string literal.
 
 **PenaltyBreakTemplateDeclaration** (``Unsigned``) :version

[PATCH] D114787: [clang][PR51931] Enable `-Wdeclaration-after-statement` for all C versions

2022-01-03 Thread Markus Böck via Phabricator via cfe-commits
zero9178 added a comment.

In D114787#3188735 , @aaron.ballman 
wrote:

> https://reviews.llvm.org/D115094 is a review for doing effectively the same 
> fix. Can you coordinate with the other patch author to determine who will 
> drive this fix?

I sent an email to the author on December 13th but have yet to hear back from 
them. Should we move forward with this version of the patch then?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114787

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


[PATCH] D116563: [clang-format][NFC] Put all state change into the for statement

2022-01-03 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: MyDeveloperDay, curdeius, owenpan.
HazardyKnusperkeks added a project: clang-format.
HazardyKnusperkeks 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/D116563

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1166,7 +1166,8 @@
   bool FirstLine = true;
   for (const AnnotatedLine *Line =
Joiner.getNextMergedLine(DryRun, IndentTracker);
-   Line; Line = NextLine, FirstLine = false) {
+   Line; PrevPrevLine = PreviousLine, PreviousLine = Line, Line = NextLine,
+   FirstLine = false) {
 const AnnotatedLine &TheLine = *Line;
 unsigned Indent = IndentTracker.getIndent();
 
@@ -1256,8 +1257,6 @@
 }
 if (!DryRun)
   markFinalized(TheLine.First);
-PrevPrevLine = PreviousLine;
-PreviousLine = &TheLine;
   }
   PenaltyCache[CacheKey] = Penalty;
   return Penalty;


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1166,7 +1166,8 @@
   bool FirstLine = true;
   for (const AnnotatedLine *Line =
Joiner.getNextMergedLine(DryRun, IndentTracker);
-   Line; Line = NextLine, FirstLine = false) {
+   Line; PrevPrevLine = PreviousLine, PreviousLine = Line, Line = NextLine,
+   FirstLine = false) {
 const AnnotatedLine &TheLine = *Line;
 unsigned Indent = IndentTracker.getIndent();
 
@@ -1256,8 +1257,6 @@
 }
 if (!DryRun)
   markFinalized(TheLine.First);
-PrevPrevLine = PreviousLine;
-PreviousLine = &TheLine;
   }
   PenaltyCache[CacheKey] = Penalty;
   return Penalty;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116562: [clang-format][NFC] Right.Previous is Left

2022-01-03 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: MyDeveloperDay, curdeius, owenpan.
HazardyKnusperkeks added a project: clang-format.
HazardyKnusperkeks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Use that name. Also remove the one check for its existence, that is given.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116562

Files:
  clang/lib/Format/TokenAnnotator.cpp


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3860,16 +3860,14 @@
(Right.NewlinesBefore > 0 && Right.HasUnescapedNewline);
   if (Left.isTrailingComment())
 return true;
-  if (Right.Previous->IsUnterminatedLiteral)
+  if (Left.IsUnterminatedLiteral)
 return true;
-  if (Right.is(tok::lessless) && Right.Next &&
-  Right.Previous->is(tok::string_literal) &&
+  if (Right.is(tok::lessless) && Right.Next && Left.is(tok::string_literal) &&
   Right.Next->is(tok::string_literal))
 return true;
   // Can break after template<> declaration
-  if (Right.Previous->ClosesTemplateDeclaration &&
-  Right.Previous->MatchingParen &&
-  Right.Previous->MatchingParen->NestingLevel == 0) {
+  if (Left.ClosesTemplateDeclaration && Left.MatchingParen &&
+  Left.MatchingParen->NestingLevel == 0) {
 // Put concepts on the next line e.g.
 // template
 // concept ...
@@ -3902,9 +3900,8 @@
 // has made a deliberate choice and might have aligned the contents of the
 // string literal accordingly. Thus, we try keep existing line breaks.
 return Right.IsMultiline && Right.NewlinesBefore > 0;
-  if ((Right.Previous->is(tok::l_brace) ||
-   (Right.Previous->is(tok::less) && Right.Previous->Previous &&
-Right.Previous->Previous->is(tok::equal))) &&
+  if ((Left.is(tok::l_brace) || (Left.is(tok::less) && Left.Previous &&
+ Left.Previous->is(tok::equal))) &&
   Right.NestingLevel == 1 && Style.Language == FormatStyle::LK_Proto) {
 // Don't put enums or option definitions onto single lines in protocol
 // buffers.
@@ -4008,7 +4005,7 @@
   Right.is(TT_SelectorName) && !Right.is(tok::r_square) && Right.Next) {
 // Keep `@submessage` together in:
 // @submessage { key: value }
-if (Right.Previous && Right.Previous->is(tok::at))
+if (Left.is(tok::at))
   return false;
 // Look for the scope opener after selector in cases like:
 // selector { ...


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3860,16 +3860,14 @@
(Right.NewlinesBefore > 0 && Right.HasUnescapedNewline);
   if (Left.isTrailingComment())
 return true;
-  if (Right.Previous->IsUnterminatedLiteral)
+  if (Left.IsUnterminatedLiteral)
 return true;
-  if (Right.is(tok::lessless) && Right.Next &&
-  Right.Previous->is(tok::string_literal) &&
+  if (Right.is(tok::lessless) && Right.Next && Left.is(tok::string_literal) &&
   Right.Next->is(tok::string_literal))
 return true;
   // Can break after template<> declaration
-  if (Right.Previous->ClosesTemplateDeclaration &&
-  Right.Previous->MatchingParen &&
-  Right.Previous->MatchingParen->NestingLevel == 0) {
+  if (Left.ClosesTemplateDeclaration && Left.MatchingParen &&
+  Left.MatchingParen->NestingLevel == 0) {
 // Put concepts on the next line e.g.
 // template
 // concept ...
@@ -3902,9 +3900,8 @@
 // has made a deliberate choice and might have aligned the contents of the
 // string literal accordingly. Thus, we try keep existing line breaks.
 return Right.IsMultiline && Right.NewlinesBefore > 0;
-  if ((Right.Previous->is(tok::l_brace) ||
-   (Right.Previous->is(tok::less) && Right.Previous->Previous &&
-Right.Previous->Previous->is(tok::equal))) &&
+  if ((Left.is(tok::l_brace) || (Left.is(tok::less) && Left.Previous &&
+ Left.Previous->is(tok::equal))) &&
   Right.NestingLevel == 1 && Style.Language == FormatStyle::LK_Proto) {
 // Don't put enums or option definitions onto single lines in protocol
 // buffers.
@@ -4008,7 +4005,7 @@
   Right.is(TT_SelectorName) && !Right.is(tok::r_square) && Right.Next) {
 // Keep `@submessage` together in:
 // @submessage { key: value }
-if (Right.Previous && Right.Previous->is(tok::at))
+if (Left.is(tok::at))
   return false;
 // Look for the scope opener after selector in cases like:
 // selector { ...
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116561: [clang-format][NFC] Use Prev instead of Current->Previous

2022-01-03 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: MyDeveloperDay, curdeius, owenpan.
HazardyKnusperkeks added a project: clang-format.
HazardyKnusperkeks 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/D116561

Files:
  clang/lib/Format/TokenAnnotator.cpp


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2567,9 +2567,9 @@
   while (Current) {
 if (isFunctionDeclarationName(Style.isCpp(), *Current, Line))
   Current->setType(TT_FunctionDeclarationName);
+const FormatToken *Prev = Current->Previous;
 if (Current->is(TT_LineComment)) {
-  if (Current->Previous->is(BK_BracedInit) &&
-  Current->Previous->opensScope())
+  if (Prev->is(BK_BracedInit) && Prev->opensScope())
 Current->SpacesRequiredBefore =
 (Style.Cpp11BracedListStyle && !Style.SpacesInParentheses) ? 0 : 1;
   else
@@ -2610,12 +2610,11 @@
 Current->CanBreakBefore =
 Current->MustBreakBefore || canBreakBefore(Line, *Current);
 unsigned ChildSize = 0;
-if (Current->Previous->Children.size() == 1) {
-  FormatToken &LastOfChild = *Current->Previous->Children[0]->Last;
+if (Prev->Children.size() == 1) {
+  FormatToken &LastOfChild = *Prev->Children[0]->Last;
   ChildSize = LastOfChild.isTrailingComment() ? Style.ColumnLimit
   : LastOfChild.TotalLength + 
1;
 }
-const FormatToken *Prev = Current->Previous;
 if (Current->MustBreakBefore || Prev->Children.size() > 1 ||
 (Prev->Children.size() == 1 &&
  Prev->Children[0]->First->MustBreakBefore) ||


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2567,9 +2567,9 @@
   while (Current) {
 if (isFunctionDeclarationName(Style.isCpp(), *Current, Line))
   Current->setType(TT_FunctionDeclarationName);
+const FormatToken *Prev = Current->Previous;
 if (Current->is(TT_LineComment)) {
-  if (Current->Previous->is(BK_BracedInit) &&
-  Current->Previous->opensScope())
+  if (Prev->is(BK_BracedInit) && Prev->opensScope())
 Current->SpacesRequiredBefore =
 (Style.Cpp11BracedListStyle && !Style.SpacesInParentheses) ? 0 : 1;
   else
@@ -2610,12 +2610,11 @@
 Current->CanBreakBefore =
 Current->MustBreakBefore || canBreakBefore(Line, *Current);
 unsigned ChildSize = 0;
-if (Current->Previous->Children.size() == 1) {
-  FormatToken &LastOfChild = *Current->Previous->Children[0]->Last;
+if (Prev->Children.size() == 1) {
+  FormatToken &LastOfChild = *Prev->Children[0]->Last;
   ChildSize = LastOfChild.isTrailingComment() ? Style.ColumnLimit
   : LastOfChild.TotalLength + 1;
 }
-const FormatToken *Prev = Current->Previous;
 if (Current->MustBreakBefore || Prev->Children.size() > 1 ||
 (Prev->Children.size() == 1 &&
  Prev->Children[0]->First->MustBreakBefore) ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116560: [clang-format][NFC] TokenAnnotator: Use range based for

2022-01-03 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: MyDeveloperDay, curdeius, owenpan.
HazardyKnusperkeks added a project: clang-format.
HazardyKnusperkeks 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/D116560

Files:
  clang/lib/Format/TokenAnnotator.cpp


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2550,11 +2550,8 @@
 }
 
 void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) {
-  for (SmallVectorImpl::iterator I = Line.Children.begin(),
-  E = Line.Children.end();
-   I != E; ++I) {
-calculateFormattingInformation(**I);
-  }
+  for (AnnotatedLine *ChildLine : Line.Children)
+calculateFormattingInformation(*ChildLine);
 
   Line.First->TotalLength =
   Line.First->IsMultiline ? Style.ColumnLimit


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2550,11 +2550,8 @@
 }
 
 void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) {
-  for (SmallVectorImpl::iterator I = Line.Children.begin(),
-  E = Line.Children.end();
-   I != E; ++I) {
-calculateFormattingInformation(**I);
-  }
+  for (AnnotatedLine *ChildLine : Line.Children)
+calculateFormattingInformation(*ChildLine);
 
   Line.First->TotalLength =
   Line.First->IsMultiline ? Style.ColumnLimit
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116557: [clang-format] Fix SeparateDefinitionBlocks docs and ...

2022-01-03 Thread ksyx via Phabricator via cfe-commits
ksyx added a comment.

Thanks for the fix :)




Comment at: clang/docs/ReleaseNotes.rst:300
 
 - Option ``SeparateDefinitionBlocks`` has been added to insert or remove empty
   lines between definition blocks including functions, classes, structs, enums,

The change is documented here to group with added options?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116557

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


[PATCH] D116559: [clang-format][NFC] Early return in TokenAnnotator::next

2022-01-03 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: MyDeveloperDay, curdeius, owenpan.
HazardyKnusperkeks added a project: clang-format.
HazardyKnusperkeks 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/D116559

Files:
  clang/lib/Format/TokenAnnotator.cpp


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1431,13 +1431,14 @@
   }
 
   void next() {
-if (CurrentToken) {
-  CurrentToken->NestingLevel = Contexts.size() - 1;
-  CurrentToken->BindingStrength = Contexts.back().BindingStrength;
-  modifyContext(*CurrentToken);
-  determineTokenType(*CurrentToken);
-  CurrentToken = CurrentToken->Next;
-}
+if (!CurrentToken)
+  return;
+
+CurrentToken->NestingLevel = Contexts.size() - 1;
+CurrentToken->BindingStrength = Contexts.back().BindingStrength;
+modifyContext(*CurrentToken);
+determineTokenType(*CurrentToken);
+CurrentToken = CurrentToken->Next;
 
 resetTokenMetadata();
   }


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1431,13 +1431,14 @@
   }
 
   void next() {
-if (CurrentToken) {
-  CurrentToken->NestingLevel = Contexts.size() - 1;
-  CurrentToken->BindingStrength = Contexts.back().BindingStrength;
-  modifyContext(*CurrentToken);
-  determineTokenType(*CurrentToken);
-  CurrentToken = CurrentToken->Next;
-}
+if (!CurrentToken)
+  return;
+
+CurrentToken->NestingLevel = Contexts.size() - 1;
+CurrentToken->BindingStrength = Contexts.back().BindingStrength;
+modifyContext(*CurrentToken);
+determineTokenType(*CurrentToken);
+CurrentToken = CurrentToken->Next;
 
 resetTokenMetadata();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116558: [clang-format][NFC] Don't pass member by argument

2022-01-03 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: owenpan, MyDeveloperDay, curdeius.
HazardyKnusperkeks added a project: clang-format.
HazardyKnusperkeks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

And then use the argument and member.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116558

Files:
  clang/lib/Format/TokenAnnotator.cpp


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -75,7 +75,7 @@
   : Style(Style), Line(Line), CurrentToken(Line.First), AutoFound(false),
 Keywords(Keywords) {
 Contexts.push_back(Context(tok::unknown, 1, /*IsExpression=*/false));
-resetTokenMetadata(CurrentToken);
+resetTokenMetadata();
   }
 
 private:
@@ -1409,8 +1409,8 @@
Tok.Next->Next->Next && Tok.Next->Next->Next->is(tok::l_paren);
   }
 
-  void resetTokenMetadata(FormatToken *Token) {
-if (!Token)
+  void resetTokenMetadata() {
+if (!CurrentToken)
   return;
 
 // Reset token type in case we have already looked at it and then
@@ -1439,7 +1439,7 @@
   CurrentToken = CurrentToken->Next;
 }
 
-resetTokenMetadata(CurrentToken);
+resetTokenMetadata();
   }
 
   /// A struct to hold information valid in a specific context, e.g.


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -75,7 +75,7 @@
   : Style(Style), Line(Line), CurrentToken(Line.First), AutoFound(false),
 Keywords(Keywords) {
 Contexts.push_back(Context(tok::unknown, 1, /*IsExpression=*/false));
-resetTokenMetadata(CurrentToken);
+resetTokenMetadata();
   }
 
 private:
@@ -1409,8 +1409,8 @@
Tok.Next->Next->Next && Tok.Next->Next->Next->is(tok::l_paren);
   }
 
-  void resetTokenMetadata(FormatToken *Token) {
-if (!Token)
+  void resetTokenMetadata() {
+if (!CurrentToken)
   return;
 
 // Reset token type in case we have already looked at it and then
@@ -1439,7 +1439,7 @@
   CurrentToken = CurrentToken->Next;
 }
 
-resetTokenMetadata(CurrentToken);
+resetTokenMetadata();
   }
 
   /// A struct to hold information valid in a specific context, e.g.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116557: [clang-format] Fix SeparateDefinitionBlocks docs and ...

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

Without the enum documentation I got

  $ ./clang/docs/tools/dump_format_style.py
  Traceback (most recent call last):
File "/c/GIT/llvm-dev/./clang/docs/tools/dump_format_style.py", line 344, 
in 
  opts = OptionsReader(f).read_options()
File "/c/GIT/llvm-dev/./clang/docs/tools/dump_format_style.py", line 280, 
in read_options
  raise Exception('Invalid format, expected comment, field or enum\n' + 
line)
  Exception: Invalid format, expected comment, field or enum
  SDS_Leave,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116557

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


[PATCH] D116557: [clang-format] Fix SeparateDefinitionBlocks docs and ...

2022-01-03 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: ksyx, MyDeveloperDay, curdeius.
HazardyKnusperkeks added a project: clang-format.
HazardyKnusperkeks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

the Style's equality operator.

This amends 6f6f88ffdae1e12e5f950ef418827a77a55c09c7 
 (D116314 
)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116557

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.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
@@ -3054,6 +3054,7 @@
   bool ReflowComments;
   // clang-format on
 
+  /// \brief The style if definition blocks should be separated.
   enum SeparateDefinitionStyle {
 /// Leave definition blocks as they are.
 SDS_Leave,
@@ -3853,6 +3854,7 @@
QualifierOrder == R.QualifierOrder &&
RawStringFormats == R.RawStringFormats &&
ReferenceAlignment == R.ReferenceAlignment &&
+   SeparateDefinitionBlocks == R.SeparateDefinitionBlocks &&
ShortNamespaceLines == R.ShortNamespaceLines &&
SortIncludes == R.SortIncludes &&
SortJavaStaticImport == R.SortJavaStaticImport &&
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -311,6 +311,9 @@
 
 - Improved C++20 Modules and Coroutines support.
 
+- Added ``SeparateDefinitionBlocks`` option, to insert or remove blank lines
+  between definition blocks.
+
 libclang
 
 
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -3192,15 +3192,15 @@
 **PenaltyBreakFirstLessLess** (``Unsigned``) :versionbadge:`clang-format 3.7`
   The penalty for breaking before the first ``<<``.
 
+**PenaltyBreakOpenParenthesis** (``Unsigned``) :versionbadge:`clang-format 14`
+  The penalty for breaking after ``(``.
+
 **PenaltyBreakString** (``Unsigned``) :versionbadge:`clang-format 3.7`
   The penalty for each line break introduced inside a string literal.
 
 **PenaltyBreakTemplateDeclaration** (``Unsigned``) :versionbadge:`clang-format 
7`
   The penalty for breaking after template declaration.
 
-**PenaltyBreakOpenParenthesis** (``Unsigned``) :versionbadge:`clang-format 14`
-  The penalty for breaking after ``(``.
-
 **PenaltyExcessCharacter** (``Unsigned``) :versionbadge:`clang-format 3.7`
   The penalty for each character outside of the column limit.
 
@@ -3403,19 +3403,8 @@
   * information */
 
 **SeparateDefinitionBlocks** (``SeparateDefinitionStyle``) 
:versionbadge:`clang-format 14`
-  Specifies the use of empty lines to separate definition blocks, including 
classes,
-  structs, enums, and functions.
-
-  Possible values:
-
-  * ``SDS_Leave`` (in configuration: ``Leave``)
-Leave definition blocks as they are.
-
-  * ``SDS_Always`` (in configuration: ``Always``)
-Insert an empty line between definition blocks.
-
-  * ``SDS_Never`` (in configuration: ``Never``)
-Remove any empty line between definition blocks.
+  Specifies the use of empty lines to separate definition blocks, including
+  classes, structs, enums, and functions.
 
   .. code-block:: c++
 
@@ -3461,6 +3450,19 @@
  class C {};
  }
 
+  Possible values:
+
+  * ``SDS_Leave`` (in configuration: ``Leave``)
+Leave definition blocks as they are.
+
+  * ``SDS_Always`` (in configuration: ``Always``)
+Insert an empty line between definition blocks.
+
+  * ``SDS_Never`` (in configuration: ``Never``)
+Remove any empty line between definition blocks.
+
+
+
 **ShortNamespaceLines** (``Unsigned``) :versionbadge:`clang-format 14`
   The maximal number of unwrapped lines that a short namespace spans.
   Defaults to 1.


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -3054,6 +3054,7 @@
   bool ReflowComments;
   // clang-format on
 
+  /// \brief The style if definition blocks should be separated.
   enum SeparateDefinitionStyle {
 /// Leave definition blocks as they are.
 SDS_Leave,
@@ -3853,6 +3854,7 @@
QualifierOrder == R.QualifierOrder &&
RawStringFormats == R.RawStringFormats &&
ReferenceAlignment == R.ReferenceAlignment &&
+   SeparateDefinitionBlocks == R.SeparateDefinitionBlocks &&
ShortNamespaceLines == R.ShortNames

[PATCH] D116549: [OpenMP][Clang] Allow passing target features in ISA trait for metadirective clause

2022-01-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Can you make the test check for the diagnose message? Also, do we have a test 
to verify an isa trait is properly handled?




Comment at: clang/lib/Parse/ParseOpenMP.cpp:2533
+std::function DiagUnknownTrait = [this, Loc](
+StringRef ISATrait) {};
+TargetOMPContext OMPCtx(ASTContext, std::move(DiagUnknownTrait),

Why doesn't this diagnose nothing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116549

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


[PATCH] D115061: [clang-format][NFC] Prefer pass by reference

2022-01-03 Thread Björn Schäpers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1188f241acb7: Revert "[clang-format][NFC] Prefer pass 
by reference" (authored by HazardyKnusperkeks).

Changed prior to commit:
  https://reviews.llvm.org/D115061?vs=391858&id=397137#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115061

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1064,9 +1064,9 @@
 
   FormatDecision LastFormat = Node->State.NextToken->getDecision();
   if (LastFormat == FD_Unformatted || LastFormat == FD_Continue)
-addNextStateToQueue(Penalty, Node, /*NewLine=*/false, Count, Queue);
+addNextStateToQueue(Penalty, Node, /*NewLine=*/false, &Count, &Queue);
   if (LastFormat == FD_Unformatted || LastFormat == FD_Break)
-addNextStateToQueue(Penalty, Node, /*NewLine=*/true, Count, Queue);
+addNextStateToQueue(Penalty, Node, /*NewLine=*/true, &Count, &Queue);
 }
 
 if (Queue.empty()) {
@@ -1092,7 +1092,7 @@
   /// Assume the current state is \p PreviousNode and has been reached with a
   /// penalty of \p Penalty. Insert a line break if \p NewLine is \c true.
   void addNextStateToQueue(unsigned Penalty, StateNode *PreviousNode,
-   bool NewLine, unsigned &Count, QueueType &Queue) {
+   bool NewLine, unsigned *Count, QueueType *Queue) {
 if (NewLine && !Indenter->canBreak(PreviousNode->State))
   return;
 if (!NewLine && Indenter->mustBreak(PreviousNode->State))
@@ -1105,8 +1105,8 @@
 
 Penalty += Indenter->addTokenToState(Node->State, NewLine, true);
 
-Queue.push(QueueItem(OrderedPenalty(Penalty, Count), Node));
-++Count;
+Queue->push(QueueItem(OrderedPenalty(Penalty, *Count), Node));
+++(*Count);
   }
 
   /// Applies the best formatting by reconstructing the path in the


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1064,9 +1064,9 @@
 
   FormatDecision LastFormat = Node->State.NextToken->getDecision();
   if (LastFormat == FD_Unformatted || LastFormat == FD_Continue)
-addNextStateToQueue(Penalty, Node, /*NewLine=*/false, Count, Queue);
+addNextStateToQueue(Penalty, Node, /*NewLine=*/false, &Count, &Queue);
   if (LastFormat == FD_Unformatted || LastFormat == FD_Break)
-addNextStateToQueue(Penalty, Node, /*NewLine=*/true, Count, Queue);
+addNextStateToQueue(Penalty, Node, /*NewLine=*/true, &Count, &Queue);
 }
 
 if (Queue.empty()) {
@@ -1092,7 +1092,7 @@
   /// Assume the current state is \p PreviousNode and has been reached with a
   /// penalty of \p Penalty. Insert a line break if \p NewLine is \c true.
   void addNextStateToQueue(unsigned Penalty, StateNode *PreviousNode,
-   bool NewLine, unsigned &Count, QueueType &Queue) {
+   bool NewLine, unsigned *Count, QueueType *Queue) {
 if (NewLine && !Indenter->canBreak(PreviousNode->State))
   return;
 if (!NewLine && Indenter->mustBreak(PreviousNode->State))
@@ -1105,8 +1105,8 @@
 
 Penalty += Indenter->addTokenToState(Node->State, NewLine, true);
 
-Queue.push(QueueItem(OrderedPenalty(Penalty, Count), Node));
-++Count;
+Queue->push(QueueItem(OrderedPenalty(Penalty, *Count), Node));
+++(*Count);
   }
 
   /// Applies the best formatting by reconstructing the path in the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115069: [clang-format][NFC] Merge another two calls to isOneOf

2022-01-03 Thread Björn Schäpers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd48d1f8ee845: [clang-format][NFC] Merge another two calls to 
isOneOf (authored by HazardyKnusperkeks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115069

Files:
  clang/lib/Format/ContinuationIndenter.cpp


Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1288,10 +1288,9 @@
 State.Stack[i].NoLineBreak = true;
 State.Stack[State.Stack.size() - 2].NestedBlockInlined = false;
   }
-  if (Previous &&
-  (Previous->isOneOf(tok::l_paren, tok::comma, tok::colon) ||
-   Previous->isOneOf(TT_BinaryOperator, TT_ConditionalExpr)) &&
-  !Previous->isOneOf(TT_DictLiteral, TT_ObjCMethodExpr)) {
+  if (Previous && (Previous->isOneOf(TT_BinaryOperator, TT_ConditionalExpr) ||
+   (Previous->isOneOf(tok::l_paren, tok::comma, tok::colon) &&
+!Previous->isOneOf(TT_DictLiteral, TT_ObjCMethodExpr {
 State.Stack.back().NestedBlockInlined =
 !Newline && hasNestedBlockInlined(Previous, Current, Style);
   }


Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1288,10 +1288,9 @@
 State.Stack[i].NoLineBreak = true;
 State.Stack[State.Stack.size() - 2].NestedBlockInlined = false;
   }
-  if (Previous &&
-  (Previous->isOneOf(tok::l_paren, tok::comma, tok::colon) ||
-   Previous->isOneOf(TT_BinaryOperator, TT_ConditionalExpr)) &&
-  !Previous->isOneOf(TT_DictLiteral, TT_ObjCMethodExpr)) {
+  if (Previous && (Previous->isOneOf(TT_BinaryOperator, TT_ConditionalExpr) ||
+   (Previous->isOneOf(tok::l_paren, tok::comma, tok::colon) &&
+!Previous->isOneOf(TT_DictLiteral, TT_ObjCMethodExpr {
 State.Stack.back().NestedBlockInlined =
 !Newline && hasNestedBlockInlined(Previous, Current, Style);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115060: [clang-format][NFC] Code Tidies in UnwrappedLineFormatter

2022-01-03 Thread Björn Schäpers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf014ab933f35: [clang-format][NFC] Code Tidies in 
UnwrappedLineFormatter (authored by HazardyKnusperkeks).

Changed prior to commit:
  https://reviews.llvm.org/D115060?vs=391853&id=397135#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115060

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp

Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -211,10 +211,12 @@
 const AnnotatedLine *TheLine = *I;
 if (TheLine->Last->is(TT_LineComment))
   return 0;
-if (I[1]->Type == LT_Invalid || I[1]->First->MustBreakBefore)
+const auto &NextLine = *I[1];
+const auto &PreviousLine = *I[-1];
+if (NextLine.Type == LT_Invalid || NextLine.First->MustBreakBefore)
   return 0;
 if (TheLine->InPPDirective &&
-(!I[1]->InPPDirective || I[1]->First->HasUnescapedNewline))
+(!NextLine.InPPDirective || NextLine.First->HasUnescapedNewline))
   return 0;
 
 if (Style.ColumnLimit > 0 && Indent > Style.ColumnLimit)
@@ -231,15 +233,15 @@
 if (TheLine->Last->is(TT_FunctionLBrace) &&
 TheLine->First == TheLine->Last &&
 !Style.BraceWrapping.SplitEmptyFunction &&
-I[1]->First->is(tok::r_brace))
+NextLine.First->is(tok::r_brace))
   return tryMergeSimpleBlock(I, E, Limit);
 
 // Handle empty record blocks where the brace has already been wrapped
 if (TheLine->Last->is(tok::l_brace) && TheLine->First == TheLine->Last &&
 I != AnnotatedLines.begin()) {
-  bool EmptyBlock = I[1]->First->is(tok::r_brace);
+  bool EmptyBlock = NextLine.First->is(tok::r_brace);
 
-  const FormatToken *Tok = I[-1]->First;
+  const FormatToken *Tok = PreviousLine.First;
   if (Tok && Tok->is(tok::comment))
 Tok = Tok->getNextNonComment();
 
@@ -267,7 +269,7 @@
 bool MergeShortFunctions =
 Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_All ||
 (Style.AllowShortFunctionsOnASingleLine >= FormatStyle::SFS_Empty &&
- I[1]->First->is(tok::r_brace)) ||
+ NextLine.First->is(tok::r_brace)) ||
 (Style.AllowShortFunctionsOnASingleLine & FormatStyle::SFS_InlineOnly &&
  TheLine->Level != 0);
 
@@ -312,73 +314,75 @@
   return MergeShortFunctions ? tryMergeSimpleBlock(I, E, Limit) : 0;
 }
 // Try to merge a control statement block with left brace unwrapped
-if (TheLine->Last->is(tok::l_brace) && TheLine->First != TheLine->Last &&
+if (TheLine->Last->is(tok::l_brace) &&
 TheLine->First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_for)) {
   return Style.AllowShortBlocksOnASingleLine != FormatStyle::SBS_Never
  ? tryMergeSimpleBlock(I, E, Limit)
  : 0;
 }
 // Try to merge a control statement block with left brace wrapped
-if (I[1]->First->is(tok::l_brace) &&
-(TheLine->First->isOneOf(tok::kw_if, tok::kw_else, tok::kw_while,
- tok::kw_for, tok::kw_switch, tok::kw_try,
- tok::kw_do, TT_ForEachMacro) ||
- (TheLine->First->is(tok::r_brace) && TheLine->First->Next &&
-  TheLine->First->Next->isOneOf(tok::kw_else, tok::kw_catch))) &&
-Style.BraceWrapping.AfterControlStatement ==
-FormatStyle::BWACS_MultiLine) {
-  // If possible, merge the next line's wrapped left brace with the current
-  // line. Otherwise, leave it on the next line, as this is a multi-line
-  // control statement.
-  return (Style.ColumnLimit == 0 ||
-  TheLine->Last->TotalLength <= Style.ColumnLimit)
- ? 1
- : 0;
-} else if (I[1]->First->is(tok::l_brace) &&
-   TheLine->First->isOneOf(tok::kw_if, tok::kw_else, tok::kw_while,
-   tok::kw_for)) {
-  return (Style.BraceWrapping.AfterControlStatement ==
-  FormatStyle::BWACS_Always)
- ? tryMergeSimpleBlock(I, E, Limit)
- : 0;
-} else if (I[1]->First->is(tok::l_brace) &&
-   TheLine->First->isOneOf(tok::kw_else, tok::kw_catch) &&
-   Style.BraceWrapping.AfterControlStatement ==
-   FormatStyle::BWACS_MultiLine) {
-  // This case if different from the upper BWACS_MultiLine processing
-  // in that a preceding r_brace is not on the same line as else/catch
-  // most likely because of BeforeElse/BeforeCatch set to true.
-  // If the line length doesn't fit ColumnLimit, leave l_brace on the
-  // next line to respect the BWACS_MultiLine.
-  return (Style.ColumnLimit == 0 ||
-  TheLine->Last->TotalLength <= Style

[clang] 1188f24 - Revert "[clang-format][NFC] Prefer pass by reference"

2022-01-03 Thread Björn Schäpers via cfe-commits

Author: Björn Schäpers
Date: 2022-01-03T23:06:56+01:00
New Revision: 1188f241acb78dacef00b7b6b3ec0b04cb43c786

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

LOG: Revert "[clang-format][NFC] Prefer pass by reference"

This reverts commit 25f637913fe31b6d23e78ff07c725bb537dd3b97.

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineFormatter.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 2d71a939d7b7..303150348ad8 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1064,9 +1064,9 @@ class OptimizingLineFormatter : public LineFormatter {
 
   FormatDecision LastFormat = Node->State.NextToken->getDecision();
   if (LastFormat == FD_Unformatted || LastFormat == FD_Continue)
-addNextStateToQueue(Penalty, Node, /*NewLine=*/false, Count, Queue);
+addNextStateToQueue(Penalty, Node, /*NewLine=*/false, &Count, &Queue);
   if (LastFormat == FD_Unformatted || LastFormat == FD_Break)
-addNextStateToQueue(Penalty, Node, /*NewLine=*/true, Count, Queue);
+addNextStateToQueue(Penalty, Node, /*NewLine=*/true, &Count, &Queue);
 }
 
 if (Queue.empty()) {
@@ -1092,7 +1092,7 @@ class OptimizingLineFormatter : public LineFormatter {
   /// Assume the current state is \p PreviousNode and has been reached with a
   /// penalty of \p Penalty. Insert a line break if \p NewLine is \c true.
   void addNextStateToQueue(unsigned Penalty, StateNode *PreviousNode,
-   bool NewLine, unsigned &Count, QueueType &Queue) {
+   bool NewLine, unsigned *Count, QueueType *Queue) {
 if (NewLine && !Indenter->canBreak(PreviousNode->State))
   return;
 if (!NewLine && Indenter->mustBreak(PreviousNode->State))
@@ -1105,8 +1105,8 @@ class OptimizingLineFormatter : public LineFormatter {
 
 Penalty += Indenter->addTokenToState(Node->State, NewLine, true);
 
-Queue.push(QueueItem(OrderedPenalty(Penalty, Count), Node));
-++Count;
+Queue->push(QueueItem(OrderedPenalty(Penalty, *Count), Node));
+++(*Count);
   }
 
   /// Applies the best formatting by reconstructing the path in the



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


[clang] d48d1f8 - [clang-format][NFC] Merge another two calls to isOneOf

2022-01-03 Thread Björn Schäpers via cfe-commits

Author: Björn Schäpers
Date: 2022-01-03T23:06:55+01:00
New Revision: d48d1f8ee84577a1ca38d4fe03956ee27884e399

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

LOG: [clang-format][NFC] Merge another two calls to isOneOf

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

Added: 


Modified: 
clang/lib/Format/ContinuationIndenter.cpp

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 4225d6b67b0e..31f5de673362 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1288,10 +1288,9 @@ unsigned 
ContinuationIndenter::moveStateToNextToken(LineState &State,
 State.Stack[i].NoLineBreak = true;
 State.Stack[State.Stack.size() - 2].NestedBlockInlined = false;
   }
-  if (Previous &&
-  (Previous->isOneOf(tok::l_paren, tok::comma, tok::colon) ||
-   Previous->isOneOf(TT_BinaryOperator, TT_ConditionalExpr)) &&
-  !Previous->isOneOf(TT_DictLiteral, TT_ObjCMethodExpr)) {
+  if (Previous && (Previous->isOneOf(TT_BinaryOperator, TT_ConditionalExpr) ||
+   (Previous->isOneOf(tok::l_paren, tok::comma, tok::colon) &&
+!Previous->isOneOf(TT_DictLiteral, TT_ObjCMethodExpr {
 State.Stack.back().NestedBlockInlined =
 !Newline && hasNestedBlockInlined(Previous, Current, Style);
   }



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


[clang] f014ab9 - [clang-format][NFC] Code Tidies in UnwrappedLineFormatter

2022-01-03 Thread Björn Schäpers via cfe-commits

Author: Björn Schäpers
Date: 2022-01-03T23:06:55+01:00
New Revision: f014ab933f35805159021d2d0c856a3c9af21a85

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

LOG: [clang-format][NFC] Code Tidies in UnwrappedLineFormatter

* Give I[1] and I[-1] a name:
  - Easier to understand
  - Easier to debug (since you don't go through operator[] everytime)
* TheLine->First != TheLine->Last follows since last is a l brace and
  first isn't.
* Factor the check for is(tok::l_brace) out.
* Drop else after return.

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineFormatter.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 89f87f0375cdc..2d71a939d7b7a 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -211,10 +211,12 @@ class LineJoiner {
 const AnnotatedLine *TheLine = *I;
 if (TheLine->Last->is(TT_LineComment))
   return 0;
-if (I[1]->Type == LT_Invalid || I[1]->First->MustBreakBefore)
+const auto &NextLine = *I[1];
+const auto &PreviousLine = *I[-1];
+if (NextLine.Type == LT_Invalid || NextLine.First->MustBreakBefore)
   return 0;
 if (TheLine->InPPDirective &&
-(!I[1]->InPPDirective || I[1]->First->HasUnescapedNewline))
+(!NextLine.InPPDirective || NextLine.First->HasUnescapedNewline))
   return 0;
 
 if (Style.ColumnLimit > 0 && Indent > Style.ColumnLimit)
@@ -231,15 +233,15 @@ class LineJoiner {
 if (TheLine->Last->is(TT_FunctionLBrace) &&
 TheLine->First == TheLine->Last &&
 !Style.BraceWrapping.SplitEmptyFunction &&
-I[1]->First->is(tok::r_brace))
+NextLine.First->is(tok::r_brace))
   return tryMergeSimpleBlock(I, E, Limit);
 
 // Handle empty record blocks where the brace has already been wrapped
 if (TheLine->Last->is(tok::l_brace) && TheLine->First == TheLine->Last &&
 I != AnnotatedLines.begin()) {
-  bool EmptyBlock = I[1]->First->is(tok::r_brace);
+  bool EmptyBlock = NextLine.First->is(tok::r_brace);
 
-  const FormatToken *Tok = I[-1]->First;
+  const FormatToken *Tok = PreviousLine.First;
   if (Tok && Tok->is(tok::comment))
 Tok = Tok->getNextNonComment();
 
@@ -267,7 +269,7 @@ class LineJoiner {
 bool MergeShortFunctions =
 Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_All ||
 (Style.AllowShortFunctionsOnASingleLine >= FormatStyle::SFS_Empty &&
- I[1]->First->is(tok::r_brace)) ||
+ NextLine.First->is(tok::r_brace)) ||
 (Style.AllowShortFunctionsOnASingleLine & FormatStyle::SFS_InlineOnly 
&&
  TheLine->Level != 0);
 
@@ -312,73 +314,75 @@ class LineJoiner {
   return MergeShortFunctions ? tryMergeSimpleBlock(I, E, Limit) : 0;
 }
 // Try to merge a control statement block with left brace unwrapped
-if (TheLine->Last->is(tok::l_brace) && TheLine->First != TheLine->Last &&
+if (TheLine->Last->is(tok::l_brace) &&
 TheLine->First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_for)) {
   return Style.AllowShortBlocksOnASingleLine != FormatStyle::SBS_Never
  ? tryMergeSimpleBlock(I, E, Limit)
  : 0;
 }
 // Try to merge a control statement block with left brace wrapped
-if (I[1]->First->is(tok::l_brace) &&
-(TheLine->First->isOneOf(tok::kw_if, tok::kw_else, tok::kw_while,
- tok::kw_for, tok::kw_switch, tok::kw_try,
- tok::kw_do, TT_ForEachMacro) ||
- (TheLine->First->is(tok::r_brace) && TheLine->First->Next &&
-  TheLine->First->Next->isOneOf(tok::kw_else, tok::kw_catch))) &&
-Style.BraceWrapping.AfterControlStatement ==
-FormatStyle::BWACS_MultiLine) {
-  // If possible, merge the next line's wrapped left brace with the current
-  // line. Otherwise, leave it on the next line, as this is a multi-line
-  // control statement.
-  return (Style.ColumnLimit == 0 ||
-  TheLine->Last->TotalLength <= Style.ColumnLimit)
- ? 1
- : 0;
-} else if (I[1]->First->is(tok::l_brace) &&
-   TheLine->First->isOneOf(tok::kw_if, tok::kw_else, tok::kw_while,
-   tok::kw_for)) {
-  return (Style.BraceWrapping.AfterControlStatement ==
-  FormatStyle::BWACS_Always)
- ? tryMergeSimpleBlock(I, E, Limit)
- : 0;
-} else if (I[1]->First->is(tok::l_brace) &&
-   TheLine->First->isOneOf(tok::kw_else, tok::kw_catch) &&
-   Style.BraceWrapping.AfterContr

[PATCH] D116020: [clang][#52782] Bail on incomplete parameter type in stdcall name mangling

2022-01-03 Thread Markus Böck via Phabricator via cfe-commits
zero9178 added a comment.

Friendly bump :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116020

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


[PATCH] D115064: [clang-format][NFC] Replace deque with vector

2022-01-03 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 397131.
HazardyKnusperkeks set the repository for this revision to rG LLVM Github 
Monorepo.
HazardyKnusperkeks added a comment.

Now with SmallVector.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115064

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1112,22 +1112,22 @@
   /// Applies the best formatting by reconstructing the path in the
   /// solution space that leads to \c Best.
   void reconstructPath(LineState &State, StateNode *Best) {
-std::deque Path;
+llvm::SmallVector Path;
 // We do not need a break before the initial token.
 while (Best->Previous) {
-  Path.push_front(Best);
+  Path.push_back(Best);
   Best = Best->Previous;
 }
-for (auto I = Path.begin(), E = Path.end(); I != E; ++I) {
+for (const auto &Node : llvm::reverse(Path)) {
   unsigned Penalty = 0;
-  formatChildren(State, (*I)->NewLine, /*DryRun=*/false, Penalty);
-  Penalty += Indenter->addTokenToState(State, (*I)->NewLine, false);
+  formatChildren(State, Node->NewLine, /*DryRun=*/false, Penalty);
+  Penalty += Indenter->addTokenToState(State, Node->NewLine, false);
 
   LLVM_DEBUG({
-printLineState((*I)->Previous->State);
-if ((*I)->NewLine) {
+printLineState(Node->Previous->State);
+if (Node->NewLine) {
   llvm::dbgs() << "Penalty for placing "
-   << (*I)->Previous->State.NextToken->Tok.getName()
+   << Node->Previous->State.NextToken->Tok.getName()
<< " on a new line: " << Penalty << "\n";
 }
   });


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1112,22 +1112,22 @@
   /// Applies the best formatting by reconstructing the path in the
   /// solution space that leads to \c Best.
   void reconstructPath(LineState &State, StateNode *Best) {
-std::deque Path;
+llvm::SmallVector Path;
 // We do not need a break before the initial token.
 while (Best->Previous) {
-  Path.push_front(Best);
+  Path.push_back(Best);
   Best = Best->Previous;
 }
-for (auto I = Path.begin(), E = Path.end(); I != E; ++I) {
+for (const auto &Node : llvm::reverse(Path)) {
   unsigned Penalty = 0;
-  formatChildren(State, (*I)->NewLine, /*DryRun=*/false, Penalty);
-  Penalty += Indenter->addTokenToState(State, (*I)->NewLine, false);
+  formatChildren(State, Node->NewLine, /*DryRun=*/false, Penalty);
+  Penalty += Indenter->addTokenToState(State, Node->NewLine, false);
 
   LLVM_DEBUG({
-printLineState((*I)->Previous->State);
-if ((*I)->NewLine) {
+printLineState(Node->Previous->State);
+if (Node->NewLine) {
   llvm::dbgs() << "Penalty for placing "
-   << (*I)->Previous->State.NextToken->Tok.getName()
+   << Node->Previous->State.NextToken->Tok.getName()
<< " on a new line: " << Penalty << "\n";
 }
   });
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116313: [MSVC] Silence -Wnon-virtual-dtor on DIA APIs

2022-01-03 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a subscriber: dblaikie.
aganea added a comment.

I was wondering, can we mandate `LLVM_ENABLE_WERROR=ON` for all bots at least? 
(or maybe enable it through cmake, if ever there's a setting to detect we're 
running as a bot)
Or just reverse the default setting on the main branch, ie. make 
`LLVM_ENABLE_WERROR=ON` by default and let users disable it locally. I think 
that would encourage users to care more about warnings? Release branches could 
have it disabled somehow, to accommodate for the changing compiler 
environments. Was this discussed before?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116313

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


[PATCH] D116154: [ARM] Adding macros for coprocessor intrinsics as per ACLE

2022-01-03 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson updated this revision to Diff 397127.
tmatheson added a comment.

Combine V8 and V9 macros


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116154

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Headers/arm_acle.h
  clang/test/CodeGen/arm-acle-coproc.c
  clang/test/Preprocessor/aarch64-target-features.c

Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -43,6 +43,7 @@
 // CHECK-NOT: __ARM_PCS_VFP 1
 // CHECK-NOT: __ARM_SIZEOF_MINIMAL_ENUM 1
 // CHECK-NOT: __ARM_SIZEOF_WCHAR_T 2
+// CHECK-NOT: __ARM_TARGET_COPROC 1
 // CHECK-NOT: __ARM_FEATURE_SVE
 // CHECK-NOT: __ARM_FEATURE_DOTPROD
 // CHECK-NOT: __ARM_FEATURE_PAC_DEFAULT
Index: clang/test/CodeGen/arm-acle-coproc.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-acle-coproc.c
@@ -0,0 +1,350 @@
+// RUN: %clang_cc1 -triple armv4 %s -E -dD -o - | FileCheck --check-prefix=CHECK-V4 %s
+// RUN: %clang_cc1 -triple armv4t %s -E -dD -o - | FileCheck --check-prefix=CHECK-V4 %s
+// RUN: %clang_cc1 -triple armv5 %s -E -dD -o - | FileCheck --check-prefix=CHECK-V5 %s
+// RUN: %clang_cc1 -triple armv5te %s -E -dD -o - | FileCheck --check-prefix=CHECK-V5-TE %s
+// RUN: %clang_cc1 -triple armv5tej %s -E -dD -o - | FileCheck --check-prefix=CHECK-V5-TE %s
+// RUN: %clang_cc1 -triple armv6 %s -E -dD -o - | FileCheck --check-prefix=CHECK-V6 %s
+// RUN: %clang_cc1 -triple armv6m %s -E -dD -o - | FileCheck --check-prefix=CHECK-V6M %s
+// RUN: %clang_cc1 -triple armv7a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V7 %s
+// RUN: %clang_cc1 -triple armv7r %s -E -dD -o - | FileCheck --check-prefix=CHECK-V7 %s
+// RUN: %clang_cc1 -triple armv7m %s -E -dD -o - | FileCheck --check-prefix=CHECK-V7 %s
+// RUN: %clang_cc1 -triple armv8a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple armv8r %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple armv8.1a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple armv8.2a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple armv8.3a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple armv8.4a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple armv8.5a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple armv8.6a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple armv8.7a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv4 %s -E -dD -o - | FileCheck --check-prefix=CHECK-V4-THUMB %s
+// RUN: %clang_cc1 -triple thumbv4t %s -E -dD -o - | FileCheck --check-prefix=CHECK-V4-THUMB %s
+// RUN: %clang_cc1 -triple thumbv5 %s -E -dD -o - | FileCheck --check-prefix=CHECK-V5-THUMB %s
+// RUN: %clang_cc1 -triple thumbv5te %s -E -dD -o - | FileCheck --check-prefix=CHECK-V5-TE-THUMB %s
+// RUN: %clang_cc1 -triple thumbv5tej %s -E -dD -o - | FileCheck --check-prefix=CHECK-V5-TE-THUMB %s
+// RUN: %clang_cc1 -triple thumbv6 %s -E -dD -o - | FileCheck --check-prefix=CHECK-V6-THUMB %s
+// RUN: %clang_cc1 -triple thumbv6k %s -E -dD -o - | FileCheck --check-prefix=CHECK-V6-THUMB %s
+// RUN: %clang_cc1 -triple thumbv6kz %s -E -dD -o - | FileCheck --check-prefix=CHECK-V6-THUMB %s
+// RUN: %clang_cc1 -triple thumbv6m %s -E -dD -o - | FileCheck --check-prefix=CHECK-V6M %s
+// RUN: %clang_cc1 -triple thumbv7a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V7 %s
+// RUN: %clang_cc1 -triple thumbv7r %s -E -dD -o - | FileCheck --check-prefix=CHECK-V7 %s
+// RUN: %clang_cc1 -triple thumbv7m %s -E -dD -o - | FileCheck --check-prefix=CHECK-V7 %s
+// RUN: %clang_cc1 -triple thumbv8a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv8.1a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv8.2a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv8.3a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv8.4a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv8.5a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv8.6a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv8.7a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv8r %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv8m.base %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8-BASE %s
+// RUN: %clang_cc1 -triple thumbv8m.main %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8-MAIN %s
+

[PATCH] D116527: [clang-format] Fix indentation for array variables with alignment of consecutive assignments and declarations.

2022-01-03 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

In D116527#3217211 , @MyDeveloperDay 
wrote:

> The fix looks ok, butr I don't understand the cause of the side effect? is it 
> explicitly aligning to the v of `auto v`?

It's adding two spaces inside the `auto  v  = ...`, because of aligned 
declaration (identifier `v`, additional 1 space) and aligned assignment 
operator (`=`, 1 more space).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116527

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


[PATCH] D116314: [clang-format] Add style to separate definition blocks

2022-01-03 Thread ksyx 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 rG6f6f88ffdae1: [clang-format] Style to separate definition 
blocks (authored by ksyx).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116314

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/CMakeLists.txt
  clang/lib/Format/DefinitionBlockSeparator.cpp
  clang/lib/Format/DefinitionBlockSeparator.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/lib/Format/WhitespaceManager.h
  clang/unittests/Format/CMakeLists.txt
  clang/unittests/Format/DefinitionBlockSeparatorTest.cpp

Index: clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
===
--- /dev/null
+++ clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
@@ -0,0 +1,309 @@
+//===- DefinitionBlockSeparatorTest.cpp - Formatting unit tests ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "FormatTestUtils.h"
+#include "clang/Format/Format.h"
+
+#include "llvm/Support/Debug.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "definition-block-separator-test"
+
+namespace clang {
+namespace format {
+namespace {
+
+class DefinitionBlockSeparatorTest : public ::testing::Test {
+protected:
+  static std::string
+  separateDefinitionBlocks(llvm::StringRef Code,
+   const std::vector &Ranges,
+   const FormatStyle &Style = getLLVMStyle()) {
+LLVM_DEBUG(llvm::errs() << "---\n");
+LLVM_DEBUG(llvm::errs() << Code << "\n\n");
+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
+  separateDefinitionBlocks(llvm::StringRef Code,
+   const FormatStyle &Style = getLLVMStyle()) {
+return separateDefinitionBlocks(
+Code,
+/*Ranges=*/{1, tooling::Range(0, Code.size())}, Style);
+  }
+
+  static void verifyFormat(llvm::StringRef Code,
+   const FormatStyle &Style = getLLVMStyle(),
+   llvm::StringRef ExpectedCode = "") {
+bool HasOriginalCode = true;
+if (ExpectedCode == "") {
+  ExpectedCode = Code;
+  HasOriginalCode = false;
+}
+
+FormatStyle InverseStyle = Style;
+if (Style.SeparateDefinitionBlocks == FormatStyle::SDS_Always)
+  InverseStyle.SeparateDefinitionBlocks = FormatStyle::SDS_Never;
+else
+  InverseStyle.SeparateDefinitionBlocks = FormatStyle::SDS_Always;
+EXPECT_EQ(ExpectedCode.str(), separateDefinitionBlocks(ExpectedCode, Style))
+<< "Expected code is not stable";
+std::string InverseResult = separateDefinitionBlocks(Code, InverseStyle);
+EXPECT_NE(Code.str(), InverseResult)
+<< "Inverse formatting makes no difference";
+std::string CodeToFormat =
+HasOriginalCode ? Code.str() : removeEmptyLines(Code);
+std::string Result = separateDefinitionBlocks(CodeToFormat, Style);
+EXPECT_EQ(ExpectedCode.str(), Result) << "Test failed. Formatted:\n"
+  << Result;
+  }
+
+  static std::string removeEmptyLines(llvm::StringRef Code) {
+std::string Result = "";
+for (auto Char : Code.str()) {
+  if (Result.size()) {
+auto LastChar = Result.back();
+if ((Char == '\n' && LastChar == '\n') ||
+(Char == '\r' && (LastChar == '\r' || LastChar == '\n')))
+  continue;
+  }
+  Result.push_back(Char);
+}
+return Result;
+  }
+};
+
+TEST_F(DefinitionBlockSeparatorTest, Basic) {
+  FormatStyle Style = getLLVMStyle();
+  Style.SeparateDefinitionBlocks = FormatStyle::SDS_Always;
+  verifyFormat("int foo(int i, int j) {\n"
+   "  int r = i + j;\n"
+   "  return r;\n"
+   "}\n"
+   "\n"
+   "int bar(int j, int k) {\n"
+   "  int r = j + k;\n"
+   "  return r;\n"
+   "}",
+   Style);
+
+  verifyFormat("struct foo {\n"
+   "  int i, j;\n"
+   "};\n"
+   "\n"
+   "struct bar {\n"
+   "  int j, k;\n"
+   "};",
+   Style);
+
+  verifyFormat("class foo {\n"
+   "  int i, j;\n"
+   "};\n"
+   "\n"
+   "class bar {\n"
+   

[PATCH] D115003: [funcattrs] Infer writeonly argument attribute [part 2]

2022-01-03 Thread Philip Reames via Phabricator via cfe-commits
reames updated this revision to Diff 397124.
reames edited the summary of this revision.
reames added a comment.

Rework account for only being to infer on nocapture arguments.


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

https://reviews.llvm.org/D115003

Files:
  llvm/lib/Transforms/IPO/FunctionAttrs.cpp
  llvm/test/Analysis/TypeBasedAliasAnalysis/functionattrs.ll
  llvm/test/Other/cgscc-devirt-iteration.ll
  llvm/test/Transforms/FunctionAttrs/norecurse.ll
  llvm/test/Transforms/FunctionAttrs/writeonly.ll

Index: llvm/test/Transforms/FunctionAttrs/writeonly.ll
===
--- llvm/test/Transforms/FunctionAttrs/writeonly.ll
+++ llvm/test/Transforms/FunctionAttrs/writeonly.ll
@@ -78,15 +78,23 @@
 
 declare void @direct2_callee(i8* %p) writeonly
 
+; writeonly w/o nocapture is not enough
 ; CHECK: define void @direct2(i8* %p)
 define void @direct2(i8* %p) {
   call void @direct2_callee(i8* %p)
+  ; read back from global, read through pointer...
   ret void
 }
 
-declare void @direct3_callee(i8* writeonly %p)
+; CHECK: define void @direct2b(i8* nocapture writeonly %p)
+define void @direct2b(i8* %p) {
+  call void @direct2_callee(i8* nocapture %p)
+  ret void
+}
+
+declare void @direct3_callee(i8* nocapture writeonly %p)
 
-; CHECK: define void @direct3(i8* %p)
+; CHECK: define void @direct3(i8* nocapture writeonly %p)
 define void @direct3(i8* %p) {
   call void @direct3_callee(i8* %p)
   ret void
@@ -98,15 +106,15 @@
   ret void
 }
 
-; CHECK: define void @fptr_test2(i8* %p, void (i8*)* nocapture readonly %f)
+; CHECK: define void @fptr_test2(i8* nocapture writeonly %p, void (i8*)* nocapture readonly %f)
 define void @fptr_test2(i8* %p, void (i8*)* %f) {
-  call void %f(i8* writeonly %p)
+  call void %f(i8* nocapture writeonly %p)
   ret void
 }
 
-; CHECK: define void @fptr_test3(i8* %p, void (i8*)* nocapture readonly %f)
+; CHECK: define void @fptr_test3(i8* nocapture writeonly %p, void (i8*)* nocapture readonly %f)
 define void @fptr_test3(i8* %p, void (i8*)* %f) {
-  call void %f(i8* %p) writeonly
+  call void %f(i8* nocapture %p) writeonly
   ret void
 }
 
Index: llvm/test/Transforms/FunctionAttrs/norecurse.ll
===
--- llvm/test/Transforms/FunctionAttrs/norecurse.ll
+++ llvm/test/Transforms/FunctionAttrs/norecurse.ll
@@ -50,7 +50,7 @@
 ; CHECK: Function Attrs
 ; CHECK-SAME: nounwind
 ; CHECK-NOT: norecurse
-; CHECK-NEXT: define void @intrinsic(i8* nocapture %dest, i8* nocapture readonly %src, i32 %len)
+; CHECK-NEXT: define void @intrinsic(i8* nocapture writeonly %dest, i8* nocapture readonly %src, i32 %len)
 define void @intrinsic(i8* %dest, i8* %src, i32 %len) {
   call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 %len, i1 false)
   ret void
Index: llvm/test/Other/cgscc-devirt-iteration.ll
===
--- llvm/test/Other/cgscc-devirt-iteration.ll
+++ llvm/test/Other/cgscc-devirt-iteration.ll
@@ -112,7 +112,7 @@
 ; CHECK-NOT: read
 ; CHECK-SAME: noinline
 ; BEFORE-LABEL: define void @test3(i8* %src, i8* %dest, i64 %size)
-; AFTER-LABEL: define void @test3(i8* nocapture readonly %src, i8* nocapture %dest, i64 %size)
+; AFTER-LABEL: define void @test3(i8* nocapture readonly %src, i8* nocapture writeonly %dest, i64 %size)
   %fptr = alloca i8* (i8*, i8*, i64)*
   store i8* (i8*, i8*, i64)* @memcpy, i8* (i8*, i8*, i64)** %fptr
   %f = load i8* (i8*, i8*, i64)*, i8* (i8*, i8*, i64)** %fptr
Index: llvm/test/Analysis/TypeBasedAliasAnalysis/functionattrs.ll
===
--- llvm/test/Analysis/TypeBasedAliasAnalysis/functionattrs.ll
+++ llvm/test/Analysis/TypeBasedAliasAnalysis/functionattrs.ll
@@ -49,7 +49,7 @@
   ret void
 }
 
-; CHECK: define void @test2_no(i8* nocapture %p, i8* nocapture readonly %q, i64 %n) #5 {
+; CHECK: define void @test2_no(i8* nocapture writeonly %p, i8* nocapture readonly %q, i64 %n) #5 {
 define void @test2_no(i8* %p, i8* %q, i64 %n) nounwind {
   call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p, i8* %q, i64 %n, i1 false), !tbaa !2
   ret void
Index: llvm/lib/Transforms/IPO/FunctionAttrs.cpp
===
--- llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -720,10 +720,16 @@
 
   // The accessors used on call site here do the right thing for calls and
   // invokes with operand bundles.
-  if (!CB.onlyReadsMemory() && !CB.onlyReadsMemory(UseIndex))
-return Attribute::None;
-  if (!CB.doesNotAccessMemory(UseIndex))
+  if (CB.doesNotAccessMemory(UseIndex)) {
+/* nop */
+  } else if (CB.onlyReadsMemory() || CB.onlyReadsMemory(UseIndex)) {
 IsRead = true;
+  } else if (CB.hasFnAttr(Attribute::WriteOnly) ||
+ CB.dataOperandHasImpliedAttr(UseIndex, Attribute::WriteOnly)) 

[clang] 6f6f88f - [clang-format] Style to separate definition blocks

2022-01-03 Thread via cfe-commits

Author: ksyx
Date: 2022-01-03T15:47:39-05:00
New Revision: 6f6f88ffdae1e12e5f950ef418827a77a55c09c7

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

LOG: [clang-format] Style to separate definition blocks

This commit resolves GitHub issue #45895 (Bugzilla #46550), to
add or remove empty line between definition blocks including
namespaces, classes, structs, enums and functions.

Reviewed By: MyDeveloperDay, curdeius, HazardyKnusperkeks

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

Added: 
clang/lib/Format/DefinitionBlockSeparator.cpp
clang/lib/Format/DefinitionBlockSeparator.h
clang/unittests/Format/DefinitionBlockSeparatorTest.cpp

Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/CMakeLists.txt
clang/lib/Format/Format.cpp
clang/lib/Format/WhitespaceManager.cpp
clang/lib/Format/WhitespaceManager.h
clang/unittests/Format/CMakeLists.txt

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 777398f460e0..4f3a9eb9f4a6 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3402,6 +3402,65 @@ the configuration (without a prefix: ``Auto``).
  /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with 
plenty of
   * information */
 
+**SeparateDefinitionBlocks** (``SeparateDefinitionStyle``) 
:versionbadge:`clang-format 14`
+  Specifies the use of empty lines to separate definition blocks, including 
classes,
+  structs, enums, and functions.
+
+  Possible values:
+
+  * ``SDS_Leave`` (in configuration: ``Leave``)
+Leave definition blocks as they are.
+
+  * ``SDS_Always`` (in configuration: ``Always``)
+Insert an empty line between definition blocks.
+
+  * ``SDS_Never`` (in configuration: ``Never``)
+Remove any empty line between definition blocks.
+
+  .. code-block:: c++
+
+ Never  v.s. Always
+ #include   #include 
+ struct Foo {
+   int a, b, c;  struct Foo {
+ };int a, b, c;
+ namespace Ns {  };
+ class Bar {
+ public: namespace Ns {
+   struct Foobar {   class Bar {
+ int a;  public:
+ int b;struct Foobar {
+   };int a;
+ private:int b;
+   int t;  };
+   int method1() {
+ // ...  private:
+   }   int t;
+   enum List {
+ ITEM1,int method1() {
+ ITEM2   // ...
+   };  }
+   template
+   int method2(T x) {  enum List {
+ // ...  ITEM1,
+   } ITEM2
+   int i, j, k;};
+   int method3(int par) {
+ // ...template
+   }   int method2(T x) {
+ };  // ...
+ class C {};   }
+ }
+   int i, j, k;
+
+   int method3(int par) {
+ // ...
+   }
+ };
+
+ class C {};
+ }
+
 **ShortNamespaceLines** (``Unsigned``) :versionbadge:`clang-format 14`
   The maximal number of unwrapped lines that a short namespace spans.
   Defaults to 1.

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 20e7e6cc26ce..2f48b1424d09 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -297,6 +297,10 @@ clang-format
   `const` `volatile` `static` `inline` `constexpr` `restrict`
   to be controlled relative to the `type`.
 
+- Option ``SeparateDefinitionBlocks`` has been added to insert or remove empty
+  lines between definition blocks including functions, classes, structs, enums,
+  and namespaces.
+
 - Add a ``Custom`` style to ``SpaceBeforeParens``, to better configure the
   space before parentheses. The custom options can be set using
   ``SpaceBeforeParensOptions``.

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 5044158a2015..24c245642e6a 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3054,6 +3054,63 @@ struct FormatStyle {
   bool R

[PATCH] D116553: [clang-format] Fix incorrect formatting of lambdas inside brace initialisation when the return type has square brackets `[]`.

2022-01-03 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius updated this revision to Diff 397123.
curdeius added a comment.

This patch fixes as well https://github.com/llvm/llvm-project/issues/27146.
Added a test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116553

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -20232,6 +20232,11 @@
"};");
   verifyFormat("[]() -> Void {};");
   verifyFormat("[a, b]() -> Tuple { return {}; };");
+  verifyFormat("SomeFunction({[]() -> int[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> int *[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> int (*)[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> ns::type { return {}; }});");
+  verifyFormat("return int{[x = x]() { return x; }()};");
 
   // Lambdas with explicit template argument lists.
   verifyFormat(
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1786,6 +1786,9 @@
 case tok::l_paren:
   parseParens();
   break;
+case tok::l_square:
+  parseSquare();
+  break;
 case tok::amp:
 case tok::star:
 case tok::kw_const:


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -20232,6 +20232,11 @@
"};");
   verifyFormat("[]() -> Void {};");
   verifyFormat("[a, b]() -> Tuple { return {}; };");
+  verifyFormat("SomeFunction({[]() -> int[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> int *[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> int (*)[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> ns::type { return {}; }});");
+  verifyFormat("return int{[x = x]() { return x; }()};");
 
   // Lambdas with explicit template argument lists.
   verifyFormat(
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1786,6 +1786,9 @@
 case tok::l_paren:
   parseParens();
   break;
+case tok::l_square:
+  parseSquare();
+  break;
 case tok::amp:
 case tok::star:
 case tok::kw_const:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116553: [clang-format] Fix incorrect formatting of lambdas inside brace initialisation when the return type has square brackets `[]`.

2022-01-03 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: MyDeveloperDay, HazardyKnusperkeks, owenpan.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes https://github.com/llvm/llvm-project/issues/52943.

Before:

  namespace ns {
  
  void foo() {
std::variant v;
std::visit(overloaded{[](auto &&) -> int (*)[] { return nullptr; }}, v);
  }
  
  } // namespace ns

got formatted as:

  namespace ns {
  
  void foo() {
std::variant v;
std::visit(overloaded{[](auto &&) -> int (*)[] { return nullptr;
  }
  } // namespace ns
  , v);
  }
  
  } // namespace ns


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116553

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -20232,6 +20232,10 @@
"};");
   verifyFormat("[]() -> Void {};");
   verifyFormat("[a, b]() -> Tuple { return {}; };");
+  verifyFormat("SomeFunction({[]() -> int[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> int *[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> int (*)[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> ns::type { return {}; }});");
 
   // Lambdas with explicit template argument lists.
   verifyFormat(
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1786,6 +1786,9 @@
 case tok::l_paren:
   parseParens();
   break;
+case tok::l_square:
+  parseSquare();
+  break;
 case tok::amp:
 case tok::star:
 case tok::kw_const:


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -20232,6 +20232,10 @@
"};");
   verifyFormat("[]() -> Void {};");
   verifyFormat("[a, b]() -> Tuple { return {}; };");
+  verifyFormat("SomeFunction({[]() -> int[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> int *[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> int (*)[] { return {}; }});");
+  verifyFormat("SomeFunction({[]() -> ns::type { return {}; }});");
 
   // Lambdas with explicit template argument lists.
   verifyFormat(
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1786,6 +1786,9 @@
 case tok::l_paren:
   parseParens();
   break;
+case tok::l_square:
+  parseSquare();
+  break;
 case tok::amp:
 case tok::star:
 case tok::kw_const:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115982: [clang][AVR] Implement '__flashN' for variables on different flash banks

2022-01-03 Thread Ayke via Phabricator via cfe-commits
aykevl added a comment.

avr-gcc checks whether the device supports the flash bank used. For example:

  $ cat test.c
  int d = 5;
  const int ro = 5;
  __flash const int f = 5;
  __flash1 const int f1 = 5;
  __flash2 const int f2 = 5;
  
  $ avr-gcc -mmcu=attiny84 -Os -c -o test.o test.c
  test.c:4:20: error: variable ‘f1’ located in address space ‘__flash1’ beyond 
flash of 64 KiB
   __flash1 const int f1 = 5;
  ^
  test.c:5:20: error: variable ‘f2’ located in address space ‘__flash2’ beyond 
flash of 64 KiB
   __flash2 const int f2 = 5;
  ^

It does not appear that this patch has a similar check, while I think that 
would be useful. Or did you leave it out intentionally?


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

https://reviews.llvm.org/D115982

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


[PATCH] D116283: [clang-format] Add an option to add a space between operator overloading and opening parentheses

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

Thanks for adding the parse checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116283

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


[PATCH] D115106: [clang-tidy] Fix `readability-static-accessed-through-instance` false negative for static methods

2022-01-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D115106#3218000 , @aaron.ballman 
wrote:

>> I think `anyRedeclaration(functionDecl(isStaticStorageClass))`is too 
>> difficult to get right and too easy to get wrong for such a common/simple 
>> concept.
>
> Get right in terms of implementation, or in terms of use, or both?

Use, if I'm understanding your question.
If we don't expose this as a matcher with some name, it's a recipe the person 
writing the matcher has to remember.
There's no good way to look it up, and it's easy to write something that seems 
good but isn't.

(This problem is pervasive with AST and matchers, and this isn't the worst 
example.)

>> I know what a static method is, but I would have made the same mistake here. 
>> In general asking people to describe syntax to answer a semantic question 
>> invites this.
>
> Because our AST is intended to reflect the syntax, our AST matchers kind of 
> *do* match syntax -- I think it's the reason we're in the problem (and this 
> is not the first time it's come up).

The clang AST is the best tool we have to describe syntax *and* to describe 
semantics.
Maybe by design it captures "all" syntax and "enough" semantics, but users 
reasonably care less about the design than about their alternatives and 
problems. The clang AST is useful for answering syntax questions (better than 
regex!) but it's _irreplaceable_ for answering semantics questions (better 
than... err?).

So we have syntax and semantics in one namespace, and static is the worst 
because it means like 3 syntactic and 5 semantic things :-(

> There's a cognitive disconnect between the AST matchers traversing the AST 
> and applying a match on all node and the C & C++ concept of redeclarations.

Definitely, this highlights the disconnect really well.
And some of the accessors on a redecl will delegate to the canonical while 
others won't. (Can we call this "syntax semantics" vs "semantics semantics"?!)

I definitely think we *should* have a redecl matcher - I just don't think we 
should make users use it to answer common semantic questions.
That leaves matcher authors remembering and reciting the rules about how syntax 
aggregates over redecls to produce semantics. We'll make mistakes.

>> Here's a hack: CXXMethodDecl has both `isStatic()` and `isInstance()`. I 
>> agree that `isStatic` is a risky name, but I don't think `isInstance` is. 
>> Can we just spell the matcher you want `not(isInstance())`?
>
> This could work, but I don't think it's particularly satisfying in situations 
> that aren't binary.

Oh, I totally agree. I just meant specifically for this case, as a way to avoid 
the dilemma of ambiguous vs unwieldy.

> This could work, but I don't think it's particularly satisfying in situations 
> that aren't binary. Like asking "does this have static storage duration" (as 
> opposed to thread, automatic, or dynamic storage duration). And it turns out 
> that the behavior there is opposite to asking about the storage class 
> specifier: https://godbolt.org/z/hqserfxzs

I'm not totally surprised by that, because "storage duration" sounds like a 
semantic property to me, while "storage class" (specifier) is a syntactic 
feature.
But it's not a distinction I'd pick up on if I wasn't looking for it, and 
different people are going to read things different ways.

My favorite naming convention I've seen in the AST is e.g. `getBlob()` vs 
`getBlobAsWritten()`.
Maybe `getEffectiveBlob()` would be even clearer for the semantic version.
But I'm not sure how much it's possible to realign matcher names around that 
sort of thing if the AST names aren't going to change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115106

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


[PATCH] D116518: [ast-matchers] Add hasSubstatementSequence matcher

2022-01-03 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood updated this revision to Diff 397121.
LegalizeAdulthood marked an inline comment as done.
LegalizeAdulthood added a comment.

Add `stmtExpr` test case


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

https://reviews.llvm.org/D116518

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

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2604,6 +2604,73 @@
   EXPECT_TRUE(matchesObjC("void f() { ^{}(); }", blockExpr()));
 }
 
+TEST_P(ASTMatchersTest, HasSubstatementSequenceSimple) {
+  const char *Text = "int f() { int x = 5; if (x < 0) return 1; return 0; }";
+  EXPECT_TRUE(matches(
+  Text, compoundStmt(hasSubstatementSequence(ifStmt(), returnStmt();
+  EXPECT_FALSE(matches(
+  Text, compoundStmt(hasSubstatementSequence(ifStmt(), labelStmt();
+  EXPECT_FALSE(matches(
+  Text, compoundStmt(hasSubstatementSequence(returnStmt(), ifStmt();
+  EXPECT_FALSE(matches(
+  Text, compoundStmt(hasSubstatementSequence(switchStmt(), labelStmt();
+}
+
+TEST_P(ASTMatchersTest, HasSubstatementSequenceAlmost) {
+  const char *Text = R"code(
+int f() {
+  int x = 5;
+  if (x < 10)
+;
+  if (x < 0)
+return 1;
+  return 0;
+}
+)code";
+  EXPECT_TRUE(matches(
+  Text, compoundStmt(hasSubstatementSequence(ifStmt(), returnStmt();
+  EXPECT_TRUE(
+  matches(Text, compoundStmt(hasSubstatementSequence(ifStmt(), ifStmt();
+}
+
+TEST_P(ASTMatchersTest, HasSubstatementSequenceComplex) {
+  const char *Text = R"code(
+int f() {
+  int x = 5;
+  if (x < 10)
+x -= 10;
+  if (x < 0)
+return 1;
+  return 0;
+}
+)code";
+  EXPECT_TRUE(matches(
+  Text, compoundStmt(hasSubstatementSequence(ifStmt(), returnStmt();
+  EXPECT_FALSE(
+  matches(Text, compoundStmt(hasSubstatementSequence(ifStmt(), expr();
+}
+
+TEST_P(ASTMatchersTest, HasSubstatementSequenceExpression) {
+const char *Text = R"code(
+int f() {
+  return ({ int x = 5;
+  int result;
+  if (x < 10)
+x -= 10;
+  if (x < 0)
+result = 1;
+  else
+result = 0;
+  result;
+});
+  }
+)code";
+EXPECT_TRUE(matches(
+Text, stmtExpr(hasSubstatementSequence(ifStmt(), expr();
+EXPECT_FALSE(
+matches(Text, stmtExpr(hasSubstatementSequence(ifStmt(), returnStmt();
+}
+
 TEST_P(ASTMatchersTest,
StatementCountIs_FindsNoStatementsInAnEmptyCompoundStatement) {
   EXPECT_TRUE(matches("void f() { }", compoundStmt(statementCountIs(0;
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -355,6 +355,7 @@
   REGISTER_MATCHER(hasSpecializedTemplate);
   REGISTER_MATCHER(hasStaticStorageDuration);
   REGISTER_MATCHER(hasStructuredBlock);
+  REGISTER_MATCHER(hasSubstatementSequence);
   REGISTER_MATCHER(hasSyntacticForm);
   REGISTER_MATCHER(hasTargetDecl);
   REGISTER_MATCHER(hasTemplateArgument);
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -5432,6 +5432,35 @@
   Builder) != CS->body_end();
 }
 
+/// Matches two consecutive statements within a compound statement.
+///
+/// Given
+/// \code
+///   { if (x > 0) return true; return false; }
+/// \endcode
+/// compoundStmt(hasSubstatementSequence(ifStmt(), returnStmt()))
+///   matches '{ if (x > 0) return true; return false; }'
+AST_POLYMORPHIC_MATCHER_P2(hasSubstatementSequence,
+   AST_POLYMORPHIC_SUPPORTED_TYPES(CompoundStmt,
+   StmtExpr),
+   internal::Matcher, InnerMatcher1,
+   internal::Matcher, InnerMatcher2) {
+  if (const CompoundStmt *CS = CompoundStmtMatcher::get(Node)) {
+auto It = matchesFirstInPointerRange(InnerMatcher1, CS->body_begin(),
+ CS->body_end(), Finder, Builder);
+while (It != CS->body_end()) {
+  ++It;
+  if (It == CS->body_end())
+return false;
+  if (InnerMatcher2.matches(**It, Finder, Builder))
+return true;
+  It = matchesFirstInPointerRange(InnerMatcher1, It, CS->body_end(), Finder,
+  Builder);
+}
+  }
+  return false;
+}
+
 /// Checks that a compound statement contains a specific number of
 /// child statements.
 ///
Index: 

[PATCH] D116170: [clang-format] Add penalty for breaking after '('

2022-01-03 Thread Marek Kurdej 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 rGcfe3180742ad: [clang-format] Add penalty for breaking after 
'(' (authored by G. Pery , committed by curdeius).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116170

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -18524,6 +18524,66 @@
 format("int a = /* long block comment */ 42;", Style));
 }
 
+TEST_F(FormatTest, BreakPenaltyAfterLParen) {
+  FormatStyle Style = getLLVMStyle();
+  Style.ColumnLimit = 8;
+  Style.PenaltyExcessCharacter = 15;
+  verifyFormat("int foo(\n"
+   "int );",
+   Style);
+  Style.PenaltyBreakOpenParenthesis = 200;
+  EXPECT_EQ("int foo(int );",
+format("int foo(\n"
+   "int );",
+   Style));
+}
+
+TEST_F(FormatTest, BreakPenaltyAfterCastLParen) {
+  FormatStyle Style = getLLVMStyle();
+  Style.ColumnLimit = 5;
+  Style.PenaltyExcessCharacter = 150;
+  verifyFormat("foo((\n"
+   "int));",
+
+   Style);
+  Style.PenaltyBreakOpenParenthesis = 10;
+  EXPECT_EQ("foo((int)\n"
+");",
+format("foo((\n"
+   "int));",
+   Style));
+}
+
+TEST_F(FormatTest, BreakPenaltyAfterForLoopLParen) {
+  FormatStyle Style = getLLVMStyle();
+  Style.ColumnLimit = 4;
+  Style.PenaltyExcessCharacter = 100;
+  verifyFormat("for (\n"
+   "int i =\n"
+   "0;\n"
+   "i <\n"
+   "2;\n"
+   "i++) {\n"
+   "}",
+
+   Style);
+  Style.PenaltyBreakOpenParenthesis = 1250;
+  EXPECT_EQ("for (int i =\n"
+" 0;\n"
+" i <\n"
+" 2;\n"
+" i++) {\n"
+"}",
+format("for (\n"
+   "int i =\n"
+   "0;\n"
+   "i <\n"
+   "2;\n"
+   "i++) {\n"
+   "}",
+   Style));
+}
+
 #define EXPECT_ALL_STYLES_EQUAL(Styles)\
   for (size_t i = 1; i < Styles.size(); ++i)   \
   EXPECT_EQ(Styles[0], Styles[i])  \
@@ -18729,6 +18789,8 @@
   PenaltyBreakBeforeFirstCallParameter, 1234u);
   CHECK_PARSE("PenaltyBreakTemplateDeclaration: 1234",
   PenaltyBreakTemplateDeclaration, 1234u);
+  CHECK_PARSE("PenaltyBreakOpenParenthesis: 1234", PenaltyBreakOpenParenthesis,
+  1234u);
   CHECK_PARSE("PenaltyExcessCharacter: 1234", PenaltyExcessCharacter, 1234u);
   CHECK_PARSE("PenaltyReturnTypeOnItsOwnLine: 1234",
   PenaltyReturnTypeOnItsOwnLine, 1234u);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2857,6 +2857,8 @@
   Left.Previous->isOneOf(tok::identifier, tok::greater))
 return 500;
 
+  if (Left.is(tok::l_paren) && Style.PenaltyBreakOpenParenthesis != 0)
+return Style.PenaltyBreakOpenParenthesis;
   if (Left.is(tok::l_paren) && InFunctionDecl &&
   Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign)
 return 100;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -756,6 +756,8 @@
 IO.mapOptional("PenaltyBreakComment", Style.PenaltyBreakComment);
 IO.mapOptional("PenaltyBreakFirstLessLess",
Style.PenaltyBreakFirstLessLess);
+IO.mapOptional("PenaltyBreakOpenParenthesis",
+   Style.PenaltyBreakOpenParenthesis);
 IO.mapOptional("PenaltyBreakString", Style.PenaltyBreakString);
 IO.mapOptional("PenaltyBreakTemplateDeclaration",
Style.PenaltyBreakTemplateDeclaration);
@@ -1232,6 +1234,7 @@
   LLVMStyle.PenaltyExcessCharacter = 100;
   LLVMStyle.PenaltyReturnTypeOnItsOwnLine = 60;
   LLVMStyle.PenaltyBreakBeforeFirstCallParameter = 19;
+  LLVMStyle.Penal

[clang] cfe3180 - [clang-format] Add penalty for breaking after '('

2022-01-03 Thread Marek Kurdej via cfe-commits

Author: G. Pery
Date: 2022-01-03T21:06:34+01:00
New Revision: cfe3180742adfc72ad6f5de55cbfc84befb90c97

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

LOG: [clang-format] Add penalty for breaking after '('

My team has a vendetta against lines ending with an open parenthesis, thought 
it might be useful for others too 😊

Reviewed By: HazardyKnusperkeks, curdeius

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 07c77acb84810..777398f460e09 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3198,6 +3198,9 @@ the configuration (without a prefix: ``Auto``).
 **PenaltyBreakTemplateDeclaration** (``Unsigned``) :versionbadge:`clang-format 
7`
   The penalty for breaking after template declaration.
 
+**PenaltyBreakOpenParenthesis** (``Unsigned``) :versionbadge:`clang-format 14`
+  The penalty for breaking after ``(``.
+
 **PenaltyExcessCharacter** (``Unsigned``) :versionbadge:`clang-format 3.7`
   The penalty for each character outside of the column limit.
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index dbc406417ba19..5044158a20156 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2887,6 +2887,10 @@ struct FormatStyle {
   /// \version 3.7
   unsigned PenaltyBreakFirstLessLess;
 
+  /// The penalty for breaking after ``(``.
+  /// \version 14
+  unsigned PenaltyBreakOpenParenthesis;
+
   /// The penalty for each line break introduced inside a string literal.
   /// \version 3.7
   unsigned PenaltyBreakString;
@@ -3781,6 +3785,7 @@ struct FormatStyle {
R.PenaltyBreakBeforeFirstCallParameter &&
PenaltyBreakComment == R.PenaltyBreakComment &&
PenaltyBreakFirstLessLess == R.PenaltyBreakFirstLessLess &&
+   PenaltyBreakOpenParenthesis == R.PenaltyBreakOpenParenthesis &&
PenaltyBreakString == R.PenaltyBreakString &&
PenaltyExcessCharacter == R.PenaltyExcessCharacter &&
PenaltyReturnTypeOnItsOwnLine == R.PenaltyReturnTypeOnItsOwnLine &&

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 0ae9fa60d3376..fdccb8b15e829 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -756,6 +756,8 @@ template <> struct MappingTraits {
 IO.mapOptional("PenaltyBreakComment", Style.PenaltyBreakComment);
 IO.mapOptional("PenaltyBreakFirstLessLess",
Style.PenaltyBreakFirstLessLess);
+IO.mapOptional("PenaltyBreakOpenParenthesis",
+   Style.PenaltyBreakOpenParenthesis);
 IO.mapOptional("PenaltyBreakString", Style.PenaltyBreakString);
 IO.mapOptional("PenaltyBreakTemplateDeclaration",
Style.PenaltyBreakTemplateDeclaration);
@@ -1232,6 +1234,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.PenaltyExcessCharacter = 100;
   LLVMStyle.PenaltyReturnTypeOnItsOwnLine = 60;
   LLVMStyle.PenaltyBreakBeforeFirstCallParameter = 19;
+  LLVMStyle.PenaltyBreakOpenParenthesis = 0;
   LLVMStyle.PenaltyBreakTemplateDeclaration = prec::Relational;
   LLVMStyle.PenaltyIndentedWhitespace = 0;
 

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 914997a54989d..a161ee87e6b52 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2857,6 +2857,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine 
&Line,
   Left.Previous->isOneOf(tok::identifier, tok::greater))
 return 500;
 
+  if (Left.is(tok::l_paren) && Style.PenaltyBreakOpenParenthesis != 0)
+return Style.PenaltyBreakOpenParenthesis;
   if (Left.is(tok::l_paren) && InFunctionDecl &&
   Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign)
 return 100;

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 470b0c7a19e5d..49635f3f15eae 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -18524,6 +18524,66 @@ TEST_F(FormatTest, OptimizeBreakPenaltyVsExcess) {
 format("int a = /* long block comment */ 42;", Style));
 }
 
+TEST_F(FormatTest, BreakPenaltyAfterLParen) {
+  FormatStyle Style = getLLVMStyle();
+  Style.ColumnLimit = 8;
+  Style.PenaltyExcessCharacter = 15;
+  verifyFormat("int foo(\n"
+   "int );",

[PATCH] D116283: [clang-format] Add an option to add a space between operator overloading and opening parentheses

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

LGTM.
If you need help landing this (if you don't have commit rights), just give your 
name and email that you want to be used for the contribution and someone will 
land it for you.

See also https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access if 
you think contributing more patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116283

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


[PATCH] D116547: Revert "[amdgpu] Enable selection of `s_cselect_b64`."

2022-01-03 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai requested changes to this revision.
smeenai added a comment.
This revision now requires changes to proceed.
Herald added a subscriber: JDevlieghere.

This doesn't seem like a correct revert.

What command are you using to generate this? `git revert` is what you should be 
using, e.g.

  git revert 640beb38e7710b939b3cfb3f4c54accc694b1d30

You should also edit the commit message afterwards (`git commit --amend`) to 
explain why you're reverting the change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116547

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


[PATCH] D116518: [ast-matchers] Add hasSubstatementSequence matcher

2022-01-03 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood marked an inline comment as done.
LegalizeAdulthood added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:5435-5442
+/// Matches two consecutive statements within a compound statement.
+///
+/// Given
+/// \code
+///   { if (x > 0) return true; return false; }
+/// \endcode
+/// compoundStmt(hasSubstatementSequence(ifStmt(), returnStmt()))

aaron.ballman wrote:
> How do we extend this to support testing arbitrary sequences of statements? 
> (If this supports two statements, someone will find a need for three, etc).
Yeah, I was wondering that too.  I didn't see (but didn't look extensively) any 
support for variadic matchers taking a parameter pack.

I stopped at 2 because this suits my immediate needs with 
`readability-simplify-boolean-expr` where I have to manually loop over 
`CompoundStmt` matches in order to verify that the `if (x) return true; return 
false;` constructs consist of two adjacent statements.



Comment at: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp:2636
+
+TEST_P(ASTMatchersTest, HasSubstatementSequenceComplex) {
+  const char *Text = R"code(

aaron.ballman wrote:
> Some more complex-ish tests: can we match within function try or catch blocks 
> and GNU statement expressions?
Adding something for GNU statement expressions is a good idea.

I'm open for other suggestions that might improve coverage.

At the moment, I believe I have 100% coverage of the new matcher, with the 
exception of GNU statement expressions (honestly, I just copy/pasted that from 
another matcher on `CompoundStmt`, I wasn't even aware of this GNU extension).


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

https://reviews.llvm.org/D116518

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


[PATCH] D116521: [CMake] Factor out config prefix finding logic

2022-01-03 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 397116.
Ericson2314 added a comment.

Oops, forgot some includes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116521

Files:
  clang/CMakeLists.txt
  clang/cmake/modules/CMakeLists.txt
  cmake/Modules/FindPrefixFromConfig.cmake
  flang/cmake/modules/CMakeLists.txt
  lld/cmake/modules/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/CMakeLists.txt
  mlir/CMakeLists.txt
  mlir/cmake/modules/CMakeLists.txt

Index: mlir/cmake/modules/CMakeLists.txt
===
--- mlir/cmake/modules/CMakeLists.txt
+++ mlir/cmake/modules/CMakeLists.txt
@@ -1,4 +1,5 @@
 include(LLVMDistributionSupport)
+include(FindPrefixFromConfig)
 
 # Generate a list of CMake library targets so that other CMake projects can
 # link against them. LLVM calls its version of this file LLVMExports.cmake, but
@@ -44,16 +45,7 @@
   )
 
 # Generate MLIRConfig.cmake for the install tree.
-set(MLIR_CONFIG_CODE "
-# Compute the installation prefix from this MLIRConfig.cmake file location.
-get_filename_component(MLIR_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
-# Construct the proper number of get_filename_component(... PATH)
-# calls to compute the installation prefix.
-string(REGEX REPLACE "/" ";" _count "${MLIR_INSTALL_PACKAGE_DIR}")
-foreach(p ${_count})
-  set(MLIR_CONFIG_CODE "${MLIR_CONFIG_CODE}
-get_filename_component(MLIR_INSTALL_PREFIX \"\${MLIR_INSTALL_PREFIX}\" PATH)")
-endforeach(p)
+find_prefix_from_config(MLIR_CONFIG_CODE MLIR_INSTALL_PREFIX "${MLIR_INSTALL_PACKAGE_DIR}")
 set(MLIR_CONFIG_CMAKE_DIR "\${MLIR_INSTALL_PREFIX}/${MLIR_INSTALL_PACKAGE_DIR}")
 set(MLIR_CONFIG_LLVM_CMAKE_DIR "\${MLIR_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
 get_config_exports_includes(MLIR MLIR_CONFIG_INCLUDE_EXPORTS)
Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -33,7 +33,16 @@
 set(MLIR_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
 set(MLIR_TOOLS_DIR   ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 
-list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
+if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
+  set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
+endif()
+
+# Make sure that our source directory is on the current cmake module path so
+# that we can include cmake files from this directory.
+list(INSERT CMAKE_MODULE_PATH 0
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
+  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
+  )
 
 include(AddMLIR)
 
Index: llvm/cmake/modules/CMakeLists.txt
===
--- llvm/cmake/modules/CMakeLists.txt
+++ llvm/cmake/modules/CMakeLists.txt
@@ -1,4 +1,5 @@
 include(LLVMDistributionSupport)
+include(FindPrefixFromConfig)
 
 set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
 set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
@@ -99,16 +100,7 @@
   )
 
 # Generate LLVMConfig.cmake for the install tree.
-set(LLVM_CONFIG_CODE "
-# Compute the installation prefix from this LLVMConfig.cmake file location.
-get_filename_component(LLVM_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
-# Construct the proper number of get_filename_component(... PATH)
-# calls to compute the installation prefix.
-string(REGEX REPLACE "/" ";" _count "${LLVM_INSTALL_PACKAGE_DIR}")
-foreach(p ${_count})
-  set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE}
-get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)")
-endforeach(p)
+find_prefix_from_config(LLVM_CONFIG_CODE LLVM_INSTALL_PREFIX "${LLVM_INSTALL_PACKAGE_DIR}")
 set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include")
 set(LLVM_CONFIG_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}")
 set(LLVM_CONFIG_MAIN_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}")
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -196,11 +196,13 @@
   set(LLVM_GISEL_COV_PREFIX "${CMAKE_BINARY_DIR}/gisel-coverage-" CACHE STRING "Provide a filename prefix to collect the GlobalISel rule coverage")
 endif()
 
+set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
+
 # Add path for custom modules
-set(CMAKE_MODULE_PATH
-  ${CMAKE_MODULE_PATH}
+list(INSERT CMAKE_MODULE_PATH 0
   "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
   "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
+  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
   )
 
 # Generate a CompilationDatabase (compile_commands.json file) for our build,
@@ -308,7 +310,6 @@
 set(LLVM_BINARY_DIR   ${CMAKE_CURRENT_BINARY_DIR}  ) # --prefix
 
 set(LLVM_THIRD_PARTY_DIR  ${CMAKE_CURRENT_SOURCE_DIR}/../third-party)
-set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
 
 # Note: LLVM_CMAKE_DIR does not include generated files
 set(LLVM_CMAKE_DIR ${LLVM_MAIN_SRC_

[PATCH] D116550: [clang-tidy] Recognize transformer checks as providing fixits

2022-01-03 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood updated this revision to Diff 397115.
LegalizeAdulthood added a comment.

Formatting


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

https://reviews.llvm.org/D116550

Files:
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
  clang-tools-extra/docs/clang-tidy/checks/list.rst

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
@@ -116,13 +116,12 @@
`cert-dcl50-cpp `_,
`cert-dcl58-cpp `_,
`cert-env33-c `_,
+   `cert-err33-c `_,
`cert-err34-c `_,
`cert-err52-cpp `_,
`cert-err58-cpp `_,
`cert-err60-cpp `_,
-   `cert-exp42-c `_,
`cert-flp30-c `_,
-   `cert-flp37-c `_,
`cert-mem57-cpp `_,
`cert-msc50-cpp `_,
`cert-msc51-cpp `_,
@@ -213,7 +212,7 @@
`llvmlibc-implementation-in-namespace `_,
`llvmlibc-restrict-system-libc-headers `_, "Yes"
`misc-definitions-in-headers `_, "Yes"
-   `misc-misleading-identifier `_,
+   `misc-misleading-identifier `_,
`misc-misplaced-const `_,
`misc-new-delete-overloads `_,
`misc-no-recursion `_,
@@ -260,8 +259,8 @@
`modernize-use-using `_, "Yes"
`mpi-buffer-deref `_, "Yes"
`mpi-type-mismatch `_, "Yes"
-   `objc-avoid-nserror-init `_,
`objc-assert-equals `_, "Yes"
+   `objc-avoid-nserror-init `_,
`objc-dealloc-in-category `_,
`objc-forbidden-subclassing `_,
`objc-missing-hash `_,
@@ -283,16 +282,16 @@
`performance-noexcept-move-constructor `_, "Yes"
`performance-trivially-destructible `_, "Yes"
`performance-type-promotion-in-math-fn `_, "Yes"
-   `performance-unnecessary-copy-initialization `_,
+   `performance-unnecessary-copy-initialization `_, "Yes"
`performance-unnecessary-value-param `_, "Yes"
`portability-restrict-system-includes `_, "Yes"
`portability-simd-intrinsics `_,
-   `readability-avoid-const-params-in-decls `_,
+   `readability-avoid-const-params-in-decls `_, "Yes"
`readability-braces-around-statements `_, "Yes"
`readability-const-return-type `_, "Yes"
`readability-container-data-pointer `_, "Yes"
`readability-container-size-empty `_, "Yes"
-   `readability-convert-member-functions-to-static `_,
+   `readability-convert-member-functions-to-static `_, "Yes"
`readability-delete-null-pointer `_, "Yes"
`readability-else-after-return `_, "Yes"
`readability-function-cognitive-complexity `_,
@@ -338,13 +337,14 @@
`cert-dcl03-c `_, `misc-static-assert `_, "Yes"
`cert-dcl16-c `_, `readability-uppercase-literal-suffix `_, "Yes"
`cert-dcl37-c `_, `bugprone-reserved-identifier `_, "Yes"
-   `cert-err33-c `_, `bugprone-unused-return-value `_,
`cert-dcl51-cpp `_, `bugprone-reserved-identifier `_, "Yes"
`cert-dcl54-cpp `_, `misc-new-delete-overloads `_,
`cert-dcl59-cpp `_, `google-build-namespaces `_,
`cert-err09-cpp `_, `misc-throw-by-value-catch-by-reference `_,
`cert-err61-cpp `_, `misc-throw-by-value-catch-by-reference `_,
+   `cert-exp42-c `_, `bugprone-suspicious-memory-comparison `_,
`cert-fio38-c `_, `misc-non-copyable-objects `_,
+   `cert-flp37-c `_, `bugprone-suspicious-memory-comparison `_,
`cert-msc30-c `_, `cert-msc50-cpp `_,
`cert-msc32-c `_, `cert-msc51-cpp `_,
`cert-oop11-cpp `_, `performance-move-constructor-init `_,
Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
===
--- clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
@@ -54,7 +54,7 @@
 StringRef Name, ClangTidyContext *Context);
 
   /// Convenience overload of the constructor when the rule doesn't have any
-  /// dependies.
+  /// dependencies.
   TransformerClangTidyCheck(transformer::RewriteRule R, StringRef Name,
 ClangTidyContext *Context);
 
Index: clang-tools-extra/clang-tidy/add_new_check.py
===
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -324,16 +324,20 @@
 dirname, _, check_name = check_name.partition("-")
 
 checker_code = get_actual_filename(os.path.join(clang_tidy_path, dirname),
-   get_camel_name(check_name) + '.cpp')
-
+   get_camel_check_name(check_name) + '.cpp')
 if not os.path.isfile(checker_code):
-  return ""
+  # Some older checks don't end with 'Check.cpp'
+  checker_code = get_actual_filename(os.path.join(clang_tidy_path, dirname),
+ get_camel_name(check_name) + '.cpp')
+  if not os.path.isfile(checker_code):
+return ''
 
 with io

[PATCH] D114077: [clangd] Basic IncludeCleaner support for c/c++ standard library

2022-01-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D114077#3218006 , @thakis wrote:

> Breaks building on windows: http://45.33.8.238/win/51774/step_4.txt
>
> Ptal!

Fixed (I think) in a61f34ea2502d900c57a332174d4c103b6963c80 
.
Clang successfully emulated MSVC's misunderstanding of the code :-(




Comment at: clang-tools-extra/clangd/Headers.h:330
+  static inline clang::clangd::stdlib::Header getEmptyKey() {
+return clang::clangd::stdlib::Header(-1);
+  }

kbobyrev wrote:
> sammccall wrote:
> > kbobyrev wrote:
> > > maybe `DenseMapInfo::getEmptyKey()` and 
> > > `DenseMapInfo::getTombstoneKey()` just like above?
> > empty/tombstone keys are reserved values, and we know what sensible 
> > reserved values are better than the traits for unsigned do. 
> > 
> > I can fix the code above if you like.
> Okay, that makes sense! Yes, that would be great if you could fix the code 
> above for consistency :)
Done... yikes, the existing HeaderID empty key was zero... which is also the 
HeaderID for the main file!

Changed these to -1 and -2. Hopefully this is NFC, else maybe it fixed a scary 
bug...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114077

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


[PATCH] D116521: [llvm][clang][flang][lld][cmake] Factor out config prefix finding logic

2022-01-03 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 397114.
Ericson2314 added a comment.
Herald added subscribers: sdasgup3, wenzhicui, wrengr, Chia-hungDuan, dcaballe, 
cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, 
Joonsoo, stephenneuendorffer, liufengdb, aartbik, lucyrfox, mgester, 
arpith-jacob, nicolasvasilache, antiagainst, shauheen, rriddle, mehdi_amini.
Herald added a project: MLIR.

Get MLIR too


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116521

Files:
  clang/CMakeLists.txt
  clang/cmake/modules/CMakeLists.txt
  cmake/Modules/FindPrefixFromConfig.cmake
  flang/cmake/modules/CMakeLists.txt
  lld/cmake/modules/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/CMakeLists.txt
  mlir/CMakeLists.txt
  mlir/cmake/modules/CMakeLists.txt

Index: mlir/cmake/modules/CMakeLists.txt
===
--- mlir/cmake/modules/CMakeLists.txt
+++ mlir/cmake/modules/CMakeLists.txt
@@ -44,16 +44,7 @@
   )
 
 # Generate MLIRConfig.cmake for the install tree.
-set(MLIR_CONFIG_CODE "
-# Compute the installation prefix from this MLIRConfig.cmake file location.
-get_filename_component(MLIR_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
-# Construct the proper number of get_filename_component(... PATH)
-# calls to compute the installation prefix.
-string(REGEX REPLACE "/" ";" _count "${MLIR_INSTALL_PACKAGE_DIR}")
-foreach(p ${_count})
-  set(MLIR_CONFIG_CODE "${MLIR_CONFIG_CODE}
-get_filename_component(MLIR_INSTALL_PREFIX \"\${MLIR_INSTALL_PREFIX}\" PATH)")
-endforeach(p)
+find_prefix_from_config(MLIR_CONFIG_CODE MLIR_INSTALL_PREFIX "${MLIR_INSTALL_PACKAGE_DIR}")
 set(MLIR_CONFIG_CMAKE_DIR "\${MLIR_INSTALL_PREFIX}/${MLIR_INSTALL_PACKAGE_DIR}")
 set(MLIR_CONFIG_LLVM_CMAKE_DIR "\${MLIR_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
 get_config_exports_includes(MLIR MLIR_CONFIG_INCLUDE_EXPORTS)
Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -33,7 +33,16 @@
 set(MLIR_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
 set(MLIR_TOOLS_DIR   ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 
-list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
+if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
+  set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
+endif()
+
+# Make sure that our source directory is on the current cmake module path so
+# that we can include cmake files from this directory.
+list(INSERT CMAKE_MODULE_PATH 0
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
+  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
+  )
 
 include(AddMLIR)
 
Index: llvm/cmake/modules/CMakeLists.txt
===
--- llvm/cmake/modules/CMakeLists.txt
+++ llvm/cmake/modules/CMakeLists.txt
@@ -1,4 +1,5 @@
 include(LLVMDistributionSupport)
+include(FindPrefixFromConfig)
 
 set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
 set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
@@ -99,16 +100,7 @@
   )
 
 # Generate LLVMConfig.cmake for the install tree.
-set(LLVM_CONFIG_CODE "
-# Compute the installation prefix from this LLVMConfig.cmake file location.
-get_filename_component(LLVM_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
-# Construct the proper number of get_filename_component(... PATH)
-# calls to compute the installation prefix.
-string(REGEX REPLACE "/" ";" _count "${LLVM_INSTALL_PACKAGE_DIR}")
-foreach(p ${_count})
-  set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE}
-get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)")
-endforeach(p)
+find_prefix_from_config(LLVM_CONFIG_CODE LLVM_INSTALL_PREFIX "${LLVM_INSTALL_PACKAGE_DIR}")
 set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include")
 set(LLVM_CONFIG_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}")
 set(LLVM_CONFIG_MAIN_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}")
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -196,11 +196,13 @@
   set(LLVM_GISEL_COV_PREFIX "${CMAKE_BINARY_DIR}/gisel-coverage-" CACHE STRING "Provide a filename prefix to collect the GlobalISel rule coverage")
 endif()
 
+set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
+
 # Add path for custom modules
-set(CMAKE_MODULE_PATH
-  ${CMAKE_MODULE_PATH}
+list(INSERT CMAKE_MODULE_PATH 0
   "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
   "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
+  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
   )
 
 # Generate a CompilationDatabase (compile_commands.json file) for our build,
@@ -308,7 +310,6 @@
 set(LLVM_BINARY_DIR   ${CMAKE_CURRENT_BINARY_DIR}  ) # --prefix
 
 set(LLVM_THIRD_PARTY_DIR  ${CMAKE_CURRENT_SOURCE_DIR}/../third-party)
-set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
 
 # Note: LL

[PATCH] D116283: [clang-format] Add an option to add a space between operator overloading and opening parentheses

2022-01-03 Thread Rajat Bajpai via Phabricator via cfe-commits
rajatbajpai updated this revision to Diff 397112.
rajatbajpai added a comment.

Incorporated review comments.

Updated release note and example scenario.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116283

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14529,6 +14529,24 @@
   // verifyFormat("X A::operator++ (T);", SomeSpace2);
   verifyFormat("int x = int (y);", SomeSpace2);
   verifyFormat("auto lambda = []() { return 0; };", SomeSpace2);
+
+  FormatStyle SpaceAfterOverloadedOperator = getLLVMStyle();
+  SpaceAfterOverloadedOperator.SpaceBeforeParens = FormatStyle::SBPO_Custom;
+  SpaceAfterOverloadedOperator.SpaceBeforeParensOptions
+  .AfterOverloadedOperator = true;
+
+  verifyFormat("auto operator++ () -> int;", SpaceAfterOverloadedOperator);
+  verifyFormat("X A::operator++ ();", SpaceAfterOverloadedOperator);
+  verifyFormat("some_object.operator++ ();", SpaceAfterOverloadedOperator);
+  verifyFormat("auto func() -> int;", SpaceAfterOverloadedOperator);
+
+  SpaceAfterOverloadedOperator.SpaceBeforeParensOptions
+  .AfterOverloadedOperator = false;
+
+  verifyFormat("auto operator++() -> int;", SpaceAfterOverloadedOperator);
+  verifyFormat("X A::operator++();", SpaceAfterOverloadedOperator);
+  verifyFormat("some_object.operator++();", SpaceAfterOverloadedOperator);
+  verifyFormat("auto func() -> int;", SpaceAfterOverloadedOperator);
 }
 
 TEST_F(FormatTest, SpaceAfterLogicalNot) {
@@ -18704,6 +18722,15 @@
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, SplitEmptyFunction);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, SplitEmptyRecord);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, SplitEmptyNamespace);
+  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterControlStatements);
+  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterForeachMacros);
+  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions,
+  AfterFunctionDeclarationName);
+  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions,
+  AfterFunctionDefinitionName);
+  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterIfMacros);
+  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterOverloadedOperator);
+  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, BeforeNonEmptyParentheses);
 }
 
 #undef CHECK_PARSE_BOOL
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2921,9 +2921,15 @@
 }
 
 bool TokenAnnotator::spaceRequiredBeforeParens(const FormatToken &Right) const {
-  return Style.SpaceBeforeParens == FormatStyle::SBPO_Always ||
- (Style.SpaceBeforeParensOptions.BeforeNonEmptyParentheses &&
-  Right.ParameterCount > 0);
+  if (Style.SpaceBeforeParens == FormatStyle::SBPO_Always)
+return true;
+  if (Right.is(TT_OverloadedOperatorLParen) &&
+  Style.SpaceBeforeParensOptions.AfterOverloadedOperator)
+return true;
+  if (Style.SpaceBeforeParensOptions.BeforeNonEmptyParentheses &&
+  Right.ParameterCount > 0)
+return true;
+  return false;
 }
 
 bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -855,6 +855,7 @@
 IO.mapOptional("AfterFunctionDeclarationName",
Spacing.AfterFunctionDeclarationName);
 IO.mapOptional("AfterIfMacros", Spacing.AfterIfMacros);
+IO.mapOptional("AfterOverloadedOperator", Spacing.AfterOverloadedOperator);
 IO.mapOptional("BeforeNonEmptyParentheses",
Spacing.BeforeNonEmptyParentheses);
   }
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -3368,6 +3368,14 @@
 ///   
 /// \endcode
 bool AfterIfMacros;
+/// If ``true``, put a space between operator overloading and opening
+/// parentheses.
+/// \code
+///true:  false:
+///void operator++ (int a);vs.void operator++(int a);
+///object.operator++ (10);object.operator++(10);
+/// \endcode
+bool AfterOverloadedOperator;
 /// If ``true``, put a space before opening parentheses only if the
 /// parentheses are not empty.
 /// \code
@@ -3381,7 +3389,7 @@
 :

[clang] db77f7a - Silence a "not all control paths return a value" warning; NFC

2022-01-03 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-01-03T14:20:09-05:00
New Revision: db77f7a074d70f0092ba0870ad0ce42417095348

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

LOG: Silence a "not all control paths return a value" warning; NFC

Added: 


Modified: 
clang/lib/Sema/SemaCodeComplete.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index d3c154f18937..f9f20af1497a 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -6150,6 +6150,7 @@ static bool argMatchesTemplateParams(const 
ParsedTemplateArgument &Arg,
   case ParsedTemplateArgument::Template:
 return llvm::isa(Param); // signature not checked
   }
+  llvm_unreachable("Unhandled switch case");
 }
 
 QualType Sema::ProduceTemplateArgumentSignatureHelp(



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


[PATCH] D116550: [clang-tidy] Recognize transformer checks as providing fixits

2022-01-03 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood created this revision.
LegalizeAdulthood added a reviewer: alexfh.
LegalizeAdulthood added a project: clang-tools-extra.
Herald added subscribers: carlosgalvezp, xazax.hun.
LegalizeAdulthood requested review of this revision.

[clang-tidy] Recognize transformer checks as providing fixits

- Recognize older checks that might not end with Check.cpp
- Update list of checks based on improvements to add_new_check
- Fix spelling error in TransformerClangTidyCheck.h

Fixes #52962


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116550

Files:
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
  clang-tools-extra/docs/clang-tidy/checks/list.rst

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
@@ -116,13 +116,12 @@
`cert-dcl50-cpp `_,
`cert-dcl58-cpp `_,
`cert-env33-c `_,
+   `cert-err33-c `_,
`cert-err34-c `_,
`cert-err52-cpp `_,
`cert-err58-cpp `_,
`cert-err60-cpp `_,
-   `cert-exp42-c `_,
`cert-flp30-c `_,
-   `cert-flp37-c `_,
`cert-mem57-cpp `_,
`cert-msc50-cpp `_,
`cert-msc51-cpp `_,
@@ -213,7 +212,7 @@
`llvmlibc-implementation-in-namespace `_,
`llvmlibc-restrict-system-libc-headers `_, "Yes"
`misc-definitions-in-headers `_, "Yes"
-   `misc-misleading-identifier `_,
+   `misc-misleading-identifier `_,
`misc-misplaced-const `_,
`misc-new-delete-overloads `_,
`misc-no-recursion `_,
@@ -260,8 +259,8 @@
`modernize-use-using `_, "Yes"
`mpi-buffer-deref `_, "Yes"
`mpi-type-mismatch `_, "Yes"
-   `objc-avoid-nserror-init `_,
`objc-assert-equals `_, "Yes"
+   `objc-avoid-nserror-init `_,
`objc-dealloc-in-category `_,
`objc-forbidden-subclassing `_,
`objc-missing-hash `_,
@@ -283,16 +282,16 @@
`performance-noexcept-move-constructor `_, "Yes"
`performance-trivially-destructible `_, "Yes"
`performance-type-promotion-in-math-fn `_, "Yes"
-   `performance-unnecessary-copy-initialization `_,
+   `performance-unnecessary-copy-initialization `_, "Yes"
`performance-unnecessary-value-param `_, "Yes"
`portability-restrict-system-includes `_, "Yes"
`portability-simd-intrinsics `_,
-   `readability-avoid-const-params-in-decls `_,
+   `readability-avoid-const-params-in-decls `_, "Yes"
`readability-braces-around-statements `_, "Yes"
`readability-const-return-type `_, "Yes"
`readability-container-data-pointer `_, "Yes"
`readability-container-size-empty `_, "Yes"
-   `readability-convert-member-functions-to-static `_,
+   `readability-convert-member-functions-to-static `_, "Yes"
`readability-delete-null-pointer `_, "Yes"
`readability-else-after-return `_, "Yes"
`readability-function-cognitive-complexity `_,
@@ -338,13 +337,14 @@
`cert-dcl03-c `_, `misc-static-assert `_, "Yes"
`cert-dcl16-c `_, `readability-uppercase-literal-suffix `_, "Yes"
`cert-dcl37-c `_, `bugprone-reserved-identifier `_, "Yes"
-   `cert-err33-c `_, `bugprone-unused-return-value `_,
`cert-dcl51-cpp `_, `bugprone-reserved-identifier `_, "Yes"
`cert-dcl54-cpp `_, `misc-new-delete-overloads `_,
`cert-dcl59-cpp `_, `google-build-namespaces `_,
`cert-err09-cpp `_, `misc-throw-by-value-catch-by-reference `_,
`cert-err61-cpp `_, `misc-throw-by-value-catch-by-reference `_,
+   `cert-exp42-c `_, `bugprone-suspicious-memory-comparison `_,
`cert-fio38-c `_, `misc-non-copyable-objects `_,
+   `cert-flp37-c `_, `bugprone-suspicious-memory-comparison `_,
`cert-msc30-c `_, `cert-msc50-cpp `_,
`cert-msc32-c `_, `cert-msc51-cpp `_,
`cert-oop11-cpp `_, `performance-move-constructor-init `_,
Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
===
--- clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
@@ -54,7 +54,7 @@
 StringRef Name, ClangTidyContext *Context);
 
   /// Convenience overload of the constructor when the rule doesn't have any
-  /// dependies.
+  /// dependencies.
   TransformerClangTidyCheck(transformer::RewriteRule R, StringRef Name,
 ClangTidyContext *Context);
 
Index: clang-tools-extra/clang-tidy/add_new_check.py
===
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -324,16 +324,19 @@
 dirname, _, check_name = check_name.partition("-")
 
 checker_code = get_actual_filename(os.path.join(clang_tidy_path, dirname),
-   get_camel_name(check_name) + '.cpp')
-
+   get_camel_check_name(check_na

[clang-tools-extra] a61f34e - [clangd] Fix windows build after 478863ef58c7f7314e06

2022-01-03 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-01-03T20:17:20+01:00
New Revision: a61f34ea2502d900c57a332174d4c103b6963c80

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

LOG: [clangd] Fix windows build after 478863ef58c7f7314e06

http://45.33.8.238/win/51774/step_4.txt

MS extension causes the wrong class to be friended.

Added: 


Modified: 
clang-tools-extra/clangd/Headers.h

Removed: 




diff  --git a/clang-tools-extra/clangd/Headers.h 
b/clang-tools-extra/clangd/Headers.h
index 9612ce8def46..3b510325da04 100644
--- a/clang-tools-extra/clangd/Headers.h
+++ b/clang-tools-extra/clangd/Headers.h
@@ -38,6 +38,7 @@ namespace clangd {
 
 // clangd has a built-in database of standard library symbols.
 namespace stdlib {
+class Symbol;
 
 // A standard library header, such as 
 // Lightweight class, in fact just an index into a table.
@@ -53,7 +54,7 @@ class Header {
 private:
   Header(unsigned ID) : ID(ID) {}
   unsigned ID;
-  friend class Symbol;
+  friend Symbol;
   friend llvm::DenseMapInfo;
   friend bool operator==(const Header &L, const Header &R) {
 return L.ID == R.ID;



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


[PATCH] D116317: [CodeCompletion] Signature help for braced constructor calls

2022-01-03 Thread Sam McCall 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 rG92417eaf3329: [CodeCompletion] Signature help for braced 
constructor calls (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D116317?vs=396362&id=397111#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116317

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseInit.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/CodeCompleteConsumer.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/ctor-signature.cpp
  clang/tools/libclang/CIndexCodeCompletion.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -995,7 +995,8 @@
   void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
  OverloadCandidate *Candidates,
  unsigned NumCandidates,
- SourceLocation OpenParLoc) override {
+ SourceLocation OpenParLoc,
+ bool Braced) override {
 // At the moment we don't filter out any overloaded candidates.
   }
 
Index: clang/tools/libclang/CIndexCodeCompletion.cpp
===
--- clang/tools/libclang/CIndexCodeCompletion.cpp
+++ clang/tools/libclang/CIndexCodeCompletion.cpp
@@ -656,14 +656,15 @@
 void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
OverloadCandidate *Candidates,
unsigned NumCandidates,
-   SourceLocation OpenParLoc) override {
+   SourceLocation OpenParLoc,
+   bool Braced) override {
   StoredResults.reserve(StoredResults.size() + NumCandidates);
   for (unsigned I = 0; I != NumCandidates; ++I) {
-CodeCompletionString *StoredCompletion
-  = Candidates[I].CreateSignatureString(CurrentArg, S, getAllocator(),
+CodeCompletionString *StoredCompletion =
+Candidates[I].CreateSignatureString(CurrentArg, S, getAllocator(),
 getCodeCompletionTUInfo(),
-includeBriefComments());
-
+includeBriefComments(), Braced);
+
 CXCompletionResult R;
 R.CursorKind = CXCursor_OverloadCandidate;
 R.CompletionString = StoredCompletion;
Index: clang/test/CodeCompletion/ctor-signature.cpp
===
--- clang/test/CodeCompletion/ctor-signature.cpp
+++ clang/test/CodeCompletion/ctor-signature.cpp
@@ -15,3 +15,40 @@
   // CHECK-CC2: OVERLOAD: Foo(<#const Foo &#>)
   // CHECK-CC2: OVERLOAD: Foo(<#Foo &&#>
 }
+
+namespace std {
+template  struct initializer_list {};
+} // namespace std
+
+struct Bar {
+  // CHECK-BRACED: OVERLOAD: Bar{<#int#>}
+  Bar(int);
+  // CHECK-BRACED: OVERLOAD: Bar{<#double#>, double}
+  Bar(double, double);
+  // FIXME: no support for init-list constructors yet.
+  // CHECK-BRACED-NOT: OVERLOAD: {{.*}}char
+  Bar(std::initializer_list C);
+  // CHECK-BRACED: OVERLOAD: Bar{<#const Bar &#>}
+  // CHECK-BRACED: OVERLOAD: Bar{<#T *Pointer#>}
+  template  Bar(T *Pointer);
+};
+
+auto b1 = Bar{};
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:36:15 %s | FileCheck -check-prefix=CHECK-BRACED %s
+Bar b2{};
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:38:8 %s | FileCheck -check-prefix=CHECK-BRACED %s
+static int consumeBar(Bar) { return 0; }
+int b3 = consumeBar({});
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:41:22 %s | FileCheck -check-prefix=CHECK-BRACED %s
+
+struct Aggregate {
+  // FIXME: no support for aggregates yet.
+  // CHECK-AGGREGATE-NOT: OVERLOAD: Aggregate{<#const Aggregate &#>}
+  // CHECK-AGGREGATE-NOT: OVERLOAD: {{.*}}first
+  int first;
+  int second;
+};
+
+Aggregate a{};
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:52:13 %s | FileCheck -check-prefix=CHECK-AGGREGATE %s
+
Index: clang/lib/Sema/SemaCo

[clang-tools-extra] 92417ea - [CodeCompletion] Signature help for braced constructor calls

2022-01-03 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-01-03T20:14:59+01:00
New Revision: 92417eaf3329dc823c905ec6a608b83ac62b4f7c

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

LOG: [CodeCompletion] Signature help for braced constructor calls

Implementation is based on the "expected type" as used for
designated-initializers in braced init lists. This means it can deduce the type
in some cases where it's not written:

  void foo(Widget);
  foo({ /*help here*/ });

Only basic constructor calls are in scope of this patch, excluded are:
 - aggregate initialization (no help is offered for aggregates)
 - initializer_list initialization (no help is offered for these constructors)

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

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/test/initialize-params.test
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang/include/clang/Sema/CodeCompleteConsumer.h
clang/include/clang/Sema/Sema.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Parse/ParseInit.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/CodeCompleteConsumer.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/test/CodeCompletion/ctor-signature.cpp
clang/tools/libclang/CIndexCodeCompletion.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 774cdea218d00..edde19f96202f 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -555,7 +555,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
&Params,
}},
   {"signatureHelpProvider",
llvm::json::Object{
-   {"triggerCharacters", {"(", ",", ")", "<", ">"}},
+   {"triggerCharacters", {"(", ")", "{", "}", "<", ">", ","}},
}},
   {"declarationProvider", true},
   {"definitionProvider", true},

diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index bdfa1df194537..53d8f0d6cdeb7 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -921,7 +921,8 @@ class SignatureHelpCollector final : public 
CodeCompleteConsumer {
   void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
  OverloadCandidate *Candidates,
  unsigned NumCandidates,
- SourceLocation OpenParLoc) override {
+ SourceLocation OpenParLoc,
+ bool Braced) override {
 assert(!OpenParLoc.isInvalid());
 SourceManager &SrcMgr = S.getSourceManager();
 OpenParLoc = SrcMgr.getFileLoc(OpenParLoc);
@@ -961,8 +962,9 @@ class SignatureHelpCollector final : public 
CodeCompleteConsumer {
 paramIndexForArg(Candidate, SigHelp.activeParameter);
   }
 
-  const auto *CCS = Candidate.CreateSignatureString(
-  CurrentArg, S, *Allocator, CCTUInfo, true);
+  const auto *CCS =
+  Candidate.CreateSignatureString(CurrentArg, S, *Allocator, CCTUInfo,
+  /*IncludeBriefComment=*/true, 
Braced);
   assert(CCS && "Expected the CodeCompletionString to be non-null");
   ScoredSignatures.push_back(processOverloadCandidate(
   Candidate, *CCS,
@@ -1163,7 +1165,8 @@ class ParamNameCollector final : public 
CodeCompleteConsumer {
   void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
  OverloadCandidate *Candidates,
  unsigned NumCandidates,
- SourceLocation OpenParLoc) override {
+ SourceLocation OpenParLoc,
+ bool Braced) override {
 assert(CurrentArg <= (unsigned)std::numeric_limits::max() &&
"too many arguments");
 

diff  --git a/clang-tools-extra/clangd/test/initialize-params.test 
b/clang-tools-extra/clangd/test/initialize-params.test
index 72823f3a0683d..2affc8b2466dd 100644
--- a/clang-tools-extra/clangd/test/initialize-params.test
+++ b/clang-tools-extra/clangd/test/initialize-params.test
@@ -107,10 +107,12 @@
 # CHECK-NEXT:  "signatureHelpProvider": {
 # CHECK-NEXT:"triggerCharacters": [
 # CHECK-NEXT:  "(",
-# CHECK-NEXT:  ",",
 # CHECK-NEXT:  ")",
+# CHECK-NEXT:  "{",
+# CHE

[clang] 92417ea - [CodeCompletion] Signature help for braced constructor calls

2022-01-03 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-01-03T20:14:59+01:00
New Revision: 92417eaf3329dc823c905ec6a608b83ac62b4f7c

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

LOG: [CodeCompletion] Signature help for braced constructor calls

Implementation is based on the "expected type" as used for
designated-initializers in braced init lists. This means it can deduce the type
in some cases where it's not written:

  void foo(Widget);
  foo({ /*help here*/ });

Only basic constructor calls are in scope of this patch, excluded are:
 - aggregate initialization (no help is offered for aggregates)
 - initializer_list initialization (no help is offered for these constructors)

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

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/test/initialize-params.test
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang/include/clang/Sema/CodeCompleteConsumer.h
clang/include/clang/Sema/Sema.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Parse/ParseInit.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/CodeCompleteConsumer.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/test/CodeCompletion/ctor-signature.cpp
clang/tools/libclang/CIndexCodeCompletion.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 774cdea218d00..edde19f96202f 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -555,7 +555,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
&Params,
}},
   {"signatureHelpProvider",
llvm::json::Object{
-   {"triggerCharacters", {"(", ",", ")", "<", ">"}},
+   {"triggerCharacters", {"(", ")", "{", "}", "<", ">", ","}},
}},
   {"declarationProvider", true},
   {"definitionProvider", true},

diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index bdfa1df194537..53d8f0d6cdeb7 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -921,7 +921,8 @@ class SignatureHelpCollector final : public 
CodeCompleteConsumer {
   void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
  OverloadCandidate *Candidates,
  unsigned NumCandidates,
- SourceLocation OpenParLoc) override {
+ SourceLocation OpenParLoc,
+ bool Braced) override {
 assert(!OpenParLoc.isInvalid());
 SourceManager &SrcMgr = S.getSourceManager();
 OpenParLoc = SrcMgr.getFileLoc(OpenParLoc);
@@ -961,8 +962,9 @@ class SignatureHelpCollector final : public 
CodeCompleteConsumer {
 paramIndexForArg(Candidate, SigHelp.activeParameter);
   }
 
-  const auto *CCS = Candidate.CreateSignatureString(
-  CurrentArg, S, *Allocator, CCTUInfo, true);
+  const auto *CCS =
+  Candidate.CreateSignatureString(CurrentArg, S, *Allocator, CCTUInfo,
+  /*IncludeBriefComment=*/true, 
Braced);
   assert(CCS && "Expected the CodeCompletionString to be non-null");
   ScoredSignatures.push_back(processOverloadCandidate(
   Candidate, *CCS,
@@ -1163,7 +1165,8 @@ class ParamNameCollector final : public 
CodeCompleteConsumer {
   void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
  OverloadCandidate *Candidates,
  unsigned NumCandidates,
- SourceLocation OpenParLoc) override {
+ SourceLocation OpenParLoc,
+ bool Braced) override {
 assert(CurrentArg <= (unsigned)std::numeric_limits::max() &&
"too many arguments");
 

diff  --git a/clang-tools-extra/clangd/test/initialize-params.test 
b/clang-tools-extra/clangd/test/initialize-params.test
index 72823f3a0683d..2affc8b2466dd 100644
--- a/clang-tools-extra/clangd/test/initialize-params.test
+++ b/clang-tools-extra/clangd/test/initialize-params.test
@@ -107,10 +107,12 @@
 # CHECK-NEXT:  "signatureHelpProvider": {
 # CHECK-NEXT:"triggerCharacters": [
 # CHECK-NEXT:  "(",
-# CHECK-NEXT:  ",",
 # CHECK-NEXT:  ")",
+# CHECK-NEXT:  "{",
+# CHE

[PATCH] D114995: clang-tidy: improve the 'modernize-use-default-member-init'

2022-01-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D114995#3218004 , @oleg.smolsky 
wrote:

> @aaron.ballman could you commit this change please? I've never had commit 
> rights... Thanks!

Sure can! Is `Oleg Smolsky ` the correct attribution 
for the patch, or would you like me to use a different name or email address?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114995

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


[PATCH] D116540: [OpenMP] Add nec and nvidia as compiler vendors for OpenMP

2022-01-03 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam added a comment.

In D116540#3217689 , @jdoerfert wrote:

> In D116540#3217684 , @saiislam 
> wrote:
>
>> 1. I don't know why "pgi" is present here as a vendor. Should it be renamed 
>> as nvidia instead? @Meinersbur @tra
>
> It was in the spec list and I would not remove it now.

Specs 5.0 and 5.1 linked above doesn't contain PGI as a vendor. But, we can 
leave it as is.

>> 1. Should "cray" be renamed as "hpe" here? @sandoval
>
> No, both are listed in the spec.

Ok.

>> 1. Should this vendor list be reordered as per Spec 5.1 
>> [https://www.openmp.org/wp-content/uploads/OpenMP-API-Additional-Definitions-2-0.pdf]
>>  ?
>
> It was ordered as per that spec, which is just alphabetical. Can you add 
> `nec` as well and keep the others please.

Spec 5.1 has moved "unknown" from last position to the first. Some reordering 
also due to "hpe or cray" thing as well.

> LG, see above.

Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116540

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


[PATCH] D114077: [clangd] Basic IncludeCleaner support for c/c++ standard library

2022-01-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Breaks building on windows: http://45.33.8.238/win/51774/step_4.txt

Ptal!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114077

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


[PATCH] D114995: clang-tidy: improve the 'modernize-use-default-member-init'

2022-01-03 Thread Oleg Smolsky via Phabricator via cfe-commits
oleg.smolsky added a comment.

@aaron.ballman could you commit this change please? I've never had commit 
rights... Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114995

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


[PATCH] D115456: Implement on-demand TLS initialization for Microsoft CXX ABI

2022-01-03 Thread Maurice Heumann via Phabricator via cfe-commits
momo5502 updated this revision to Diff 397107.
momo5502 added a comment.

In D115456#3217857 , @majnemer wrote:

> In D115456#3217595 , @momo5502 
> wrote:
>
>> In D115456#3216811 , @majnemer 
>> wrote:
>>
>>> This is looking great! Just a few more questions.
>>>
>>> What is the behavior with something like:
>>>
>>>   thread_local int x = 2;
>>>   int f() {
>>> return x;
>>>   }
>>>
>>> I'm wondering if we need to move this logic 
>>> 
>>>  into the generic C++ ABI implementation.
>>
>> The MS compiler only emits the dynamic initializers for variables with 
>> constructors/destructors, just like it is currently done here for the 
>> Itanium ABI.
>> I also thought about adopting that behaviour, but I think threre are 
>> edge-cases when triggering dynamic TLS initialization even for constant 
>> variables is useful.
>> For example there might be custom TLS callbacks that can affect the value of 
>> this variable.
>>
>> If desired, I can change it to match the behaviour of MS, but I thought it 
>> could be beneficial to diverge in this case.
>
> IMO, it is probably best to match behavior here within reason (ignoring bugs 
> latent in MSVC) here. My thinking is that in the face of COMDATs, we cannot 
> ensure which copy of an inline function will make its way to the binary and 
> different link orders would provide different behavior.

Fair enough. Logic has now moved to the generic C++ ABI implementation and the 
test was adjusted.


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

https://reviews.llvm.org/D115456

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/lib/CodeGen/CGCXXABI.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/test/CodeGenCXX/ms-thread_local.cpp

Index: clang/test/CodeGenCXX/ms-thread_local.cpp
===
--- clang/test/CodeGenCXX/ms-thread_local.cpp
+++ clang/test/CodeGenCXX/ms-thread_local.cpp
@@ -1,5 +1,6 @@
-// RUN: %clang_cc1 %s -std=c++1y -triple=i686-pc-win32 -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 %s  -std=c++1y -triple=i686-pc-win32 -ftls-model=local-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LD
+// RUN: %clang_cc1 %s -std=c++1y -triple=i686-pc-win32 -fms-compatibility-version=19.25 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -std=c++1y -triple=i686-pc-win32 -fms-compatibility-version=19.20 -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LEGACY
+// RUN: %clang_cc1 %s -std=c++1y -triple=i686-pc-win32 -fms-compatibility-version=19.25 -ftls-model=local-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LD
 
 struct A {
   A();
@@ -17,14 +18,22 @@
 
 // CHECK-DAG: @"?b@@3UA@@A" = dso_local thread_local global %struct.A zeroinitializer, align 1
 // CHECK-DAG: @"__tls_init$initializer$" = internal constant void ()* @__tls_init, section ".CRT$XDU"
+// CHECK-DAG: @__tls_guard = external dso_local thread_local global i8
 // CHECK-LD-DAG: @"?b@@3UA@@A" = dso_local thread_local(localdynamic) global %struct.A zeroinitializer, align 1
 // CHECK-LD-DAG: @"__tls_init$initializer$" = internal constant void ()* @__tls_init, section ".CRT$XDU"
+// CHECK-LD-DAG: @__tls_guard = external dso_local thread_local global i8
+// CHECK-LEGACY-NOT: @__tls_guard = external dso_local thread_local global i8
 thread_local A b;
 
-// CHECK-LABEL: define internal void @__tls_init()
-// CHECK: call void @"??__Eb@@YAXXZ"
-// CHECK-LD-LABEL: define internal void @__tls_init()
-// CHECK-LD: call void @"??__Eb@@YAXXZ"
+// CHECK-LABEL: declare dso_local void @__dyn_tls_on_demand_init()
+// CHECK-LD-LABEL: declare dso_local void @__dyn_tls_on_demand_init()
+// CHECK-LEGACY-NOT: declare dso_local void @__dyn_tls_on_demand_init()
+
+// CHECK-LABEL: define dso_local void @"?f@@YA?AUA@@XZ"(%struct.A* noalias sret(%struct.A) align 1 %agg.result)
+// CHECK: call void @__dyn_tls_on_demand_init()
+// CHECK-LD-LABEL: define dso_local void @"?f@@YA?AUA@@XZ"(%struct.A* noalias sret(%struct.A) align 1 %agg.result)
+// CHECK-LD: call void @__dyn_tls_on_demand_init()
+// CHECK-LEGACY-NOT: call void @__dyn_tls_on_demand_init()
 
 thread_local A &c = b;
 thread_local A &d = c;
@@ -35,6 +44,22 @@
   return c;
 }
 
+// CHECK-LABEL: define dso_local i32 @"?g@@YAHXZ"()
+// CHECK-NOT: call void @__dyn_tls_on_demand_init()
+// CHECK-LD-LABEL: define dso_local i32 @"?g@@YAHXZ"()
+// CHECK-LD-NOT: call void @__dyn_tls_on_demand_init()
+
+thread_local int e = 2;
+
+int g() {
+  return e;
+}
+
+// CHECK-LABEL: define internal void @__tls_init()
+// CHECK: call void @"??__Eb@@YAXXZ"
+// CHECK-LD-LABEL: define internal void @__tls_init()
+// CHECK-LD: call void @"??__Eb@@YAXXZ"
+
 // CHECK: 

[PATCH] D115106: [clang-tidy] Fix `readability-static-accessed-through-instance` false negative for static methods

2022-01-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D115106#3217968 , @sammccall wrote:

> Yeah, this is a thorny question. The language hasn't chosen clear names and 
> neither has the AST in many cases.
> (Just yesterday I lost a lot of time to CXXRecordDecl->getBodyRBrace()...)

Yeah, I've run into this problem with attribute subject lists as well, so it's 
definitely an AST-level problem with how we expose the information in the AST.

> I think `anyRedeclaration(functionDecl(isStaticStorageClass))`is too 
> difficult to get right and too easy to get wrong for such a common/simple 
> concept.

Get right in terms of implementation, or in terms of use, or both?

> I know what a static method is, but I would have made the same mistake here. 
> In general asking people to describe syntax to answer a semantic question 
> invites this.

Because our AST is intended to reflect the syntax, our AST matchers kind of 
*do* match syntax -- I think it's the reason we're in the problem (and this is 
not the first time it's come up). There's a cognitive disconnect between the 
AST matchers traversing the AST and applying a match on all node and the C & 
C++ concept of redeclarations. People writing the matchers are thinking exactly 
what you said -- I know what a static method is -- but they don't realize they 
get this behavior with the most straight-forward matching code 
(https://godbolt.org/z/rWW48MT8T):

  static void f(); // Get a match for this
  void f() {} // But not this, despite it being static



> Here's a hack: CXXMethodDecl has both `isStatic()` and `isInstance()`. I 
> agree that `isStatic` is a risky name, but I don't think `isInstance` is. Can 
> we just spell the matcher you want `not(isInstance())`?

This could work, but I don't think it's particularly satisfying in situations 
that aren't binary. Like asking "does this have static storage duration" (as 
opposed to thread, automatic, or dynamic storage duration). And it turns out 
that the behavior there is opposite to asking about the storage class 
specifier: https://godbolt.org/z/hqserfxzs (the `extern` redeclaration is still 
matched because that declaration retains the internal linkage from the first 
declaration). So we sometimes take prior declarations into account and we 
sometimes don't. :-(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115106

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


[PATCH] D116540: [OpenMP] Add nvidia as a compiler vendor for OpenMP

2022-01-03 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 397108.
saiislam added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

1. Added nec as compiler vendor.
2. Fixed clang test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116540

Files:
  clang/test/OpenMP/begin_declare_variant_messages.c
  clang/test/OpenMP/declare_variant_messages.c
  clang/test/OpenMP/declare_variant_messages.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def


Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -1130,6 +1130,8 @@
 __OMP_TRAIT_PROPERTY(implementation, vendor, ibm)
 __OMP_TRAIT_PROPERTY(implementation, vendor, intel)
 __OMP_TRAIT_PROPERTY(implementation, vendor, llvm)
+__OMP_TRAIT_PROPERTY(implementation, vendor, nec)
+__OMP_TRAIT_PROPERTY(implementation, vendor, nvidia)
 __OMP_TRAIT_PROPERTY(implementation, vendor, pgi)
 __OMP_TRAIT_PROPERTY(implementation, vendor, ti)
 __OMP_TRAIT_PROPERTY(implementation, vendor, unknown)
Index: clang/test/OpenMP/declare_variant_messages.cpp
===
--- clang/test/OpenMP/declare_variant_messages.cpp
+++ clang/test/OpenMP/declare_variant_messages.cpp
@@ -31,11 +31,11 @@
 #pragma omp declare variant(foofoo ) match(implementation = {vvv}) 
implementation // expected-warning {{'vvv' is not a valid context selector for 
the context set 'implementation'; selector ignored}} expected-note {{context 
selector options are: 'vendor' 'extension' 'unified_address' 
'unified_shared_memory' 'reverse_offload' 'dynamic_allocators' 
'atomic_default_mem_order'}} expected-note {{the ignored selector spans until 
here}} expected-error {{expected 'match' clause on 'omp declare variant' 
directive}}
 #pragma omp declare variant(foofoo ) match(implementation={xxx}) // 
expected-warning {{'xxx' is not a valid context selector for the context set 
'implementation'; selector ignored}} expected-note {{context selector options 
are: 'vendor' 'extension' 'unified_address' 'unified_shared_memory' 
'reverse_offload' 'dynamic_allocators' 'atomic_default_mem_order'}} 
expected-note {{the ignored selector spans until here}}
 #pragma omp declare variant(foofoo ) match(implementation={vendor}) // 
expected-warning {{the context selector 'vendor' in context set 
'implementation' requires a context property defined in parentheses; selector 
ignored}} expected-note {{the ignored selector spans until here}}
-#pragma omp declare variant(foofoo ) match(implementation={vendor(}) // 
expected-error {{expected ')'}} expected-warning {{expected identifier or 
string literal describing a context property; property skipped}} expected-note 
{{context property options are: 'amd' 'arm' 'bsc' 'cray' 'fujitsu' 'gnu' 'ibm' 
'intel' 'llvm' 'pgi' 'ti' 'unknown'}} expected-note {{to match this '('}}
-#pragma omp declare variant(foofoo ) match(implementation={vendor()}) // 
expected-warning {{expected identifier or string literal describing a context 
property; property skipped}} expected-note {{context property options are: 
'amd' 'arm' 'bsc' 'cray' 'fujitsu' 'gnu' 'ibm' 'intel' 'llvm' 'pgi' 'ti' 
'unknown'}}
+#pragma omp declare variant(foofoo ) match(implementation={vendor(}) // 
expected-error {{expected ')'}} expected-warning {{expected identifier or 
string literal describing a context property; property skipped}} expected-note 
{{context property options are: 'amd' 'arm' 'bsc' 'cray' 'fujitsu' 'gnu' 'ibm' 
'intel' 'llvm' 'nec' 'nvidia' 'pgi' 'ti' 'unknown'}} expected-note {{to match 
this '('}}
+#pragma omp declare variant(foofoo ) match(implementation={vendor()}) // 
expected-warning {{expected identifier or string literal describing a context 
property; property skipped}} expected-note {{context property options are: 
'amd' 'arm' 'bsc' 'cray' 'fujitsu' 'gnu' 'ibm' 'intel' 'llvm' 'nec' 'nvidia' 
'pgi' 'ti' 'unknown'}}
 #pragma omp declare variant(foofoo ) match(implementation={vendor(score 
ibm)}) // expected-error {{expected '(' after 'score'}} expected-warning 
{{expected '':'' after the score expression; '':'' assumed}}
-#pragma omp declare variant(foofoo ) match(implementation={vendor(score( 
ibm)}) // expected-error {{use of undeclared identifier 'ibm'}} expected-error 
{{expected ')'}} expected-warning {{expected '':'' after the score expression; 
'':'' assumed}} expected-warning {{expected identifier or string literal 
describing a context property; property skipped}} expected-note {{context 
property options are: 'amd' 'arm' 'bsc' 'cray' 'fujitsu' 'gnu' 'ibm' 'intel' 
'llvm' 'pgi' 'ti' 'unknown'}} expected-note {{to match this '('}}
-#pragma omp declare variant(foofoo ) match(implementation={vendor(score(2 
ibm)}) // expected-error {{expected ')'}} expected-error {{expected ')'}} 

[PATCH] D106349: [clang-format] respect AfterEnum for enums

2022-01-03 Thread Marek Kurdej 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 rG7972b2e42276: [clang-format] respect AfterEnum for enums 
(authored by m1cha, committed by curdeius).

Changed prior to commit:
  https://reviews.llvm.org/D106349?vs=361493&id=397106#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106349

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2535,6 +2535,13 @@
"  C\n"
"} ShortEnum1, ShortEnum2;",
Style);
+  verifyFormat("typedef enum\n"
+   "{\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
 }
 
 TEST_F(FormatTest, ShortCaseLabels) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -782,6 +782,8 @@
 return Style.BraceWrapping.AfterUnion;
   if (InitialToken.is(tok::kw_struct))
 return Style.BraceWrapping.AfterStruct;
+  if (InitialToken.is(tok::kw_enum))
+return Style.BraceWrapping.AfterEnum;
   return false;
 }
 
@@ -2606,12 +2608,12 @@
 }
 
 bool UnwrappedLineParser::parseEnum() {
+  const FormatToken &InitialToken = *FormatTok;
+
   // Won't be 'enum' for NS_ENUMs.
   if (FormatTok->Tok.is(tok::kw_enum))
 nextToken();
 
-  const FormatToken &InitialToken = *FormatTok;
-
   // In TypeScript, "enum" can also be used as property name, e.g. in interface
   // declarations. An "enum" keyword followed by a colon would be a syntax
   // error and thus assume it is just an identifier.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2535,6 +2535,13 @@
"  C\n"
"} ShortEnum1, ShortEnum2;",
Style);
+  verifyFormat("typedef enum\n"
+   "{\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
 }
 
 TEST_F(FormatTest, ShortCaseLabels) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -782,6 +782,8 @@
 return Style.BraceWrapping.AfterUnion;
   if (InitialToken.is(tok::kw_struct))
 return Style.BraceWrapping.AfterStruct;
+  if (InitialToken.is(tok::kw_enum))
+return Style.BraceWrapping.AfterEnum;
   return false;
 }
 
@@ -2606,12 +2608,12 @@
 }
 
 bool UnwrappedLineParser::parseEnum() {
+  const FormatToken &InitialToken = *FormatTok;
+
   // Won't be 'enum' for NS_ENUMs.
   if (FormatTok->Tok.is(tok::kw_enum))
 nextToken();
 
-  const FormatToken &InitialToken = *FormatTok;
-
   // In TypeScript, "enum" can also be used as property name, e.g. in interface
   // declarations. An "enum" keyword followed by a colon would be a syntax
   // error and thus assume it is just an identifier.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7972b2e - [clang-format] respect AfterEnum for enums

2022-01-03 Thread Marek Kurdej via cfe-commits

Author: Michael Zimmermann
Date: 2022-01-03T20:01:10+01:00
New Revision: 7972b2e42276346e85bb6d4fb7e03bbd5a9af53f

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

LOG: [clang-format] respect AfterEnum for enums

There is some similar looking code in `TokenAnnotator.cpp` but given that I've
never worked on clang-format before I don't know what the purpose of that code
is and how it's related to `UnwrappedLineParser.cpp`.

Either way, it fixes clang-format with `BraceWrapping.AfterEnum=true` and
`AllowShortEnumsOnASingleLine=false` to behave like the documentation says.

Before this patch:
```
enum
{
  A,
  B
} myEnum;
```

After this patch:
```
enum {
  A,
  B
} myEnum;
```

According to the unittests which I had to modify this would change the LLVM
style. Please evaluate if you want to change the defaults or if you consider
the current style a bug.

Reviewed By: curdeius, HazardyKnusperkeks

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index b6e55aab708f..0579acf36391 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -782,6 +782,8 @@ static bool ShouldBreakBeforeBrace(const FormatStyle &Style,
 return Style.BraceWrapping.AfterUnion;
   if (InitialToken.is(tok::kw_struct))
 return Style.BraceWrapping.AfterStruct;
+  if (InitialToken.is(tok::kw_enum))
+return Style.BraceWrapping.AfterEnum;
   return false;
 }
 
@@ -2606,12 +2608,12 @@ void UnwrappedLineParser::parseRequires() {
 }
 
 bool UnwrappedLineParser::parseEnum() {
+  const FormatToken &InitialToken = *FormatTok;
+
   // Won't be 'enum' for NS_ENUMs.
   if (FormatTok->Tok.is(tok::kw_enum))
 nextToken();
 
-  const FormatToken &InitialToken = *FormatTok;
-
   // In TypeScript, "enum" can also be used as property name, e.g. in interface
   // declarations. An "enum" keyword followed by a colon would be a syntax
   // error and thus assume it is just an identifier.

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 7a7976c8b081..470b0c7a19e5 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -2535,6 +2535,13 @@ TEST_F(FormatTest, ShortEnums) {
"  C\n"
"} ShortEnum1, ShortEnum2;",
Style);
+  verifyFormat("typedef enum\n"
+   "{\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
 }
 
 TEST_F(FormatTest, ShortCaseLabels) {



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


[PATCH] D116317: [CodeCompletion] Signature help for braced constructor calls

2022-01-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp:995
   /// \param NumCandidates the number of overload candidates
   void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
  OverloadCandidate *Candidates,

kadircet wrote:
> why not just drop the method? it is not pure, and no-op in base too.
That's a reasonable question, but it's not my code so IDK if it's a style thing.
(I was tempted to remove it but it seems gratuitous for this kind of change)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116317

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


[PATCH] D115106: [clang-tidy] Fix `readability-static-accessed-through-instance` false negative for static methods

2022-01-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Yeah, this is a thorny question. The language hasn't chosen clear names and 
neither has the AST in many cases.
(Just yesterday I lost a lot of time to CXXRecordDecl->getBodyRBrace()...)

I think `anyRedeclaration(functionDecl(isStaticStorageClass))`is too difficult 
to get right and too easy to get wrong for such a common/simple concept.
I know what a static method is, but I would have made the same mistake here. In 
general asking people to describe syntax to answer a semantic question invites 
this.

Here's a hack: CXXMethodDecl has both `isStatic()` and `isInstance()`. I agree 
that `isStatic` is a risky name, but I don't think `isInstance` is. Can we just 
spell the matcher you want `not(isInstance())`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115106

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


[PATCH] D116549: [OpenMP][Clang] Allow passing target features in ISA trait for metadirective clause

2022-01-03 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam created this revision.
saiislam added reviewers: jdoerfert, alokmishra.besu, cchen, JonChesterfield.
Herald added subscribers: guansong, yaxunl.
saiislam requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Passing any feature in the device-isa trait which is not supported by the host
was causing a compilation failure.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116549

Files:
  clang/lib/Parse/ParseOpenMP.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.c
  clang/test/OpenMP/metadirective_implementation_codegen.cpp


Index: clang/test/OpenMP/metadirective_implementation_codegen.cpp
===
--- clang/test/OpenMP/metadirective_implementation_codegen.cpp
+++ clang/test/OpenMP/metadirective_implementation_codegen.cpp
@@ -35,6 +35,9 @@
: parallel) default(parallel for)
   for (int i = 0; i < 100; i++)
 ;
+#pragma omp metadirective when(device = {isa("flat-address-space")}
   \
+   : parallel) default(target teams)
+  bar();
 }
 
 // CHECK-LABEL: void @_Z3foov()
@@ -44,6 +47,7 @@
 // CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, 
...)* bitcast (void (i32*, i32*)* [[OUTLINED_5:@.+]] to void
 // CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, 
...)* bitcast (void (i32*, i32*)* [[OUTLINED_6:@.+]] to void
 // CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, 
...)* bitcast (void (i32*, i32*)* [[OUTLINED_7:@.+]] to void
+// CHECK: call void @__omp_offloading_{{.*}}()
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTLINED_2]](
@@ -73,4 +77,11 @@
 // NO-CHECK: call void @__kmpc_for_static_fini
 // CHECK: ret void
 
+// CHECK: define internal void @__omp_offloading_
+// CHECK: ...) @__kmpc_fork_teams({{.*}}@.omp_outlined..6
+// CHECK: ret void
+
+// CHECK: define internal void @.omp_outlined..6(
+// CHECK: @_Z3barv
+// CHECK: ret void
 #endif
Index: clang/test/OpenMP/metadirective_implementation_codegen.c
===
--- clang/test/OpenMP/metadirective_implementation_codegen.c
+++ clang/test/OpenMP/metadirective_implementation_codegen.c
@@ -35,10 +35,14 @@
: parallel) default(parallel for)
   for (int i = 0; i < 100; i++)
 ;
+#pragma omp metadirective when(device = {isa("flat-address-space")}
   \
+   : parallel) default(target teams)
+  bar();
 }
 
 // CHECK: void @foo()
 // CHECK-COUNT-6: ...) @__kmpc_fork_call(
+// CHECK: call void @__omp_offloading_{{.*}}()
 // CHECK: ret void
 
 // CHECK: define internal void @.omp_outlined.(
@@ -68,4 +72,11 @@
 // NO-CHECK: call void @__kmpc_for_static_fini
 // CHECK: ret void
 
+// CHECK: define internal void @__omp_offloading_
+// CHECK: ...) @__kmpc_fork_teams({{.*}}@.omp_outlined..6
+// CHECK: ret void
+
+// CHECK: define internal void @.omp_outlined..6(
+// CHECK: @bar
+// CHECK: ret void
 #endif
Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -2529,7 +2529,9 @@
 TPA.Revert();
 // End of the first iteration. Parser is reset to the start of 
metadirective
 
-TargetOMPContext OMPCtx(ASTContext, /* DiagUnknownTrait */ nullptr,
+std::function DiagUnknownTrait = [this, Loc](
+StringRef ISATrait) {};
+TargetOMPContext OMPCtx(ASTContext, std::move(DiagUnknownTrait),
 /* CurrentFunctionDecl */ nullptr,
 ArrayRef());
 


Index: clang/test/OpenMP/metadirective_implementation_codegen.cpp
===
--- clang/test/OpenMP/metadirective_implementation_codegen.cpp
+++ clang/test/OpenMP/metadirective_implementation_codegen.cpp
@@ -35,6 +35,9 @@
: parallel) default(parallel for)
   for (int i = 0; i < 100; i++)
 ;
+#pragma omp metadirective when(device = {isa("flat-address-space")}   \
+   : parallel) default(target teams)
+  bar();
 }
 
 // CHECK-LABEL: void @_Z3foov()
@@ -44,6 +47,7 @@
 // CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_5:@.+]] to void
 // CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_6:@.+]] to void
 // CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_7:@.+]] to void
+// CHECK: call void @__omp_offloading_{{.*}}()
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTLINED_2]](
@@ -73,4 +77,11 @@
 // NO-CH

[PATCH] D116337: [clang] set __NO_MATH_ERRNO__ if -fno-math-errno

2022-01-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: rsmith, joerg, rjmccall, andrew.w.kaylor, 
aaron.ballman.
aaron.ballman added a comment.

Thanks for this! I'm adding some more reviewers to the list to help get this 
reviewed.

The patch doesn't seem to apply cleanly, so precommit CI isn't running on it. 
Can you rectify that? Also, the change needs test coverage of some kind.




Comment at: clang/lib/Frontend/InitPreprocessor.cpp:1022
+Builder.defineMacro("__NO_MATH_ERRNO__");
+
   if (LangOpts.FastMath || LangOpts.FiniteMathOnly)

Does GCC gate on `-ffast-math`? My testing suggests that `-fno-math-errno` 
alone is what sets this macro in GCC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116337

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


[PATCH] D116492: [lld] Deprecate using llvm-config to detect llvm installation

2022-01-03 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added inline comments.



Comment at: lld/CMakeLists.txt:17
-  execute_process(COMMAND "${LLVM_CONFIG_PATH}"
-  "--obj-root"
-  "--includedir"

`--obj-root` is the same thing as `--prefix`, so this is in fact a mere 
reordering in behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116492

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


  1   2   3   >