[PATCH] D121042: [clang-format] Handle goto labels for RemoveBracesLLVM

2022-03-05 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

Looks good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121042

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


[clang] fda7d02 - [NFC][Clang] Fix a couple of typos

2022-03-05 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2022-03-05T09:45:04+01:00
New Revision: fda7d029e52dcfb090ae97adf1c3d98121da6d98

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

LOG: [NFC][Clang] Fix a couple of typos

Added: 


Modified: 
clang/lib/Parse/ParseDecl.cpp
clang/lib/Sema/SemaTemplate.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 0938d5c6e9add..01f57e205fc50 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5803,7 +5803,7 @@ static bool isPtrOperatorToken(tok::TokenKind Kind, const 
LangOptions &Lang,
 }
 
 // Indicates whether the given declarator is a pipe declarator.
-static bool isPipeDeclerator(const Declarator &D) {
+static bool isPipeDeclarator(const Declarator &D) {
   const unsigned NumTypes = D.getNumTypeObjects();
 
   for (unsigned Idx = 0; Idx != NumTypes; ++Idx)
@@ -5896,7 +5896,7 @@ void Parser::ParseDeclaratorInternal(Declarator &D,
 
   tok::TokenKind Kind = Tok.getKind();
 
-  if (D.getDeclSpec().isTypeSpecPipe() && !isPipeDeclerator(D)) {
+  if (D.getDeclSpec().isTypeSpecPipe() && !isPipeDeclarator(D)) {
 DeclSpec DS(AttrFactory);
 ParseTypeQualifierListOpt(DS);
 

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 537e286c44193..ab365d34f8757 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -4280,7 +4280,7 @@ DeclResult Sema::ActOnVarTemplateSpecialization(
 bool IsPartialSpecialization) {
   // D must be variable template id.
   assert(D.getName().getKind() == UnqualifiedIdKind::IK_TemplateId &&
- "Variable template specialization is declared with a template it.");
+ "Variable template specialization is declared with a template id.");
 
   TemplateIdAnnotation *TemplateId = D.getName().TemplateId;
   TemplateArgumentListInfo TemplateArgs =



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


[PATCH] D119172: [pseudo] Implement LRGraph

2022-03-05 Thread Alex Tsao via Phabricator via cfe-commits
alextsao1999 added inline comments.
Herald added a project: All.



Comment at: clang/include/clang/Tooling/Syntax/Pseudo/LRGraph.h:96
+  uint8_t DotPos = 0;
+  uint8_t RuleLength = 0; // the length of rule body.
+};

Can we add LookaheadSymbol here to implement LR(1)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119172

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


[PATCH] D121045: [Analyzer][Refactor] Removed the duplicating of a if statement having same condition

2022-03-05 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets created this revision.
Herald added subscribers: manas, steakhal, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a project: All.
phyBrackets 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/D121045

Files:
  clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -107,11 +107,7 @@
   dyn_cast(Ex->IgnoreParenCasts());
 if (!BO)
   break;
-if (BO->getOpcode() == BO_Assign) {
-  Ex = BO->getRHS();
-  continue;
-}
-if (BO->getOpcode() == BO_Comma) {
+if (BO->getOpcode() == BO_Assign || BO->getOpcode() == BO_Comma) {
   Ex = BO->getRHS();
   continue;
 }


Index: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -107,11 +107,7 @@
   dyn_cast(Ex->IgnoreParenCasts());
 if (!BO)
   break;
-if (BO->getOpcode() == BO_Assign) {
-  Ex = BO->getRHS();
-  continue;
-}
-if (BO->getOpcode() == BO_Comma) {
+if (BO->getOpcode() == BO_Assign || BO->getOpcode() == BO_Comma) {
   Ex = BO->getRHS();
   continue;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119599: [clang-format] Add option to align compound assignments like `+=`

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



Comment at: clang/docs/tools/dump_format_style.py:293
   state = State.InNestedStruct
-  field_type, field_name = re.match(r'([<>:\w(,\s)]+)\s+(\w+);', 
line).groups()
+  field_type, field_name = re.match(r'([<>:\w(,\s)]+)\s+(\w+)', 
line).groups()
   if field_type in enums:

sstwcw wrote:
> This change is needed to parse the entry `bool PadOperators = true;`.
That is a sign that you should keep consistency and initialize `PadOperators` 
like the rest.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119599

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


[PATCH] D103313: [RISCV][Clang] Implement support for zmmul-experimental

2022-03-05 Thread ksyx via Phabricator via cfe-commits
ksyx updated this revision to Diff 413211.
ksyx added a comment.
Herald added a subscriber: jdoerfert.

Rebase and adapt to new ISAInfo module.


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

https://reviews.llvm.org/D103313

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

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

[PATCH] D103313: [RISCV][Clang] Implement support for zmmul-experimental

2022-03-05 Thread ksyx via Phabricator via cfe-commits
ksyx updated this revision to Diff 413212.
ksyx added a comment.

Fix patch apply failed


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

https://reviews.llvm.org/D103313

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

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

[PATCH] D121019: [clang-tools-extra] Document clang tidy unit tests target

2022-03-05 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/clang-tidy/Contributing.rst:367
 
+You can build the Clang Tidy unit tests by building the ``ClangTidyTests`` 
target.
+Test targets in LLVM and Clang are excluded from the "build all" style action 
of

Clang-tidy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121019

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


[PATCH] D121049: [Clang][VE] Add vector load intrinsics

2022-03-05 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 created this revision.
kaz7 added reviewers: simoll, efocht.
kaz7 added a project: clang.
Herald added a subscriber: mgorny.
Herald added a project: All.
kaz7 requested review of this revision.
Herald added a subscriber: cfe-commits.

Add vector load intrinsic instructions for VE.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121049

Files:
  clang/include/clang/Basic/BuiltinsVE.def
  clang/include/clang/Basic/BuiltinsVEVL.gen.def
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/module.modulemap
  clang/lib/Basic/Targets/VE.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/velintrin.h
  clang/lib/Headers/velintrin_gen.h
  clang/test/CodeGen/VE/ve-velintrin.c

Index: clang/test/CodeGen/VE/ve-velintrin.c
===
--- /dev/null
+++ clang/test/CodeGen/VE/ve-velintrin.c
@@ -0,0 +1,120 @@
+// REQUIRES: ve-registered-target
+
+// RUN: %clang_cc1 -S -emit-llvm -triple ve-unknown-linux-gnu \
+// RUN:   -ffreestanding %s -o - | FileCheck %s
+
+#include 
+
+__vr vr1;
+
+void __attribute__((noinline))
+test_vld_vssl(char* p, long idx) {
+  // CHECK-LABEL: @test_vld_vssl
+  // CHECK: call <256 x double> @llvm.ve.vl.vld.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
+  vr1 = _vel_vld_vssl(idx, p, 256);
+}
+
+void __attribute__((noinline))
+test_vld_vssvl(char* p, long idx) {
+  // CHECK-LABEL: @test_vld_vssvl
+  // CHECK: call <256 x double> @llvm.ve.vl.vld.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
+  vr1 = _vel_vld_vssvl(idx, p, vr1, 256);
+}
+
+void __attribute__((noinline))
+test_vldnc_vssl(char* p, long idx) {
+  // CHECK-LABEL: @test_vldnc_vssl
+  // CHECK: call <256 x double> @llvm.ve.vl.vldnc.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
+  vr1 = _vel_vldnc_vssl(idx, p, 256);
+}
+
+void __attribute__((noinline))
+test_vldnc_vssvl(char* p, long idx) {
+  // CHECK-LABEL: @test_vldnc_vssvl
+  // CHECK: call <256 x double> @llvm.ve.vl.vldnc.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
+  vr1 = _vel_vldnc_vssvl(idx, p, vr1, 256);
+}
+
+void __attribute__((noinline))
+test_vldu_vssl(char* p, long idx) {
+  // CHECK-LABEL: @test_vldu_vssl
+  // CHECK: call <256 x double> @llvm.ve.vl.vldu.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
+  vr1 = _vel_vldu_vssl(idx, p, 256);
+}
+
+void __attribute__((noinline))
+test_vldu_vssvl(char* p, long idx) {
+  // CHECK-LABEL: @test_vldu_vssvl
+  // CHECK: call <256 x double> @llvm.ve.vl.vldu.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
+  vr1 = _vel_vldu_vssvl(idx, p, vr1, 256);
+}
+
+void __attribute__((noinline))
+test_vldunc_vssl(char* p, long idx) {
+  // CHECK-LABEL: @test_vldunc_vssl
+  // CHECK: call <256 x double> @llvm.ve.vl.vldunc.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
+  vr1 = _vel_vldunc_vssl(idx, p, 256);
+}
+
+void __attribute__((noinline))
+test_vldunc_vssvl(char* p, long idx) {
+  // CHECK-LABEL: @test_vldunc_vssvl
+  // CHECK: call <256 x double> @llvm.ve.vl.vldunc.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
+  vr1 = _vel_vldunc_vssvl(idx, p, vr1, 256);
+}
+
+void __attribute__((noinline))
+test_vldlsx_vssl(char* p, long idx) {
+  // CHECK-LABEL: @test_vldlsx_vssl
+  // CHECK: call <256 x double> @llvm.ve.vl.vldlsx.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
+  vr1 = _vel_vldlsx_vssl(idx, p, 256);
+}
+
+void __attribute__((noinline))
+test_vldlsx_vssvl(char* p, long idx) {
+  // CHECK-LABEL: @test_vldlsx_vssvl
+  // CHECK: call <256 x double> @llvm.ve.vl.vldlsx.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
+  vr1 = _vel_vldlsx_vssvl(idx, p, vr1, 256);
+}
+
+void __attribute__((noinline))
+test_vldlsxnc_vssl(char* p, long idx) {
+  // CHECK-LABEL: @test_vldlsxnc_vssl
+  // CHECK: call <256 x double> @llvm.ve.vl.vldlsxnc.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
+  vr1 = _vel_vldlsxnc_vssl(idx, p, 256);
+}
+
+void __attribute__((noinline))
+test_vldlsxnc_vssvl(char* p, long idx) {
+  // CHECK-LABEL: @test_vldlsxnc_vssvl
+  // CHECK: call <256 x double> @llvm.ve.vl.vldlsxnc.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
+  vr1 = _vel_vldlsxnc_vssvl(idx, p, vr1, 256);
+}
+
+void __attribute__((noinline))
+test_vldlzx_vssl(char* p, long idx) {
+  // CHECK-LABEL: @test_vldlzx_vssl
+  // CHECK: call <256 x double> @llvm.ve.vl.vldlzx.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
+  vr1 = _vel_vldlzx_vssl(idx, p, 256);
+}
+
+void __attribute__((noinline))
+test_vldlzx_vssvl(char* p, long idx) {
+  // CHECK-LABEL: @test_vldlzx_vssvl
+  // CHECK: call <256 x double> @llvm.ve.vl.vldlzx.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
+  vr1 = _vel_vldlzx_vssvl(idx, p, vr1, 256);
+}
+
+void __attribute__((noinline))
+test_vldlzxnc_vssl(char* p, long idx) {
+  // CHECK-LABEL: @test_vldlzxnc_vssl
+  // CHECK: call <256 x double> @llvm.ve.vl.vldlzxnc.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
+  vr1 = _vel_vldlzxnc_vssl(idx, p, 256);
+}
+
+void __attribute__((noinline))

[clang] a887b95 - [clang-format] Turn global COperatorsFollowingVar vector into a switch

2022-03-05 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2022-03-05T18:00:16+01:00
New Revision: a887b95edf34117b0274e5c9443ef6afa58b058a

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

LOG: [clang-format] Turn global COperatorsFollowingVar vector into a switch

LLVM optimizes this into a bit test. NFCI.

Added: 


Modified: 
clang/lib/Format/FormatToken.h
clang/lib/Format/UnwrappedLineParser.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index e72df7d377823..b00b8ab7b927c 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -134,34 +134,6 @@ namespace format {
   TYPE(CSharpGenericTypeConstraintComma)   
\
   TYPE(Unknown)
 
-/// Sorted operators that can follow a C variable.
-static const std::vector COperatorsFollowingVar = [] {
-  std::vector ReturnVal = {
-  tok::l_square, tok::r_square,
-  tok::l_paren,  tok::r_paren,
-  tok::r_brace,  tok::period,
-  tok::ellipsis, tok::ampamp,
-  tok::ampequal, tok::star,
-  tok::starequal,tok::plus,
-  tok::plusplus, tok::plusequal,
-  tok::minus,tok::arrow,
-  tok::minusminus,   tok::minusequal,
-  tok::exclaim,  tok::exclaimequal,
-  tok::slash,tok::slashequal,
-  tok::percent,  tok::percentequal,
-  tok::less, tok::lessless,
-  tok::lessequal,tok::lesslessequal,
-  tok::greater,  tok::greatergreater,
-  tok::greaterequal, tok::greatergreaterequal,
-  tok::caret,tok::caretequal,
-  tok::pipe, tok::pipepipe,
-  tok::pipeequal,tok::question,
-  tok::semi, tok::equal,
-  tok::equalequal,   tok::comma};
-  assert(std::is_sorted(ReturnVal.begin(), ReturnVal.end()));
-  return ReturnVal;
-}();
-
 /// Determines the semantic type of a syntactic token, e.g. whether "<" is a
 /// template opener or binary operator.
 enum TokenType : uint8_t {

diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 68b0e2a630bcd..646374c0cd626 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2816,6 +2816,57 @@ void UnwrappedLineParser::parseSwitch() {
 NestedTooDeep.pop_back();
 }
 
+// Operators that can follow a C variable.
+static bool isCOperatorFollowingVar(tok::TokenKind kind) {
+  switch (kind) {
+  case tok::ampamp:
+  case tok::ampequal:
+  case tok::arrow:
+  case tok::caret:
+  case tok::caretequal:
+  case tok::comma:
+  case tok::ellipsis:
+  case tok::equal:
+  case tok::equalequal:
+  case tok::exclaim:
+  case tok::exclaimequal:
+  case tok::greater:
+  case tok::greaterequal:
+  case tok::greatergreater:
+  case tok::greatergreaterequal:
+  case tok::l_paren:
+  case tok::l_square:
+  case tok::less:
+  case tok::lessequal:
+  case tok::lessless:
+  case tok::lesslessequal:
+  case tok::minus:
+  case tok::minusequal:
+  case tok::minusminus:
+  case tok::percent:
+  case tok::percentequal:
+  case tok::period:
+  case tok::pipe:
+  case tok::pipeequal:
+  case tok::pipepipe:
+  case tok::plus:
+  case tok::plusequal:
+  case tok::plusplus:
+  case tok::question:
+  case tok::r_brace:
+  case tok::r_paren:
+  case tok::r_square:
+  case tok::semi:
+  case tok::slash:
+  case tok::slashequal:
+  case tok::star:
+  case tok::starequal:
+return true;
+  default:
+return false;
+  }
+}
+
 void UnwrappedLineParser::parseAccessSpecifier() {
   FormatToken *AccessSpecifierCandidate = FormatTok;
   nextToken();
@@ -2827,9 +2878,7 @@ void UnwrappedLineParser::parseAccessSpecifier() {
 nextToken();
 addUnwrappedLine();
   } else if (!FormatTok->is(tok::coloncolon) &&
- !std::binary_search(COperatorsFollowingVar.begin(),
- COperatorsFollowingVar.end(),
- FormatTok->Tok.getKind())) {
+ !isCOperatorFollowingVar(FormatTok->Tok.getKind())) {
 // Not a variable name nor namespace name.
 addUnwrappedLine();
   } else if (AccessSpecifierCandidate) {



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


[PATCH] D120296: [Attr] Fix a btf_type_tag AST generation bug

2022-03-05 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 413219.
yonghong-song edited the summary of this revision.
yonghong-song added a comment.
Herald added subscribers: dexonsmith, arphaman, martong.
Herald added a project: All.

- Create a separate type BTFTagAttributed instead of using Attributed type 
based on previous discussion


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120296

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/TypeNodes.td
  clang/include/clang/Serialization/ASTRecordReader.h
  clang/include/clang/Serialization/ASTRecordWriter.h
  clang/include/clang/Serialization/TypeBitCodes.def
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CodeGen/attr-btf_type_tag-similar-type.c
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXType.cpp

Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -116,6 +116,7 @@
 TKCASE(Elaborated);
 TKCASE(Pipe);
 TKCASE(Attributed);
+TKCASE(BTFTagAttributed);
 TKCASE(Atomic);
 default:
   return CXType_Unexposed;
@@ -136,6 +137,10 @@
 return MakeCXType(ATT->getEquivalentType(), TU);
   }
 }
+if (auto *ATT = T->getAs()) {
+  if (!(TU->ParsingOptions & CXTranslationUnit_IncludeAttributedTypes))
+return MakeCXType(ATT->getEquivalentType(), TU);
+}
 // Handle paren types as the original type
 if (auto *PTT = T->getAs()) {
   return MakeCXType(PTT->getInnerType(), TU);
@@ -610,6 +615,7 @@
 TKIND(Elaborated);
 TKIND(Pipe);
 TKIND(Attributed);
+TKIND(BTFTagAttributed);
 TKIND(BFloat16);
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) TKIND(Id);
 #include "clang/Basic/OpenCLImageTypes.def"
@@ -1051,6 +1057,9 @@
   if (auto *ATT = T->getAs())
 return MakeCXType(ATT->getModifiedType(), GetTU(CT));
 
+  if (auto *ATT = T->getAs())
+return MakeCXType(ATT->getModifiedType(), GetTU(CT));
+
   return MakeCXType(QualType(), GetTU(CT));
 }
 
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1672,6 +1672,10 @@
   return Visit(TL.getModifiedLoc());
 }
 
+bool CursorVisitor::VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc TL) {
+  return Visit(TL.getModifiedLoc());
+}
+
 bool CursorVisitor::VisitFunctionTypeLoc(FunctionTypeLoc TL,
  bool SkipResultType) {
   if (!SkipResultType && Visit(TL.getReturnLoc()))
Index: clang/test/CodeGen/attr-btf_type_tag-similar-type.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-btf_type_tag-similar-type.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck %s
+
+struct map_value {
+int __attribute__((btf_type_tag("tag1"))) __attribute__((btf_type_tag("tag3"))) *a;
+int __attribute__((btf_type_tag("tag2"))) __attribute__((btf_type_tag("tag4"))) *b;
+};
+
+struct map_value *func(void);
+
+int test(struct map_value *arg)
+{
+return *arg->a;
+}
+
+// CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "map_value", file: ![[#]], line: [[#]], size: [[#]], elements: ![[L14:[0-9]+]]
+// CHECK: ![[L14]] = !{![[L15:[0-9]+]], ![[L20:[0-9]+]]}
+// CHECK: ![[L15]] = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: ![[#]], file: ![[#]], line: [[#]], baseType: ![[L16:[0-9]+]]
+// CHECK: ![[L16]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[#]], size: [[#]], annotations: ![[L17:[0-9]+]]
+// CHECK: ![[L17]] = !{![[L18:[0-9]+]], ![[L19:[0-9]+]]}
+// CHECK: ![[L18]] = !{!"btf_type_tag", !"tag1"}
+// CHECK: ![[L19]] = !{!"btf_type_tag", !"tag3"}
+// CHECK: ![[L20]] = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: ![[#]], file: ![[#]], line: [[#]], baseType: ![[L21:[0-9]+]]
+// CHECK: ![[L21:[0-9]+]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[#]], size: [[#]], annotations: ![[L22:[0-9]+]]
+// CHECK: ![[L22]] = !{![[L23:[0-9]+]], ![[L24:[0-9]+]]}
+// CHEC

[PATCH] D120296: [Attr] Fix a btf_type_tag AST generation bug

2022-03-05 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

@aaron.ballman @erichkeane Just updated the patch with a new implementation, 
which added a new BTFTagAttributedType instead of reusing existing 
AttributedType. It is quite complicated and various parts of clang are touched. 
I mostly just followed what AttributedType did but considering 
BTFTagAttributedType is C only so my current implementation may unnecessarily 
complicate things. I didn't have much test coverage either. It would be great 
you can give a look and let me know (1). what I am missing, (2). where I can 
simplify things, (3) a different approach if you see fit, (4). what additional 
tests I should have. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120296

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


[clang] 28bb040 - [clang-format] QualifierOrder does not reorder template arguments

2022-03-05 Thread via cfe-commits

Author: mydeveloperday
Date: 2022-03-05T18:08:25Z
New Revision: 28bb040ded83b7cffdd6e6102080ccbe7935dbfe

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

LOG: [clang-format] QualifierOrder does not reorder template arguments

https://github.com/llvm/llvm-project/issues/53981

Reorder the qualifiers inside the template argument. This should handle the 
simple cases of

```


```

But only by relaxing that single letter capital variables are not possible 
macros

Fixes: #53981

Reviewed By: HazardyKnusperkeks, curdeius

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

Added: 


Modified: 
clang/lib/Format/QualifierAlignmentFixer.cpp
clang/unittests/Format/QualifierFixerTest.cpp

Removed: 




diff  --git a/clang/lib/Format/QualifierAlignmentFixer.cpp 
b/clang/lib/Format/QualifierAlignmentFixer.cpp
index aff5562dd9721..74802026690ef 100644
--- a/clang/lib/Format/QualifierAlignmentFixer.cpp
+++ b/clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -223,6 +223,12 @@ const FormatToken 
*LeftRightQualifierAlignmentFixer::analyzeRight(
   if (LastQual && Qual != LastQual) {
 rotateTokens(SourceMgr, Fixes, Tok, LastQual, /*Left=*/false);
 Tok = LastQual;
+  } else if (Tok->startsSequence(QualifierType, tok::identifier,
+ TT_TemplateCloser)) {
+FormatToken *Closer = Tok->Next->Next;
+rotateTokens(SourceMgr, Fixes, Tok, Tok->Next, /*Left=*/false);
+Tok = Closer;
+return Tok;
   } else if (Tok->startsSequence(QualifierType, tok::identifier,
  TT_TemplateOpener)) {
 // Read from the TemplateOpener to
@@ -307,6 +313,11 @@ const FormatToken 
*LeftRightQualifierAlignmentFixer::analyzeLeft(
 rotateTokens(SourceMgr, Fixes, Tok, Tok->Next, /*Left=*/true);
 Tok = Tok->Next;
   }
+} else if (Tok->startsSequence(tok::identifier, QualifierType,
+   TT_TemplateCloser)) {
+  FormatToken *Closer = Tok->Next->Next;
+  rotateTokens(SourceMgr, Fixes, Tok, Tok->Next, /*Left=*/true);
+  Tok = Closer;
 }
   }
   if (Tok->is(TT_TemplateOpener) && Tok->Next &&
@@ -329,8 +340,12 @@ const FormatToken 
*LeftRightQualifierAlignmentFixer::analyzeLeft(
 Next = Next->getNextNonComment();
   assert(Next->MatchingParen && "Missing template closer");
   Next = Next->MatchingParen;
+
+  // If the template closer is closing the requires clause,
+  // then stop and go back to the TemplateOpener and do whatever is
+  // inside the <>.
   if (Next->ClosesRequiresClause)
-return Next;
+return Next->MatchingParen;
   Next = Next->Next;
 
   // Move to the end of any template class members e.g.
@@ -461,7 +476,8 @@ bool 
LeftRightQualifierAlignmentFixer::isPossibleMacro(const FormatToken *Tok) {
   if (!Tok->is(tok::identifier))
 return false;
   if (Tok->TokenText.upper() == Tok->TokenText.str())
-return true;
+// T,K,U,V likely could be template arguments
+return (Tok->TokenText.size() != 1);
   return false;
 }
 

diff  --git a/clang/unittests/Format/QualifierFixerTest.cpp 
b/clang/unittests/Format/QualifierFixerTest.cpp
index 0c81c831e1f18..167a30ec09d3f 100755
--- a/clang/unittests/Format/QualifierFixerTest.cpp
+++ b/clang/unittests/Format/QualifierFixerTest.cpp
@@ -895,5 +895,40 @@ TEST_F(QualifierFixerTest, DisableRegions) {
Style);
 }
 
+TEST_F(QualifierFixerTest, TemplatesRight) {
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Custom;
+  Style.QualifierOrder = {"type", "const"};
+
+  verifyFormat("template \n"
+   "  requires Concept\n"
+   "void f();",
+   "template \n"
+   "  requires Concept\n"
+   "void f();",
+   Style);
+  verifyFormat("TemplateType t;", "TemplateType t;", Style);
+  verifyFormat("TemplateType t;",
+   "TemplateType t;", Style);
+}
+
+TEST_F(QualifierFixerTest, TemplatesLeft) {
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Custom;
+  Style.QualifierOrder = {"const", "type"};
+
+  verifyFormat("template  t;", "template  t;", Style);
+  verifyFormat("template \n"
+   "  requires Concept\n"
+   "void f();",
+   "template \n"
+   "  requires Concept\n"
+   "void f();",
+   Style);
+  verifyFormat("TemplateType t;", "TemplateType t;", Style);
+  verifyFormat("TemplateType t;",
+   "TemplateType t;", Style);
+}
+
 } // namespace format
 } // namespace clang



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

[PATCH] D120710: [clang-format] QualifierOrder does not reorder template arguments

2022-03-05 Thread MyDeveloperDay 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 rG28bb040ded83: [clang-format] QualifierOrder does not reorder 
template arguments (authored by MyDeveloperDay).

Changed prior to commit:
  https://reviews.llvm.org/D120710?vs=412029&id=413229#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120710

Files:
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/unittests/Format/QualifierFixerTest.cpp


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -895,5 +895,40 @@
Style);
 }
 
+TEST_F(QualifierFixerTest, TemplatesRight) {
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Custom;
+  Style.QualifierOrder = {"type", "const"};
+
+  verifyFormat("template \n"
+   "  requires Concept\n"
+   "void f();",
+   "template \n"
+   "  requires Concept\n"
+   "void f();",
+   Style);
+  verifyFormat("TemplateType t;", "TemplateType t;", Style);
+  verifyFormat("TemplateType t;",
+   "TemplateType t;", Style);
+}
+
+TEST_F(QualifierFixerTest, TemplatesLeft) {
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Custom;
+  Style.QualifierOrder = {"const", "type"};
+
+  verifyFormat("template  t;", "template  t;", Style);
+  verifyFormat("template \n"
+   "  requires Concept\n"
+   "void f();",
+   "template \n"
+   "  requires Concept\n"
+   "void f();",
+   Style);
+  verifyFormat("TemplateType t;", "TemplateType t;", Style);
+  verifyFormat("TemplateType t;",
+   "TemplateType t;", Style);
+}
+
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -223,6 +223,12 @@
   if (LastQual && Qual != LastQual) {
 rotateTokens(SourceMgr, Fixes, Tok, LastQual, /*Left=*/false);
 Tok = LastQual;
+  } else if (Tok->startsSequence(QualifierType, tok::identifier,
+ TT_TemplateCloser)) {
+FormatToken *Closer = Tok->Next->Next;
+rotateTokens(SourceMgr, Fixes, Tok, Tok->Next, /*Left=*/false);
+Tok = Closer;
+return Tok;
   } else if (Tok->startsSequence(QualifierType, tok::identifier,
  TT_TemplateOpener)) {
 // Read from the TemplateOpener to
@@ -307,6 +313,11 @@
 rotateTokens(SourceMgr, Fixes, Tok, Tok->Next, /*Left=*/true);
 Tok = Tok->Next;
   }
+} else if (Tok->startsSequence(tok::identifier, QualifierType,
+   TT_TemplateCloser)) {
+  FormatToken *Closer = Tok->Next->Next;
+  rotateTokens(SourceMgr, Fixes, Tok, Tok->Next, /*Left=*/true);
+  Tok = Closer;
 }
   }
   if (Tok->is(TT_TemplateOpener) && Tok->Next &&
@@ -329,8 +340,12 @@
 Next = Next->getNextNonComment();
   assert(Next->MatchingParen && "Missing template closer");
   Next = Next->MatchingParen;
+
+  // If the template closer is closing the requires clause,
+  // then stop and go back to the TemplateOpener and do whatever is
+  // inside the <>.
   if (Next->ClosesRequiresClause)
-return Next;
+return Next->MatchingParen;
   Next = Next->Next;
 
   // Move to the end of any template class members e.g.
@@ -461,7 +476,8 @@
   if (!Tok->is(tok::identifier))
 return false;
   if (Tok->TokenText.upper() == Tok->TokenText.str())
-return true;
+// T,K,U,V likely could be template arguments
+return (Tok->TokenText.size() != 1);
   return false;
 }
 


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -895,5 +895,40 @@
Style);
 }
 
+TEST_F(QualifierFixerTest, TemplatesRight) {
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Custom;
+  Style.QualifierOrder = {"type", "const"};
+
+  verifyFormat("template \n"
+   "  requires Concept\n"
+   "void f();",
+   "template \n"
+   "  requires Concept\n"
+   "void f();",
+   Style);
+  verifyFormat("TemplateType t;", "TemplateType t;", Style);
+  verifyFormat("TemplateType t;",
+   "TemplateType t;", Style);
+}
+
+TEST_F(QualifierFixerTest, TemplatesLeft) {
+  FormatStyle Style = getLLVMStyl

[PATCH] D114231: [clang][docs][dataflow] Added an introduction to dataflow analysis

2022-03-05 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

> Did you add somewhere what dependency we need in order to build the 
> documentation now as mine is having problems with "recommonmark"

I didn't change the documentation because recommonmark is not a new dependency 
for llvm-project, llvm/docs was depending on it before this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114231

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


[clang] 14af99d - [OpenCL] Turn global vector into static array. NFCI.

2022-03-05 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2022-03-05T19:16:28+01:00
New Revision: 14af99d375b6c47e4b5ec457fb1f1f02b71a8566

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

LOG: [OpenCL] Turn global vector into static array. NFCI.

Added: 


Modified: 
clang/include/clang/Basic/OpenCLOptions.h
clang/lib/Basic/OpenCLOptions.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/OpenCLOptions.h 
b/clang/include/clang/Basic/OpenCLOptions.h
index 512bcb1e6ef10..d6cb1a210519d 100644
--- a/clang/include/clang/Basic/OpenCLOptions.h
+++ b/clang/include/clang/Basic/OpenCLOptions.h
@@ -212,15 +212,6 @@ class OpenCLOptions {
   bool isEnabled(llvm::StringRef Ext) const;
 
   OpenCLOptionInfoMap OptMap;
-
-  // First feature in a pair requires the second one to be supported.
-  using FeatureDepEntry = std::pair;
-  using FeatureDepList = llvm::SmallVector;
-
-  static const FeatureDepList DependentFeaturesList;
-
-  // Extensions and equivalent feature pairs.
-  static const llvm::StringMap FeatureExtensionMap;
 };
 
 } // end namespace clang

diff  --git a/clang/lib/Basic/OpenCLOptions.cpp 
b/clang/lib/Basic/OpenCLOptions.cpp
index 7e89b3f1b804d..44edf54025405 100644
--- a/clang/lib/Basic/OpenCLOptions.cpp
+++ b/clang/lib/Basic/OpenCLOptions.cpp
@@ -12,14 +12,16 @@
 
 namespace clang {
 
-const OpenCLOptions::FeatureDepList OpenCLOptions::DependentFeaturesList = {
+// First feature in a pair requires the second one to be supported.
+static const std::pair DependentFeaturesList[] = {
 {"__opencl_c_read_write_images", "__opencl_c_images"},
 {"__opencl_c_3d_image_writes", "__opencl_c_images"},
 {"__opencl_c_pipes", "__opencl_c_generic_address_space"},
 {"__opencl_c_device_enqueue", "__opencl_c_generic_address_space"},
 {"__opencl_c_device_enqueue", 
"__opencl_c_program_scope_global_variables"}};
 
-const llvm::StringMap OpenCLOptions::FeatureExtensionMap = {
+// Extensions and equivalent feature pairs.
+static const std::pair FeatureExtensionMap[] = {
 {"cl_khr_fp64", "__opencl_c_fp64"},
 {"cl_khr_3d_image_writes", "__opencl_c_3d_image_writes"}};
 
@@ -140,11 +142,11 @@ bool OpenCLOptions::diagnoseFeatureExtensionDifferences(
 
   bool IsValid = true;
   for (auto &ExtAndFeat : FeatureExtensionMap)
-if (TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.getKey()) !=
-TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.getValue())) {
+if (TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.first) !=
+TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.second)) {
   IsValid = false;
   Diags.Report(diag::err_opencl_extension_and_feature_
diff ers)
-  << ExtAndFeat.getKey() << ExtAndFeat.getValue();
+  << ExtAndFeat.first << ExtAndFeat.second;
 }
   return IsValid;
 }



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


[clang] e44bbed - Make ParsedAttrInfo and subclasses use constexpr construction

2022-03-05 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2022-03-05T20:37:21+01:00
New Revision: e44bbedb3261e918dcbd77d271dcdf0c89a41ce0

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

LOG: Make ParsedAttrInfo and subclasses use constexpr construction

This removes a 30 kB global initializer. NFCI.

Added: 


Modified: 
clang/include/clang/Sema/ParsedAttr.h
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/ParsedAttr.h 
b/clang/include/clang/Sema/ParsedAttr.h
index ef59e14b58c46..f8abb8cb119ba 100644
--- a/clang/include/clang/Sema/ParsedAttr.h
+++ b/clang/include/clang/Sema/ParsedAttr.h
@@ -74,12 +74,29 @@ struct ParsedAttrInfo {
   // The names of the known arguments of this attribute.
   ArrayRef ArgNames;
 
-  ParsedAttrInfo(AttributeCommonInfo::Kind AttrKind =
- AttributeCommonInfo::NoSemaHandlerAttribute)
-  : AttrKind(AttrKind), NumArgs(0), OptArgs(0), HasCustomParsing(0),
-IsTargetSpecific(0), IsType(0), IsStmt(0), IsKnownToGCC(0),
-IsSupportedByPragmaAttribute(0) {}
+protected:
+  constexpr ParsedAttrInfo(AttributeCommonInfo::Kind AttrKind =
+   AttributeCommonInfo::NoSemaHandlerAttribute)
+  : AttrKind(AttrKind), NumArgs(0), OptArgs(0), NumArgMembers(0),
+HasCustomParsing(0), AcceptsExprPack(0), IsTargetSpecific(0), 
IsType(0),
+IsStmt(0), IsKnownToGCC(0), IsSupportedByPragmaAttribute(0) {}
+
+  constexpr ParsedAttrInfo(AttributeCommonInfo::Kind AttrKind, unsigned 
NumArgs,
+   unsigned OptArgs, unsigned NumArgMembers,
+   unsigned HasCustomParsing, unsigned AcceptsExprPack,
+   unsigned IsTargetSpecific, unsigned IsType,
+   unsigned IsStmt, unsigned IsKnownToGCC,
+   unsigned IsSupportedByPragmaAttribute,
+   ArrayRef Spellings,
+   ArrayRef ArgNames)
+  : AttrKind(AttrKind), NumArgs(NumArgs), OptArgs(OptArgs),
+NumArgMembers(NumArgMembers), HasCustomParsing(HasCustomParsing),
+AcceptsExprPack(AcceptsExprPack), IsTargetSpecific(IsTargetSpecific),
+IsType(IsType), IsStmt(IsStmt), IsKnownToGCC(IsKnownToGCC),
+IsSupportedByPragmaAttribute(IsSupportedByPragmaAttribute),
+Spellings(Spellings), ArgNames(ArgNames) {}
 
+public:
   virtual ~ParsedAttrInfo() = default;
 
   /// Check if this attribute appertains to D, and issue a diagnostic if not.

diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 3a9df85b017b3..47c06cdd147cb 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3577,9 +3577,9 @@ static void emitArgInfo(const Record &R, raw_ostream &OS) 
{
 
   // If there is a variadic argument, we will set the optional argument count
   // to its largest value. Since it's currently a 4-bit number, we set it to 
15.
-  OS << "NumArgs = " << ArgCount << ";\n";
-  OS << "OptArgs = " << (HasVariadic ? 15 : OptCount) << ";\n";
-  OS << "NumArgMembers = " << ArgMemberCount << ";\n";
+  OS << "/*NumArgs=*/" << ArgCount << ",\n";
+  OS << "/*OptArgs=*/" << (HasVariadic ? 15 : OptCount) << ",\n";
+  OS << "/*NumArgMembers=*/" << ArgMemberCount << ",\n";
 }
 
 static std::string GetDiagnosticSpelling(const Record &R) {
@@ -4205,30 +4205,34 @@ void EmitClangAttrParsedAttrImpl(RecordKeeper &Records, 
raw_ostream &OS) {
 
 OS << "struct ParsedAttrInfo" << I->first
<< " final : public ParsedAttrInfo {\n";
-OS << "  ParsedAttrInfo" << I->first << "() {\n";
-OS << "AttrKind = ParsedAttr::AT_" << AttrName << ";\n";
+OS << "  constexpr ParsedAttrInfo" << I->first << "() : ParsedAttrInfo(\n";
+OS << "/*AttrKind=*/ParsedAttr::AT_" << AttrName << ",\n";
 emitArgInfo(Attr, OS);
-OS << "HasCustomParsing = ";
-OS << Attr.getValueAsBit("HasCustomParsing") << ";\n";
-OS << "AcceptsExprPack = ";
-OS << Attr.getValueAsBit("AcceptsExprPack") << ";\n";
-OS << "IsTargetSpecific = ";
-OS << Attr.isSubClassOf("TargetSpecificAttr") << ";\n";
-OS << "IsType = ";
-OS << (Attr.isSubClassOf("TypeAttr") ||
-   Attr.isSubClassOf("DeclOrTypeAttr")) << ";\n";
-OS << "IsStmt = ";
+OS << "/*HasCustomParsing=*/";
+OS << Attr.getValueAsBit("HasCustomParsing") << ",\n";
+OS << "/*AcceptsExprPack=*/";
+OS << Attr.getValueAsBit("AcceptsExprPack") << ",\n";
+OS << "/*IsTargetSpecific=*/";
+OS << Attr.isSubClassOf("TargetSpecificAttr") << ",\n";
+OS << "/*IsType=*/";
+OS << (Attr.isSubClassOf("TypeAttr") || 
Attr.isSubClas

[clang] 28b76b1 - [clang-format] Handle goto labels for RemoveBracesLLVM

2022-03-05 Thread via cfe-commits

Author: owenca
Date: 2022-03-05T12:46:57-08:00
New Revision: 28b76b1e23bb25ed333183361705841ff8f77574

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

LOG: [clang-format] Handle goto labels for RemoveBracesLLVM

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 646374c0cd626..a62aa5e649839 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -476,6 +476,7 @@ bool UnwrappedLineParser::parseLevel(bool HasOpeningBrace,
   : TT_Unknown;
   const bool IsPrecededByCommentOrPPDirective =
   !Style.RemoveBracesLLVM || precededByCommentOrPPDirective();
+  bool HasLabel = false;
   unsigned StatementCount = 0;
   bool SwitchLabelEncountered = false;
   do {
@@ -486,9 +487,9 @@ bool UnwrappedLineParser::parseLevel(bool HasOpeningBrace,
   kind = tok::r_brace;
 
 auto ParseDefault = [this, HasOpeningBrace, IfKind, NextLevelLBracesType,
- &StatementCount] {
-  parseStructuralElement(IfKind, /*IsTopLevel=*/!HasOpeningBrace,
- /*NextLBracesType=*/NextLevelLBracesType);
+ &HasLabel, &StatementCount] {
+  parseStructuralElement(IfKind, !HasOpeningBrace, NextLevelLBracesType,
+ HasLabel ? nullptr : &HasLabel);
   ++StatementCount;
   assert(StatementCount > 0 && "StatementCount overflow!");
 };
@@ -523,7 +524,7 @@ bool UnwrappedLineParser::parseLevel(bool HasOpeningBrace,
   if (HasOpeningBrace) {
 if (!Style.RemoveBracesLLVM)
   return false;
-if (FormatTok->isNot(tok::r_brace) || StatementCount != 1 ||
+if (FormatTok->isNot(tok::r_brace) || StatementCount != 1 || HasLabel 
||
 IsPrecededByCommentOrPPDirective ||
 precededByCommentOrPPDirective())
   return false;
@@ -1312,7 +1313,8 @@ void UnwrappedLineParser::readTokenWithJavaScriptASI() {
 
 void UnwrappedLineParser::parseStructuralElement(IfStmtKind *IfKind,
  bool IsTopLevel,
- TokenType NextLBracesType) {
+ TokenType NextLBracesType,
+ bool *HasLabel) {
   if (Style.Language == FormatStyle::LK_TableGen &&
   FormatTok->is(tok::pp_include)) {
 nextToken();
@@ -1758,6 +1760,8 @@ void 
UnwrappedLineParser::parseStructuralElement(IfStmtKind *IfKind,
 if (FormatTok->is(tok::colon) && !Line->MustBeDeclaration) {
   Line->Tokens.begin()->Tok->MustBreakBefore = true;
   parseLabel(!Style.IndentGotoLabels);
+  if (HasLabel)
+*HasLabel = true;
   return;
 }
 // Recognize function-like macro usages without trailing semicolon as

diff  --git a/clang/lib/Format/UnwrappedLineParser.h 
b/clang/lib/Format/UnwrappedLineParser.h
index b2a2ae1bedc17..5cc01398a5457 100644
--- a/clang/lib/Format/UnwrappedLineParser.h
+++ b/clang/lib/Format/UnwrappedLineParser.h
@@ -112,7 +112,8 @@ class UnwrappedLineParser {
   void readTokenWithJavaScriptASI();
   void parseStructuralElement(IfStmtKind *IfKind = nullptr,
   bool IsTopLevel = false,
-  TokenType NextLBracesType = TT_Unknown);
+  TokenType NextLBracesType = TT_Unknown,
+  bool *HasLabel = nullptr);
   bool tryToParseBracedList();
   bool parseBracedList(bool ContinueOnSemicolons = false, bool IsEnum = false,
tok::TokenKind ClosingBraceKind = tok::r_brace);

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index f453a4f77f8b3..8909acdae5dc3 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -25018,6 +25018,23 @@ TEST_F(FormatTest, RemoveBraces) {
"}",
Style);
 
+  verifyFormat("if (a) {\n"
+   "Label:\n"
+   "}",
+   Style);
+
+  verifyFormat("if (a) {\n"
+   "Label:\n"
+   "  f();\n"
+   "}",
+   Style);
+
+  verifyFormat("if (a) {\n"
+   "  f();\n"
+   "Label:\n"
+   "}",
+   Style);
+
   // FIXME: See https://github.com/llvm/llvm-project/issues/53543.
 #if 0
   Style.ColumnLimit = 65;



___

[PATCH] D121042: [clang-format] Handle goto labels for RemoveBracesLLVM

2022-03-05 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG28b76b1e23bb: [clang-format] Handle goto labels for 
RemoveBracesLLVM (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121042

Files:
  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
@@ -25018,6 +25018,23 @@
"}",
Style);
 
+  verifyFormat("if (a) {\n"
+   "Label:\n"
+   "}",
+   Style);
+
+  verifyFormat("if (a) {\n"
+   "Label:\n"
+   "  f();\n"
+   "}",
+   Style);
+
+  verifyFormat("if (a) {\n"
+   "  f();\n"
+   "Label:\n"
+   "}",
+   Style);
+
   // FIXME: See https://github.com/llvm/llvm-project/issues/53543.
 #if 0
   Style.ColumnLimit = 65;
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -112,7 +112,8 @@
   void readTokenWithJavaScriptASI();
   void parseStructuralElement(IfStmtKind *IfKind = nullptr,
   bool IsTopLevel = false,
-  TokenType NextLBracesType = TT_Unknown);
+  TokenType NextLBracesType = TT_Unknown,
+  bool *HasLabel = nullptr);
   bool tryToParseBracedList();
   bool parseBracedList(bool ContinueOnSemicolons = false, bool IsEnum = false,
tok::TokenKind ClosingBraceKind = tok::r_brace);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -476,6 +476,7 @@
   : TT_Unknown;
   const bool IsPrecededByCommentOrPPDirective =
   !Style.RemoveBracesLLVM || precededByCommentOrPPDirective();
+  bool HasLabel = false;
   unsigned StatementCount = 0;
   bool SwitchLabelEncountered = false;
   do {
@@ -486,9 +487,9 @@
   kind = tok::r_brace;
 
 auto ParseDefault = [this, HasOpeningBrace, IfKind, NextLevelLBracesType,
- &StatementCount] {
-  parseStructuralElement(IfKind, /*IsTopLevel=*/!HasOpeningBrace,
- /*NextLBracesType=*/NextLevelLBracesType);
+ &HasLabel, &StatementCount] {
+  parseStructuralElement(IfKind, !HasOpeningBrace, NextLevelLBracesType,
+ HasLabel ? nullptr : &HasLabel);
   ++StatementCount;
   assert(StatementCount > 0 && "StatementCount overflow!");
 };
@@ -523,7 +524,7 @@
   if (HasOpeningBrace) {
 if (!Style.RemoveBracesLLVM)
   return false;
-if (FormatTok->isNot(tok::r_brace) || StatementCount != 1 ||
+if (FormatTok->isNot(tok::r_brace) || StatementCount != 1 || HasLabel 
||
 IsPrecededByCommentOrPPDirective ||
 precededByCommentOrPPDirective())
   return false;
@@ -1312,7 +1313,8 @@
 
 void UnwrappedLineParser::parseStructuralElement(IfStmtKind *IfKind,
  bool IsTopLevel,
- TokenType NextLBracesType) {
+ TokenType NextLBracesType,
+ bool *HasLabel) {
   if (Style.Language == FormatStyle::LK_TableGen &&
   FormatTok->is(tok::pp_include)) {
 nextToken();
@@ -1758,6 +1760,8 @@
 if (FormatTok->is(tok::colon) && !Line->MustBeDeclaration) {
   Line->Tokens.begin()->Tok->MustBreakBefore = true;
   parseLabel(!Style.IndentGotoLabels);
+  if (HasLabel)
+*HasLabel = true;
   return;
 }
 // Recognize function-like macro usages without trailing semicolon as


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25018,6 +25018,23 @@
"}",
Style);
 
+  verifyFormat("if (a) {\n"
+   "Label:\n"
+   "}",
+   Style);
+
+  verifyFormat("if (a) {\n"
+   "Label:\n"
+   "  f();\n"
+   "}",
+   Style);
+
+  verifyFormat("if (a) {\n"
+   "  f();\n"
+   "Label:\n"
+   "}",
+   Style);
+
   // FIXME: See https://github.com/llvm/llvm-pr

[PATCH] D119599: [clang-format] Add option to align compound assignments like `+=`

2022-03-05 Thread sstwcw via Phabricator via cfe-commits
sstwcw updated this revision to Diff 413251.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119599

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

Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2699,7 +2699,7 @@
 
 TEST_F(FormatTestJS, AlignConsecutiveDeclarations) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
-  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  Style.AlignConsecutiveDeclarations.Enabled = true;
   verifyFormat("letletVariable = 5;\n"
"double constVariable = 10;",
Style);
@@ -2736,7 +2736,7 @@
 TEST_F(FormatTestJS, AlignConsecutiveAssignments) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
 
-  Style.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive;
+  Style.AlignConsecutiveAssignments.Enabled = true;
   verifyFormat("let letVariable  = 5;\n"
"double constVariable = 10;",
Style);
@@ -2772,8 +2772,8 @@
 
 TEST_F(FormatTestJS, AlignConsecutiveAssignmentsAndDeclarations) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
-  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
-  Style.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive;
+  Style.AlignConsecutiveDeclarations.Enabled = true;
+  Style.AlignConsecutiveAssignments.Enabled = true;
   verifyFormat("letletVariable   = 5;\n"
"double constVariable = 10;",
Style);
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2076,7 +2076,7 @@
   " res2 = [](int &a) { return 0; };",
   Style);
 
-  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  Style.AlignConsecutiveDeclarations.Enabled = true;
   verifyFormat("Const unsigned int *c;\n"
"const unsigned int *d;\n"
"Const unsigned int &e;\n"
@@ -2117,7 +2117,7 @@
   "res2 = [](int& a) { return 0; };",
   Style);
 
-  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  Style.AlignConsecutiveDeclarations.Enabled = true;
   verifyFormat("Const unsigned int* c;\n"
"const unsigned int* d;\n"
"Const unsigned int& e;\n"
@@ -2138,7 +2138,7 @@
   verifyFormat("for (int a = 0, b = 0; const Foo *c : {1, 2, 3})", Style);
   verifyFormat("for (int a = 0, b++; const Foo *c : {1, 2, 3})", Style);
 
-  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  Style.AlignConsecutiveDeclarations.Enabled = true;
   verifyFormat("Const unsigned int *c;\n"
"const unsigned int *d;\n"
"Const unsigned int& e;\n"
@@ -2174,7 +2174,7 @@
   " res2 = [](int & a) { return 0; };",
   Style);
 
-  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  Style.AlignConsecutiveDeclarations.Enabled = true;
   verifyFormat("Const unsigned int*  c;\n"
"const unsigned int*  d;\n"
"Const unsigned int & e;\n"
@@ -14425,8 +14425,8 @@
"*/\n"
"}",
Tab));
-  Tab.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive;
-  Tab.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  Tab.AlignConsecutiveAssignments.Enabled = true;
+  Tab.AlignConsecutiveDeclarations.Enabled = true;
   Tab.TabWidth = 4;
   Tab.IndentWidth = 4;
   verifyFormat("class Assign {\n"
@@ -14664,8 +14664,8 @@
"*/\n"
"}",
Tab));
-  Tab.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive;
-  Tab.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  Tab.AlignConsecutiveAssignments.Enabled = true;
+  Tab.AlignConsecutiveDeclarations.Enabled = true;
   Tab.TabWidth = 4;
   Tab.IndentWidth = 4;
   verifyFormat("class Assign {\n"
@@ -15835,9 +15835,8 @@
 
 TEST_F(FormatTest, AlignConsecutiveMacros) {
   FormatStyle Style = getLLVMStyle();
-  Style.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive;
-  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
-  Style.AlignConsecutiveMacros = FormatStyle::ACS_None;
+  Style.AlignConsecutiveAssignments.Enabled = true;
+  Style.AlignConsecutiveDeclarations.Enabled = true;
 
   verifyFormat("#define a 3\n"
"#define  4\n"
@@ -15861,7 +15860,7 @@

[PATCH] D119599: [clang-format] Add option to align compound assignments like `+=`

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

Only some small things, I think we are nearly done and this is a great change.




Comment at: clang/include/clang/Format/Format.h:139-140
+  ///
+  /// They can also be read as a whole for compatibility. The choices
+  /// are:
+  /// - None

This fits in one line.

(Please also recheck the other comments.)



Comment at: clang/include/clang/Format/Format.h:243
+  return Enabled == R.Enabled && AcrossEmptyLines == R.AcrossEmptyLines &&
+ AcrossComments == R.AcrossComments;
+}

Please add `AlignCompound` and `PadOperators`.



Comment at: clang/lib/Format/Format.cpp:182
+IO.mapOptional("AcrossComments", Value.AcrossComments);
+IO.mapOptional("Aligncompound", Value.AlignCompound);
+IO.mapOptional("PadOperators", Value.PadOperators);





Comment at: clang/lib/Format/WhitespaceManager.cpp:466
+// and `=`.
+// When RightJustify and PadAnchors are true, operators in each block to
+// be aligned will be padded on the left to the same length before

There is no `PadAnchors` anymore.



Comment at: clang/unittests/Format/FormatTest.cpp:16800
+   Alignment));
+}
+

Can you test it with `AlignConsecutiveDeclarations`?



Comment at: clang/unittests/Format/FormatTest.cpp:19781
+CHECK_PARSE(#FIELD ": Consecutive", FIELD, 
\
+FormatStyle::AlignConsecutiveStyle({/*.Enabled=*/true}));  
\
+CHECK_PARSE(#FIELD ": AcrossEmptyLines", FIELD,
\

Drop the .
Same below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119599

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


[PATCH] D120857: WIP [randstruct] Create basis for unit test module

2022-03-05 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 413260.
void added a comment.

Update with coding style.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120857

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/Randstruct.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/Decl.cpp
  clang/lib/AST/Randstruct.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/AST/RandstructTest.cpp

Index: clang/unittests/AST/RandstructTest.cpp
===
--- /dev/null
+++ clang/unittests/AST/RandstructTest.cpp
@@ -0,0 +1,413 @@
+//===- unittest/AST/RandstructTest.cpp ===//
+//
+// 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
+//
+//===--===//
+//
+// This file contains tests for Clang's structure field layout randomization.
+//
+//===--===//
+
+/*
+ * Build this test suite by running `make ASTTests` in the build folder.
+ *
+ * Run this test suite by running the following in the build folder:
+ * ` ./tools/clang/unittests/AST/ASTTests
+ * --gtest_filter=StructureLayoutRandomization*`
+ */
+
+#include "clang/AST/Randstruct.h"
+#include "gtest/gtest.h"
+
+#include "DeclMatcher.h"
+#include "clang/AST/RecordLayout.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Frontend/ASTUnit.h"
+#include "clang/Testing/CommandLineArgs.h"
+#include "clang/Tooling/Tooling.h"
+
+#include 
+
+using namespace clang::randstruct;
+
+namespace clang {
+namespace ast_matchers {
+
+static std::unique_ptr makeAST(const std::string &SourceCode,
+TestLanguage Lang) {
+  std::vector Args = getCommandLineArgsForTesting(Lang);
+  Args.push_back("-frandstruct-seed=1234567890abcdef");
+  auto AST = tooling::buildASTFromCodeWithArgs(SourceCode, Args, "input.cc");
+  return AST;
+}
+
+static RecordDecl *getRecordDeclFromAST(const ASTContext &C,
+const std::string &Name) {
+  return FirstDeclMatcher().match(C.getTranslationUnitDecl(),
+  recordDecl(hasName(Name)));
+}
+
+static std::vector getFieldNamesFromRecord(const RecordDecl *RD) {
+  std::vector Fields;
+  Fields.reserve(8);
+  for (auto *Field : RD->fields())
+Fields.push_back(Field->getNameAsString());
+  return Fields;
+}
+
+static bool isSubsequence(const std::vector &Seq,
+  const std::vector &Subseq) {
+  const auto SeqLen = Seq.size();
+  const auto SubLen = Subseq.size();
+
+  auto IsSubseq = false;
+  for (auto I = 0u; I < SeqLen; ++I) {
+if (Seq[I] == Subseq[0]) {
+  IsSubseq = true;
+  for (auto J = 0u; J + I < SeqLen && J < SubLen; ++J) {
+if (Seq[J + I] != Subseq[J]) {
+  IsSubseq = false;
+  break;
+}
+  }
+}
+  }
+  return IsSubseq;
+}
+
+#define RANDSTRUCT_TEST_SUITE_TEST StructureLayoutRandomizationTestSuiteTest
+
+TEST(RANDSTRUCT_TEST_SUITE_TEST, CanDetermineIfSubsequenceExists) {
+  const std::vector S0 = {"a", "b", "c", "d"};
+  ASSERT_TRUE(isSubsequence(S0, {"b", "c"}));
+  ASSERT_TRUE(isSubsequence(S0, {"a", "b", "c", "d"}));
+  ASSERT_TRUE(isSubsequence(S0, {"b", "c", "d"}));
+  ASSERT_TRUE(isSubsequence(S0, {"a"}));
+  ASSERT_FALSE(isSubsequence(S0, {"a", "d"}));
+}
+
+#define RANDSTRUCT_TEST StructureLayoutRandomization
+
+TEST(RANDSTRUCT_TEST, UnmarkedStructuresAreNotRandomized) {
+  std::string Code =
+  R"(
+struct dont_randomize_me {
+int potato;
+float tomato;
+long cabbage;
+};
+)";
+
+  const auto AST = makeAST(Code, Lang_C99);
+  const auto *RD =
+  getRecordDeclFromAST(AST->getASTContext(), "dont_randomize_me");
+  const std::vector Expected = {"potato", "tomato", "cabbage"};
+  const std::vector Actual = getFieldNamesFromRecord(RD);
+
+  ASSERT_EQ(Expected, Actual);
+}
+
+TEST(RANDSTRUCT_TEST, StructuresCanBeMarkedWithRandomizeLayoutAttr) {
+  std::string Code =
+  R"(
+struct marked {
+int bacon;
+long lettuce;
+   

[PATCH] D121063: [AST] Make the last element in the linked list null

2022-03-05 Thread Bill Wendling via Phabricator via cfe-commits
void created this revision.
void added reviewers: erichkeane, aaron.ballman, urnathan.
Herald added a project: All.
void requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The last element in a linked list should point to null, so that we can
identify when the linked list ends.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121063

Files:
  clang/lib/AST/DeclBase.cpp


Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -1344,6 +1344,10 @@
 PrevDecl = D;
   }
 
+  if (PrevDecl)
+// Last item in the linked list should have a null next pointer.
+PrevDecl->NextInContextAndBits.setPointer(nullptr);
+
   return std::make_pair(FirstNewDecl, PrevDecl);
 }
 


Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -1344,6 +1344,10 @@
 PrevDecl = D;
   }
 
+  if (PrevDecl)
+// Last item in the linked list should have a null next pointer.
+PrevDecl->NextInContextAndBits.setPointer(nullptr);
+
   return std::make_pair(FirstNewDecl, PrevDecl);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119599: [clang-format] Add option to align compound assignments like `+=`

2022-03-05 Thread sstwcw via Phabricator via cfe-commits
sstwcw updated this revision to Diff 413271.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119599

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

Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2699,7 +2699,7 @@
 
 TEST_F(FormatTestJS, AlignConsecutiveDeclarations) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
-  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  Style.AlignConsecutiveDeclarations.Enabled = true;
   verifyFormat("letletVariable = 5;\n"
"double constVariable = 10;",
Style);
@@ -2736,7 +2736,7 @@
 TEST_F(FormatTestJS, AlignConsecutiveAssignments) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
 
-  Style.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive;
+  Style.AlignConsecutiveAssignments.Enabled = true;
   verifyFormat("let letVariable  = 5;\n"
"double constVariable = 10;",
Style);
@@ -2772,8 +2772,8 @@
 
 TEST_F(FormatTestJS, AlignConsecutiveAssignmentsAndDeclarations) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
-  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
-  Style.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive;
+  Style.AlignConsecutiveDeclarations.Enabled = true;
+  Style.AlignConsecutiveAssignments.Enabled = true;
   verifyFormat("letletVariable   = 5;\n"
"double constVariable = 10;",
Style);
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2076,7 +2076,7 @@
   " res2 = [](int &a) { return 0; };",
   Style);
 
-  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  Style.AlignConsecutiveDeclarations.Enabled = true;
   verifyFormat("Const unsigned int *c;\n"
"const unsigned int *d;\n"
"Const unsigned int &e;\n"
@@ -2117,7 +2117,7 @@
   "res2 = [](int& a) { return 0; };",
   Style);
 
-  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  Style.AlignConsecutiveDeclarations.Enabled = true;
   verifyFormat("Const unsigned int* c;\n"
"const unsigned int* d;\n"
"Const unsigned int& e;\n"
@@ -2138,7 +2138,7 @@
   verifyFormat("for (int a = 0, b = 0; const Foo *c : {1, 2, 3})", Style);
   verifyFormat("for (int a = 0, b++; const Foo *c : {1, 2, 3})", Style);
 
-  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  Style.AlignConsecutiveDeclarations.Enabled = true;
   verifyFormat("Const unsigned int *c;\n"
"const unsigned int *d;\n"
"Const unsigned int& e;\n"
@@ -2174,7 +2174,7 @@
   " res2 = [](int & a) { return 0; };",
   Style);
 
-  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  Style.AlignConsecutiveDeclarations.Enabled = true;
   verifyFormat("Const unsigned int*  c;\n"
"const unsigned int*  d;\n"
"Const unsigned int & e;\n"
@@ -14425,8 +14425,8 @@
"*/\n"
"}",
Tab));
-  Tab.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive;
-  Tab.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  Tab.AlignConsecutiveAssignments.Enabled = true;
+  Tab.AlignConsecutiveDeclarations.Enabled = true;
   Tab.TabWidth = 4;
   Tab.IndentWidth = 4;
   verifyFormat("class Assign {\n"
@@ -14664,8 +14664,8 @@
"*/\n"
"}",
Tab));
-  Tab.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive;
-  Tab.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  Tab.AlignConsecutiveAssignments.Enabled = true;
+  Tab.AlignConsecutiveDeclarations.Enabled = true;
   Tab.TabWidth = 4;
   Tab.IndentWidth = 4;
   verifyFormat("class Assign {\n"
@@ -15835,9 +15835,8 @@
 
 TEST_F(FormatTest, AlignConsecutiveMacros) {
   FormatStyle Style = getLLVMStyle();
-  Style.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive;
-  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
-  Style.AlignConsecutiveMacros = FormatStyle::ACS_None;
+  Style.AlignConsecutiveAssignments.Enabled = true;
+  Style.AlignConsecutiveDeclarations.Enabled = true;
 
   verifyFormat("#define a 3\n"
"#define  4\n"
@@ -15861,7 +15860,7 @@

[PATCH] D119599: [clang-format] Add option to align compound assignments like `+=`

2022-03-05 Thread sstwcw via Phabricator via cfe-commits
sstwcw marked 5 inline comments as done.
sstwcw added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:16800
+   Alignment));
+}
+

HazardyKnusperkeks wrote:
> Can you test it with `AlignConsecutiveDeclarations`?
Do you mean like the formatting the same code with 
`AlignConsecutiveAssignments.Enabled` being false and 
`AlignConsecutiveDeclarations.Enabled` being true?  By the way, I just realized 
that things like `int a += 5;` are not valid code.  Should I remove the `int ` 
instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119599

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


[clang] 17a6806 - [Clang] Use = default(NFC)

2022-03-05 Thread Jun Zhang via cfe-commits

Author: Jun Zhang
Date: 2022-03-06T14:25:22+08:00
New Revision: 17a68065c378da74805e4e1b9a5b78cc9f83e580

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

LOG: [Clang] Use = default(NFC)

Added: 


Modified: 
clang/include/clang/Basic/Builtins.h

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.h 
b/clang/include/clang/Basic/Builtins.h
index 1dabafce54f39..2926e0fa2c8d6 100644
--- a/clang/include/clang/Basic/Builtins.h
+++ b/clang/include/clang/Basic/Builtins.h
@@ -70,7 +70,7 @@ class Context {
   llvm::ArrayRef AuxTSRecords;
 
 public:
-  Context() {}
+  Context() = default;
 
   /// Perform target-specific initialization
   /// \param AuxTarget Target info to incorporate builtins from. May be 
nullptr.



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


[PATCH] D120888: [clang] Stop dragging a EndLoc around when parsing attributes

2022-03-05 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 413276.

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

https://reviews.llvm.org/D120888

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/ParseTentative.cpp

Index: clang/lib/Parse/ParseTentative.cpp
===
--- clang/lib/Parse/ParseTentative.cpp
+++ clang/lib/Parse/ParseTentative.cpp
@@ -1913,7 +1913,7 @@
   /*OuterMightBeMessageSend*/true))
   return TPResult::True;
 
-ParsedAttributes attrs(AttrFactory);
+ParsedAttributesWithRange attrs(AttrFactory);
 MaybeParseMicrosoftAttributes(attrs);
 
 // decl-specifier-seq
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -106,7 +106,7 @@
   // at the start of the statement. Thus, we're not using MaybeParseAttributes
   // here because we don't want to allow arbitrary orderings.
   ParsedAttributesWithRange Attrs(AttrFactory);
-  MaybeParseCXX11Attributes(Attrs, nullptr, /*MightBeObjCMessageSend*/ true);
+  MaybeParseCXX11Attributes(Attrs, /*MightBeObjCMessageSend*/ true);
   if (getLangOpts().OpenCL)
 MaybeParseGNUAttributes(Attrs);
 
@@ -1119,8 +1119,7 @@
 ConsumeToken();
 
   ParsedAttributesWithRange attrs(AttrFactory);
-  MaybeParseCXX11Attributes(attrs, nullptr,
-/*MightBeObjCMessageSend*/ true);
+  MaybeParseCXX11Attributes(attrs, /*MightBeObjCMessageSend*/ true);
 
   // If this is the start of a declaration, parse it as such.
   if (isDeclarationStatement()) {
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -341,7 +341,7 @@
 Token &FirstToken) override;
 
   /// A pool of attributes that were parsed in \#pragma clang attribute.
-  ParsedAttributes AttributesForPragmaAttribute;
+  ParsedAttributesWithRange AttributesForPragmaAttribute;
 };
 
 struct PragmaMaxTokensHereHandler : public PragmaHandler {
@@ -1365,12 +1365,13 @@
 namespace {
 struct PragmaAttributeInfo {
   enum ActionType { Push, Pop, Attribute };
-  ParsedAttributes &Attributes;
+  ParsedAttributesWithRange &Attributes;
   ActionType Action;
   const IdentifierInfo *Namespace = nullptr;
   ArrayRef Tokens;
 
-  PragmaAttributeInfo(ParsedAttributes &Attributes) : Attributes(Attributes) {}
+  PragmaAttributeInfo(ParsedAttributesWithRange &Attributes)
+  : Attributes(Attributes) {}
 };
 
 #include "clang/Parse/AttrSubMatchRulesParserStringSwitches.inc"
@@ -1640,7 +1641,7 @@
   /*IsReinject=*/false);
   ConsumeAnnotationToken();
 
-  ParsedAttributes &Attrs = Info->Attributes;
+  ParsedAttributesWithRange &Attrs = Info->Attributes;
   Attrs.clearListOnly();
 
   auto SkipToEnd = [this]() {
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -1252,7 +1252,7 @@
   TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
   Actions.PushLambdaScope();
 
-  ParsedAttributes Attr(AttrFactory);
+  ParsedAttributesWithRange Attr(AttrFactory);
   if (getLangOpts().CUDA) {
 // In CUDA code, GNU attributes are allowed to appear immediately after the
 // "[...]", even if there is no "(...)" before the lambda body.
@@ -1355,7 +1355,8 @@
   DeclEndLoc = ESpecRange.getEnd();
 
 // Parse attribute-specifier[opt].
-MaybeParseCXX11Attributes(Attr, &DeclEndLoc);
+if (MaybeParseCXX11Attributes(Attr))
+  DeclEndLoc = Attr.Range.getEnd();
 
 // Parse OpenCL addr space attribute.
 if (Tok.isOneOf(tok::kw___private, tok::kw___global, tok::kw___local,
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -4513,19 +4513,17 @@
 ///
 /// attribute-specifier-seq:
 ///   attribute-specifier-seq[opt] attribute-specifier
-void Parser::ParseCXX11Attributes(ParsedAttributesWithRange &attrs,
-  SourceLocation *endLoc) {
+void Parser::ParseCXX11Attributes(ParsedAttributesWithRange &attrs) {
   assert(standardAttributesAllowed());
 
-  SourceLocation StartLoc = Tok.getLocation(), Loc;
-  if (!endLoc)
-endLoc = &Loc;
+  SourceLocation StartLoc = Tok.getLocation();
+  SourceLocation EndLoc = StartLoc;
 
   do {
-ParseCXX11AttributeSpecifier(attrs, endLoc);
+ParseCXX11AttributeSpecifier(attrs, &EndLoc);

[PATCH] D119599: [clang-format] Add option to align compound assignments like `+=`

2022-03-05 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

How does this handle cases with multiple assignments in one statement, and can 
tests be added to demonstrate the behaviour.

  Foo += Bar <<= 5;
  Int Baz = 5;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119599

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