[clang] a1449a1 - [clang][FPEnv] Clang floatng point model ffp-model=precise enables ffp-contract=on

2021-06-19 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-19T06:49:27-04:00
New Revision: a1449a10dbcfcf353f4f761281c4e572b4ce9308

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

LOG: [clang][FPEnv] Clang floatng point model ffp-model=precise enables 
ffp-contract=on

This patch changes the ffp-model=precise to enables -ffp-contract=on
(previously -ffp-model=precise enabled -ffp-contract=fast). This is a
follow-up to Andy Kaylor's comments in the llvm-dev discussion
"Floating Point semantic modes". From the same email thread, I put
Andy's distillation of floating point options and floating point modes
into UsersManual.rst

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

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ffp-contract-option.c
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 244212a1336db..96512f7514b3e 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1260,8 +1260,50 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior. The options
-are listed below.
+Clang provides a number of ways to control floating point behavior, including
+with command line options and source pragmas. This section
+describes the various floating point semantic modes and the corresponding 
options.
+
+.. csv-table:: Floating Point Semantic Modes
+  :header: "Mode", "Values"
+  :widths: 15, 30, 30
+
+  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
+  "fenv_access", "{off, on}", "(none)"
+  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
+  "contract", "{on, off, fast}", "ffp-contract"
+  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
+  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
+  "support_math_errno", "{on, off}", "fmath-errno"
+  "no_honor_nans", "{on, off}", "fhonor-nans"
+  "no_honor_infinities", "{on, off}", "fhonor-infinities"
+  "no_signed_zeros", "{on, off}", "fsigned-zeros"
+  "allow_reciprocal", "{on, off}", "freciprocal-math"
+  "allow_approximate_fns", "{on, off}", "(none)"
+  "allow_reassociation", "{on, off}", "fassociative-math"
+
+
+This table describes the option settings that correspond to the three
+floating point semantic models: precise (the default), strict, and fast.
+
+
+.. csv-table:: Floating Point Models
+  :header: "Mode", "Precise", "Strict", "Fast"
+  :widths: 25, 15, 15, 15
+
+  "except_behavior", "ignore", "strict", "ignore"
+  "fenv_access", "off", "on", "off"
+  "rounding_mode", "tonearest", "dynamic", "tonearest"
+  "contract", "on", "off", "fast"
+  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
+  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
+  "support_math_errno", "on", "on", "off"
+  "no_honor_nans", "off", "off", "on"
+  "no_honor_infinities", "off", "off", "on"
+  "no_signed_zeros", "off", "off", "on"
+  "allow_reciprocal", "off", "off", "on"
+  "allow_approximate_fns", "off", "off", "on"
+  "allow_reassociation", "off", "off", "on"
 
 .. option:: -ffast-math
 
@@ -1456,7 +1498,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index f6e3447eccb02..1fc395cdda0bc 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2631,7 +2631,7 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef F

[clang] c9889c4 - [clang-cl] Don't expand /permissive- to /ZC:strictStrings yet

2021-06-19 Thread Markus Böck via cfe-commits

Author: Markus Böck
Date: 2021-06-19T13:28:32+02:00
New Revision: c9889c44ec5a4054833457c813e155f284703ef4

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

LOG: [clang-cl] Don't expand /permissive- to /ZC:strictStrings yet

Follow up on rGc70b0e808da8

/Zc:strictStrings is an alias to an option part of the -W group. When the 
driver tries to render the option back to a string for the cc1 invocation, it 
sadly gets rendered with the original spelling instead of the alias, causing 
issues reported here: https://reviews.llvm.org/D103773#inline-989447

I am thinking it's the best to revert this part of the patch until I figured 
out how to correctly add the arg and until /Zc:strictStrings- exists/is needed.

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index bb17f73e1488..cf08c42965c8 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -1493,14 +1493,12 @@ static void TranslatePermissive(Arg *A, 
llvm::opt::DerivedArgList &DAL,
 const OptTable &Opts) {
   DAL.AddFlagArg(A, Opts.getOption(options::OPT__SLASH_Zc_twoPhase_));
   DAL.AddFlagArg(A, Opts.getOption(options::OPT_fno_operator_names));
-  // There is currently no /Zc:strictStrings- in clang-cl
 }
 
 static void TranslatePermissiveMinus(Arg *A, llvm::opt::DerivedArgList &DAL,
  const OptTable &Opts) {
   DAL.AddFlagArg(A, Opts.getOption(options::OPT__SLASH_Zc_twoPhase));
   DAL.AddFlagArg(A, Opts.getOption(options::OPT_foperator_names));
-  DAL.AddFlagArg(A, Opts.getOption(options::OPT__SLASH_Zc_strictStrings));
 }
 
 llvm::opt::DerivedArgList *



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


[PATCH] D103773: [clang-cl] Add /permissive and /permissive-

2021-06-19 Thread Markus Böck via Phabricator via cfe-commits
zero9178 marked an inline comment as done.
zero9178 added inline comments.



Comment at: clang/test/Driver/cl-permissive.c:15
+// PERMISSIVE-OVERWRITE-NOT: "-fdelayed-template-parsing"
+// RUN: %clang_cl /permissive- /Zc:twoPhase- -### -- %s 2>&1 | FileCheck 
-check-prefix=PERMISSIVE-MINUS-OVERWRITE %s
+// PERMISSIVE-MINUS-OVERWRITE-NOT: "-fno-operator-names"

zero9178 wrote:
> aganea wrote:
> > Hello @zero9178 !
> > After this patch, the following fails:
> > `// RUN: %clang_cl /permissive- -- %s`
> > generates:
> > `error: error reading '/Zc:strictStrings'`
> > Because `/Zc:strictStrings` isn't correctly expanded to 
> > `-Werror=c++11-compat-deprecated-writable-strings` as it should, but it is 
> > passed as-is to cc1. You can put a breakpoint here: 
> > https://github.com/llvm/llvm-project/blob/fc018ebb608ee0c1239b405460e49f1835ab6175/clang/lib/Driver/ToolChains/Clang.cpp#L5374
> >  and observe before/after this line.
> > Would you possibly have a chance to take a look please?
> Absolutely! I will take a look as soon as possible which will be on the 
> weekend. Meanwhile feel free to either revert the commit or remove the 
> expansion to /Zc:strictStrings
I have removed the expansion to strictStrings in 
https://reviews.llvm.org/rGc9889c44ec5a4054833457c813e155f284703ef4. Apparently 
when AdAllArgs is called it does not correctly render it as I thought it would. 
The fix isn't very obvious to me, and my time is sadly limited. In hindsight it 
is also probably not a good idea to add strictStrings until strictStrings 
exists/is neeeded. 

Hope this helps.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103773

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


[clang] 9abaf5c - Revert "[clang][FPEnv] Clang floatng point model ffp-model=precise enables ffp-contract=on"

2021-06-19 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-19T08:01:22-04:00
New Revision: 9abaf5c359ca29fcdd4f42b72ae0a62f18626180

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

LOG: Revert "[clang][FPEnv] Clang floatng point model ffp-model=precise enables 
ffp-contract=on"

This reverts commit a1449a10dbcfcf353f4f761281c4e572b4ce9308.
Seems like my changes to LNT had no effect -- puzzled.
The 21 tests pass on my sandbox with the clang patch but are
failing in exec time in the bot

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ffp-contract-option.c
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 96512f7514b3e..244212a1336db 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1260,50 +1260,8 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior, including
-with command line options and source pragmas. This section
-describes the various floating point semantic modes and the corresponding 
options.
-
-.. csv-table:: Floating Point Semantic Modes
-  :header: "Mode", "Values"
-  :widths: 15, 30, 30
-
-  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
-  "fenv_access", "{off, on}", "(none)"
-  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
-  "contract", "{on, off, fast}", "ffp-contract"
-  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
-  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
-  "support_math_errno", "{on, off}", "fmath-errno"
-  "no_honor_nans", "{on, off}", "fhonor-nans"
-  "no_honor_infinities", "{on, off}", "fhonor-infinities"
-  "no_signed_zeros", "{on, off}", "fsigned-zeros"
-  "allow_reciprocal", "{on, off}", "freciprocal-math"
-  "allow_approximate_fns", "{on, off}", "(none)"
-  "allow_reassociation", "{on, off}", "fassociative-math"
-
-
-This table describes the option settings that correspond to the three
-floating point semantic models: precise (the default), strict, and fast.
-
-
-.. csv-table:: Floating Point Models
-  :header: "Mode", "Precise", "Strict", "Fast"
-  :widths: 25, 15, 15, 15
-
-  "except_behavior", "ignore", "strict", "ignore"
-  "fenv_access", "off", "on", "off"
-  "rounding_mode", "tonearest", "dynamic", "tonearest"
-  "contract", "on", "off", "fast"
-  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
-  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
-  "support_math_errno", "on", "on", "off"
-  "no_honor_nans", "off", "off", "on"
-  "no_honor_infinities", "off", "off", "on"
-  "no_signed_zeros", "off", "off", "on"
-  "allow_reciprocal", "off", "off", "on"
-  "allow_approximate_fns", "off", "off", "on"
-  "allow_reassociation", "off", "off", "on"
+Clang provides a number of ways to control floating point behavior. The options
+are listed below.
 
 .. option:: -ffast-math
 
@@ -1498,7 +1456,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1fc395cdda0bc..f6e3447eccb02 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2631,7 +2631,7 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef FPContract = "on";
+  StringRef FPContract = "";
   bool StrictFPModel = false;
 
 
@@ -2656,7 +2656,7 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
   Reciproc

[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-06-19 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

I’ve been trying to commit this patch. However, when I commit, the tests fail 
some 21 floating point tests in LNT.  Also there is both performance 
improvement as well as regression which shouldn’t happen because the sum total 
of my clang patch + my LNT patch should effectively be a no-op.

It appears that the correction I made to LNT is not effective, but I’ve tested 
the patch on my Linux box and it does work.  My patch unconditionally overrides 
the command line to restore the original LNT behavior. I verified the commit 
revision to LNT and the bot is running my patched version of LNT.  It looks 
like the bot is using a different rule to build the test cases.

It’s hard to see exactly what the bot is doing, there isn’t enough information. 
 It would be nice if the bot Makefile was built with ‘verbose’ so I could see 
all the compile commands that the bot is using.

One of the bot failures is here: http://lnt.llvm.org/db_default/v4/nts/147167

I can see the bot owner is Yin Yang, I will reach out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74436

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


[PATCH] D103008: Handle multiple escaped newlines between */ correctly

2021-06-19 Thread Lode Willems via Phabricator via cfe-commits
lodewillems abandoned this revision.
lodewillems added a comment.

Made obsolete by commit de6164ec4da0cfea1b0d0e472c432ea1be4d9c29 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103008

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


[clang] decfad7 - Revert "Re-Revert "DirectoryWatcher: add an implementation for Windows""

2021-06-19 Thread Saleem Abdulrasool via cfe-commits

Author: Saleem Abdulrasool
Date: 2021-06-19T09:19:52-07:00
New Revision: decfad7d8e9b268654dd2d76a7f5f777502b60a6

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

LOG: Revert "Re-Revert "DirectoryWatcher: add an implementation for Windows""

This reverts commit fb32de9e97af0921242a021e30020ffacf7aa6e2.

Remove the secondary synchronization point as noted by Adrian.  This is
technically only to make the builders happier about tests and should not
be needed.  This also pushes the condition variable setting to after the
watch is actually established (which was the source of the original race
condition, but would normally succeed as the thread shouldn't get put to
sleep immediately on the trigger of the condition variable).

This also was pretested on the chromium builders:
https://ci.chromium.org/ui/p/chromium/builders/try/win_upload_clang/1612/overview.

Added: 


Modified: 
clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp
clang/unittests/DirectoryWatcher/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp 
b/clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp
index 25cbcf536388a..1f040f60ff19d 100644
--- a/clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp
+++ b/clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp
@@ -6,19 +6,12 @@
 //
 
//===--===//
 
-// TODO: This is not yet an implementation, but it will make it so Windows
-//   builds don't fail.
-
 #include "DirectoryScanner.h"
 #include "clang/DirectoryWatcher/DirectoryWatcher.h"
-
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/ScopeExit.h"
-#include "llvm/Support/AlignOf.h"
-#include "llvm/Support/Errno.h"
-#include "llvm/Support/Mutex.h"
+#include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Path.h"
-#include 
+#include "llvm/Support/Windows/WindowsSupport.h"
 #include 
 #include 
 #include 
@@ -28,23 +21,271 @@
 
 namespace {
 
+using DirectoryWatcherCallback =
+std::function, bool)>;
+
 using namespace llvm;
 using namespace clang;
 
 class DirectoryWatcherWindows : public clang::DirectoryWatcher {
+  OVERLAPPED Overlapped;
+
+  std::vector Notifications;
+
+  std::thread WatcherThread;
+  std::thread HandlerThread;
+  std::function, bool)> Callback;
+  SmallString Path;
+  HANDLE Terminate;
+
+  std::mutex Mutex;
+  bool WatcherActive = false;
+  std::condition_variable Ready;
+
+  class EventQueue {
+std::mutex M;
+std::queue Q;
+std::condition_variable CV;
+
+  public:
+void emplace(DirectoryWatcher::Event::EventKind Kind, StringRef Path) {
+  {
+std::unique_lock L(M);
+Q.emplace(Kind, Path);
+  }
+  CV.notify_one();
+}
+
+DirectoryWatcher::Event pop_front() {
+  std::unique_lock L(M);
+  while (true) {
+if (!Q.empty()) {
+  DirectoryWatcher::Event E = Q.front();
+  Q.pop();
+  return E;
+}
+CV.wait(L, [this]() { return !Q.empty(); });
+  }
+}
+  } Q;
+
 public:
-  ~DirectoryWatcherWindows() override { }
-  void InitialScan() { }
-  void EventReceivingLoop() { }
-  void StopWork() { }
+  DirectoryWatcherWindows(HANDLE DirectoryHandle, bool WaitForInitialSync,
+  DirectoryWatcherCallback Receiver);
+
+  ~DirectoryWatcherWindows() override;
+
+  void InitialScan();
+  void WatcherThreadProc(HANDLE DirectoryHandle);
+  void NotifierThreadProc(bool WaitForInitialSync);
 };
+
+DirectoryWatcherWindows::DirectoryWatcherWindows(
+HANDLE DirectoryHandle, bool WaitForInitialSync,
+DirectoryWatcherCallback Receiver)
+: Callback(Receiver), Terminate(INVALID_HANDLE_VALUE) {
+  // Pre-compute the real location as we will be handing over the directory
+  // handle to the watcher and performing synchronous operations.
+  {
+DWORD Size = GetFinalPathNameByHandleW(DirectoryHandle, NULL, 0, 0);
+std::unique_ptr Buffer{new WCHAR[Size]};
+Size = GetFinalPathNameByHandleW(DirectoryHandle, Buffer.get(), Size, 0);
+Buffer[Size] = L'\0';
+llvm::sys::windows::UTF16ToUTF8(Buffer.get(), Size, Path);
+  }
+
+  size_t EntrySize = sizeof(FILE_NOTIFY_INFORMATION) + MAX_PATH * 
sizeof(WCHAR);
+  Notifications.resize((4 * EntrySize) / sizeof(DWORD));
+
+  memset(&Overlapped, 0, sizeof(Overlapped));
+  Overlapped.hEvent =
+  CreateEventW(NULL, /*bManualReset=*/FALSE, /*bInitialState=*/FALSE, 
NULL);
+  assert(Overlapped.hEvent && "unable to create event");
+
+  Terminate =
+  CreateEventW(NULL, /*bManualReset=*/TRUE, /*bInitialState=*/FALSE, NULL);
+
+  WatcherThread = std::thread([this, DirectoryHandle]() {
+this->WatcherThreadProc(DirectoryHandle);
+  });
+
+  if (WaitF

[PATCH] D104044: [clang-format] Fix the issue that empty lines being removed at the beginning of namespace

2021-06-19 Thread Darwin Xu via Phabricator via cfe-commits
darwin updated this revision to Diff 353200.
darwin added a comment.

Updated with the fix code.

Look into the code, I am pretty sure this is a bug, it is about the logic of 
the parameter `KeepEmptyLinesAtTheStartOfBlocks`.

When `KeepEmptyLinesAtTheStartOfBlocks` is false, it will remove the empty 
lines at the start of the block, and namespace will be an exception. So the 
empty lines will be kept inside namespace.

The problem is, it can only handle the situation in which the `namespace` and 
the `{` are on the same line. If `BraceWrapping.AfterNamespace` is true, it 
will cause the `namespace` and the `{` to be separated into different lines. 
The original code overlooked this situation:

  // Remove empty lines after "{".
  if (!Style.KeepEmptyLinesAtTheStartOfBlocks && PreviousLine &&
  PreviousLine->Last->is(tok::l_brace) &&
  !PreviousLine->startsWithNamespace() &&
  !startsExternCBlock(*PreviousLine))
Newlines = 1;

As you can see, it only checks if previous line starts with namespace.

The solution is a bit of tricky, we need to check not only the **previous 
line**, but also the **line before the previous line**. There isn't an easy way 
to get this. So I added a new parameter `PrevPrevLine` to the 
`UnwrappedLineFormatter::formatFirstToken()` function. I have to admit this 
isn't an elegant solution. Let me know if there is a better way to do so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104044

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineFormatter.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -262,6 +262,89 @@
"}",
getGoogleStyle()));
 
+  auto CustomStyle = clang::format::getLLVMStyle();
+  CustomStyle.BreakBeforeBraces = clang::format::FormatStyle::BS_Custom;
+  CustomStyle.BraceWrapping.AfterNamespace = true;
+  CustomStyle.KeepEmptyLinesAtTheStartOfBlocks = false;
+  EXPECT_EQ("namespace N\n"
+"{\n"
+"\n"
+"int i;\n"
+"}",
+format("namespace N\n"
+   "{\n"
+   "\n"
+   "\n"
+   "inti;\n"
+   "}",
+   CustomStyle));
+  EXPECT_EQ("/* something */ namespace N\n"
+"{\n"
+"\n"
+"int i;\n"
+"}",
+format("/* something */ namespace N {\n"
+   "\n"
+   "\n"
+   "inti;\n"
+   "}",
+   CustomStyle));
+  EXPECT_EQ("inline namespace N\n"
+"{\n"
+"\n"
+"int i;\n"
+"}",
+format("inline namespace N\n"
+   "{\n"
+   "\n"
+   "\n"
+   "inti;\n"
+   "}",
+   CustomStyle));
+  EXPECT_EQ("/* something */ inline namespace N\n"
+"{\n"
+"\n"
+"int i;\n"
+"}",
+format("/* something */ inline namespace N\n"
+   "{\n"
+   "\n"
+   "inti;\n"
+   "}",
+   CustomStyle));
+  EXPECT_EQ("export namespace N\n"
+"{\n"
+"\n"
+"int i;\n"
+"}",
+format("export namespace N\n"
+   "{\n"
+   "\n"
+   "inti;\n"
+   "}",
+   CustomStyle));
+  EXPECT_EQ("namespace a\n"
+"{\n"
+"namespace b\n"
+"{\n"
+"\n"
+"class AA {};\n"
+"\n"
+"} // namespace b\n"
+"} // namespace a\n",
+format("namespace a\n"
+   "{\n"
+   "namespace b\n"
+   "{\n"
+   "\n"
+   "\n"
+   "class AA {};\n"
+   "\n"
+   "\n"
+   "}\n"
+   "}\n",
+   CustomStyle));
+
   // ...but do keep inlining and removing empty lines for non-block extern "C"
   // functions.
   verifyFormat("extern \"C\" int f() { return 42; }", getGoogleStyle());
Index: clang/lib/Format/UnwrappedLineFormatter.h
===
--- clang/lib/Format/UnwrappedLineFormatter.h
+++ clang/lib/Format/UnwrappedLineFormatter.h
@@ -47,6 +47,7 @@
   /// of the \c UnwrappedLine if there was no structural parsing error.
   void formatFirstToken(const AnnotatedLine &Line,
 const AnnotatedLine *PreviousLine,
+const A

[PATCH] D103750: [analyzer] Handle std::make_unique for SmartPtrModeling

2021-06-19 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

In D103750#2827548 , @RedDocMD wrote:

> In D103750#2825342 , @NoQ wrote:
>
>> Do the above tests pass when your new `evalCall` modeling is enabled?
>
> The analyzer doesn't seem to be able to make up its mind.
>
>   member-constructor.cpp:15:5: warning: FALSE [debug.ExprInspection]
>   clang_analyzer_eval(*P->p == 0);
>   ^~~
>   member-constructor.cpp:15:25: note: Assuming the condition is false
>   clang_analyzer_eval(*P->p == 0);
>   ^~
>   member-constructor.cpp:15:5: note: FALSE
>   clang_analyzer_eval(*P->p == 0);
>   ^~~
>   member-constructor.cpp:15:5: warning: TRUE [debug.ExprInspection]
>   clang_analyzer_eval(*P->p == 0);
>   ^~~
>   member-constructor.cpp:15:25: note: Assuming the condition is true
>   clang_analyzer_eval(*P->p == 0);
>   ^~
>   member-constructor.cpp:15:5: note: TRUE
>   clang_analyzer_eval(*P->p == 0);
>   ^~~
>   2 warnings generated.

What about this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103750

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


[PATCH] D103750: [analyzer] Handle std::make_unique for SmartPtrModeling

2021-06-19 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In D103750#2828995 , @RedDocMD wrote:

> What about this?

I believe that you might see `analyzer-eagerly-assume` in action. Basically, 
instead of keeping a constraint unknown, the analyzer can split the path 
eagerly. So you have one path where the constraint is assumed to be true and 
one where it is assumed to be false. I think the rationale was that the user is 
likely to branch on certain conditions and doing it eagerly can make the 
analysis more precise in some cases but I do not really remember the details. 
Hopefully Artem has some more contexts.




Comment at: clang/test/Analysis/smart-ptr-text-output.cpp:374
+}
\ No newline at end of file


Nit: we usually add new lines to the ends of the files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103750

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


[PATCH] D104553: [compiler-rt][hwasan] Add InitState options to thread initialization

2021-06-19 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: compiler-rt/lib/hwasan/hwasan_linux.cpp:430
 
-void Thread::InitStackAndTls() {
+void Thread::InitStackAndTls(const InitState *state) {
   uptr tls_size;

If it's unused then you can omit the argument name to avoid the unused variable 
warning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104553

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


[PATCH] D94333: [Inliner] Change inline remark format and update ReplayInlineAdvisor to use it

2021-06-19 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.
Herald added a subscriber: ormris.

I think this change broke apt.llvm.org

  > [100%] Linking CXX shared library ../../lib/libLLVM-13.so
  > cd 
"/build/llvm-toolchain-snapshot-13~++20210619083511+1605fce6c307/build-llvm/tools/llvm-shlib"
 && /usr/bin/cmake -E cmake_link_script CMakeFiles/LLVM.dir/link.txt --verbose=1
  > /usr/lib/ccache/g++-10 -fPIC -g -O2 
-fdebug-prefix-map=/build/llvm-toolchain-snapshot-13~++20210619083511+1605fce6c307=.
 -fstack-protector-strong -Wformat -Werror=format-security -fPIC 
-fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall 
-Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move 
-Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor 
-Wsuggest-override -Wno-comment -Wmisleading-indentation -ffunction-sections 
-fdata-sections -O2 -DNDEBUG -g1  
-Wl,-rpath-link,/build/llvm-toolchain-snapshot-13~++20210619083511+1605fce6c307/build-llvm/./lib
  -Wl,-O3 -Wl,--gc-sections -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions 
-Wl,-z,relro -Wl,-z,defs -Wl,-z,nodelete -shared -Wl,-soname,libLLVM-13.so.1 -o 
../../lib/libLLVM-13.so.1 CMakeFiles/LLVM.dir/libllvm.cpp.o  
-Wl,-rpath,"\$ORIGIN/../lib" 
-Wl,--version-script,/build/llvm-toolchain-snapshot-13~++20210619083511+1605fce6c307/build-llvm/./lib/tools/llvm-shlib/simple_version_script.map
 -Wl,--whole-archive ../../lib/libLLVMDemangle.a ../../lib/libLLVMSupport.a 
../../lib/libLLVMCore.a ../../lib/libLLVMFuzzMutate.a 
../../lib/libLLVMFileCheck.a ../../lib/libLLVMInterfaceStub.a 
../../lib/libLLVMIRReader.a ../../lib/libLLVMCodeGen.a 
../../lib/libLLVMSelectionDAG.a ../../lib/libLLVMAsmPrinter.a 
../../lib/libLLVMMIRParser.a ../../lib/libLLVMGlobalISel.a 
../../lib/libLLVMBinaryFormat.a ../../lib/libLLVMBitReader.a 
../../lib/libLLVMBitWriter.a ../../lib/libLLVMBitstreamReader.a 
../../lib/libLLVMDWARFLinker.a ../../lib/libLLVMExtensions.a 
../../lib/libLLVMFrontendOpenACC.a ../../lib/libLLVMFrontendOpenMP.a 
../../lib/libLLVMTransformUtils.a ../../lib/libLLVMInstrumentation.a 
../../lib/libLLVMAggressiveInstCombine.a ../../lib/libLLVMInstCombine.a 
../../lib/libLLVMScalarOpts.a ../../lib/libLLVMipo.a 
../../lib/libLLVMVectorize.a ../../lib/libLLVMObjCARCOpts.a 
../../lib/libLLVMCoroutines.a ../../lib/libLLVMCFGuard.a 
../../lib/libLLVMLinker.a ../../lib/libLLVMAnalysis.a ../../lib/libLLVMLTO.a 
../../lib/libLLVMMC.a ../../lib/libLLVMMCParser.a 
../../lib/libLLVMMCDisassembler.a ../../lib/libLLVMMCA.a 
../../lib/libLLVMObject.a ../../lib/libLLVMObjectYAML.a 
../../lib/libLLVMOption.a ../../lib/libLLVMRemarks.a 
../../lib/libLLVMDebugInfoDWARF.a ../../lib/libLLVMDebugInfoGSYM.a 
../../lib/libLLVMDebugInfoMSF.a ../../lib/libLLVMDebugInfoCodeView.a 
../../lib/libLLVMDebugInfoPDB.a ../../lib/libLLVMSymbolize.a 
../../lib/libLLVMExecutionEngine.a ../../lib/libLLVMInterpreter.a 
../../lib/libLLVMJITLink.a ../../lib/libLLVMMCJIT.a ../../lib/libLLVMOrcJIT.a 
../../lib/libLLVMOrcShared.a ../../lib/libLLVMOrcTargetProcess.a 
../../lib/libLLVMRuntimeDyld.a ../../lib/libLLVMPerfJITEvents.a 
../../lib/libLLVMTarget.a ../../lib/libLLVMAArch64CodeGen.a 
../../lib/libLLVMAArch64AsmParser.a ../../lib/libLLVMAArch64Disassembler.a 
../../lib/libLLVMAArch64Desc.a ../../lib/libLLVMAArch64Info.a 
../../lib/libLLVMAArch64Utils.a ../../lib/libLLVMAMDGPUCodeGen.a 
../../lib/libLLVMAMDGPUAsmParser.a ../../lib/libLLVMAMDGPUDisassembler.a 
../../lib/libLLVMAMDGPUDesc.a ../../lib/libLLVMAMDGPUInfo.a 
../../lib/libLLVMAMDGPUUtils.a ../../lib/libLLVMARMCodeGen.a 
../../lib/libLLVMARMAsmParser.a ../../lib/libLLVMARMDisassembler.a 
../../lib/libLLVMARMDesc.a ../../lib/libLLVMARMInfo.a 
../../lib/libLLVMARMUtils.a ../../lib/libLLVMAVRCodeGen.a 
../../lib/libLLVMAVRAsmParser.a ../../lib/libLLVMAVRDisassembler.a 
../../lib/libLLVMAVRDesc.a ../../lib/libLLVMAVRInfo.a 
../../lib/libLLVMBPFCodeGen.a ../../lib/libLLVMBPFAsmParser.a 
../../lib/libLLVMBPFDisassembler.a ../../lib/libLLVMBPFDesc.a 
../../lib/libLLVMBPFInfo.a ../../lib/libLLVMHexagonCodeGen.a 
../../lib/libLLVMHexagonAsmParser.a ../../lib/libLLVMHexagonDisassembler.a 
../../lib/libLLVMHexagonDesc.a ../../lib/libLLVMHexagonInfo.a 
../../lib/libLLVMLanaiCodeGen.a ../../lib/libLLVMLanaiAsmParser.a 
../../lib/libLLVMLanaiDisassembler.a ../../lib/libLLVMLanaiDesc.a 
../../lib/libLLVMLanaiInfo.a ../../lib/libLLVMMipsCodeGen.a 
../../lib/libLLVMMipsAsmParser.a ../../lib/libLLVMMipsDisassembler.a 
../../lib/libLLVMMipsDesc.a ../../lib/libLLVMMipsInfo.a 
../../lib/libLLVMMSP430CodeGen.a ../../lib/libLLVMMSP430Desc.a 
../../lib/libLLVMMSP430Info.a ../../lib/libLLVMMSP430AsmParser.a 
../../lib/libLLVMMSP430Disassembler.a ../../lib/libLLVMNVPTXCodeGen.a 
../../lib/libLLVMNVPTXDesc.a ../../lib/libLLVMNVPTXInfo.a 
../../lib/libLLVMPowerPCCodeGen.a ../../lib/libLLVMPowerPCAsmParser.a 
../../lib/libLLVMP

[PATCH] D104500: [clang] Apply P1825 as Defect Report for all C++ standards from C++11 up to C++20.

2021-06-19 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 353215.
mizvekov added a comment.

tests: improve consistency of expcted messages..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104500

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
  clang/test/SemaCXX/P1155.cpp
  clang/test/SemaCXX/conversion-function.cpp
  clang/test/SemaCXX/warn-return-std-move.cpp
  clang/test/SemaObjCXX/block-capture.mm

Index: clang/test/SemaObjCXX/block-capture.mm
===
--- clang/test/SemaObjCXX/block-capture.mm
+++ clang/test/SemaObjCXX/block-capture.mm
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx20_2b,cxx2b %s
-// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx20_2b   %s
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx98_11   %s
-// RUN: %clang_cc1 -std=c++98 -fsyntax-only -fobjc-arc -fblocks -Wno-c++11-extensions -verify=cxx98_2b,cxx98_11   %s
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx11_2b,cxx2b %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx11_2b   %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx11_2b   %s
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -fobjc-arc -fblocks -Wno-c++11-extensions -verify=cxx98_2b,cxx98  %s
 
 #define TEST(T) void test_##T() { \
   __block T x;\
@@ -14,54 +14,68 @@
 };
 TEST(CopyOnly); // cxx2b-error {{no matching constructor}}
 
+struct ConstCopyOnly {
+  ConstCopyOnly();
+  ConstCopyOnly(ConstCopyOnly &) = delete; // cxx98-note {{marked deleted here}}
+  ConstCopyOnly(const ConstCopyOnly &);
+};
+TEST(ConstCopyOnly); // cxx98-error {{call to deleted constructor}}
+
+struct NonConstCopyOnly {
+  NonConstCopyOnly();
+  NonConstCopyOnly(NonConstCopyOnly &);
+  NonConstCopyOnly(const NonConstCopyOnly &) = delete; // cxx11_2b-note {{marked deleted here}}
+};
+TEST(NonConstCopyOnly); // cxx11_2b-error {{call to deleted constructor}}
+
 struct CopyNoMove {
   CopyNoMove();
   CopyNoMove(CopyNoMove &);
-  CopyNoMove(CopyNoMove &&) = delete; // cxx98_2b-note {{marked deleted here}}
+  CopyNoMove(CopyNoMove &&) = delete; // cxx11_2b-note {{marked deleted here}}
 };
-TEST(CopyNoMove); // cxx98_2b-error {{call to deleted constructor}}
+TEST(CopyNoMove); // cxx11_2b-error {{call to deleted constructor}}
 
 struct MoveOnly {
   MoveOnly();
-  MoveOnly(MoveOnly &) = delete;
+  MoveOnly(MoveOnly &) = delete; // cxx98-note {{marked deleted here}}
   MoveOnly(MoveOnly &&);
 };
-TEST(MoveOnly);
+TEST(MoveOnly); // cxx98-error {{call to deleted constructor}}
 
 struct NoCopyNoMove {
   NoCopyNoMove();
-  NoCopyNoMove(NoCopyNoMove &) = delete;
-  NoCopyNoMove(NoCopyNoMove &&) = delete; // cxx98_2b-note {{marked deleted here}}
+  NoCopyNoMove(NoCopyNoMove &) = delete;  // cxx98-note {{marked deleted here}}
+  NoCopyNoMove(NoCopyNoMove &&) = delete; // cxx11_2b-note {{marked deleted here}}
 };
 TEST(NoCopyNoMove); // cxx98_2b-error {{call to deleted constructor}}
 
 struct ConvertingRVRef {
   ConvertingRVRef();
-  ConvertingRVRef(ConvertingRVRef &) = delete; // cxx98_11-note {{marked deleted here}}
+  ConvertingRVRef(ConvertingRVRef &) = delete; // cxx98-note {{marked deleted here}}
 
   struct X {};
   ConvertingRVRef(X &&);
   operator X() const & = delete;
   operator X() &&;
 };
-TEST(ConvertingRVRef); // cxx98_11-error {{call to deleted constructor}}
+TEST(ConvertingRVRef); // cxx98-error {{call to deleted constructor}}
 
 struct ConvertingCLVRef {
   ConvertingCLVRef();
   ConvertingCLVRef(ConvertingCLVRef &);
 
   struct X {};
-  ConvertingCLVRef(X &&); // cxx20_2b-note {{passing argument to parameter here}}
+  ConvertingCLVRef(X &&); // cxx11_2b-note {{passing argument to parameter here}}
   operator X() const &;
-  operator X() && = delete; // cxx20_2b-note {{marked deleted here}}
+  operator X() && = delete; // cxx11_2b-note {{marked deleted here}}
 };
-TEST(ConvertingCLVRef); // cxx20_2b-error {{invokes a deleted function}}
+TEST(ConvertingCLVRef); // cxx11_2b-error {{invokes a deleted function}}
 
 struct SubSubMove {};
 struct SubMove : SubSubMove {
   SubMove();
-  SubMove(SubMove &) = delete; // cxx98_11-note {{marked deleted here}}
+  SubMove(SubMove &) = delete; // cxx98-note {{marked deleted here}}
 
   SubMove(SubSubMove &&);
 };
-TEST(SubMove); // cxx98_11-error {{call to deleted constructor}}
+TEST(SubMove); // cxx98-error {{call to deleted constructor}}
Index: clang/test/SemaCXX/warn-return-std-move.cpp

[PATCH] D104601: [Preprocessor] Implement -fnormalize-whitespace.

2021-06-19 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur created this revision.
Herald added subscribers: dang, jvesely.
Meinersbur requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: openmp-commits, libcxx-commits, cfe-commits, sstefan1.
Herald added projects: clang, libc++, OpenMP.
Herald added a reviewer: libc++.

This patch adds the `-fnormalize-whitespace` with the following effects:

- If combined with `-E`, remove as much non-line-breaking whitespace as possible
- If combined with `-E -P`, removes as much whitespace as possible, including 
line-breaks.

The motivation is to reduce


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104601

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/PreprocessorOutputOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/test/CXX/lex/lex.pptoken/p3-2a.cpp
  
clang/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/i386-unknown-linux-gnu-ld
  
clang/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/x86_64-unknown-linux-gnu-ld
  
clang/test/Driver/Inputs/basic_cross_linux_tree/usr/i386-unknown-linux-gnu/bin/ld
  
clang/test/Driver/Inputs/basic_cross_linux_tree/usr/x86_64-unknown-linux-gnu/bin/ld
  clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/bin/as
  clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/bin/ld
  
clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/bin/as
  
clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/bin/ld
  clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/bin/as
  clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/bin/ld
  
clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/bin/as
  
clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/bin/ld
  clang/test/Preprocessor/c99-6_10_3_4_p5.c
  clang/test/Preprocessor/c99-6_10_3_4_p6.c
  clang/test/Preprocessor/comment_save.c
  clang/test/Preprocessor/first-line-indent.c
  clang/test/Preprocessor/hash_line.c
  clang/test/Preprocessor/line-directive-output-normcol.c
  clang/test/Preprocessor/line-directive-output.c
  clang/test/Preprocessor/macro_space.c
  clang/test/Preprocessor/normalize-whitespace.c
  clang/test/Preprocessor/print_line_include.c
  clang/test/Preprocessor/stringize_space.c
  libclc/amdgcn-mesa3d
  libcxx/test/std/pstl
  openmp/tools/analyzer/llvm-openmp-analyzer++

Index: openmp/tools/analyzer/llvm-openmp-analyzer++
===
--- /dev/null
+++ openmp/tools/analyzer/llvm-openmp-analyzer++
@@ -0,0 +1 @@
+llvm-openmp-analyzer
\ No newline at end of file
Index: libcxx/test/std/pstl
===
--- /dev/null
+++ libcxx/test/std/pstl
@@ -0,0 +1 @@
+../../../pstl/test/std
\ No newline at end of file
Index: libclc/amdgcn-mesa3d
===
--- /dev/null
+++ libclc/amdgcn-mesa3d
@@ -0,0 +1 @@
+amdgcn-amdhsa
\ No newline at end of file
Index: clang/test/Preprocessor/stringize_space.c
===
--- clang/test/Preprocessor/stringize_space.c
+++ clang/test/Preprocessor/stringize_space.c
@@ -1,16 +1,18 @@
 // RUN: %clang_cc1 -E %s | FileCheck --strict-whitespace %s
+// RUN: %clang_cc1 -E -P -fnormalize-whitespace %s | FileCheck --strict-whitespace %s --check-prefix=NORMWS
 
 #define A(b) -#b  ,  - #b  ,  -# b  ,  - # b
 A()
 
 // CHECK: {{^}}-"" , - "" , -"" , - ""{{$}}
-
+// NORMWS: {{^}}-"",-"",-"",-""
 
 #define t(x) #x
 t(a
 c)
 
 // CHECK: {{^}}"a c"{{$}}
+// NORMWS-SAME: "a c"
 
 #define str(x) #x
 #define f(x) str(-x)
@@ -18,6 +20,7 @@
 1)
 
 // CHECK: {{^}}"-1"
+// NORMWS-SAME: "-1"
 
 #define paste(a,b) str(a&1 | FileCheck %s --strict-whitespace --check-prefix=NORMCOL
+// RUN: %clang_cc1 -E -C -fnormalize-whitespace %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=NORMCCOL
+// RUN: %clang_cc1 -E -P -fnormalize-whitespace %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=NORMWS
+// RUN: %clang_cc1 -E -C -P -fnormalize-whitespace %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=NORMCWS
+
+#define NOT_OMP  omp  something
+#define HASH #
+
+  int  a; /*  span-comment  */
+  int  b  ;   //  line-comment
+  _Pragma  (  "omp  barrier"  ) x //  more line-comments
+  #pragma  omp  nothing  //  another comment
+HASH  pragma  NOT_OMP
+  int  e;// again a line
+  int  f  ;
+
+
+// NORMCOL:  {{^}}# 9 "{{.*}}normalize-whitespace.c"{{$}}
+// NORMCOL:  {{^}}int a;{{$}}
+// NORMCOL-NEXT: {{^}}int b;{{$}}
+// NORMCOL-NEXT: {{^}}#pragma omp barrier{{$}}
+// NORMCOL-NEXT: # 11 "{{.*}}normalize-whitespace.c"
+// NORMCOL-NEXT: {{^}}x{{$}}
+// NORMCOL-NEXT: {{^}}#pragma omp nothing{{$}}
+// NORMCOL-NEXT: {{^ }}#pragma omp something{{$}}
+// NORMCOL-NEXT: {{^}}int e;{{$}}
+// NORMCOL-NEXT: 

[PATCH] D104601: [Preprocessor] Implement -fnormalize-whitespace.

2021-06-19 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 353220.
Meinersbur edited the summary of this revision.
Meinersbur added a comment.

- Undo "typechange" changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/PreprocessorOutputOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/test/CXX/lex/lex.pptoken/p3-2a.cpp
  clang/test/Preprocessor/c99-6_10_3_4_p5.c
  clang/test/Preprocessor/c99-6_10_3_4_p6.c
  clang/test/Preprocessor/comment_save.c
  clang/test/Preprocessor/first-line-indent.c
  clang/test/Preprocessor/hash_line.c
  clang/test/Preprocessor/line-directive-output-normcol.c
  clang/test/Preprocessor/line-directive-output.c
  clang/test/Preprocessor/macro_space.c
  clang/test/Preprocessor/normalize-whitespace.c
  clang/test/Preprocessor/print_line_include.c
  clang/test/Preprocessor/stringize_space.c

Index: clang/test/Preprocessor/stringize_space.c
===
--- clang/test/Preprocessor/stringize_space.c
+++ clang/test/Preprocessor/stringize_space.c
@@ -1,16 +1,18 @@
 // RUN: %clang_cc1 -E %s | FileCheck --strict-whitespace %s
+// RUN: %clang_cc1 -E -P -fnormalize-whitespace %s | FileCheck --strict-whitespace %s --check-prefix=NORMWS
 
 #define A(b) -#b  ,  - #b  ,  -# b  ,  - # b
 A()
 
 // CHECK: {{^}}-"" , - "" , -"" , - ""{{$}}
-
+// NORMWS: {{^}}-"",-"",-"",-""
 
 #define t(x) #x
 t(a
 c)
 
 // CHECK: {{^}}"a c"{{$}}
+// NORMWS-SAME: "a c"
 
 #define str(x) #x
 #define f(x) str(-x)
@@ -18,6 +20,7 @@
 1)
 
 // CHECK: {{^}}"-1"
+// NORMWS-SAME: "-1"
 
 #define paste(a,b) str(a&1 | FileCheck %s --strict-whitespace --check-prefix=NORMCOL
+// RUN: %clang_cc1 -E -C -fnormalize-whitespace %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=NORMCCOL
+// RUN: %clang_cc1 -E -P -fnormalize-whitespace %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=NORMWS
+// RUN: %clang_cc1 -E -C -P -fnormalize-whitespace %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=NORMCWS
+
+#define NOT_OMP  omp  something
+#define HASH #
+
+  int  a; /*  span-comment  */
+  int  b  ;   //  line-comment
+  _Pragma  (  "omp  barrier"  ) x //  more line-comments
+  #pragma  omp  nothing  //  another comment
+HASH  pragma  NOT_OMP
+  int  e;// again a line
+  int  f  ;
+
+
+// NORMCOL:  {{^}}# 9 "{{.*}}normalize-whitespace.c"{{$}}
+// NORMCOL:  {{^}}int a;{{$}}
+// NORMCOL-NEXT: {{^}}int b;{{$}}
+// NORMCOL-NEXT: {{^}}#pragma omp barrier{{$}}
+// NORMCOL-NEXT: # 11 "{{.*}}normalize-whitespace.c"
+// NORMCOL-NEXT: {{^}}x{{$}}
+// NORMCOL-NEXT: {{^}}#pragma omp nothing{{$}}
+// NORMCOL-NEXT: {{^ }}#pragma omp something{{$}}
+// NORMCOL-NEXT: {{^}}int e;{{$}}
+// NORMCOL-NEXT: {{^}}int f;{{$}}
+
+// FIXME: Comments after pragmas disappear, even without -fnormalize-whitespace
+// NORMCCOL:  {{^}}# 9 "{{.*}}normalize-whitespace.c"{{$}}
+// NORMCCOL:  {{^}}int a;/*  span-comment  */{{$}}
+// NORMCCOL-NEXT: {{^}}int b;//  line-comment{{$}}
+// NORMCCOL-NEXT: {{^}}#pragma omp barrier{{$}}
+// NORMCCOL-NEXT: # 11 "{{.*}}normalize-whitespace.c"
+// NORMCCOL-NEXT: {{^}}x//  more line-comments{{$}}
+// NORMCCOL-NEXT: {{^}}#pragma omp nothing{{$}}
+// NORMCCOL-NEXT: {{^ }}#pragma omp something{{$}}
+// NORMCCOL-NEXT: {{^}}int e;// again a line{{$}}
+// NORMCCOL-NEXT: {{^}}int f;{{$}}
+
+// NORMWS:  {{^}}int a;int b;{{$}}
+// NORMWS-NEXT: {{^}}#pragma omp barrier{{$}}
+// NORMWS-NEXT: {{^}}x{{$}}
+// NORMWS-NEXT: {{^}}#pragma omp nothing{{$}}
+// NORMWS-NEXT: {{^ }}#pragma omp something int e;int f;{{$}}
+
+// FIXME: Comments after pragmas disappear, even without -fnormalize-whitespace
+// NORMCWS:  {{^}}int a;/*  span-comment  */int b;//  line-comment{{$}}
+// NORMCWS-NEXT: {{^}}#pragma omp barrier{{$}}
+// NORMCWS-NEXT: {{^}}x//  more line-comments{{$}}
+// NORMCWS-NEXT: {{^}}#pragma omp nothing{{$}}
+// NORMCWS-NEXT: {{^ }}#pragma omp something int e;// again a line{{$}}
+// NORMCWS-NEXT: {{^}}int f;
+
Index: clang/test/Preprocessor/macro_space.c
===
--- clang/test/Preprocessor/macro_space.c
+++ clang/test/Preprocessor/macro_space.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -E %s | FileCheck --strict-whitespace %s
+// RUN: %clang_cc1 -E -P -fnormalize-whitespace %s | FileCheck --strict-whitespace %s --check-prefix=NORMWS
 
 #define FOO1()
 #define FOO2(x)x
@@ -13,24 +14,32 @@
 
 TEST(FOO1,)
 // CHECK: FOO1 <> < > <> <> < > <> < > < >
+// NORMWS: FOO1<><><><><><><><>
 
 TEST(FOO2,)
 // CHECK: FOO2 <> < > <> <> < > <> < > < >
+// NORMWS-SAME: FOO2<><><><><><><><>
 
 TEST(FOO3,)
 // CHECK: FOO3 <> < > <> <> < > <> < > < >
+// NORMWS-SAME: FOO3<><><><><><><><>
 
 TEST(FOO4,)
 // CHECK: FOO4 < > < > < > < > < > < > < > < >

[PATCH] D98710: [clang-tidy] Add --skip-headers, part 1 (use setTraversalScope)

2021-06-19 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 353224.
chh marked an inline comment as done.
chh edited the summary of this revision.
chh added a comment.

Sync up; moved DeclFilter to ClangTidy.cpp.


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

https://reviews.llvm.org/D98710

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header1.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header2.h
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-forward-declaration-namespace.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-interfaces-global-init.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-objc-function-naming.m
  clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvm-prefer-register-over-unsigned.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx03.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx11.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-return.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-members.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
  clang/include/clang/ASTMatchers/ASTMatchFinder.h
  clang/lib/ASTMatchers/ASTMatchFinder.cpp

Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -1306,12 +1306,25 @@
MatchFinder::ParsingDoneTestCallback *ParsingDone)
   : Finder(Finder), ParsingDone(ParsingDone) {}
 
+  bool HandleTopLevelDecl(DeclGroupRef DG) override {
+Finder->HandleTopLevelDecl(DG);
+return true;
+  }
+
 private:
   void HandleTranslationUnit(ASTContext &Context) override {
 if (ParsingDone != nullptr) {
   ParsingDone->run();
 }
-Finder->matchAST(Context);
+if (Finder->hasFilter()) {
+  auto SavedScope = Context.getTraversalScope();
+  auto &MyTopDecls = Finder->getTraversalScope();
+  Context.setTraversalScope(MyTopDecls);
+  Finder->matchAST(Context);
+  Context.setTraversalScope(SavedScope);
+} else {
+  Finder->matchAST(Context);
+}
   }
 
   MatchFinder *Finder;
@@ -1454,5 +1467,44 @@
   return llvm::None;
 }
 
+// Out of line key method.
+MatchFinder::MatchFinderOptions::DeclFilter::~DeclFilter() = default;
+
+template 
+bool isTemplateSpecializationKind(const NamedDecl *D,
+  TemplateSpecializationKind Kind) {
+  if (const auto *TD = dyn_cast(D))
+return TD->getTemplateSpecializationKind() == Kind;
+  return false;
+}
+
+bool isTemplateSpecializationKind(const NamedDecl *D,
+  TemplateSpecializationKind Kind) {
+  return isTemplateSpecializationKind(D, Kind) ||
+ isTemplateSpecializationKind(D, Kind) ||
+ isTemplateSpecializationKind(D, Kind);
+}
+
+bool isImplicitTemplateInstantiation(const NamedDecl *D) {
+  return isTemplateSpecializationKind(D, TSK_ImplicitInstantiation);
+}
+
+void MatchFinder::HandleTopLevelDecl(DeclGroupRef DG) {
+  if (hasFilter()) {
+for (Decl *D : DG) {
+  if (const NamedDecl *ND = dyn_cast(D))
+if (isImplicitTemplateInstantiation(ND))
+  continue;
+
+  // ObjCMethodDecl are not actually top-level decls.
+  if (isa(D))
+continue;
+
+  if (!Options.Filter->skipDecl(D))
+TopLevelDecls.push_back(D);
+}
+  }
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: clang/include/clang/ASTMatchers/ASTMatchFinder.h
===
--- clan

[PATCH] D98710: [clang-tidy] Add --skip-headers, part 1 (use setTraversalScope)

2021-06-19 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.h:31
+
+struct DeclFilter : public OptionsDeclFilter {
+  DeclFilter(ClangTidyContext &Ctx, SourceManager &SM)

sammccall wrote:
> The layering in clang-tidy is... not particularly great or clear, but there 
> is a distinction between driver-y type code (the clang-tidy application) vs 
> the checks themselves.
> 
> As I understand our plan, this filter is "just" a way to configure the 
> traversal scope before running, i.e. what information the AST will expose to 
> the checks.
> That is, this is a driver concern and should not be visible to the checks - 
> probably should go in `ClangTidy.h` or even just `ClangTidy.cpp` as part of 
> the `ClangTidyASTConsumer`. My litmus test here is that we do have other 
> drivers (at least clangd that I know of), and they shouldn't be 
> seeing/reusing this mechanism, and so neither should checks.
> 
> (Similarly if we do something with PP in the future, hopefully this can 
> *also* be transparent to checks)
> 
> 
Thanks. Moved this class to ClangTidy.cpp.




Comment at: clang/include/clang/ASTMatchers/ASTMatchFinder.h:148
+/// Check if a Decl should be skipped.
+std::shared_ptr Filter;
   };

sammccall wrote:
> I don't think the filter belongs here.
> The design of traversal scope is that it's a property of the AST that affects 
> all traversals, so it shouldn't be a configuration property of particular 
> traversals like ASTMatchFinder.
> 
> There's a question of what to do about `MatchFinder::newASTConsumer()`, which 
> runs the finder immediately after an AST is created, and so covers the point 
> at which we might set a scope. There are several good options, e.g.:
>  - Don't provide any facility for setting traversal scope when 
> newASTConsumer() is used - it's not commonly needed, and the ASTConsumer is 
> trivial to reimplement where that's actually needed
>  - Accept an optional `function` which should run just 
> before matching starts
> 
> This seems a bit subtle, but the difference between having this in 
> MatchFinder proper vs just in newASTConsumer() is important I think, 
> precisely because it's common to run the matchers directly on an existing AST.
> 
I have some similar concerns too.

clangd calls MatchFinder::matchAST explicitly after setTraversalScope,
but clang-tidy uses MultiplexConsumer and MatchFinder::newASTConsumer
is just one of the two consumers.
(1) I am not sure if it would be safe or even work to make big changes in
ClangTidy.cpp's CreateASTConsumer to call MatchFinder::matchAST explicitly.
(2) Similarly, I wonder if setTraversalScope will work for both MatchFinder
and other consumers in the same MultiplexConsumer.

Could you check if my current change to MatchFinder::HandleTranslationUnit
is right, especially in the saving/restoring of traversal scope?

I am assuming that each consumer in a MultiplexConsumer will have its own
chance to HandleTranslationUnit and HandleTopLevelDecl.
If that's correct, it seems to me that changing those two handlers in
MatchFinder is right for clang-tidy. Then they will need the optional
MatchFinder::MatchFinderOptions::DeclFilter.




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

https://reviews.llvm.org/D98710

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