[PATCH] D116415: [Arm] Remove duplicate CPU tests

2021-12-31 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added inline comments.



Comment at: clang/test/Driver/arm-cortex-cpus.c:217
 // RUN: %clang -target arm -march=armv8.1-a -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V81A %s
-// RUN: %clang -target arm -march=armv8.1a -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-V81A %s
 // RUN: %clang -target armv8.1a -mlittle-endian -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V81A %s

nickdesaulniers wrote:
> I'm definitely ok with the half of changes in this patch that remove 
> `-mlittle-endian` when it appears twice on one line.
> 
> The other half of the changes remove `-mlittle-endian` when it's not 
> specified more than once. I suspect `-mlittle-endian` is implied by `-target` 
> in this case; was the test validating that by being explicit about 
> endianness?  I guess I don't see how being explicit about the endianness 
> could affect the `-triple`, which is what is being checked, so I guess this 
> LGTM.
The second set of changes that you mention are the duplicate tests that you 
pointed out in D116159. For example, this line that is removed is a duplicate 
of line 219.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116415

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


[PATCH] D116415: [Arm] Remove duplicate CPU tests

2021-12-31 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added reviewers: lenary, dmgreen, cpirker, olista01, vsukharev, 
SjoerdMeijer.
tmatheson added a comment.

Thanks for the review @nickdesaulniers. Adding a few more reviewers just to 
check that I'm not missing something.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116415

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


[PATCH] D95589: [RISCV] Support experimental 'P' extension 0.9

2021-12-31 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu added a comment.
Herald added subscribers: VincentWu, luke957, achieveartificialintelligence.

Could abandon it due to D108189 ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95589

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


[PATCH] D116271: [Docs] Document C++ for OpenCL 2021 support in clang

2021-12-31 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 396771.
Anastasia added a comment.

Added corrections from Justas


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

https://reviews.llvm.org/D116271

Files:
  clang/docs/OpenCLSupport.rst
  clang/docs/UsersManual.rst

Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -41,8 +41,8 @@
variants depending on base language.
 -  :ref:`C++ Language `
 -  :ref:`Objective C++ Language `
--  :ref:`OpenCL Kernel Language `: OpenCL C v1.0, v1.1, v1.2, v2.0,
-   plus C++ for OpenCL.
+-  :ref:`OpenCL Kernel Language `: OpenCL C 1.0, 1.1, 1.2, 2.0, 3.0,
+   and C++ for OpenCL 1.0 and 2021.
 
 In addition to these base languages and their dialects, Clang supports a
 broad variety of language extensions, which are documented in the
@@ -3303,20 +3303,25 @@
 `_ and
 there is no plan to support it in clang in any new releases in the near future.
 
-
-Clang currently supports C++ for OpenCL v1.0.
+Clang currently supports C++ for OpenCL 1.0 and 2021.
 For detailed information about this language refer to the C++ for OpenCL
 Programming Language Documentation available
 in `the latest build
 `_
 or in `the official release
-`_.
+`_.
 
 To enable the C++ for OpenCL mode, pass one of following command line options when
-compiling ``.cl`` file ``-cl-std=clc++``, ``-cl-std=CLC++``, ``-cl-std=clc++1.0``,
-``-cl-std=CLC++1.0``, ``-std=clc++``, ``-std=CLC++``, ``-std=clc++1.0`` or
-``-std=CLC++1.0``.
+compiling ``.clcpp`` file:
+
+- C++ for OpenCL 1.0: ``-cl-std=clc++``, ``-cl-std=CLC++``, ``-cl-std=clc++1.0``,
+  ``-cl-std=CLC++1.0``, ``-std=clc++``, ``-std=CLC++``, ``-std=clc++1.0`` or
+  ``-std=CLC++1.0``.
+
+- C++ for OpenCL 2021: ``-cl-std=clc++2021``, ``-cl-std=CLC++2021``,
+  ``-std=clc++2021``, ``-std=CLC++2021``.
 
+Example of use:
.. code-block:: c++
 
  template T add( T x, T y )
@@ -,15 +3338,27 @@
 
.. code-block:: console
 
- clang -cl-std=clc++ test.cl
+ clang -cl-std=clc++1.0 test.clcpp
+
 
-Alternatively, files with ``.clcpp`` extension are compiled with the C++ for OpenCL
-mode.
+By default, files with ``.clcpp`` extension are compiled with the C++ for
+OpenCL 1.0 mode.
 
.. code-block:: console
 
  clang test.clcpp
 
+For backward compatibility files with ``.cl`` extensions can also be compiled
+in C++ for OpenCL mode but the desirable language mode must be activated with
+a flag.
+
+   .. code-block:: console
+
+ clang -cl-std=clc++ test.cl
+
+Support of C++ for OpenCL 2021 is currently in experimental phase, refer to
+:doc:`OpenCLSupport` for more details.
+
 C++ for OpenCL kernel sources can also be compiled online in drivers supporting
 `cl_ext_cxx_for_opencl
 `_
Index: clang/docs/OpenCLSupport.rst
===
--- clang/docs/OpenCLSupport.rst
+++ clang/docs/OpenCLSupport.rst
@@ -18,15 +18,16 @@
 ==
 
 Clang has complete support of OpenCL C versions from 1.0 to 2.0.
+There is an ongoing work to support :ref:`OpenCL 3.0 `.
 
 Clang also supports :ref:`the C++ for OpenCL kernel language `.
 
-There is an ongoing work to support :ref:`OpenCL 3.0 `.
-
-There are also other :ref:`new and experimental features ` available.
+There are also other :ref:`new and experimental features `
+available.
 
-For general issues and bugs with OpenCL in clang refer to `Bugzilla
-`__.
+For general issues and bugs with OpenCL in clang refer to `the GitHub issue
+list
+`__.
 
 Internals Manual
 
@@ -127,7 +128,7 @@
 
.. code-block:: console
 
- $ clang -target spir-unknown-unknown -c -emit-llvm -Xclang -finclude-default-header -fmodules -fimplicit-module-maps -fm odules-cache-path= test.cl
+ $ clang -target spir-unknown-unknown -c -emit-llvm -Xclang -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path= test.cl
 
 Another way to circumvent long parsing latency for the OpenCL builtin
 declarations is to use mechanism enabled by :ref:`-fdeclare-opencl-builtins
@@ -319,24 +320,32 @@
 C++ for OpenCL Implementation Status
 
 
-Clang implements language version 1.0 published in `the official
+Clang implements language versions 1.0 and 2021 published in `the official
 release of C++ for OpenCL Documentation
-

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

2021-12-31 Thread gehry via Phabricator via cfe-commits
Sockke created this revision.
Sockke added a reviewer: aaron.ballman.
Herald added a subscriber: carlosgalvezp.
Sockke requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

It cannot match a `pure virtual function`. This patch fixes this behavior.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116439

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


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
@@ -271,3 +271,17 @@
 
 int **const * n_multiple_ptr();
 int *const & n_pointer_ref();
+
+class PVBase {
+public:
+  virtual const int getC() = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 
'const'-qualified at the top level, which may reduce code readability without 
improving const correctness
+  // CHECK-FIXES: virtual int getC() = 0;
+};
+
+class PVDerive : public PVBase {
+public:
+  const int getC() { return 1; }
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 
'const'-qualified at the top level, which may reduce code readability without 
improving const correctness
+  // CHECK-FIXES: int getC() { return 1; }
+};
Index: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -97,7 +97,9 @@
   // Find all function definitions for which the return types are `const`
   // qualified.
   Finder->addMatcher(
-  functionDecl(returns(isConstQualified()), isDefinition()).bind("func"),
+  functionDecl(returns(isConstQualified()),
+   anyOf(isDefinition(), cxxMethodDecl(isPure(
+  .bind("func"),
   this);
 }
 


Index: clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
@@ -271,3 +271,17 @@
 
 int **const * n_multiple_ptr();
 int *const & n_pointer_ref();
+
+class PVBase {
+public:
+  virtual const int getC() = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 'const'-qualified at the top level, which may reduce code readability without improving const correctness
+  // CHECK-FIXES: virtual int getC() = 0;
+};
+
+class PVDerive : public PVBase {
+public:
+  const int getC() { return 1; }
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 'const'-qualified at the top level, which may reduce code readability without improving const correctness
+  // CHECK-FIXES: int getC() { return 1; }
+};
Index: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -97,7 +97,9 @@
   // Find all function definitions for which the return types are `const`
   // qualified.
   Finder->addMatcher(
-  functionDecl(returns(isConstQualified()), isDefinition()).bind("func"),
+  functionDecl(returns(isConstQualified()),
+   anyOf(isDefinition(), cxxMethodDecl(isPure(
+  .bind("func"),
   this);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115694: [ARM] Introduce an empty "armv8.8-a" architecture.

2021-12-31 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas accepted this revision.
pratlucas added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115694

___
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

2021-12-31 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/DefinitionBlockSeparator.cpp:25
+FormatTokenLexer &Tokens) {
+  if (Style.SeparateDefinitionBlocks == FormatStyle::SDS_Leave)
+return {{}, 0};

Better, but I still think we should have the assert here. The class should not 
be instantiated at all, if you don't want to use it.



Comment at: clang/lib/Format/DefinitionBlockSeparator.cpp:35
+return;
+  auto likelyDefinition = [this](AnnotatedLine *Line) {
+if (Line->MightBeFunctionDecl && Line->mightBeFunctionDefinition())

ksyx wrote:
> HazardyKnusperkeks wrote:
> > 
> [[ 
> https://github.com/llvm/llvm-project/blob/298367ee6e36eeb1b193ad9fa92082c2ef2345a3/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp#L2393
>  | Some other lambdas ]] I found use lowercased leading letter, as it looks 
> like a function (call).
Okay, then I don't know what the LLVM Style is, probably there is none in this 
regard. I think the lambdas I saw in clang-format are with a capital letter.


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

https://reviews.llvm.org/D116314

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


[PATCH] D116238: [mips] Add -mfix4300 flag to enable vr4300 mulmul bugfix pass

2021-12-31 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for the patch.


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

https://reviews.llvm.org/D116238

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


[clang] 2edcde0 - [MIPS] Add -mfix4300 flag to enable vr4300 mulmul bugfix pass

2021-12-31 Thread Simon Atanasyan via cfe-commits

Author: Random
Date: 2021-12-31T15:59:44+03:00
New Revision: 2edcde00cb396cc17d8d8b171a6ebaa97fd30e59

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

LOG: [MIPS] Add -mfix4300 flag to enable vr4300 mulmul bugfix pass

Early revisions of the VR4300 have a hardware bug where two consecutive
multiplications can produce an incorrect result in the second multiply.
This revision adds the `-mfix4300` flag to llvm (and clang) which, when
passed, provides a software fix for this issue.

More precise description of the "mulmul" bug:
```
mul.[s,d] fd,fs,ft
mul.[s,d] fd,fs,ft  or  [D]MULT[U] rs,rt
```

When the above sequence is executed by the CPU, if at least one of the
source operands of the first mul instruction happens to be `sNaN`, `0`
or `Infinity`, then the second mul instruction may produce an incorrect
result. This can happen both if the two mul instructions are next to each
other and if the first one is in a delay slot and the second is the first
instruction of the branch target.

Description of the fix:
This fix adds a backend pass to llvm which scans for mul instructions in
each basic block and inserts a nop whenever the following conditions are
met:

 - The current instruction is a single or double-precision floating-point
   mul instruction.
 - The next instruction is either a mul instruction (any kind) or a branch
   instruction.

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

Added: 
llvm/lib/Target/Mips/MipsMulMulBugPass.cpp
llvm/test/CodeGen/Mips/vr4300-mulbranch.ll
llvm/test/CodeGen/Mips/vr4300-mulmul.ll

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
llvm/lib/Target/Mips/CMakeLists.txt
llvm/lib/Target/Mips/Mips.h
llvm/lib/Target/Mips/MipsTargetMachine.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index dc8bd831f2a26..6c56d9739de2a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3617,6 +3617,7 @@ def mcheck_zero_division : Flag<["-"], 
"mcheck-zero-division">,
Group;
 def mno_check_zero_division : Flag<["-"], "mno-check-zero-division">,
   Group;
+def mfix4300 : Flag<["-"], "mfix4300">, Group;
 def mcompact_branches_EQ : Joined<["-"], "mcompact-branches=">,
Group;
 def mbranch_likely : Flag<["-"], "mbranch-likely">, Group,

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

diff  --git a/llvm/lib/Target/Mips/CMakeLists.txt 
b/llvm/lib/Target/Mips/CMakeLists.txt
index cbfd187fdfa21..5759fd9736e78 100644
--- a/llvm/lib/Target/Mips/CMakeLists.txt
+++ b/llvm/lib/Target/Mips/CMakeLists.txt
@@ -59,6 +59,7 @@ add_llvm_target(MipsCodeGen
   MipsTargetMachine.cpp
   MipsTargetObjectFile.cpp
   MicroMipsSizeReduction.cpp
+  MipsMulMulBugPass.cpp
 
   LINK_COMPONENTS
   Analysis

diff  --git a/llvm/lib/Target/Mips/Mips.h b/llvm/lib/Target/Mips/Mips.h
index b3faaab436f01..faf58545db626 100644
--- a/llvm/lib/Target/Mips/Mips.h
+++ b/llvm/lib/Target/Mips/Mips.h
@@ -38,6 +38,7 @@ namespace llvm {
   FunctionPass *createMicroMipsSizeReducePass();
   FunctionPass *createMipsExpandPseudoPass();
   FunctionPass *createMipsPreLegalizeCombiner();
+  FunctionPass *createMipsMulMulBugPass();
 
   InstructionSelector *createMipsInstructionSelector(const MipsTargetMachine &,
  MipsSubtarget &,
@@ -47,6 +48,7 @@ namespace llvm {
   void initializeMipsBranchExpansionPass(PassRegistry &);
   void initializeMicroMipsSizeReducePass(PassRegistry &);
   void initializeMipsPreLegalizerCombinerPass(PassRegistry&);
+  void initializeMipsMulMulBugFixPass(PassRegistry&);
 } // end namespace llvm;
 
 #endif

diff  --git a/llvm/lib/Target/Mips/MipsMulMulBugPass.cpp 
b/llvm/lib/Target/Mips/MipsMulMulBugPass.cpp
new file mode 100644
index 0..cb112ca1dfffe
--- /dev/null
+++ b/llvm/lib/Target/Mips/MipsMulMulBugPass.cpp
@@ -0,0 +1,134 @@
+//===- MipsMulMulBugPass.cpp - Mips VR4300 mulmul bugfix pass 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPD

[PATCH] D116238: [mips] Add -mfix4300 flag to enable vr4300 mulmul bugfix pass

2021-12-31 Thread Simon Atanasyan 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 rG2edcde00cb39: [MIPS] Add -mfix4300 flag to enable vr4300 
mulmul bugfix pass (authored by Random06457, committed by atanasyan).

Changed prior to commit:
  https://reviews.llvm.org/D116238?vs=396171&id=396774#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116238

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  llvm/lib/Target/Mips/CMakeLists.txt
  llvm/lib/Target/Mips/Mips.h
  llvm/lib/Target/Mips/MipsMulMulBugPass.cpp
  llvm/lib/Target/Mips/MipsTargetMachine.cpp
  llvm/test/CodeGen/Mips/vr4300-mulbranch.ll
  llvm/test/CodeGen/Mips/vr4300-mulmul.ll

Index: llvm/test/CodeGen/Mips/vr4300-mulmul.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Mips/vr4300-mulmul.ll
@@ -0,0 +1,24 @@
+; RUN: llc -march=mips -mfix4300 -verify-machineinstrs < %s | FileCheck %s
+
+; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
+define dso_local float @fun_s(float %x) local_unnamed_addr #0 {
+entry:
+; CHECK-LABEL: fun_s
+; CHECK: mul.s
+; CHECK-NEXT: nop
+; CHECK: mul.s
+  %mul = fmul float %x, %x
+  %mul1 = fmul float %mul, %x
+  ret float %mul1
+}
+
+define dso_local double @fun_d(double %x) local_unnamed_addr #0 {
+entry:
+; CHECK-LABEL: fun_d
+; CHECK: mul.d
+; CHECK-NEXT: nop
+; CHECK: mul.d
+  %mul = fmul double %x, %x
+  %mul1 = fmul double %mul, %x
+  ret double %mul1
+}
Index: llvm/test/CodeGen/Mips/vr4300-mulbranch.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Mips/vr4300-mulbranch.ll
@@ -0,0 +1,27 @@
+; RUN: llc -march=mips -mfix4300 -verify-machineinstrs < %s | FileCheck %s
+
+; Function Attrs: nounwind
+define dso_local void @fun_s(float %a) local_unnamed_addr #0 {
+entry:
+; CHECK-LABEL: fun_s
+; CHECK: mul.s
+; CHECK-NEXT: nop
+  %mul = fmul float %a, %a
+  tail call void @foo_s(float %mul) #2
+  ret void
+}
+
+declare dso_local void @foo_s(float) local_unnamed_addr #1
+
+; Function Attrs: nounwind
+define dso_local void @fun_d(double %a) local_unnamed_addr #0 {
+entry:
+; CHECK-LABEL: fun_d
+; CHECK: mul.d
+; CHECK-NEXT: nop
+  %mul = fmul double %a, %a
+  tail call void @foo_d(double %mul) #2
+  ret void
+}
+
+declare dso_local void @foo_d(double) local_unnamed_addr #1
Index: llvm/lib/Target/Mips/MipsTargetMachine.cpp
===
--- llvm/lib/Target/Mips/MipsTargetMachine.cpp
+++ llvm/lib/Target/Mips/MipsTargetMachine.cpp
@@ -45,6 +45,10 @@
 
 #define DEBUG_TYPE "mips"
 
+static cl::opt
+EnableMulMulFix("mfix4300", cl::init(false),
+cl::desc("Enable the VR4300 mulmul bug fix."), cl::Hidden);
+
 extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsTarget() {
   // Register the target.
   RegisterTargetMachine X(getTheMipsTarget());
@@ -58,6 +62,7 @@
   initializeMipsBranchExpansionPass(*PR);
   initializeMicroMipsSizeReducePass(*PR);
   initializeMipsPreLegalizerCombinerPass(*PR);
+  initializeMipsMulMulBugFixPass(*PR);
 }
 
 static std::string computeDataLayout(const Triple &TT, StringRef CPU,
@@ -292,6 +297,11 @@
   // instructions which can be remapped to a 16 bit instruction.
   addPass(createMicroMipsSizeReducePass());
 
+  // This pass inserts a nop instruction between two back-to-back multiplication
+  // instructions when the "mfix4300" flag is passed.
+  if (EnableMulMulFix)
+addPass(createMipsMulMulBugPass());
+
   // The delay slot filler pass can potientially create forbidden slot hazards
   // for MIPSR6 and therefore it should go before MipsBranchExpansion pass.
   addPass(createMipsDelaySlotFillerPass());
Index: llvm/lib/Target/Mips/MipsMulMulBugPass.cpp
===
--- /dev/null
+++ llvm/lib/Target/Mips/MipsMulMulBugPass.cpp
@@ -0,0 +1,134 @@
+//===- MipsMulMulBugPass.cpp - Mips VR4300 mulmul bugfix pass -===//
+//
+// 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
+//
+//===--===//
+//
+// Early revisions of the VR4300 have a hardware bug where two consecutive
+// multiplications can produce an incorrect result in the second multiply.
+//
+// This pass scans for mul instructions in each basic block and inserts
+// a nop whenever the following conditions are met:
+//
+// - The current instruction is a single or double-precision floating-point
+//   mul instruction.
+// - The next instruction is either a mul instruction (any kind)
+//   or a branch instruction.
+//===--

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

2021-12-31 Thread Rajat Bajpai via Phabricator via cfe-commits
rajatbajpai added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:14545
   verifyFormat("auto lambda = []() { return 0; };", SomeSpace2);
+
+  FormatStyle SpaceAfterOperatorOverloading = getLLVMStyle();

HazardyKnusperkeks wrote:
> rajatbajpai wrote:
> > MyDeveloperDay wrote:
> > > There should be a PARSE unit test too please
> > I'm sorry if I misunderstood it, do you mean tests using CHECK_PARSE? I am 
> > confirming this because I didn't find any such test case for existing 
> > //SpaceBeforeParensOptions// options.
> Than this has slipped through, but there should be a test for every parsing 
> aspect.
Thanks for confirming. 

Not an issue, I'll try to add a test case for existing options as well then.


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] D116368: [clang][dataflow] Add transfer function for VarDecl statements

2021-12-31 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev updated this revision to Diff 396778.
sgatev added a comment.

Address reviewers' comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116368

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/include/clang/Analysis/FlowSensitive/StorageLocation.h
  clang/include/clang/Analysis/FlowSensitive/Transfer.h
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/Value.h
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/NoopAnalysis.h
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -6,12 +6,14 @@
 //
 //===--===//
 
+#include "NoopAnalysis.h"
 #include "TestingSupport.h"
 #include "clang/AST/Decl.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Analysis/FlowSensitive/DataflowAnalysis.h"
+#include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h"
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
 #include "clang/Analysis/FlowSensitive/DataflowLattice.h"
 #include "clang/Tooling/Tooling.h"
@@ -28,6 +30,8 @@
 #include 
 #include 
 
+namespace {
+
 using namespace clang;
 using namespace dataflow;
 using ::testing::IsEmpty;
@@ -50,7 +54,8 @@
 ControlFlowContext::build(nullptr, Body, Result.Context));
 
 AnalysisT Analysis(*Result.Context);
-Environment Env;
+DataflowAnalysisContext DACtx;
+Environment Env(DACtx);
 BlockStates = runDataflowAnalysis(CFCtx, Analysis, Env);
   }
 
@@ -75,27 +80,6 @@
   return Callback.BlockStates;
 }
 
-class NoopLattice {
-public:
-  bool operator==(const NoopLattice &) const { return true; }
-
-  LatticeJoinEffect join(const NoopLattice &) {
-return LatticeJoinEffect::Unchanged;
-  }
-};
-
-class NoopAnalysis : public DataflowAnalysis {
-public:
-  NoopAnalysis(ASTContext &Context)
-  : DataflowAnalysis(Context) {}
-
-  static NoopLattice initialElement() { return {}; }
-
-  NoopLattice transfer(const Stmt *S, const NoopLattice &E, Environment &Env) {
-return {};
-  }
-};
-
 TEST(DataflowAnalysisTest, NoopAnalysis) {
   auto BlockStates = runAnalysis(R"(
 void target() {}
@@ -314,3 +298,5 @@
   UnorderedElementsAre("baz", "foo"));
   // FIXME: Called functions at point `p` should contain only "foo".
 }
+
+} // namespace
Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- /dev/null
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -0,0 +1,540 @@
+//===- unittests/Analysis/FlowSensitive/TransferTest.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
+//
+//===--===//
+
+#include "NoopAnalysis.h"
+#include "TestingSupport.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
+#include "clang/Analysis/FlowSensitive/StorageLocation.h"
+#include "clang/Analysis/FlowSensitive/Value.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+namespace {
+
+using namespace clang;
+using namespace dataflow;
+using ::testing::_;
+using ::testing::ElementsAre;
+using ::testing::IsNull;
+using ::testing::NotNull;
+using ::testing::Pair;
+
+class TransferTest : public ::testing::Test {
+protected:
+  template 
+  void runDataflow(llvm::StringRef Code, Matcher Match) {
+test::checkDataflow(
+Code, "target",
+[](ASTContext &C, Environment &) { return Noo

[PATCH] D115694: [ARM] Introduce an empty "armv8.8-a" architecture.

2021-12-31 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson updated this revision to Diff 396779.
tmatheson added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115694

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  clang/test/Preprocessor/arm-target-features.c
  llvm/include/llvm/ADT/Triple.h
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/AArch64TargetParser.cpp
  llvm/lib/Support/ARMTargetParser.cpp
  llvm/lib/Support/Triple.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -18,21 +18,21 @@
 
 namespace {
 const char *ARMArch[] = {
-"armv2",   "armv2a",   "armv3",   "armv3m",   "armv4",
-"armv4t",  "armv5","armv5t",  "armv5e",   "armv5te",
-"armv5tej","armv6","armv6j",  "armv6k",   "armv6hl",
-"armv6t2", "armv6kz",  "armv6z",  "armv6zk",  "armv6-m",
-"armv6m",  "armv6sm",  "armv6s-m","armv7-a",  "armv7",
-"armv7a",  "armv7ve",  "armv7hl", "armv7l",   "armv7-r",
-"armv7r",  "armv7-m",  "armv7m",  "armv7k",   "armv7s",
-"armv7e-m","armv7em",  "armv8-a", "armv8","armv8a",
-"armv8l",  "armv8.1-a","armv8.1a","armv8.2-a","armv8.2a",
-"armv8.3-a",   "armv8.3a", "armv8.4-a",   "armv8.4a", "armv8.5-a",
-"armv8.5a","armv8.6-a","armv8.6a","armv8.7-a","armv8.7a",
-"armv8-r", "armv8r",   "armv8-m.base","armv8m.base",  "armv8-m.main",
-"armv8m.main", "iwmmxt",   "iwmmxt2", "xscale",   "armv8.1-m.main",
-"armv9-a", "armv9","armv9a",  "armv9.1-a","armv9.1a",
-"armv9.2-a",   "armv9.2a",
+"armv2",   "armv2a", "armv3",   "armv3m","armv4",
+"armv4t",  "armv5",  "armv5t",  "armv5e","armv5te",
+"armv5tej","armv6",  "armv6j",  "armv6k","armv6hl",
+"armv6t2", "armv6kz","armv6z",  "armv6zk",   "armv6-m",
+"armv6m",  "armv6sm","armv6s-m","armv7-a",   "armv7",
+"armv7a",  "armv7ve","armv7hl", "armv7l","armv7-r",
+"armv7r",  "armv7-m","armv7m",  "armv7k","armv7s",
+"armv7e-m","armv7em","armv8-a", "armv8", "armv8a",
+"armv8l",  "armv8.1-a",  "armv8.1a","armv8.2-a", "armv8.2a",
+"armv8.3-a",   "armv8.3a",   "armv8.4-a",   "armv8.4a",  "armv8.5-a",
+"armv8.5a","armv8.6-a",  "armv8.6a","armv8.7-a", "armv8.7a",
+"armv8.8-a",   "armv8.8a",   "armv8-r", "armv8r","armv8-m.base",
+"armv8m.base", "armv8-m.main",   "armv8m.main", "iwmmxt","iwmmxt2",
+"xscale",  "armv8.1-m.main", "armv9-a", "armv9", "armv9a",
+"armv9.1-a",   "armv9.1a",   "armv9.2-a",   "armv9.2a",
 };
 
 template 
@@ -501,6 +501,8 @@
   EXPECT_TRUE(
   testARMArch("armv8.7-a", "generic", "v8.7a",
   ARMBuildAttrs::CPUArch::v8_A));
+  EXPECT_TRUE(testARMArch("armv8.8-a", "generic", "v8.8a",
+  ARMBuildAttrs::CPUArch::v8_A));
   EXPECT_TRUE(
   testARMArch("armv9-a", "generic", "v9a",
   ARMBuildAttrs::CPUArch::v8_A));
@@ -765,15 +767,17 @@
 
 TEST(TargetParserTest, ARMparseArchEndianAndISA) {
   const char *Arch[] = {
-  "v2",   "v2a","v3","v3m","v4","v4t","v5","v5t",
-  "v5e",  "v5te",   "v5tej", "v6", "v6j",   "v6k","v6hl",  "v6t2",
-  "v6kz", "v6z","v6zk",  "v6-m",   "v6m",   "v6sm",   "v6s-m", "v7-a",
-  "v7",   "v7a","v7ve",  "v7hl",   "v7l",   "v7-r",   "v7r",   "v7-m",
-  "v7m",  "v7k","v7s",   "v7e-m",  "v7em",  "v8-a",   "v8","v8a",
-  "v8l",  "v8.1-a", "v8.1a", "v8.2-a", "v8.2a", "v8.3-a", "v8.3a", "v8.4-a",
-  "v8.4a", "v8.5-a","v8.5a", "v8.6-a", "v8.6a", "v8.7-a", "v8.7a", "v8-r",
-  "v8m.base", "v8m.main", "v8.1m.main"
-  };
+  "v2","v2a","v3","v3m","v4",   "v4t",
+  "v5","v5t","v5e",   "v5te",   "v5tej","v6",
+  "v6j",   "v6k","v6hl",  "v6t2",   "v6kz", "v6z",
+  "v6zk",  "v6-m",   "v6m",   "v6sm",   "v6s-m","v7-a",
+  "v7","v7a","v7ve",  "v7hl", 

[PATCH] D115694: [ARM] Introduce an empty "armv8.8-a" architecture.

2021-12-31 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson updated this revision to Diff 396780.
tmatheson added a comment.

Minor fix after rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115694

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  clang/test/Preprocessor/arm-target-features.c
  llvm/include/llvm/ADT/Triple.h
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/AArch64TargetParser.cpp
  llvm/lib/Support/ARMTargetParser.cpp
  llvm/lib/Support/Triple.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -18,21 +18,21 @@
 
 namespace {
 const char *ARMArch[] = {
-"armv2",   "armv2a",   "armv3",   "armv3m",   "armv4",
-"armv4t",  "armv5","armv5t",  "armv5e",   "armv5te",
-"armv5tej","armv6","armv6j",  "armv6k",   "armv6hl",
-"armv6t2", "armv6kz",  "armv6z",  "armv6zk",  "armv6-m",
-"armv6m",  "armv6sm",  "armv6s-m","armv7-a",  "armv7",
-"armv7a",  "armv7ve",  "armv7hl", "armv7l",   "armv7-r",
-"armv7r",  "armv7-m",  "armv7m",  "armv7k",   "armv7s",
-"armv7e-m","armv7em",  "armv8-a", "armv8","armv8a",
-"armv8l",  "armv8.1-a","armv8.1a","armv8.2-a","armv8.2a",
-"armv8.3-a",   "armv8.3a", "armv8.4-a",   "armv8.4a", "armv8.5-a",
-"armv8.5a","armv8.6-a","armv8.6a","armv8.7-a","armv8.7a",
-"armv8-r", "armv8r",   "armv8-m.base","armv8m.base",  "armv8-m.main",
-"armv8m.main", "iwmmxt",   "iwmmxt2", "xscale",   "armv8.1-m.main",
-"armv9-a", "armv9","armv9a",  "armv9.1-a","armv9.1a",
-"armv9.2-a",   "armv9.2a",
+"armv2",   "armv2a", "armv3",   "armv3m","armv4",
+"armv4t",  "armv5",  "armv5t",  "armv5e","armv5te",
+"armv5tej","armv6",  "armv6j",  "armv6k","armv6hl",
+"armv6t2", "armv6kz","armv6z",  "armv6zk",   "armv6-m",
+"armv6m",  "armv6sm","armv6s-m","armv7-a",   "armv7",
+"armv7a",  "armv7ve","armv7hl", "armv7l","armv7-r",
+"armv7r",  "armv7-m","armv7m",  "armv7k","armv7s",
+"armv7e-m","armv7em","armv8-a", "armv8", "armv8a",
+"armv8l",  "armv8.1-a",  "armv8.1a","armv8.2-a", "armv8.2a",
+"armv8.3-a",   "armv8.3a",   "armv8.4-a",   "armv8.4a",  "armv8.5-a",
+"armv8.5a","armv8.6-a",  "armv8.6a","armv8.7-a", "armv8.7a",
+"armv8.8-a",   "armv8.8a",   "armv8-r", "armv8r","armv8-m.base",
+"armv8m.base", "armv8-m.main",   "armv8m.main", "iwmmxt","iwmmxt2",
+"xscale",  "armv8.1-m.main", "armv9-a", "armv9", "armv9a",
+"armv9.1-a",   "armv9.1a",   "armv9.2-a",   "armv9.2a",
 };
 
 template 
@@ -501,6 +501,8 @@
   EXPECT_TRUE(
   testARMArch("armv8.7-a", "generic", "v8.7a",
   ARMBuildAttrs::CPUArch::v8_A));
+  EXPECT_TRUE(testARMArch("armv8.8-a", "generic", "v8.8a",
+  ARMBuildAttrs::CPUArch::v8_A));
   EXPECT_TRUE(
   testARMArch("armv9-a", "generic", "v9a",
   ARMBuildAttrs::CPUArch::v8_A));
@@ -765,15 +767,17 @@
 
 TEST(TargetParserTest, ARMparseArchEndianAndISA) {
   const char *Arch[] = {
-  "v2",   "v2a","v3","v3m","v4","v4t","v5","v5t",
-  "v5e",  "v5te",   "v5tej", "v6", "v6j",   "v6k","v6hl",  "v6t2",
-  "v6kz", "v6z","v6zk",  "v6-m",   "v6m",   "v6sm",   "v6s-m", "v7-a",
-  "v7",   "v7a","v7ve",  "v7hl",   "v7l",   "v7-r",   "v7r",   "v7-m",
-  "v7m",  "v7k","v7s",   "v7e-m",  "v7em",  "v8-a",   "v8","v8a",
-  "v8l",  "v8.1-a", "v8.1a", "v8.2-a", "v8.2a", "v8.3-a", "v8.3a", "v8.4-a",
-  "v8.4a", "v8.5-a","v8.5a", "v8.6-a", "v8.6a", "v8.7-a", "v8.7a", "v8-r",
-  "v8m.base", "v8m.main", "v8.1m.main"
-  };
+  "v2","v2a","v3","v3m","v4",   "v4t",
+  "v5","v5t","v5e",   "v5te",   "v5tej","v6",
+  "v6j",   "v6k","v6hl",  "v6t2",   "v6kz", "v6z",
+  "v6zk",  "v6-m",   "v6m",   "v6sm",   "v6s-m","v7-a",
+  "v7","v7a","

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

2021-12-31 Thread ksyx via Phabricator via cfe-commits
ksyx updated this revision to Diff 396781.
ksyx marked 5 inline comments as done.
ksyx added a comment.

Change lambda variable names' leading letter to uppercase.


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

https://reviews.llvm.org/D116314

Files:
  clang/docs/ClangFormatStyleOptions.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,316 @@
+//===- 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 =
+clang::format::separateDefinitionBlocks(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() {\n"
+   "  int i, j;\n"
+   "}\n"
+   "\n"
+   "int bar() {\n"
+   "  int j, k;\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"
+   "  int j, k;\n"
+   "};",
+   Style);
+
+  verifyFormat("namespace foo {\n"
+   "  int i, j;\n"
+   "}\n"
+   "\n"
+   "n

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

2021-12-31 Thread ksyx via Phabricator via cfe-commits
ksyx updated this revision to Diff 396782.
ksyx added a comment.

Change lambda variable names' leading letter to uppercase.


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

https://reviews.llvm.org/D116314

Files:
  clang/docs/ClangFormatStyleOptions.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,316 @@
+//===- 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 =
+clang::format::separateDefinitionBlocks(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() {\n"
+   "  int i, j;\n"
+   "}\n"
+   "\n"
+   "int bar() {\n"
+   "  int j, k;\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"
+   "  int j, k;\n"
+   "};",
+   Style);
+
+  verifyFormat("namespace foo {\n"
+   "  int i, j;\n"
+   "}\n"
+   "\n"
+   "namespace bar {\n"
+   "  in

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

2021-12-31 Thread ksyx via Phabricator via cfe-commits
ksyx added inline comments.



Comment at: clang/lib/Format/DefinitionBlockSeparator.cpp:25
+FormatTokenLexer &Tokens) {
+  if (Style.SeparateDefinitionBlocks == FormatStyle::SDS_Leave)
+return {{}, 0};

HazardyKnusperkeks wrote:
> Better, but I still think we should have the assert here. The class should 
> not be instantiated at all, if you don't want to use it.
My idea is that it would be too redundant to have every user of this method to 
check style once before it calls it?



Comment at: clang/lib/Format/DefinitionBlockSeparator.cpp:35
+return;
+  auto likelyDefinition = [this](AnnotatedLine *Line) {
+if (Line->MightBeFunctionDecl && Line->mightBeFunctionDefinition())

HazardyKnusperkeks wrote:
> ksyx wrote:
> > HazardyKnusperkeks wrote:
> > > 
> > [[ 
> > https://github.com/llvm/llvm-project/blob/298367ee6e36eeb1b193ad9fa92082c2ef2345a3/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp#L2393
> >  | Some other lambdas ]] I found use lowercased leading letter, as it looks 
> > like a function (call).
> Okay, then I don't know what the LLVM Style is, probably there is none in 
> this regard. I think the lambdas I saw in clang-format are with a capital 
> letter.
Ok. Then I will make changes.


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

https://reviews.llvm.org/D116314

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


[PATCH] D116368: [clang][dataflow] Add transfer function for VarDecl statements

2021-12-31 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev marked 4 inline comments as done.
sgatev added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp:32
+template 
+bool denseMapsAreEqual(const llvm::DenseMap &Map1,
+   const llvm::DenseMap &Map2) {

xazax.hun wrote:
> sgatev wrote:
> > xazax.hun wrote:
> > > Shouldn't we add `operator==` instead?
> > I'd be happy to do that. Do we need reviews from other folks for it? Would 
> > it make sense to move the code to the other location in a follow-up PR, to 
> > limit the scope of the change?
> Actually, I think DenseMaps should already have `operator==` so we should be 
> able to remove this code.
Thanks, I must have missed that. Removed the local implementation.



Comment at: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp:88
+for (const FieldDecl *Field : Type->getAsRecordDecl()->fields()) {
+  FieldLocs.insert({Field, &createStorageLocation(Field->getType())});
+}

xazax.hun wrote:
> sgatev wrote:
> > xazax.hun wrote:
> > > Could this end up creating an overly large state? There might be objects 
> > > with quite a lot fields but each function would only access a small 
> > > subset of those. Alternatively, we could attempt to create the 
> > > representations for fields on demand (this is the approach what the clang 
> > > static analyzer is using). 
> > That's a great point, however I don't think initialization on demand plays 
> > well with the dataflow algorithm. For example:
> > 
> > ```
> > struct S {
> >   int Val;
> > };
> > 
> > void target(bool b) {
> >   // basic block 1:
> >   S Foo;
> >   int Bar;
> >   if (b) {
> > // basic block 2:
> > Bar = Foo.Val;
> >   } else {
> > // basic block 3:
> > Bar = Foo.Val;
> >   }
> >   // basic block 4:
> >   ...
> > }
> > ```
> > In basic block 4 we should be able to infer that the value that is assigned 
> > to the storage location for `Bar` is unambiguous. However, since 
> > `Foo.Value` isn't created in basic block 1, this means that it's not 
> > inherited by basic block 2 and basic block 3. Each of these blocks will end 
> > up creating distinct values to assign to the storage location for 
> > `Foo.Value` and so in basic block 4 the value for `Bar` will end up being 
> > ambiguous.
> > 
> > Alternatively, we can do a pass over all statements in all basic blocks 
> > before running the analysis to identify which fields are used in the 
> > function. We can use this information here to initialize only parts that 
> > are being used.
> > 
> > What do you think?
> I am not convinced about this example. I think it should not matter where and 
> when we create the location for Foo.Val, it always should be equivalent to 
> the others, i.e., they should have the same identity regardless their 
> creation. Basically, I think the identity of such a location should be 
> determined by the base object (Foo in this case), and the access path to the 
> subobject. 
> 
> This would be a non-trivial change, so I'm ok with deferring this discussion 
> to some follow-up PRs. But I'd love to see some alternatives explored because 
> eagerly evaluating all fields used to bite me in the past in other static 
> analysis tools performance-wise.
Right. I agree with the comment about storage locations. The issue I see has to 
do with values that are assigned to the respective storage locations. In 
general, different values can be assigned to the same storage location in 
different basic blocks. I don't see a straightforward way to incorporate 
on-demand initialization while preserving the behavior with respect to values. 
Perhaps we can achieve this by storing references to parent environments in 
`Environment` instead of merging their `LocToVal` maps when creating 
environments for successor basic blocks, but this patch is already pretty big 
so I'd rather defer that. I do agree that this is an important problem we 
should solve so I added a FIXME to remind us.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116368

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


[PATCH] D116351: Update Bug report URL to Github Issues

2021-12-31 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn:10
   output = "$target_gen_dir/config.h"
   values = [
+"BUG_REPORT_URL=https://github.com/llvm/llvm-project/issues/";,

This url should redirect to github - who maintains llvm website?


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

https://reviews.llvm.org/D116351

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


[PATCH] D116351: Update Bug report URL to Github Issues

2021-12-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: lld/docs/_templates/indexsidebar.html:3-4
 
 lld bugs should be reported at the
-  LLVM https://bugs.llvm.org/";>Bugzilla.
+  LLVM https://github.com/llvm/llvm-project/issues/";>Issues.

ChuanqiXu wrote:
> MaskRay wrote:
> > Quuxplusone wrote:
> > > 
> > While here, mention the labels: lld:COFF lld:ELF lld:MachO lld:wasm.
> I found label lld would cover the sub-labels.
You can drop changes to this file. I updated it separately.


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

https://reviews.llvm.org/D116351

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


[PATCH] D116351: Update Bug report URL to Github Issues

2021-12-31 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 396737.
ChuanqiXu marked an inline comment as done.
ChuanqiXu added a comment.

Drop the change in lld.


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

https://reviews.llvm.org/D116351

Files:
  clang-tools-extra/docs/clang-doc.rst
  clang/docs/CommandGuide/clang.rst
  clang/www/c_status.html
  clang/www/cxx_status.html
  clang/www/get_involved.html
  clang/www/get_started.html
  clang/www/menu.html.incl
  libcxx/docs/index.rst
  libunwind/docs/index.rst
  lldb/docs/index.rst
  llvm/CMakeLists.txt
  llvm/docs/CommandGuide/llvm-install-name-tool.rst
  llvm/docs/CommandGuide/llvm-libtool-darwin.rst
  llvm/docs/CommandGuide/llvm-lipo.rst
  llvm/docs/CommandGuide/llvm-objcopy.rst
  llvm/docs/CommandGuide/llvm-objdump.rst
  llvm/docs/CommandGuide/llvm-otool.rst
  llvm/docs/CommandGuide/llvm-size.rst
  llvm/docs/CommandGuide/llvm-strings.rst
  llvm/docs/CommandGuide/llvm-strip.rst
  llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
  llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
  utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
  utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h

Index: utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
===
--- utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
+++ utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
@@ -24,7 +24,7 @@
 #include "llvm/Config/llvm-config.h"
 
 /* Bug report URL. */
-#define BUG_REPORT_URL "https://bugs.llvm.org/";
+#define BUG_REPORT_URL "https://github.com/llvm/llvm-project/issues/";
 
 /* Define to 1 to enable backtraces, and to 0 otherwise. */
 #define ENABLE_BACKTRACES 1
@@ -332,7 +332,7 @@
 /* LTDL_SHLIB_EXT defined in Bazel */
 
 /* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "https://bugs.llvm.org/";
+#define PACKAGE_BUGREPORT "https://github.com/llvm/llvm-project/issues/";
 
 /* Define to the full name of this package. */
 #define PACKAGE_NAME "LLVM"
Index: utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
===
--- utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
+++ utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
@@ -20,7 +20,7 @@
 #define CLANG_CONFIG_H
 
 /* Bug report URL. */
-#define BUG_REPORT_URL "https://bugs.llvm.org/";
+#define BUG_REPORT_URL "https://github.com/llvm/llvm-project/issues/";
 
 /* Default to -fPIE and -pie on Linux. */
 #define CLANG_DEFAULT_PIE_ON_LINUX 0
Index: llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
@@ -72,7 +72,7 @@
   input = "config.h.cmake"
   output = "$target_gen_dir/config.h"
   values = [
-"BUG_REPORT_URL=https://bugs.llvm.org/";,
+"BUG_REPORT_URL=https://github.com/llvm/llvm-project/issues/";,
 "ENABLE_BACKTRACES=1",
 "ENABLE_CRASH_OVERRIDES=1",
 "BACKTRACE_HEADER=execinfo.h",
@@ -120,7 +120,7 @@
 "LLVM_VERSION_INFO=",
 "LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO=1",
 "LLVM_WINDOWS_PREFER_FORWARD_SLASH=",
-"PACKAGE_BUGREPORT=https://bugs.llvm.org/";,
+"PACKAGE_BUGREPORT=https://github.com/llvm/llvm-project/issues/";,
 "PACKAGE_NAME=LLVM",
 "PACKAGE_STRING=LLVM ${llvm_version}git",
 "PACKAGE_VERSION=${llvm_version}git",
Index: llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
+++ llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
@@ -8,7 +8,7 @@
   input = "config.h.cmake"
   output = "$target_gen_dir/config.h"
   values = [
-"BUG_REPORT_URL=https://bugs.llvm.org/";,
+"BUG_REPORT_URL=https://github.com/llvm/llvm-project/issues/";,
 "CLANG_DEFAULT_PIE_ON_LINUX=",
 "CLANG_DEFAULT_LINKER=",
 "CLANG_DEFAULT_STD_C=",
Index: llvm/docs/CommandGuide/llvm-strip.rst
===
--- llvm/docs/CommandGuide/llvm-strip.rst
+++ llvm/docs/CommandGuide/llvm-strip.rst
@@ -194,7 +194,7 @@
 BUGS
 
 
-To report bugs, please visit .
+To report bugs, please visit .
 
 SEE ALSO
 
Index: llvm/docs/CommandGuide/llvm-strings.rst
===
--- llvm/docs/CommandGuide/llvm-strings.rst
+++ llvm/docs/CommandGuide/llvm-strings.rst
@@ -123,4 +123,4 @@
 BUGS
 
 
-To report bugs, please visit .
+To report bugs, please visit 

[PATCH] D116351: Update Bug report URL to Github Issues

2021-12-31 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn:10
   output = "$target_gen_dir/config.h"
   values = [
+"BUG_REPORT_URL=https://github.com/llvm/llvm-project/issues/";,

xbolva00 wrote:
> This url should redirect to github - who maintains llvm website?
It redirects to the issue list correctly in my environment. Or you mean the url 
shouldn't refer to GitHub issues? I am a little bit confused.


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

https://reviews.llvm.org/D116351

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


[PATCH] D116351: Update Bug report URL to Github Issues

2021-12-31 Thread ksyx via Phabricator via cfe-commits
ksyx added inline comments.



Comment at: libcxx/docs/index.rst:220
 * `libc++abi Homepage `_
-* `LLVM Bugzilla `_
+* `LLVM Issues `_
 * `libcxx-commits Mailing List`_

MaskRay wrote:
> Quuxplusone wrote:
> > 
> Would https://github.com/llvm/llvm-project/labels/libc++ be better?
> 
> Unfortunately "New issue" on that page does not apply the label automatically.
Adding parameter like in 
 could be the most 
direct way of doing this, given the label exists, so do assignee (untested)? 
Besides, the new 
[[ 
https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-issue-forms
 | Issue Forms ]] feature of GitHub is also a good idea that also unifys what 
to fill out in a request and what to automatically do with the issue.


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

https://reviews.llvm.org/D116351

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


[PATCH] D116351: Update Bug report URL to Github Issues

2021-12-31 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: libcxx/docs/index.rst:220
 * `libc++abi Homepage `_
-* `LLVM Bugzilla `_
+* `LLVM Issues `_
 * `libcxx-commits Mailing List`_

ksyx wrote:
> MaskRay wrote:
> > Quuxplusone wrote:
> > > 
> > Would https://github.com/llvm/llvm-project/labels/libc++ be better?
> > 
> > Unfortunately "New issue" on that page does not apply the label 
> > automatically.
> Adding parameter like in 
>  could be the 
> most direct way of doing this, given the label exists, so do assignee 
> (untested)? Besides, the new 
> [[ 
> https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-issue-forms
>  | Issue Forms ]] feature of GitHub is also a good idea that also unifys what 
> to fill out in a request and what to automatically do with the issue.
Given that you are using the "search for label" URLs in the other places now, I 
think (for consistency) it //does// make sense to change this one to 
`https://github.com/llvm/llvm-project/labels/libc++/`. (With or without the 
trailing slash, but be consistent.)

Please do //not// hard-code any links to 
`https://github.com/llvm/llvm-project/issues/new`-anything; IMHO that makes it 
far too likely that people (or robots) who click there will end up creating a 
new spam issue by accident. Someone who's found a bug to report should be taken 
to the //search page// (to search and see if it's already been filed). Taking 
them straight to "create a (probably spam) issue" is completely 
counterproductive.


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

https://reviews.llvm.org/D116351

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


[PATCH] D116351: Update Bug report URL to Github Issues

2021-12-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: libcxx/docs/index.rst:220
 * `libc++abi Homepage `_
-* `LLVM Bugzilla `_
+* `LLVM Issues `_
 * `libcxx-commits Mailing List`_

Quuxplusone wrote:
> ksyx wrote:
> > MaskRay wrote:
> > > Quuxplusone wrote:
> > > > 
> > > Would https://github.com/llvm/llvm-project/labels/libc++ be better?
> > > 
> > > Unfortunately "New issue" on that page does not apply the label 
> > > automatically.
> > Adding parameter like in 
> >  could be the 
> > most direct way of doing this, given the label exists, so do assignee 
> > (untested)? Besides, the new 
> > [[ 
> > https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-issue-forms
> >  | Issue Forms ]] feature of GitHub is also a good idea that also unifys 
> > what to fill out in a request and what to automatically do with the issue.
> Given that you are using the "search for label" URLs in the other places now, 
> I think (for consistency) it //does// make sense to change this one to 
> `https://github.com/llvm/llvm-project/labels/libc++/`. (With or without the 
> trailing slash, but be consistent.)
> 
> Please do //not// hard-code any links to 
> `https://github.com/llvm/llvm-project/issues/new`-anything; IMHO that makes 
> it far too likely that people (or robots) who click there will end up 
> creating a new spam issue by accident. Someone who's found a bug to report 
> should be taken to the //search page// (to search and see if it's already 
> been filed). Taking them straight to "create a (probably spam) issue" is 
> completely counterproductive.
It's always important to check existing issues before filing a new one. I agree 
`/new` should be avoided.


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

https://reviews.llvm.org/D116351

___
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

2021-12-31 Thread Maurice Heumann via Phabricator via cfe-commits
momo5502 updated this revision to Diff 396783.
momo5502 marked 4 inline comments as done.
momo5502 added a comment.

Comments were addressed


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/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,10 +18,23 @@
 
 // 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: 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()
+
 // CHECK-LABEL: define internal void @__tls_init()
 // CHECK: call void @"??__Eb@@YAXXZ"
 // CHECK-LD-LABEL: define internal void @__tls_init()
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -401,7 +401,8 @@
   ArrayRef CXXThreadLocalInitVars) override;
 
   bool usesThreadWrapperFunction(const VarDecl *VD) const override {
-return false;
+return getContext().getLangOpts().isCompatibleWithMSVC(
+LangOptions::MSVC2019_5);
   }
   LValue EmitThreadLocalVarDeclLValue(CodeGenFunction &CGF, const VarDecl *VD,
   QualType LValType) override;
@@ -2397,11 +2398,97 @@
   }
 }
 
+static llvm::GlobalValue *getTlsGuardVar(CodeGenModule &CGM) {
+  // __tls_guard comes from the MSVC runtime and reflects
+  // whether TLS has been initialized for a particular thread.
+  // It is set from within __dyn_tls_init by the runtime.
+  // Every library and executable has its own variable.
+  llvm::Type *VTy = llvm::Type::getInt8Ty(CGM.getLLVMContext());
+  llvm::Constant *TlsGuardConstant =
+  CGM.CreateRuntimeVariable(VTy, "__tls_guard");
+  llvm::GlobalValue *TlsGuard = cast(TlsGuardConstant);
+
+  TlsGuard->setThreadLocal(true);
+
+  return TlsGuard;
+}
+
+static llvm::FunctionCallee getDynTlsOnDemandInitFn(CodeGenModule &CGM) {
+  // __dyn_tls_on_demand_init comes from the MSVC runtime and triggers
+  // dynamic TLS initialization by calling __dyn_tls_init internally.
+  llvm::FunctionType *FTy =
+  llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()), {},
+  /*isVarArg=*/false);
+  return CGM.CreateRuntimeFunction(
+  FTy, "__dyn_tls_on_demand_init",
+  llvm::AttributeList::get(CGM.getLLVMContext(),
+   llvm::AttributeList::FunctionIndex,
+   llvm::Attribute::NoUnwind),
+  /*Local=*/true);
+}
+
+static void emitTlsGuardCheck(CodeGenFunction &CGF, llvm::GlobalValue *TlsGuard,
+  llvm::BasicBlock *DynInitBB,
+  llvm::BasicBlock *ContinueBB) {
+  llvm::LoadInst *TlsGuardValue =
+  CGF.Builder.CreateLoad(Address(TlsGuard, CharUnits::One()));
+  llvm::Value *CmpResult =
+  CGF.Builder.CreateICmpEQ(TlsGuardValue, CGF

[PATCH] D116443: [clangd] Implement textDocument/typeDefinition

2021-12-31 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kbobyrev.
Herald added subscribers: usaxena95, kadircet, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

This reuses the type=>decl mapping from go-to-definition on auto.
(Which could stand some improvement, but that can happen later).

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116443

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/type-definition.test
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -38,10 +38,12 @@
 namespace {
 
 using ::testing::AllOf;
+using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::Eq;
 using ::testing::IsEmpty;
 using ::testing::Matcher;
+using ::testing::Not;
 using ::testing::UnorderedElementsAre;
 using ::testing::UnorderedElementsAreArray;
 using ::testing::UnorderedPointwise;
@@ -1781,6 +1783,65 @@
   << Test;
 }
 
+TEST(FindType, All) {
+  Annotations HeaderA(R"cpp(
+struct [[Target]] { operator int() const; };
+struct Aggregate { Target a, b; };
+Target t;
+
+template  class smart_ptr {
+  T& operator*();
+  T* operator->();
+  T* get();
+};
+  )cpp");
+  auto TU = TestTU::withHeaderCode(HeaderA.code());
+  for (const llvm::StringRef Case : {
+   "str^uct Target;",
+   "T^arget x;",
+   "Target ^x;",
+   "a^uto x = Target{};",
+   "namespace m { Target tgt; } auto x = m^::tgt;",
+   "Target funcCall(); auto x = ^funcCall();",
+   "Aggregate a = { {}, ^{} };",
+   "Aggregate a = { ^.a=t, };",
+   "struct X { Target a; X() : ^a() {} };",
+   "^using T = Target; ^T foo();",
+   "^template  Target foo();",
+   "void x() { try {} ^catch(Target e) {} }",
+   "void x() { ^throw t; }",
+   "int x() { ^return t; }",
+   "void x() { ^switch(t) {} }",
+   "void x() { ^delete (Target*)nullptr; }",
+   "Target& ^tref = t;",
+   }) {
+Annotations A(Case);
+TU.Code = A.code().str();
+ParsedAST AST = TU.build();
+
+ASSERT_GT(A.points().size(), 0u) << Case;
+for (auto Pos : A.points())
+  EXPECT_THAT(findType(AST, Pos),
+  ElementsAre(Sym("Target", HeaderA.range(), HeaderA.range(
+  << Case;
+  }
+
+  // FIXME: We'd like these cases to work. Fix them and move above.
+  for (const llvm::StringRef Case : {
+   "Target* ^tptr = &t;",
+   "smart_ptr ^tsmart;",
+   "Target ^tarray[3];",
+   }) {
+Annotations A(Case);
+TU.Code = A.code().str();
+ParsedAST AST = TU.build();
+
+EXPECT_THAT(findType(AST, A.point()),
+Not(Contains(Sym("Target", HeaderA.range(), HeaderA.range()
+<< Case;
+  }
+}
+
 void checkFindRefs(llvm::StringRef Test, bool UseIndex = false) {
   Annotations T(Test);
   auto TU = TestTU::withCode(T.code());
Index: clang-tools-extra/clangd/test/type-definition.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/type-definition.test
@@ -0,0 +1,32 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,
+  "text":"class X {};\nauto x = X{};"
+}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/typeDefinition","params":{
+  "textDocument":{"uri":"test:///main.cpp"},
+  "position":{"line":1,"character":5}
+}}
+#  CHECK:  "id": 1
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": [
+# CHECK-NEXT:{
+# CHECK-NEXT:  "range": {
+# CHECK-NEXT:"end": {
+# CHECK-NEXT:  "character": 7,
+# CHECK-NEXT:  "line": 0
+# CHECK-NEXT:},
+# CHECK-NEXT:"start": {
+# CHECK-NEXT:  "character": 6,
+# CHECK-NEXT:  "line": 0
+# CHECK-NEXT:}
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "uri": "file://{{.*}}/clangd-test/main.cpp"
+# CHECK-NEXT:}
+# CHECK-NEXT:  ]
+---
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/clangd/test/initialize-params.test
=

[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2021-12-31 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 396804.
aganea added a comment.
This revision is now accepted and ready to land.
Herald added subscribers: abrachet, mgorny.

Rebase & simplify.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833

Files:
  clang/cmake/caches/BaremetalARM.cmake
  clang/cmake/caches/CrossWinToARMLinux.cmake
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/test/CodeGen/debug-info-codeview-buildinfo.c
  lld/test/COFF/Inputs/pdb_lines_1_relative.yaml
  lld/test/COFF/Inputs/pdb_lines_2_relative.yaml
  lld/test/COFF/pdb-relative-source-lines.test
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/test/DebugInfo/COFF/build-info.ll
  llvm/test/DebugInfo/COFF/global-type-hashes.ll
  llvm/test/DebugInfo/COFF/types-basic.ll
  llvm/test/DebugInfo/COFF/types-data-members.ll

Index: llvm/test/DebugInfo/COFF/types-data-members.ll
===
--- llvm/test/DebugInfo/COFF/types-data-members.ll
+++ llvm/test/DebugInfo/COFF/types-data-members.ll
@@ -727,14 +727,22 @@
 ; ASM: .asciz	"t.cpp" # StringData
 ; ASM: .byte	242
 ; ASM: .byte	241
-; ASM: # BuildInfo (0x1022)
+; ASM: # StringId (0x1022)
+; ASM: .short	0xa # Record length
+; ASM: .short	0x1605  # Record kind: LF_STRING_ID
+; ASM: .long	0x0 # Id
+; ASM: .byte0   # StringData
+; ASM: .byte	243
+; ASM: .byte	242
+; ASM: .byte	241
+; ASM: # BuildInfo (0x1023)
 ; ASM: .short	0x1a# Record length
 ; ASM: .short	0x1603  # Record kind: LF_BUILDINFO
 ; ASM: .short	0x5 # NumArgs
 ; ASM: .long	0x1020  # Argument: D:\src\llvm\build
 ; ASM: .long	0x0 # Argument
 ; ASM: .long	0x1021  # Argument: t.cpp
-; ASM: .long	0x0 # Argument
+; ASM: .long	0x1022  # Argument
 ; ASM: .long	0x0 # Argument
 ; ASM: .byte	242
 ; ASM: .byte	241
Index: llvm/test/DebugInfo/COFF/types-basic.ll
===
--- llvm/test/DebugInfo/COFF/types-basic.ll
+++ llvm/test/DebugInfo/COFF/types-basic.ll
@@ -511,14 +511,22 @@
 ; ASM: .asciz	"t.cpp" # StringData
 ; ASM: .byte	242
 ; ASM: .byte	241
-; ASM: # BuildInfo (0x1015)
+; ASM: # StringId (0x1015)
+; ASM: .short	0xa # Record length
+; ASM: .short	0x1605  # Record kind: LF_STRING_ID
+; ASM: .long	0x0 # Id
+; ASM: .byte0   # StringData
+; ASM: .byte	243
+; ASM: .byte	242
+; ASM: .byte	241
+; ASM: # BuildInfo (0x1016)
 ; ASM: .short	0x1a# Record length
 ; ASM: .short	0x1603  # Record kind: LF_BUILDINFO
 ; ASM: .short	0x5 # NumArgs
 ; ASM: .long	0x1013  # Argument: D:\src\llvm\build
 ; ASM: .long	0x0 # Argument
 ; ASM: .long	0x1014  # Argument: t.cpp
-; ASM: .long	0x0 # Argument
+; ASM: .long	0x1015  # Argument
 ; ASM: .long	0x0 # Argument
 ; ASM: .byte	242
 ; ASM: .byte	241
Index: llvm/test/DebugInfo/COFF/global-type-hashes.ll
===
--- llvm/test/DebugInfo/COFF/global-type-hashes.ll
+++ llvm/test/DebugInfo/COFF/global-type-hashes.ll
@@ -295,7 +295,8 @@
 ; YAML: - 4470750F2E319329
 ; YAML: - 0FB556FD1FAB66D7
 ; YAML: - 5970EFB4874D0F3F
-; YAML: - EDB1D74C120CF44A
+; YAML: - D8EF11198C33843F
+; YAML: - D81F744D7366282B
 ; ...
 
 
Index: llvm/test/DebugInfo/COFF/build-info.ll
===
--- llvm/test/DebugInfo/COFF/build-info.ll
+++ llvm/test/DebugInfo/COFF/build-info.ll
@@ -5,7 +5,7 @@
 ; CHECK-NEXT:  0x{{.*}}: `D:\src\scopes\clang`
 ; CHECK-NEXT:  : ``
 ; CHECK-NEXT:  0x{{.*}}: `D:\src\scopes\foo.cpp`
-; CHECK-NEXT:  : ``
+; CHECK-NEXT:  0x{{.*}}: ``
 ; CHECK-NEXT:  : ``
 
 ; CHECK: {{.*}} | S_BUILDINFO [size = 8] BuildId = `[[INFO_IDX]]`
Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -68,6 +68,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
 #include "llvm/Support/SMLoc.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Target/TargetLoweringObjectFile.h"
@@ -887,6 +888,34 @@
   return TypeTable.writeLeafType(SIR);
 }
 
+static std::string flattenCommandLine(ArrayRef Args,
+  StringRef MainFilename) {
+ 

[clang] d50072f - [ARM] Introduce an empty "armv8.8-a" architecture.

2021-12-31 Thread Tomas Matheson via cfe-commits

Author: Simon Tatham
Date: 2021-12-31T16:43:53Z
New Revision: d50072f74e3ee50b750a618fcdf05739dec9542d

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

LOG: [ARM] Introduce an empty "armv8.8-a" architecture.

This is the first commit in a series that implements support for
"armv8.8-a" architecture. This should contain all the necessary
boilerplate to make the 8.8-A architecture exist from LLVM and Clang's
point of view: it adds the new arch as a subtarget feature, a definition
in TargetParser, a name on the command line, an appropriate set of
predefined macros, and adds appropriate tests. The new architecture name
is supported in both AArch32 and AArch64.

However, in this commit, no actual _functionality_ is added as part of
the new architecture. If you specify -march=armv8.8a, the compiler
will accept it and set the right predefines, but generate no code any
differently.

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

Added: 


Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AArch64.h
clang/lib/Basic/Targets/ARM.cpp
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/test/Driver/aarch64-cpus.c
clang/test/Driver/arm-cortex-cpus.c
clang/test/Preprocessor/arm-target-features.c
llvm/include/llvm/ADT/Triple.h
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/include/llvm/Support/ARMTargetParser.def
llvm/lib/Support/AArch64TargetParser.cpp
llvm/lib/Support/ARMTargetParser.cpp
llvm/lib/Support/Triple.cpp
llvm/lib/Target/AArch64/AArch64.td
llvm/lib/Target/AArch64/AArch64Subtarget.h
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/Target/ARM/ARM.td
llvm/lib/Target/ARM/ARMSubtarget.h
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 4089a393b7628..d7eb770995cbb 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -223,6 +223,12 @@ void AArch64TargetInfo::getTargetDefinesARMV87A(const 
LangOptions &Opts,
   getTargetDefinesARMV86A(Opts, Builder);
 }
 
+void AArch64TargetInfo::getTargetDefinesARMV88A(const LangOptions &Opts,
+MacroBuilder &Builder) const {
+  // Also include the Armv8.7 defines
+  getTargetDefinesARMV87A(Opts, Builder);
+}
+
 void AArch64TargetInfo::getTargetDefinesARMV9A(const LangOptions &Opts,
MacroBuilder &Builder) const {
   // Armv9-A maps to Armv8.5-A
@@ -446,6 +452,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case llvm::AArch64::ArchKind::ARMV8_7A:
 getTargetDefinesARMV87A(Opts, Builder);
 break;
+  case llvm::AArch64::ArchKind::ARMV8_8A:
+getTargetDefinesARMV88A(Opts, Builder);
+break;
   case llvm::AArch64::ArchKind::ARMV9A:
 getTargetDefinesARMV9A(Opts, Builder);
 break;
@@ -603,6 +612,8 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   ArchKind = llvm::AArch64::ArchKind::ARMV8_6A;
 if (Feature == "+v8.7a")
   ArchKind = llvm::AArch64::ArchKind::ARMV8_7A;
+if (Feature == "+v8.8a")
+  ArchKind = llvm::AArch64::ArchKind::ARMV8_8A;
 if (Feature == "+v9a")
   ArchKind = llvm::AArch64::ArchKind::ARMV9A;
 if (Feature == "+v9.1a")

diff  --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 74745df3be8d9..6bc0ea4eb5e11 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -92,6 +92,8 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
MacroBuilder &Builder) const;
   void getTargetDefinesARMV87A(const LangOptions &Opts,
MacroBuilder &Builder) const;
+  void getTargetDefinesARMV88A(const LangOptions &Opts,
+   MacroBuilder &Builder) const;
   void getTargetDefinesARMV9A(const LangOptions &Opts,
   MacroBuilder &Builder) const;
   void getTargetDefinesARMV91A(const LangOptions &Opts,

diff  --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index c619d6cde41df..bb0044bdc5961 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -212,6 +212,8 @@ StringRef ARMTargetInfo::getCPUAttr() const {
 return "8_6A";
   case llvm::ARM::ArchKind::ARMV8_7A:
 return "8_7A";
+  case llvm::ARM::ArchKind::ARMV8_8A:
+return "8_8A";
   case llvm::ARM::ArchKind::ARMV9A:
 return "9A";
   case llvm::ARM::ArchKind::ARMV9_1A:
@@ -930,6 +932,7 @@ void ARMTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case llvm::ARM::ArchKind::ARMV8_4A:
   ca

[PATCH] D115694: [ARM] Introduce an empty "armv8.8-a" architecture.

2021-12-31 Thread Tomas Matheson 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 rGd50072f74e3e: [ARM] Introduce an empty "armv8.8-a" 
architecture. (authored by simon_tatham, committed by tmatheson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115694

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  clang/test/Preprocessor/arm-target-features.c
  llvm/include/llvm/ADT/Triple.h
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/AArch64TargetParser.cpp
  llvm/lib/Support/ARMTargetParser.cpp
  llvm/lib/Support/Triple.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -18,21 +18,21 @@
 
 namespace {
 const char *ARMArch[] = {
-"armv2",   "armv2a",   "armv3",   "armv3m",   "armv4",
-"armv4t",  "armv5","armv5t",  "armv5e",   "armv5te",
-"armv5tej","armv6","armv6j",  "armv6k",   "armv6hl",
-"armv6t2", "armv6kz",  "armv6z",  "armv6zk",  "armv6-m",
-"armv6m",  "armv6sm",  "armv6s-m","armv7-a",  "armv7",
-"armv7a",  "armv7ve",  "armv7hl", "armv7l",   "armv7-r",
-"armv7r",  "armv7-m",  "armv7m",  "armv7k",   "armv7s",
-"armv7e-m","armv7em",  "armv8-a", "armv8","armv8a",
-"armv8l",  "armv8.1-a","armv8.1a","armv8.2-a","armv8.2a",
-"armv8.3-a",   "armv8.3a", "armv8.4-a",   "armv8.4a", "armv8.5-a",
-"armv8.5a","armv8.6-a","armv8.6a","armv8.7-a","armv8.7a",
-"armv8-r", "armv8r",   "armv8-m.base","armv8m.base",  "armv8-m.main",
-"armv8m.main", "iwmmxt",   "iwmmxt2", "xscale",   "armv8.1-m.main",
-"armv9-a", "armv9","armv9a",  "armv9.1-a","armv9.1a",
-"armv9.2-a",   "armv9.2a",
+"armv2",   "armv2a", "armv3",   "armv3m","armv4",
+"armv4t",  "armv5",  "armv5t",  "armv5e","armv5te",
+"armv5tej","armv6",  "armv6j",  "armv6k","armv6hl",
+"armv6t2", "armv6kz","armv6z",  "armv6zk",   "armv6-m",
+"armv6m",  "armv6sm","armv6s-m","armv7-a",   "armv7",
+"armv7a",  "armv7ve","armv7hl", "armv7l","armv7-r",
+"armv7r",  "armv7-m","armv7m",  "armv7k","armv7s",
+"armv7e-m","armv7em","armv8-a", "armv8", "armv8a",
+"armv8l",  "armv8.1-a",  "armv8.1a","armv8.2-a", "armv8.2a",
+"armv8.3-a",   "armv8.3a",   "armv8.4-a",   "armv8.4a",  "armv8.5-a",
+"armv8.5a","armv8.6-a",  "armv8.6a","armv8.7-a", "armv8.7a",
+"armv8.8-a",   "armv8.8a",   "armv8-r", "armv8r","armv8-m.base",
+"armv8m.base", "armv8-m.main",   "armv8m.main", "iwmmxt","iwmmxt2",
+"xscale",  "armv8.1-m.main", "armv9-a", "armv9", "armv9a",
+"armv9.1-a",   "armv9.1a",   "armv9.2-a",   "armv9.2a",
 };
 
 template 
@@ -501,6 +501,8 @@
   EXPECT_TRUE(
   testARMArch("armv8.7-a", "generic", "v8.7a",
   ARMBuildAttrs::CPUArch::v8_A));
+  EXPECT_TRUE(testARMArch("armv8.8-a", "generic", "v8.8a",
+  ARMBuildAttrs::CPUArch::v8_A));
   EXPECT_TRUE(
   testARMArch("armv9-a", "generic", "v9a",
   ARMBuildAttrs::CPUArch::v8_A));
@@ -765,15 +767,17 @@
 
 TEST(TargetParserTest, ARMparseArchEndianAndISA) {
   const char *Arch[] = {
-  "v2",   "v2a","v3","v3m","v4","v4t","v5","v5t",
-  "v5e",  "v5te",   "v5tej", "v6", "v6j",   "v6k","v6hl",  "v6t2",
-  "v6kz", "v6z","v6zk",  "v6-m",   "v6m",   "v6sm",   "v6s-m", "v7-a",
-  "v7",   "v7a","v7ve",  "v7hl",   "v7l",   "v7-r",   "v7r",   "v7-m",
-  "v7m",  "v7k","v7s",   "v7e-m",  "v7em",  "v8-a",   "v8","v8a",
-  "v8l",  "v8.1-a", "v8.1a", "v8.2-a", "v8.2a", "v8.3-a", "v8.3a", "v8.4-a",
-  "v8.4a", "v8.5-a","v8.5a", "v8.6-a", "v8.6a", "v8.7-a", "v8.7a", "v8-r",
-  "v8m.base", "v8m.main", "v8.1m.main"
-  };
+  "v2","v2a","v3","v3m","v4",   "v4t",
+  "v5","v5t","v5e",   "v5te",   "v5tej","v6",
+

[PATCH] D116368: [clang][dataflow] Add transfer function for VarDecl statements

2021-12-31 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp:88
+for (const FieldDecl *Field : Type->getAsRecordDecl()->fields()) {
+  FieldLocs.insert({Field, &createStorageLocation(Field->getType())});
+}

sgatev wrote:
> xazax.hun wrote:
> > sgatev wrote:
> > > xazax.hun wrote:
> > > > Could this end up creating an overly large state? There might be 
> > > > objects with quite a lot fields but each function would only access a 
> > > > small subset of those. Alternatively, we could attempt to create the 
> > > > representations for fields on demand (this is the approach what the 
> > > > clang static analyzer is using). 
> > > That's a great point, however I don't think initialization on demand 
> > > plays well with the dataflow algorithm. For example:
> > > 
> > > ```
> > > struct S {
> > >   int Val;
> > > };
> > > 
> > > void target(bool b) {
> > >   // basic block 1:
> > >   S Foo;
> > >   int Bar;
> > >   if (b) {
> > > // basic block 2:
> > > Bar = Foo.Val;
> > >   } else {
> > > // basic block 3:
> > > Bar = Foo.Val;
> > >   }
> > >   // basic block 4:
> > >   ...
> > > }
> > > ```
> > > In basic block 4 we should be able to infer that the value that is 
> > > assigned to the storage location for `Bar` is unambiguous. However, since 
> > > `Foo.Value` isn't created in basic block 1, this means that it's not 
> > > inherited by basic block 2 and basic block 3. Each of these blocks will 
> > > end up creating distinct values to assign to the storage location for 
> > > `Foo.Value` and so in basic block 4 the value for `Bar` will end up being 
> > > ambiguous.
> > > 
> > > Alternatively, we can do a pass over all statements in all basic blocks 
> > > before running the analysis to identify which fields are used in the 
> > > function. We can use this information here to initialize only parts that 
> > > are being used.
> > > 
> > > What do you think?
> > I am not convinced about this example. I think it should not matter where 
> > and when we create the location for Foo.Val, it always should be equivalent 
> > to the others, i.e., they should have the same identity regardless their 
> > creation. Basically, I think the identity of such a location should be 
> > determined by the base object (Foo in this case), and the access path to 
> > the subobject. 
> > 
> > This would be a non-trivial change, so I'm ok with deferring this 
> > discussion to some follow-up PRs. But I'd love to see some alternatives 
> > explored because eagerly evaluating all fields used to bite me in the past 
> > in other static analysis tools performance-wise.
> Right. I agree with the comment about storage locations. The issue I see has 
> to do with values that are assigned to the respective storage locations. In 
> general, different values can be assigned to the same storage location in 
> different basic blocks. I don't see a straightforward way to incorporate 
> on-demand initialization while preserving the behavior with respect to 
> values. Perhaps we can achieve this by storing references to parent 
> environments in `Environment` instead of merging their `LocToVal` maps when 
> creating environments for successor basic blocks, but this patch is already 
> pretty big so I'd rather defer that. I do agree that this is an important 
> problem we should solve so I added a FIXME to remind us.
> The issue I see has to do with values that are assigned to the respective 
> storage locations. 

Oh, I see. Generally, `Foo.Val` could be the initial value (representing the 
lack of knowledge) in both basic blocks, so merging them would be fine. But we 
potentially want to assign symbols to the unknown values to be able to describe 
flow constraints and solve them. So the problem is, we want `Foo.Val` to 
evaluate to the same unknown symbol in both basic blocks, so we know the values 
at `Foo.Val` are actually the same in those branches. 

While it might not be straightforward, I think there are ways around this 
problem. As far as I understand, from the values' point of view the only 
problematic case is when we access a value for the first time. We could either 
derive the unknown symbols from the location to ensure that we initialize 
`Foo.Val` to the same symbol in both cases (so the identity of the unknown 
symbol would describe the fact that this symbols is the initial value for that 
location). Alternatively, we could have a separate mapping for the initial 
values and use it to look the right symbol up. The problematic case is the 
following:

```
struct S {
  int Val;
};

void invalidate(S&);

void target(bool b) {
  // basic block 1:
  S Foo;
  int Bar;
  if (b) {
// basic block 2:
Bar = Foo.Val;
  } else {
// basic block 3:
invalidate(S);
Bar = Foo.Val;
  }
  // basic block 4:
  ...
}
```

Whatever we come up with, we should ensure that Bar will **not** have the same 
value in block 2 and 3 in t

[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2021-12-31 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

@dexonsmith The issue with `-grecord-command-line`/`-frecord-command-line` is 
that it isn't producing a self-standing command-line. For example:

  > clang-cl /c main.cpp /clang:-grecord-command-line /Z7

would record: `d:\\git\\llvm-project\\stage1\\bin\\clang-cl.exe 
--driver-mode=cl -c main.cpp /clang:-grecord-command-line /Z7 
-grecord-command-line`

Whereas our patch records the cc1 command, which is self-standing:

  > stage1\bin\clang-cl /c main.cpp /Z7 -no-canonical-prefixes 
-fdebug-compilation-dir=.
  > stage1\bin\llvm-pdbutil.exe dump -types .\main.obj | grep -A5 LF_BUILDINFO
  0x1008 | LF_BUILDINFO [size = 28]
   0x1003: `.`
   0x1006: `stage1\bin\clang-cl.exe`
   0x1004: `main.cpp`
   0x1005: ``
   0x1007: `"-cc1" "-fmessage-length=120" "-fdiagnostics-format" "msvc" 
"-ferror-limit" "19" "-fcolor-diagnostics" "-mllvm" "-x86-asm-syntax=intel" 
"-disable-free" "-emit-obj" "-x" "c++" "-target-cpu" "x86-64" "-tune-cpu" 
"generic" "-triple" "x86_64-pc-windows-msvc19.29.30138" "-resource-dir" 
"stage1\\lib\\clang\\14.0.0" "-isystem" "stage1\\lib\\clang\\14.0.0\\include" 
"-isystem" "C:\\Program Files (x86)\\Microsoft Visual 
Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30133\\include" "-isystem" 
"C:\\Program Files (x86)\\Microsoft Visual 
Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30133\\atlmfc\\include" 
"-isystem" 
"C:\\Scoop\\global\\apps\\winsdk\\10.0.22000.194\\sdk\\Include\\10.0.22000.0\\ucrt"
 "-isystem" 
"C:\\Scoop\\global\\apps\\winsdk\\10.0.22000.194\\sdk\\Include\\10.0.22000.0\\shared"
 "-isystem" 
"C:\\Scoop\\global\\apps\\winsdk\\10.0.22000.194\\sdk\\Include\\10.0.22000.0\\um"
 "-isystem" 
"C:\\Scoop\\global\\apps\\winsdk\\10.0.22000.194\\sdk\\Include\\10.0.22000.0\\winrt"
 "-std=c++14" "-fmath-errno" "-fms-compatibility" "-fdelayed-template-parsing" 
"-pic-level" "2" "-stack-protector" "2" "-fvisibility" "default" 
"-fdeprecated-macro" "-fms-compatibility-version=19.29.30138" 
"-ffp-contract=on" "-fno-experimental-relative-c++-abi-vtables" "-O0" 
"-fdebug-compilation-dir=." "-fcoverage-compilation-dir=D:\\git\\llvm-project" 
"-faddrsig" "-fms-volatile" "-fno-use-cxa-atexit" "-gcodeview" 
"-gno-column-info" "-mrelax-all" "-mincremental-linker-compatible" 
"--mrelax-relocations" "-relaxed-aliasing" "-funwind-tables=2" 
"-mconstructor-aliases" "--dependent-lib=libcmt" "--dependent-lib=oldnames" 
"-flto-visibility-public-std" "-clear-ast-before-backend" 
"-debug-info-kind=constructor" "-fdiagnostics-hotness-threshold=0" "-D" "_MT"`

(the LF_BUILDINFO record is replicated unchanged in the .PDB)

Microsoft does something similair:

  > cl /c /Z7 .\main.cpp
  Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30136 for x64
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  main.cpp
  > llvm-pdbutil.exe dump -types .\main.obj | grep -B4 -A5 LF_BUILDINFO
  0x1009 | LF_SUBSTR_LIST [size = 16]
   0x1007: `-c -Z7 -MT 
-IC:\Scoop\global\apps\vs_buildtools\16.11.5\VS\VC\Tools\MSVC\14.29.30133\ATLMFC\include
 
-IC:\Scoop\global\apps\vs_buildtools\16.11.5\VS\VC\Tools\MSVC\14.29.30133\include
 -IC:\Scoop\global\apps\winsdk\10.0.22000.194\sdk\include\10.0.22000.0\ucrt`
   0x1008: ` 
-IC:\Scoop\global\apps\winsdk\10.0.22000.194\sdk\include\10.0.22000.0\shared 
-IC:\Scoop\global\apps\winsdk\10.0.22000.194\sdk\include\10.0.22000.0\um 
-IC:\Scoop\global\apps\winsdk\10.0.22000.194\sdk\include\10.0.22000.0\winrt 
-IC:\Scoop\global\apps\winsdk\10`
  0x100A | LF_STRING_ID [size = 64] ID: 0x1009, String: 
.0.22000.194\sdk\include\10.0.22000.0\cppwinrt -TP -X
  0x100B | LF_BUILDINFO [size = 28]
   0x1003: `D:\git\llvm-project`
   0x1004: 
`C:\Scoop\global\apps\vs_buildtools\16.11.5\VS\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe`
   0x1005: `.\main.cpp`
   0x1006: `D:\git\llvm-project\vc140.pdb`
   0x100A: `.0.22000.194\sdk\include\10.0.22000.0\cppwinrt -TP -X`

MSVC splits the command over multiple string records, I suppose to increase the 
chances of de-duplication in the .PDB, something that we could do later. But 
the essence is that the command is free-standing (note `-X` and the explicit 
includes) and can be run without any env.vars set, unlike `-dwarf-debug-flags` 
or `-record-command-line`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833

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


[PATCH] D116459: [Clang][Sema] Adjust formatting (NFC)

2021-12-31 Thread Egor Zhdan via Phabricator via cfe-commits
egorzhdan created this revision.
Herald added a reviewer: aaron.ballman.
egorzhdan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is a preparation for another change in the watchOS/tvOS availability 
logic. It is extracted into a separate commit to simplify reviewing and to keep 
the linter happy at the same time.

rdar://81491680


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116459

Files:
  clang/lib/Sema/SemaDeclAttr.cpp


Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -2625,37 +2625,37 @@
   NewII = &S.Context.Idents.get("watchos_app_extension");
 
 if (NewII) {
-auto adjustWatchOSVersion = [](VersionTuple Version) -> VersionTuple {
-  if (Version.empty())
-return Version;
-  auto Major = Version.getMajor();
-  auto NewMajor = Major >= 9 ? Major - 7 : 0;
-  if (NewMajor >= 2) {
-if (Version.getMinor().hasValue()) {
-  if (Version.getSubminor().hasValue())
-return VersionTuple(NewMajor, Version.getMinor().getValue(),
-Version.getSubminor().getValue());
-  else
-return VersionTuple(NewMajor, Version.getMinor().getValue());
-}
-return VersionTuple(NewMajor);
+  auto adjustWatchOSVersion = [](VersionTuple Version) -> VersionTuple {
+if (Version.empty())
+  return Version;
+auto Major = Version.getMajor();
+auto NewMajor = Major >= 9 ? Major - 7 : 0;
+if (NewMajor >= 2) {
+  if (Version.getMinor().hasValue()) {
+if (Version.getSubminor().hasValue())
+  return VersionTuple(NewMajor, Version.getMinor().getValue(),
+  Version.getSubminor().getValue());
+else
+  return VersionTuple(NewMajor, Version.getMinor().getValue());
   }
+  return VersionTuple(NewMajor);
+}
 
-  return VersionTuple(2, 0);
-};
+return VersionTuple(2, 0);
+  };
 
-auto NewIntroduced = adjustWatchOSVersion(Introduced.Version);
-auto NewDeprecated = adjustWatchOSVersion(Deprecated.Version);
-auto NewObsoleted = adjustWatchOSVersion(Obsoleted.Version);
-
-AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(
-ND, AL, NewII, true /*Implicit*/, NewIntroduced, NewDeprecated,
-NewObsoleted, IsUnavailable, Str, IsStrict, Replacement,
-Sema::AMK_None,
-PriorityModifier + Sema::AP_InferredFromOtherPlatform);
-if (NewAttr)
-  D->addAttr(NewAttr);
-  }
+  auto NewIntroduced = adjustWatchOSVersion(Introduced.Version);
+  auto NewDeprecated = adjustWatchOSVersion(Deprecated.Version);
+  auto NewObsoleted = adjustWatchOSVersion(Obsoleted.Version);
+
+  AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(
+  ND, AL, NewII, true /*Implicit*/, NewIntroduced, NewDeprecated,
+  NewObsoleted, IsUnavailable, Str, IsStrict, Replacement,
+  Sema::AMK_None,
+  PriorityModifier + Sema::AP_InferredFromOtherPlatform);
+  if (NewAttr)
+D->addAttr(NewAttr);
+}
   } else if (S.Context.getTargetInfo().getTriple().isTvOS()) {
 // Transcribe "ios" to "tvos" (and add a new attribute) if the versioning
 // matches before the start of the tvOS platform.
@@ -2673,7 +2673,7 @@
   PriorityModifier + Sema::AP_InferredFromOtherPlatform);
   if (NewAttr)
 D->addAttr(NewAttr);
-  }
+}
   } else if (S.Context.getTargetInfo().getTriple().getOS() ==
  llvm::Triple::IOS &&
  S.Context.getTargetInfo().getTriple().isMacCatalystEnvironment()) 
{


Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -2625,37 +2625,37 @@
   NewII = &S.Context.Idents.get("watchos_app_extension");
 
 if (NewII) {
-auto adjustWatchOSVersion = [](VersionTuple Version) -> VersionTuple {
-  if (Version.empty())
-return Version;
-  auto Major = Version.getMajor();
-  auto NewMajor = Major >= 9 ? Major - 7 : 0;
-  if (NewMajor >= 2) {
-if (Version.getMinor().hasValue()) {
-  if (Version.getSubminor().hasValue())
-return VersionTuple(NewMajor, Version.getMinor().getValue(),
-Version.getSubminor().getValue());
-  else
-return VersionTuple(NewMajor, Version.getMinor().getValue());
-}
-return VersionTuple(NewMajor);
+  auto adjustWatchOSVersion = [](VersionTuple Version) -> VersionTuple {
+if

[clang-tools-extra] 255ee64 - [clang-tools-extra] Remove unused using (NFC)

2021-12-31 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2021-12-31T10:51:10-08:00
New Revision: 255ee643a8c559375a9c9787ef7d121790040818

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

LOG: [clang-tools-extra] Remove unused using (NFC)

Identified by misc-unused-using-decls.

Added: 


Modified: 
clang-tools-extra/clang-doc/Mapper.cpp
clang-tools-extra/clang-include-fixer/YamlSymbolIndex.cpp
clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/Mapper.cpp 
b/clang-tools-extra/clang-doc/Mapper.cpp
index de7e4c3410866..16a52e843fccc 100644
--- a/clang-tools-extra/clang-doc/Mapper.cpp
+++ b/clang-tools-extra/clang-doc/Mapper.cpp
@@ -14,8 +14,6 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Error.h"
 
-using clang::comments::FullComment;
-
 namespace clang {
 namespace doc {
 

diff  --git a/clang-tools-extra/clang-include-fixer/YamlSymbolIndex.cpp 
b/clang-tools-extra/clang-include-fixer/YamlSymbolIndex.cpp
index de72e9a9b9324..4271d9aa4e677 100644
--- a/clang-tools-extra/clang-include-fixer/YamlSymbolIndex.cpp
+++ b/clang-tools-extra/clang-include-fixer/YamlSymbolIndex.cpp
@@ -15,7 +15,6 @@
 #include 
 #include 
 
-using clang::find_all_symbols::SymbolInfo;
 using clang::find_all_symbols::SymbolAndSignals;
 
 namespace clang {

diff  --git 
a/clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.cpp 
b/clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.cpp
index e5b4dba4b7ad7..4a5f8353b4105 100644
--- a/clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.cpp
+++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.cpp
@@ -13,8 +13,6 @@
 #include "llvm/Support/raw_ostream.h"
 
 using llvm::yaml::MappingTraits;
-using llvm::yaml::IO;
-using llvm::yaml::Input;
 using ContextType = clang::find_all_symbols::SymbolInfo::ContextType;
 using clang::find_all_symbols::SymbolInfo;
 using clang::find_all_symbols::SymbolAndSignals;



___
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

2021-12-31 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/DefinitionBlockSeparator.cpp:25
+FormatTokenLexer &Tokens) {
+  if (Style.SeparateDefinitionBlocks == FormatStyle::SDS_Leave)
+return {{}, 0};

ksyx wrote:
> HazardyKnusperkeks wrote:
> > Better, but I still think we should have the assert here. The class should 
> > not be instantiated at all, if you don't want to use it.
> My idea is that it would be too redundant to have every user of this method 
> to check style once before it calls it?
Who are the users? `clang-format` and maybe its tests. And the only one that 
really matters is `clang-format`, which does the check.



Comment at: clang/unittests/Format/DefinitionBlockSeparatorTest.cpp:45
+
+  static void verifyFormat(llvm::StringRef Code,
+   const FormatStyle &Style = getLLVMStyle(),

Maybe one should either use the normal reformat function, or additionally. 
Because right now we do not test any interferences of these two functions.


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

https://reviews.llvm.org/D116314

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


[PATCH] D116328: [ast-matchers] Add hasSubstmt() traversal matcher for caseStmt(), defaultStmt(), labelStmt()

2021-12-31 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.



Comment at: clang/lib/ASTMatchers/Dynamic/Registry.cpp:358
   REGISTER_MATCHER(hasStructuredBlock);
+  REGISTER_MATCHER(hasSubstmt);
   REGISTER_MATCHER(hasSyntacticForm);

I see there is another matcher called hasAnySubstatement where "substatement" 
is spelled out; I think I will rename this matcher hasSubstatement to be 
consistent with hasAnySubstatement.


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

https://reviews.llvm.org/D116328

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


[clang-tools-extra] e47a224 - [clang-tidy] Use nullptr instead of 0 or NULL (NFC)

2021-12-31 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2021-12-31T13:54:34-08:00
New Revision: e47a224ccfbbfd61f31136db53768dabbb85e563

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

LOG: [clang-tidy] Use nullptr instead of 0 or NULL (NFC)

Identified with modernize-use-nullptr.

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
index 36d83b2a3ea31..200528b1c061d 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
@@ -144,7 +144,7 @@ static StringRef exprToStr(const Expr *E,
 
   return Lexer::getSourceText(
   CharSourceRange::getTokenRange(E->getSourceRange()),
-  *Result.SourceManager, Result.Context->getLangOpts(), 0);
+  *Result.SourceManager, Result.Context->getLangOpts(), nullptr);
 }
 
 // Returns the proper token based end location of \p E.
@@ -477,7 +477,7 @@ static void insertNullTerminatorExpr(StringRef Name,
   FunctionExpr->getBeginLoc());
   StringRef SpaceBeforeStmtStr = Lexer::getSourceText(
   CharSourceRange::getCharRange(SpaceRange), *Result.SourceManager,
-  Result.Context->getLangOpts(), 0);
+  Result.Context->getLangOpts(), nullptr);
 
   SmallString<128> NewAddNullTermExprStr;
   NewAddNullTermExprStr =

diff  --git 
a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index cfbe79c525942..8cede1b2c17b5 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -1404,8 +1404,8 @@ IdentifierNamingCheck::getMacroFailureInfo(const Token 
&MacroNameTok,
   if (!Style.isActive())
 return llvm::None;
 
-  return getFailureInfo("", MacroNameTok.getIdentifierInfo()->getName(), NULL,
-Loc, Style.getStyles(), Style.getHNOption(),
+  return getFailureInfo("", MacroNameTok.getIdentifierInfo()->getName(),
+nullptr, Loc, Style.getStyles(), Style.getHNOption(),
 SK_MacroDefinition, SM, IgnoreFailedSplit);
 }
 



___
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

2021-12-31 Thread ksyx via Phabricator via cfe-commits
ksyx updated this revision to Diff 396826.
ksyx added a comment.

Use `reformat` method instead of calling the single method only.


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

https://reviews.llvm.org/D116314

Files:
  clang/docs/ClangFormatStyleOptions.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"
+   "  int j, k;\n"
+   "};",
+   Style);
+
+  verifyFormat("namespace foo {\n"
+   "int i, j;\n"
+   "}\n"
+   

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

2021-12-31 Thread ksyx via Phabricator via cfe-commits
ksyx marked an inline comment as done.
ksyx added inline comments.



Comment at: clang/lib/Format/DefinitionBlockSeparator.cpp:25
+FormatTokenLexer &Tokens) {
+  if (Style.SeparateDefinitionBlocks == FormatStyle::SDS_Leave)
+return {{}, 0};

HazardyKnusperkeks wrote:
> ksyx wrote:
> > HazardyKnusperkeks wrote:
> > > Better, but I still think we should have the assert here. The class 
> > > should not be instantiated at all, if you don't want to use it.
> > My idea is that it would be too redundant to have every user of this method 
> > to check style once before it calls it?
> Who are the users? `clang-format` and maybe its tests. And the only one that 
> really matters is `clang-format`, which does the check.
Does there exist the possibility that some developer just include the header 
and link to library to obtain replacement analysis result for their other parts 
of program to use, instead of only clangfmt itself is using this class?


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

https://reviews.llvm.org/D116314

___
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

2021-12-31 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/DefinitionBlockSeparator.cpp:25
+FormatTokenLexer &Tokens) {
+  if (Style.SeparateDefinitionBlocks == FormatStyle::SDS_Leave)
+return {{}, 0};

ksyx wrote:
> HazardyKnusperkeks wrote:
> > ksyx wrote:
> > > HazardyKnusperkeks wrote:
> > > > Better, but I still think we should have the assert here. The class 
> > > > should not be instantiated at all, if you don't want to use it.
> > > My idea is that it would be too redundant to have every user of this 
> > > method to check style once before it calls it?
> > Who are the users? `clang-format` and maybe its tests. And the only one 
> > that really matters is `clang-format`, which does the check.
> Does there exist the possibility that some developer just include the header 
> and link to library to obtain replacement analysis result for their other 
> parts of program to use, instead of only clangfmt itself is using this class?
Of course the possibility exists, but I don't think there is anyone. And at 
least for me those aren't the audience. And even then, they can make sure that 
it's not `SDS_Leave`.


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

https://reviews.llvm.org/D116314

___
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

2021-12-31 Thread ksyx via Phabricator via cfe-commits
ksyx updated this revision to Diff 396835.
ksyx marked 3 inline comments as done.
ksyx added a comment.

Change the `SDS_Leave` style check to be assert not having this style.


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

https://reviews.llvm.org/D116314

Files:
  clang/docs/ClangFormatStyleOptions.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"
+   "  int j, k;\n"
+   "};",
+   Style);
+
+  verifyFormat("namespace foo {\n"
+   "int i,