[clang] f6b94e0 - [NFC] Document the solution to pr61006 and a test for it

2023-08-11 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-08-11T14:57:32+08:00
New Revision: f6b94e0026e27dd0603e5ba39886920c02ad79f0

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

LOG: [NFC] Document the solution to pr61006 and a test for it

Address https://github.com/llvm/llvm-project/issues/61006.

The actual reason for the issue is about the usage of clang-scan-deps
instead of its functionalities since clang-scan-deps has
already considered the problem before for clang modules.

So this patch tries to document the corresponding solution
and add a test case for it to address the issue.

Added: 
clang/test/ClangScanDeps/pr61006.cppm

Modified: 
clang/docs/StandardCPlusPlusModules.rst

Removed: 




diff  --git a/clang/docs/StandardCPlusPlusModules.rst 
b/clang/docs/StandardCPlusPlusModules.rst
index 06609063c61c96..3aeb55d8f4dad4 100644
--- a/clang/docs/StandardCPlusPlusModules.rst
+++ b/clang/docs/StandardCPlusPlusModules.rst
@@ -1072,12 +1072,6 @@ the user can choose to get the dependency information 
per file. For example:
 
   $ clang-scan-deps -format=p1689 -- /clang++ 
-std=c++20 impl_part.cppm -c -o impl_part.o
 
-.. warning::
-
-   The ``/clang++`` should point to the real
-   binary and not to a symlink. If it points to a symlink the include paths
-   will not be correctly resolved.
-
 And we'll get:
 
 .. code-block:: text
@@ -1134,6 +1128,32 @@ We will get:
 When clang-scan-deps detects ``-MF`` option, clang-scan-deps will try to write 
the
 dependency information for headers to the file specified by ``-MF``.
 
+Possible Issues: Failed to find system headers
+--
+
+In case the users encounter errors like ``fatal error: 'stddef.h' file not 
found``,
+probably the specified ``/clang++`` refers to a 
symlink
+instead a real binary. There are 4 potential solutions to the problem:
+
+* (1) End users can resolve the issue by pointing the specified compiler 
executable to
+  the real binary instead of the symlink.
+* (2) End users can invoke ``/clang++ 
-print-resource-dir``
+  to get the corresponding resource directory for your compiler and add that 
directory
+  to the include search paths manually in the build scripts.
+* (3) Build systems that use a compilation database as the input for 
clang-scan-deps
+  scanner, the build system can add the flag ``--resource-dir-recipe 
invoke-compiler`` to
+  the clang-scan-deps scanner to calculate the resources directory dynamically.
+  The calculation happens only once for a unique 
``/clang++``.
+* (4) For build systems that invokes the clang-scan-deps scanner per file, 
repeatedly
+  calculating the resource directory may be inefficient. In such cases, the 
build
+  system can cache the resource directory by itself and pass ``-resource-dir 
``
+  explicitly in the command line options:
+
+.. code-block:: console
+
+  $ clang-scan-deps -format=p1689 -- /clang++ 
-std=c++20 -resource-dir  mod.cppm -c -o mod.o
+
+
 Possible Questions
 ==
 

diff  --git a/clang/test/ClangScanDeps/pr61006.cppm 
b/clang/test/ClangScanDeps/pr61006.cppm
new file mode 100644
index 00..13cfe385be2e2d
--- /dev/null
+++ b/clang/test/ClangScanDeps/pr61006.cppm
@@ -0,0 +1,44 @@
+// The slash direction in linux and windows are 
diff erent.
+// Also the command to create symbolic link is 
diff erent.
+// UNSUPPORTED: system-windows
+//
+// RUN: rm -fr %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: EXPECTED_RESOURCE_DIR=`%clang -print-resource-dir`
+// RUN: ln -s %clang++ %t/clang++
+// RUN: sed "s|EXPECTED_RESOURCE_DIR|$EXPECTED_RESOURCE_DIR|g; s|DIR|%/t|g" 
%t/P1689.json.in > %t/P1689.json
+// RUN: clang-scan-deps -compilation-database %t/P1689.json -format=p1689 | 
FileCheck %t/a.cpp -DPREFIX=%/t
+// RUN: clang-scan-deps -format=p1689 \
+// RUN:   -- %t/clang++ -std=c++20 -c -fprebuilt-module-path=%t %t/a.cpp -o 
%t/a.o \
+// RUN:  -resource-dir $EXPECTED_RESOURCE_DIR | FileCheck %t/a.cpp 
-DPREFIX=%/t
+
+//--- P1689.json.in
+[
+{
+  "directory": "DIR",
+  "command": "DIR/clang++ -std=c++20 -c -fprebuilt-module-path=DIR DIR/a.cpp 
-o DIR/a.o -resource-dir EXPECTED_RESOURCE_DIR",
+  "file": "DIR/a.cpp",
+  "output": "DIR/a.o"
+}
+]
+
+//--- a.cpp
+#include 
+import b;
+
+// CHECK: {
+// CHECK-NEXT:   "revision": 0,
+// CHECK-NEXT:   "rules": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "primary-output": "[[PREFIX]]/a.o",
+// CHECK-NEXT:   "requires": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "logical-name": "b"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ]
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "version": 1
+// CHECK-NEXT: }



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists

[PATCH] D155978: [SPIRV] Add SPIR-V logical triple.

2023-08-11 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added subscribers: iliya-diyachkov, zuban32.
pmatos added a comment.

Thanks for the patch. Left a few comments. Others can take a better look, I am 
sure. Maybe @iliya-diyachkov or @zuban32 can take a look as well.




Comment at: llvm/include/llvm/TargetParser/Triple.h:106
+wasm32,  // WebAssembly with 32-bit pointers
+wasm64,  // WebAssembly with 64-bit pointers
 renderscript32, // 32-bit RenderScript

No need to reindent the whole block to add a single line.



Comment at: llvm/lib/TargetParser/Triple.cpp:74
+  case spirv:
+return "spirv";
   case spirv32:return "spirv32";

This should be in the same line.



Comment at: llvm/lib/TargetParser/Triple.cpp:387
+  .Case("spir64", spir64)
+  .Case("spirv", spirv)
+  .Case("spirv32", spirv32)

Same as above. I guess there's no need to reindent a whole block.



Comment at: llvm/lib/TargetParser/Triple.cpp:529
+  .Case("spir64", Triple::spir64)
+  .Cases("spirv", "spirv1.0", "spirv1.1", "spirv1.2", "spirv1.3",
+ "spirv1.4", "spirv1.5", Triple::spirv)

Whole block reindent.



Comment at: llvm/unittests/TargetParser/TripleTest.cpp:1307
+  EXPECT_TRUE(T.isSPIRV());
+
   T.setArch(Triple::spirv32);

I am not well-versed in SPIRV for gfx but if we are using 32bits in SPIRV 
logical, can't we reuse spirv32? Is there some sort of strong reason not to or 
adding spirv for logical spirv as an alternative to spirv32 and spirv64 is just 
easier?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155978

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


[PATCH] D157649: [clang-tidy] Fix crash when diagnostic is emit with invalid location

2023-08-11 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL updated this revision to Diff 549263.
PiotrZSL added a comment.

Add call to DiagnosticEngine::hasSourceManager()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157649

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp


Index: clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp
@@ -25,6 +25,7 @@
 // RUN: not clang-tidy -checks='-*,modernize-use-override' 
%T/diagnostics/input.cpp -- -DCOMPILATION_ERROR 2>&1 | FileCheck 
-check-prefix=CHECK6 -implicit-check-not='{{warning:|error:}}' %s
 // RUN: clang-tidy 
-checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- 
-DMACRO_FROM_COMMAND_LINE -std=c++20 | FileCheck -check-prefix=CHECK4 
-implicit-check-not='{{warning:|error:}}' %s
 // RUN: clang-tidy 
-checks='-*,modernize-use-override,clang-diagnostic-macro-redefined,clang-diagnostic-literal-conversion'
 %s -- -DMACRO_FROM_COMMAND_LINE -std=c++20 -Wno-macro-redefined | FileCheck 
--check-prefix=CHECK7 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,modernize-use-override' %s -- -std=c++20 
-DPR64602 | FileCheck -check-prefix=CHECK8 
-implicit-check-not='{{warning:|error:}}' %s
 
 // CHECK1: error: no input files [clang-diagnostic-error]
 // CHECK1: error: no such file or directory: '{{.*}}nonexistent.cpp' 
[clang-diagnostic-error]
@@ -54,3 +55,18 @@
   // CHECK6: :[[@LINE-1]]:3: error: cannot take the address of an rvalue of 
type 'int' [clang-diagnostic-error]
 }
 #endif
+
+#ifdef PR64602 // Should not crash
+template 
+struct S
+{
+auto foo(auto);
+};
+
+template <>
+auto S<>::foo(auto)
+{
+return 1;
+}
+// CHECK8: error: template parameter list matching the non-templated nested 
type 'S<>' should be empty ('template<>') [clang-diagnostic-error]
+#endif
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -437,8 +437,11 @@
 SmallString<100> Message;
 Info.FormatDiagnostic(Message);
 FullSourceLoc Loc;
-if (Info.getLocation().isValid() && Info.hasSourceManager())
+if (Info.hasSourceManager())
   Loc = FullSourceLoc(Info.getLocation(), Info.getSourceManager());
+else if (Context.DiagEngine->hasSourceManager())
+  Loc = FullSourceLoc(Info.getLocation(),
+  Context.DiagEngine->getSourceManager());
 Converter.emitDiagnostic(Loc, DiagLevel, Message, Info.getRanges(),
  Info.getFixItHints());
   }


Index: clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp
@@ -25,6 +25,7 @@
 // RUN: not clang-tidy -checks='-*,modernize-use-override' %T/diagnostics/input.cpp -- -DCOMPILATION_ERROR 2>&1 | FileCheck -check-prefix=CHECK6 -implicit-check-not='{{warning:|error:}}' %s
 // RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- -DMACRO_FROM_COMMAND_LINE -std=c++20 | FileCheck -check-prefix=CHECK4 -implicit-check-not='{{warning:|error:}}' %s
 // RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined,clang-diagnostic-literal-conversion' %s -- -DMACRO_FROM_COMMAND_LINE -std=c++20 -Wno-macro-redefined | FileCheck --check-prefix=CHECK7 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,modernize-use-override' %s -- -std=c++20 -DPR64602 | FileCheck -check-prefix=CHECK8 -implicit-check-not='{{warning:|error:}}' %s
 
 // CHECK1: error: no input files [clang-diagnostic-error]
 // CHECK1: error: no such file or directory: '{{.*}}nonexistent.cpp' [clang-diagnostic-error]
@@ -54,3 +55,18 @@
   // CHECK6: :[[@LINE-1]]:3: error: cannot take the address of an rvalue of type 'int' [clang-diagnostic-error]
 }
 #endif
+
+#ifdef PR64602 // Should not crash
+template 
+struct S
+{
+auto foo(auto);
+};
+
+template <>
+auto S<>::foo(auto)
+{
+return 1;
+}
+// CHECK8: error: template parameter list matching the non-templated nested type 'S<>' should be empty ('template<>') [clang-diagnostic-error]
+#endif
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -437,8 +437,11 @

[clang-tools-extra] a563ced - [clang-tidy] Implement cppcoreguidelines CP.52

2023-08-11 Thread Piotr Zegar via cfe-commits

Author: Chris Cotter
Date: 2023-08-11T07:13:59Z
New Revision: a563ced78bb4bda31babb85e88a89b49ffd61a90

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

LOG: [clang-tidy] Implement cppcoreguidelines CP.52

Flag code that suspends a coroutine while a lock is held.

Reviewed By: PiotrZSL

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

Added: 
clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.h

clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/no-suspend-with-lock.rst

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/no-suspend-with-lock.cpp

Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt

clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
index c2cde34fb1336d..eb35bbc6a538fe 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
@@ -18,6 +18,7 @@ add_clang_library(clangTidyCppCoreGuidelinesModule
   MissingStdForwardCheck.cpp
   NarrowingConversionsCheck.cpp
   NoMallocCheck.cpp
+  NoSuspendWithLockCheck.cpp
   OwningMemoryCheck.cpp
   PreferMemberInitializerCheck.cpp
   ProBoundsArrayToPointerDecayCheck.cpp
@@ -50,6 +51,7 @@ add_clang_library(clangTidyCppCoreGuidelinesModule
 
 clang_target_link_libraries(clangTidyCppCoreGuidelinesModule
   PRIVATE
+  clangAnalysis
   clangAST
   clangASTMatchers
   clangBasic

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
index fdbf0e11f3f5f8..e9f0201615616f 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
@@ -32,6 +32,7 @@
 #include "MissingStdForwardCheck.h"
 #include "NarrowingConversionsCheck.h"
 #include "NoMallocCheck.h"
+#include "NoSuspendWithLockCheck.h"
 #include "OwningMemoryCheck.h"
 #include "PreferMemberInitializerCheck.h"
 #include "ProBoundsArrayToPointerDecayCheck.h"
@@ -89,6 +90,8 @@ class CppCoreGuidelinesModule : public ClangTidyModule {
 CheckFactories.registerCheck(
 "cppcoreguidelines-narrowing-conversions");
 CheckFactories.registerCheck("cppcoreguidelines-no-malloc");
+CheckFactories.registerCheck(
+"cppcoreguidelines-no-suspend-with-lock");
 CheckFactories.registerCheck(
 "cppcoreguidelines-noexcept-destructor");
 CheckFactories.registerCheck(

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.cpp
new file mode 100644
index 00..ca293178c78b47
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.cpp
@@ -0,0 +1,73 @@
+//===--- NoSuspendWithLockCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "NoSuspendWithLockCheck.h"
+#include "../utils/ExprSequence.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Analysis/CFG.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::cppcoreguidelines {
+
+void NoSuspendWithLockCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "LockGuards", LockGuards);
+}
+
+void NoSuspendWithLockCheck::registerMatchers(MatchFinder *Finder) {
+  auto LockType = elaboratedType(namesType(templateSpecializationType(
+  hasDeclaration(namedDecl(matchers::matchesAnyListedName(
+  utils::options::parseStringList(LockGuards)));
+
+  StatementMatcher Lock =
+  declStmt(has(varDecl(hasType(LockType)).bind("lock-decl")))
+  .bind("lock-decl-stmt");
+  Finder->addMatcher(
+  expr(anyOf(coawaitExpr(), coyieldExpr(), dependentCoawaitExpr()),
+   forCallable(functionDecl().bind("function")),
+   unless(isInTemplateInstantiation()),
+   hasAncestor(
+   compoundStmt(has(Lock), 
forCallable(equalsBou

[PATCH] D157057: [clang-tidy] Implement cppcoreguidelines CP.52

2023-08-11 Thread Piotr Zegar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa563ced78bb4: [clang-tidy] Implement cppcoreguidelines CP.52 
(authored by ccotter, committed by PiotrZSL).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157057

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/no-suspend-with-lock.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/no-suspend-with-lock.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/no-suspend-with-lock.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/no-suspend-with-lock.cpp
@@ -0,0 +1,279 @@
+// RUN: %check_clang_tidy -std=c++20 %s cppcoreguidelines-no-suspend-with-lock %t -- -- -fno-delayed-template-parsing
+
+// NOLINTBEGIN
+namespace std {
+template 
+struct coroutine_traits {
+  using promise_type = typename T::promise_type;
+};
+template 
+struct coroutine_handle;
+template <>
+struct coroutine_handle {
+  coroutine_handle() noexcept;
+  coroutine_handle(decltype(nullptr)) noexcept;
+  static constexpr coroutine_handle from_address(void*);
+};
+template 
+struct coroutine_handle {
+  coroutine_handle() noexcept;
+  coroutine_handle(decltype(nullptr)) noexcept;
+  static constexpr coroutine_handle from_address(void*);
+  operator coroutine_handle<>() const noexcept;
+};
+
+template 
+class unique_lock {
+public:
+  unique_lock() noexcept;
+  explicit unique_lock(Mutex &m);
+  unique_lock& operator=(unique_lock&&);
+  void unlock();
+  Mutex* release() noexcept;
+  Mutex* mutex() const noexcept;
+  void swap(unique_lock& other) noexcept;
+};
+
+class mutex {
+public:
+  mutex() noexcept;
+  ~mutex();
+  mutex(const mutex &) = delete;
+  mutex &operator=(const mutex &) = delete;
+
+  void lock();
+  void unlock();
+};
+} // namespace std
+
+class my_own_mutex {
+public:
+  void lock();
+  void unlock();
+};
+
+struct Awaiter {
+  bool await_ready() noexcept;
+  void await_suspend(std::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+struct Coro {
+  struct promise_type {
+Awaiter initial_suspend();
+Awaiter final_suspend() noexcept;
+void return_void();
+Coro get_return_object();
+void unhandled_exception();
+Awaiter yield_value(int);
+  };
+};
+// NOLINTEND
+
+std::mutex mtx;
+std::mutex mtx2;
+
+Coro awaits_with_lock() {
+  std::unique_lock lock(mtx);
+
+  co_await Awaiter{};
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: coroutine suspended with lock 'lock' held [cppcoreguidelines-no-suspend-with-lock]
+
+  co_await Awaiter{};
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: coroutine suspended with lock 'lock' held [cppcoreguidelines-no-suspend-with-lock]
+
+  if (true) {
+co_await Awaiter{};
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: coroutine suspended with lock 'lock' held [cppcoreguidelines-no-suspend-with-lock]
+  }
+
+  if (true) {
+std::unique_lock lock2;
+lock2.unlock();
+co_await Awaiter{};
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: coroutine suspended with lock 'lock2' held [cppcoreguidelines-no-suspend-with-lock]
+  }
+}
+
+Coro awaits_with_lock_in_try() try {
+  std::unique_lock lock(mtx);
+  co_await Awaiter{};
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: coroutine suspended with lock 'lock' held [cppcoreguidelines-no-suspend-with-lock]
+} catch (...) {}
+
+Coro lock_possibly_unlocked() {
+  // CppCoreGuideline CP.52's enforcement strictly requires flagging
+  // code that suspends while any lock guard is not destructed.
+
+  {
+std::unique_lock lock(mtx);
+lock.unlock();
+co_await Awaiter{};
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: coroutine suspended with lock 'lock' held [cppcoreguidelines-no-suspend-with-lock]
+  }
+
+  {
+std::unique_lock lock(mtx);
+lock.release();
+co_await Awaiter{};
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: coroutine suspended with lock 'lock' held [cppcoreguidelines-no-suspend-with-lock]
+  }
+
+  {
+std::unique_lock lock(mtx);
+std::unique_lock lock2;
+lock.swap(lock2);
+co_await Awaiter{};
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: coroutine suspended with lock 'lock' held [cppcoreguidelines-no-suspend-with-lock]
+  }
+
+  {
+std::unique_lock lock(mtx);
+std::unique_lock lock2{mtx2};
+lock.swap(lock2);
+co_await Awaiter{};
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: coroutine suspended with lock 'lock' held [cppcoreguidelines-no

[PATCH] D157680: [X86]Support options -mno-gather -mno-scatter

2023-08-11 Thread Wang, Xin via Phabricator via cfe-commits
XinWang10 created this revision.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
XinWang10 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, wangpc, MaskRay.
Herald added projects: clang, LLVM.

Gather instructions could lead to security issues, details please refer to 
https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/technical-documentation/gather-data-sampling.html.
This supported options -mno-gather and -mno-scatter, which could avoid 
generating gather/scatter instructions in backend except using intrinsics or 
inline asms.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157680

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/x86-no-gather-no-scatter.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86TargetTransformInfo.cpp
  llvm/lib/Target/X86/X86TargetTransformInfo.h
  llvm/test/CodeGen/X86/x86-prefer-no-gather-no-scatter.ll

Index: llvm/test/CodeGen/X86/x86-prefer-no-gather-no-scatter.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/x86-prefer-no-gather-no-scatter.ll
@@ -0,0 +1,202 @@
+; Check that if option prefer-no-gather/scatter can disable gather/scatter instructions.
+; RUN: llc -mattr=+avx2,+fast-gather %s -o - | FileCheck %s --check-prefixes=GATHER
+; RUN: llc -mattr=+avx2,+fast-gather,+prefer-no-gather %s -o - | FileCheck %s --check-prefixes=NO-GATHER
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu  -mattr=+avx512vl,+avx512dq < %s | FileCheck %s --check-prefix=SCATTER
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu  -mattr=+avx512vl,+avx512dq,+prefer-no-gather < %s | FileCheck %s --check-prefix=SCATTER-NO-GATHER
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu  -mattr=+avx512vl,+avx512dq,+prefer-no-scatter < %s | FileCheck %s --check-prefix=GATHER-NO-SCATTER
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu  -mattr=+avx512vl,+avx512dq,+prefer-no-gather,+prefer-no-scatter < %s | FileCheck %s --check-prefix=NO-SCATTER-GATHER
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@A = global [1024 x i8] zeroinitializer, align 128
+@B = global [1024 x i64] zeroinitializer, align 128
+@C = global [1024 x i64] zeroinitializer, align 128
+
+; This tests the function that if prefer-no-gather can disable lowerMGather
+define void @test() #0 {
+; GATHER-LABEL: test:
+; GATHER: vpgatherdq
+;
+; NO-GATHER-LABEL: test:
+; NO-GATHER-NOT: vpgatherdq
+;
+; GATHER-NO-SCATTER-LABEL: test:
+; GATHER-NO-SCATTER: vpgatherdq
+;
+; NO-SCATTER-GATHER-LABEL: test:
+; NO-SCATTER-GATHER-NOT: vpgatherdq
+iter.check:
+  br i1 false, label %vec.epilog.scalar.ph, label %vector.main.loop.iter.check
+
+vector.main.loop.iter.check:  ; preds = %iter.check
+  br i1 false, label %vec.epilog.ph, label %vector.ph
+
+vector.ph:; preds = %vector.main.loop.iter.check
+  br label %vector.body
+
+vector.body:  ; preds = %vector.body, %vector.ph
+  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
+  %0 = add i64 %index, 0
+  %1 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %0
+  %2 = getelementptr inbounds i8, ptr %1, i32 0
+  %wide.load = load <32 x i8>, ptr %2, align 1
+  %3 = sext <32 x i8> %wide.load to <32 x i64>
+  %4 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, <32 x i64> %3
+  %wide.masked.gather = call <32 x i64> @llvm.masked.gather.v32i64.v32p0(<32 x ptr> %4, i32 8, <32 x i1> , <32 x i64> poison)
+  %5 = getelementptr inbounds [1024 x i64], ptr @C, i64 0, i64 %0
+  %6 = getelementptr inbounds i64, ptr %5, i32 0
+  store <32 x i64> %wide.masked.gather, ptr %6, align 8
+  %index.next = add nuw i64 %index, 32
+  %7 = icmp eq i64 %index.next, 1024
+  br i1 %7, label %middle.block, label %vector.body, !llvm.loop !0
+
+middle.block: ; preds = %vector.body
+  %cmp.n = icmp eq i64 1024, 1024
+  br i1 %cmp.n, label %for.cond.cleanup, label %vec.epilog.iter.check
+
+vec.epilog.iter.check:; preds = %middle.block
+  br i1 true, label %vec.epilog.scalar.ph, label %vec.epilog.ph
+
+vec.epilog.ph:; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
+  %vec.epilog.resume.val = phi i64 [ 1024, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
+  br label %vec.epilog.vector.body
+
+vec.epilog.vector.body:   ; preds = %vec.epilog.vector.body, %vec.epilog.ph
+  %index2 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next5, %vec.epilog.vector.body ]
+  %8 = add i64 %index2, 0
+  %9 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %8
+  %10 = getelementptr inbounds i8, ptr %9, i32 0
+  %wide.load3 = load <16 x i8>, ptr %10, align 1
+  %11 = sext <16 x 

[clang-tools-extra] 30fed17 - [clang-tidy][NFC] Enable exceptions in no-suspend-with-lock.cpp

2023-08-11 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-11T07:29:06Z
New Revision: 30fed17a08cda324b557498a6db18dd4a0281daa

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

LOG: [clang-tidy][NFC] Enable exceptions in no-suspend-with-lock.cpp

Enable exceptions in no-suspend-with-lock.cpp, because
without them this test fails on clang-x86_64-sie-ubuntu-fast.

Added: 


Modified: 

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/no-suspend-with-lock.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/no-suspend-with-lock.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/no-suspend-with-lock.cpp
index 6944864302dce0..a6e0cd778c40cf 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/no-suspend-with-lock.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/no-suspend-with-lock.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++20 %s cppcoreguidelines-no-suspend-with-lock 
%t -- -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -std=c++20 %s cppcoreguidelines-no-suspend-with-lock 
%t -- -- -fno-delayed-template-parsing -fexceptions
 
 // NOLINTBEGIN
 namespace std {



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


[PATCH] D157680: [X86]Support options -mno-gather -mno-scatter

2023-08-11 Thread Wang, Xin via Phabricator via cfe-commits
XinWang10 updated this revision to Diff 549268.
XinWang10 added a comment.

- restore blank line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157680

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/x86-no-gather-no-scatter.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86TargetTransformInfo.cpp
  llvm/lib/Target/X86/X86TargetTransformInfo.h
  llvm/test/CodeGen/X86/x86-prefer-no-gather-no-scatter.ll

Index: llvm/test/CodeGen/X86/x86-prefer-no-gather-no-scatter.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/x86-prefer-no-gather-no-scatter.ll
@@ -0,0 +1,202 @@
+; Check that if option prefer-no-gather/scatter can disable gather/scatter instructions.
+; RUN: llc -mattr=+avx2,+fast-gather %s -o - | FileCheck %s --check-prefixes=GATHER
+; RUN: llc -mattr=+avx2,+fast-gather,+prefer-no-gather %s -o - | FileCheck %s --check-prefixes=NO-GATHER
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu  -mattr=+avx512vl,+avx512dq < %s | FileCheck %s --check-prefix=SCATTER
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu  -mattr=+avx512vl,+avx512dq,+prefer-no-gather < %s | FileCheck %s --check-prefix=SCATTER-NO-GATHER
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu  -mattr=+avx512vl,+avx512dq,+prefer-no-scatter < %s | FileCheck %s --check-prefix=GATHER-NO-SCATTER
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu  -mattr=+avx512vl,+avx512dq,+prefer-no-gather,+prefer-no-scatter < %s | FileCheck %s --check-prefix=NO-SCATTER-GATHER
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@A = global [1024 x i8] zeroinitializer, align 128
+@B = global [1024 x i64] zeroinitializer, align 128
+@C = global [1024 x i64] zeroinitializer, align 128
+
+; This tests the function that if prefer-no-gather can disable lowerMGather
+define void @test() #0 {
+; GATHER-LABEL: test:
+; GATHER: vpgatherdq
+;
+; NO-GATHER-LABEL: test:
+; NO-GATHER-NOT: vpgatherdq
+;
+; GATHER-NO-SCATTER-LABEL: test:
+; GATHER-NO-SCATTER: vpgatherdq
+;
+; NO-SCATTER-GATHER-LABEL: test:
+; NO-SCATTER-GATHER-NOT: vpgatherdq
+iter.check:
+  br i1 false, label %vec.epilog.scalar.ph, label %vector.main.loop.iter.check
+
+vector.main.loop.iter.check:  ; preds = %iter.check
+  br i1 false, label %vec.epilog.ph, label %vector.ph
+
+vector.ph:; preds = %vector.main.loop.iter.check
+  br label %vector.body
+
+vector.body:  ; preds = %vector.body, %vector.ph
+  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
+  %0 = add i64 %index, 0
+  %1 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %0
+  %2 = getelementptr inbounds i8, ptr %1, i32 0
+  %wide.load = load <32 x i8>, ptr %2, align 1
+  %3 = sext <32 x i8> %wide.load to <32 x i64>
+  %4 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, <32 x i64> %3
+  %wide.masked.gather = call <32 x i64> @llvm.masked.gather.v32i64.v32p0(<32 x ptr> %4, i32 8, <32 x i1> , <32 x i64> poison)
+  %5 = getelementptr inbounds [1024 x i64], ptr @C, i64 0, i64 %0
+  %6 = getelementptr inbounds i64, ptr %5, i32 0
+  store <32 x i64> %wide.masked.gather, ptr %6, align 8
+  %index.next = add nuw i64 %index, 32
+  %7 = icmp eq i64 %index.next, 1024
+  br i1 %7, label %middle.block, label %vector.body, !llvm.loop !0
+
+middle.block: ; preds = %vector.body
+  %cmp.n = icmp eq i64 1024, 1024
+  br i1 %cmp.n, label %for.cond.cleanup, label %vec.epilog.iter.check
+
+vec.epilog.iter.check:; preds = %middle.block
+  br i1 true, label %vec.epilog.scalar.ph, label %vec.epilog.ph
+
+vec.epilog.ph:; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
+  %vec.epilog.resume.val = phi i64 [ 1024, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
+  br label %vec.epilog.vector.body
+
+vec.epilog.vector.body:   ; preds = %vec.epilog.vector.body, %vec.epilog.ph
+  %index2 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next5, %vec.epilog.vector.body ]
+  %8 = add i64 %index2, 0
+  %9 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %8
+  %10 = getelementptr inbounds i8, ptr %9, i32 0
+  %wide.load3 = load <16 x i8>, ptr %10, align 1
+  %11 = sext <16 x i8> %wide.load3 to <16 x i64>
+  %12 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, <16 x i64> %11
+  %wide.masked.gather4 = call <16 x i64> @llvm.masked.gather.v16i64.v16p0(<16 x ptr> %12, i32 8, <16 x i1> , <16 x i64> poison)
+  %13 = getelementptr inbounds [1024 x i64], ptr @C, i64 0, i64 %8
+  %14 = getelementptr inbounds i64, ptr %13, i32 0
+  store <16 x i64> %wide.masked.gather4, ptr %14, align 8
+  %index.next5 = add nuw i64 %index2, 16
+  %15 = icmp eq i64 %inde

[PATCH] D149017: [RISCV] Rewrite all found class-based subroutines to functions

2023-08-11 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu added a comment.

Is it going to commit?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149017

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


[PATCH] D157681: [clang][AST] TextNodeDumper learned to dump qualifiers (NestedNameSpecifier)

2023-08-11 Thread Timo Stripf via Phabricator via cfe-commits
strimo378 created this revision.
Herald added a project: All.
strimo378 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157681

Files:
  clang/include/clang/AST/TextNodeDumper.h
  clang/lib/AST/TextNodeDumper.cpp
  clang/test/AST/ast-dump-decl.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_namespace_1.cpp
  clang/test/AST/ast-dump-using.cpp

Index: clang/test/AST/ast-dump-using.cpp
===
--- clang/test/AST/ast-dump-using.cpp
+++ clang/test/AST/ast-dump-using.cpp
@@ -6,6 +6,7 @@
 namespace b {
 using a::S;
 // CHECK:  UsingDecl {{.*}} a::S
+// CHECK-NEXT: | `-NestedNameSpecifier NamespaceNamespace {{.*}} 'a'
 // CHECK-NEXT: UsingShadowDecl {{.*}} implicit CXXRecord {{.*}} 'S'
 // CHECK-NEXT: `-RecordType {{.*}} 'a::S'
 typedef S f; // to dump the introduced type
Index: clang/test/AST/ast-dump-openmp-begin-declare-variant_namespace_1.cpp
===
--- clang/test/AST/ast-dump-openmp-begin-declare-variant_namespace_1.cpp
+++ clang/test/AST/ast-dump-openmp-begin-declare-variant_namespace_1.cpp
@@ -114,10 +114,12 @@
 // CHECK-NEXT: |   | |-CallExpr [[ADDR_47:0x[a-z0-9]*]]  'int'
 // CHECK-NEXT: |   | | `-ImplicitCastExpr [[ADDR_48:0x[a-z0-9]*]]  'int (*)({{.*}})' 
 // CHECK-NEXT: |   | |   `-DeclRefExpr [[ADDR_49:0x[a-z0-9]*]]  'int ({{.*}})' {{.*}}Function [[ADDR_1]] 'foo' 'int ({{.*}})'
+// CHECK-NEXT: |   | |   `-NestedNameSpecifier NamespaceNamespace [[ADDR_0]] 'A'
 // CHECK-NEXT: |   | `-PseudoObjectExpr [[ADDR_50:0x[a-z0-9]*]]  'int'
 // CHECK-NEXT: |   |   |-CallExpr [[ADDR_51:0x[a-z0-9]*]]  'int'
 // CHECK-NEXT: |   |   | `-ImplicitCastExpr [[ADDR_52:0x[a-z0-9]*]]  'int (*)({{.*}})' 
 // CHECK-NEXT: |   |   |   `-DeclRefExpr [[ADDR_53:0x[a-z0-9]*]]  'int ({{.*}})' {{.*}}Function [[ADDR_6]] 'bar' 'int ({{.*}})'
+// CHECK-NEXT: |   |   |   `-NestedNameSpecifier NamespaceNamespace [[ADDR_31]] 'B'
 // CHECK-NEXT: |   |   `-CallExpr [[ADDR_54:0x[a-z0-9]*]]  'int'
 // CHECK-NEXT: |   | `-ImplicitCastExpr [[ADDR_55:0x[a-z0-9]*]]  'int (*)({{.*}})' 
 // CHECK-NEXT: |   |   `-DeclRefExpr [[ADDR_11]]  'int ({{.*}})' Function [[ADDR_12]] 'bar[implementation={vendor(llvm)}]' 'int ({{.*}})'
@@ -125,6 +127,7 @@
 // CHECK-NEXT: | |-CallExpr [[ADDR_57:0x[a-z0-9]*]]  'int'
 // CHECK-NEXT: | | `-ImplicitCastExpr [[ADDR_58:0x[a-z0-9]*]]  'int (*)({{.*}})' 
 // CHECK-NEXT: | |   `-DeclRefExpr [[ADDR_59:0x[a-z0-9]*]]  'int ({{.*}})' {{.*}}Function [[ADDR_14]] 'baz' 'int ({{.*}})'
+// CHECK-NEXT: | |   `-NestedNameSpecifier NamespaceNamespace [[ADDR_13]] 'C'
 // CHECK-NEXT: | `-CallExpr [[ADDR_60:0x[a-z0-9]*]]  'int'
 // CHECK-NEXT: |   `-ImplicitCastExpr [[ADDR_61:0x[a-z0-9]*]]  'int (*)({{.*}})' 
 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_19]]  'int ({{.*}})' Function [[ADDR_20]] 'baz[implementation={vendor(llvm)}]' 'int ({{.*}})'
Index: clang/test/AST/ast-dump-expr.cpp
===
--- clang/test/AST/ast-dump-expr.cpp
+++ clang/test/AST/ast-dump-expr.cpp
@@ -224,6 +224,8 @@
   p->::S::~S();
   // CHECK: CXXMemberCallExpr 0x{{[^ ]*}}  'void'
   // CHECK-NEXT: MemberExpr 0x{{[^ ]*}}  '' ->~S 0x{{[^ ]*}}
+  // CHECK-NEXT: NestedNameSpecifier TypeSpec 'S'
+  // CHECK-NEXT: NestedNameSpecifier Global
   // CHECK-NEXT: ImplicitCastExpr
   // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'S *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'S *'
 
@@ -231,6 +233,7 @@
   r->template U::~U();
   // CHECK: CXXMemberCallExpr 0x{{[^ ]*}}  'void'
   // CHECK-NEXT: MemberExpr 0x{{[^ ]*}}  '' ->~U 0x{{[^ ]*}}
+  // CHECK-NEXT: NestedNameSpecifier TypeSpecWithTemplate 'U':'U'
   // CHECK-NEXT: ImplicitCastExpr
   // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'U *' lvalue ParmVar 0x{{[^ ]*}} 'r' 'U *'
 
Index: clang/test/AST/ast-dump-decl.cpp
===
--- clang/test/AST/ast-dump-decl.cpp
+++ clang/test/AST/ast-dump-decl.cpp
@@ -609,24 +609,27 @@
   // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}}  col:25 referenced typename depth 0 index 0 T
   // CHECK-NEXT: |-VarDecl 0x{{.+}}  col:43 TestVarTemplate 'const T' static
   // CHECK-NEXT: |-VarTemplateSpecializationDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}}  col:14 referenced TestVarTemplate 'const int':'const int' cinit
+  // CHECK-NEXT: | |-NestedNameSpecifier TypeSpec 'testCanonicalTemplate::S'
   // CHECK-NEXT: | |-TemplateArgument type 'int'
   // CHECK-NEXT: | | `-BuiltinType 0x{{.+}} 'int'
   // CHECK-NEXT: | `-InitListExpr 0x{{.+}}  'int':'int'
-  // CHECK-NEXT: `-VarTemplateSpecializationDecl 0x{{.+}}  col:43 referenced TestVarTemplate 'const int':'const int' static
+  // CHECK-NEXT: `-VarTemplateSpecial

[PATCH] D156320: [Flang][Driver] Add support for Rpass and related options

2023-08-11 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added inline comments.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:156-158
+/// Parse a remark command line argument. It may be missing, disabled/enabled 
by
+/// '-R[no-]group' or specified with a regular expression by '-Rgroup=regexp'.
+/// On top of that, it can be disabled/enabled globally by '-R[no-]everything'.

kiranchandramohan wrote:
> awarzynski wrote:
> > Could you give an example (and write a test ) for `-Rgroup=regexp`. Also, 
> > @kiranchandramohan , is this form actually needed? I am thinking that it's 
> > a complexity that could be avoided. It  could definitely simplify this 
> > patch.
> `Rpass=regex` is used, particularly `Rpass=.`. So this is required, but can 
> be deferred to a separate patch to simplify this one.
>  can be deferred to a separate patch to simplify this one

That would be a small win - the complexity comes from the fact that we can't 
rely on TableGen to define all possible options. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156320

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


[PATCH] D157684: [clang][ASTImporter] Repeated friend templates are partially imported

2023-08-11 Thread Ding Fei via Phabricator via cfe-commits
danix800 created this revision.
danix800 added reviewers: balazske, aaron.ballman.
danix800 added a project: clang.
Herald added subscribers: pengfei, martong, kristof.beyls.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: All.
danix800 requested review of this revision.
Herald added a subscriber: cfe-commits.

1. Repeated friends of template class/function in template class are partially 
imported:

  template 
  class Container {
template  friend void m();
template  friend void m();
  };

Only one `m` can be imported,

`FromTu`:

  ClassTemplateDecl 0x5590cff47ae0  line:3:15 Container
  |-TemplateTypeParmDecl 0x5590cff47990  col:25 class depth 
0 index 0 T
  `-CXXRecordDecl 0x5590cff47a50  line:3:15 class Container 
definition
|-DefinitionData empty aggregate standard_layout trivially_copyable pod 
trivial literal has_constexpr_non_copy_move_ctor can_const_default_init
| |-DefaultConstructor exists trivial constexpr needs_implicit 
defaulted_is_constexpr
| |-CopyConstructor simple trivial has_const_param needs_implicit 
implicit_has_const_param
| |-MoveConstructor exists simple trivial needs_implicit
| |-CopyAssignment simple trivial has_const_param needs_implicit 
implicit_has_const_param
| |-MoveAssignment exists simple trivial needs_implicit
| `-Destructor simple irrelevant trivial needs_implicit
|-CXXRecordDecl 0x5590cff47d30  col:15 implicit class 
Container
|-FriendDecl 0x5590cff48048  col:42
| `-FunctionTemplateDecl 0x5590cff47f80 parent 0x5590cfefeda8  col:42 m
|   |-TemplateTypeParmDecl 0x5590cff47dc0  col:27 class 
depth 1 index 0 U
|   `-FunctionDecl 0x5590cff47ec8 parent 0x5590cfefeda8  
col:42 m 'void ()'
`-FriendDecl 0x5590cff48260  col:42
  `-FunctionTemplateDecl 0x5590cff481f8 parent 0x5590cfefeda8  col:42 m
|-TemplateTypeParmDecl 0x5590cff48088  col:27 class 
depth 1 index 0 U
`-FunctionDecl 0x5590cff48140 parent 0x5590cfefeda8  
col:42 m 'void ()'

`ToTu`:

  ClassTemplateDecl 0x5590cffe3ad8  line:3:15 Container
  |-TemplateTypeParmDecl 0x5590cffe3950  col:25 class depth 
0 index 0 T
  `-CXXRecordDecl 0x5590cffe3a10  line:3:15 class Container 
definition
|-DefinitionData empty aggregate standard_layout trivially_copyable pod 
trivial literal has_constexpr_non_copy_move_ctor can_const_default_init
| |-DefaultConstructor exists trivial constexpr needs_implicit 
defaulted_is_constexpr
| |-CopyConstructor simple trivial has_const_param needs_implicit 
implicit_has_const_param
| |-MoveConstructor exists simple trivial needs_implicit
| |-CopyAssignment simple trivial has_const_param needs_implicit 
implicit_has_const_param
| |-MoveAssignment exists simple trivial needs_implicit
| `-Destructor simple irrelevant trivial needs_implicit
|-FunctionTemplateDecl 0x5590cffe3ef8 parent 0x5590cff9b128  col:42 m // extranous node
| |-TemplateTypeParmDecl 0x5590cffe3d20  col:27 class depth 
1 index 0 U
| `-FunctionDecl 0x5590cffe3e28 parent 0x5590cff9b128  
col:42 m 'void ()'
|-FriendDecl 0x5590cffe3f60  col:42
| `-FunctionTemplateDecl 0x5590cffe3ef8 parent 0x5590cff9b128  col:42 m
|   |-TemplateTypeParmDecl 0x5590cffe3d20  col:27 class 
depth 1 index 0 U
|   `-FunctionDecl 0x5590cffe3e28 parent 0x5590cff9b128  
col:42 m 'void ()'
`-CXXRecordDecl 0x5590cffe3fa0  col:15 implicit class 
Container

Also note that an extranous `FunctionTemplateDecl 0x5590cffe3ef8` is added into 
this `ClassTemplateDecl 0x5590cffe3ad8` lexical context, which
renders it NOT identical to the original DeclContext, even after the second 
friend is successfully imported, this extra node would crash 
`clang-import-test`.
Plan to fix it in another revision.

2. Import single friend node `m` into existing context would crash with an 
assertion failure:

  ./build/tools/clang/unittests/AST/ASTTests 
--gtest_filter="*ImportFriendClasses.ImportOfRepeatedFriendFunctionTemplateDecl*"
 |& sed 's/danis/x/'
  Note: Google Test filter = 
*ImportFriendClasses.ImportOfRepeatedFriendFunctionTemplateDecl*
  [==] Running 4 tests from 1 test suite.
  [--] Global test environment set-up.
  [--] 4 tests from ParameterizedTests/ImportFriendClasses
  [ RUN  ] 
ParameterizedTests/ImportFriendClasses.ImportOfRepeatedFriendFunctionTemplateDecl/0
  ASTTests: 
/home/x/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:4139: 
clang::ExpectedDecl clang::ASTNodeImporter::VisitFriendDecl(clang::FriendDecl 
*): Assertion `ImportedEquivalentFriends.size() <= CountAndPosition.TotalCount 
&& "Class with non-matching friends is imported, ODR check wrong?"' failed.
   #0 0x7f1f53bf812a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
/home/x/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:602:11
   #1 0x7f1f53bf82db PrintStackTraceSignalHandler(void*) 
/home/x/Sources/llvm-project-main/llvm/lib/Support/Uni

[PATCH] D157684: [clang][ASTImporter] Repeated friend templates are partially imported

2023-08-11 Thread Ding Fei via Phabricator via cfe-commits
danix800 added a comment.

By `FromContext` dump it's easy to observe that there're two different 
`FunctionTemplateDecl` (`0x5590cff48048` and `0x5590cff481f8`):

  |-FriendDecl 0x5590cff48048  col:42
  | `-FunctionTemplateDecl 0x5590cff47f80 parent 0x5590cfefeda8  col:42 m
  |   |-...
  `-FriendDecl 0x5590cff48260  col:42
`-FunctionTemplateDecl 0x5590cff481f8 parent 0x5590cfefeda8  col:42 m
  |-...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157684

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


[PATCH] D140828: [C++] Implement "Deducing this" (P0847R7)

2023-08-11 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/include/clang/AST/DeclCXX.h:2063-2064
   bool isInstance() const { return !isStatic(); }
+  bool isExplicitObjectMemberFunction() const;
+  bool isImplicitObjectMemberFunction() const;
+  const ParmVarDecl *getNonObjectParameter(unsigned I) const {

Can you add some documentation to these?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140828

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


[PATCH] D157687: [clang][AST] TextNodeDumper learned to dump NRVO candidates of return stmts

2023-08-11 Thread Timo Stripf via Phabricator via cfe-commits
strimo378 created this revision.
strimo378 added a reviewer: aaron.ballman.
Herald added a project: All.
strimo378 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157687

Files:
  clang/include/clang/AST/TextNodeDumper.h
  clang/lib/AST/TextNodeDumper.cpp


Index: clang/lib/AST/TextNodeDumper.cpp
===
--- clang/lib/AST/TextNodeDumper.cpp
+++ clang/lib/AST/TextNodeDumper.cpp
@@ -995,6 +995,14 @@
 OS << " gnu_range";
 }
 
+void clang::TextNodeDumper::VisitReturnStmt(const ReturnStmt *Node) {
+  if (const VarDecl *Cand = Node->getNRVOCandidate()) {
+OS << " nrvo_candidate(";
+dumpBareDeclRef(Cand);
+OS << ")";
+  }
+}
+
 void TextNodeDumper::VisitConstantExpr(const ConstantExpr *Node) {
   if (Node->hasAPValueResult())
 AddChild("value",
Index: clang/include/clang/AST/TextNodeDumper.h
===
--- clang/include/clang/AST/TextNodeDumper.h
+++ clang/include/clang/AST/TextNodeDumper.h
@@ -246,6 +246,7 @@
   void VisitLabelStmt(const LabelStmt *Node);
   void VisitGotoStmt(const GotoStmt *Node);
   void VisitCaseStmt(const CaseStmt *Node);
+  void VisitReturnStmt(const ReturnStmt *Node);
   void VisitCompoundStmt(const CompoundStmt *Node);
   void VisitConstantExpr(const ConstantExpr *Node);
   void VisitCallExpr(const CallExpr *Node);


Index: clang/lib/AST/TextNodeDumper.cpp
===
--- clang/lib/AST/TextNodeDumper.cpp
+++ clang/lib/AST/TextNodeDumper.cpp
@@ -995,6 +995,14 @@
 OS << " gnu_range";
 }
 
+void clang::TextNodeDumper::VisitReturnStmt(const ReturnStmt *Node) {
+  if (const VarDecl *Cand = Node->getNRVOCandidate()) {
+OS << " nrvo_candidate(";
+dumpBareDeclRef(Cand);
+OS << ")";
+  }
+}
+
 void TextNodeDumper::VisitConstantExpr(const ConstantExpr *Node) {
   if (Node->hasAPValueResult())
 AddChild("value",
Index: clang/include/clang/AST/TextNodeDumper.h
===
--- clang/include/clang/AST/TextNodeDumper.h
+++ clang/include/clang/AST/TextNodeDumper.h
@@ -246,6 +246,7 @@
   void VisitLabelStmt(const LabelStmt *Node);
   void VisitGotoStmt(const GotoStmt *Node);
   void VisitCaseStmt(const CaseStmt *Node);
+  void VisitReturnStmt(const ReturnStmt *Node);
   void VisitCompoundStmt(const CompoundStmt *Node);
   void VisitConstantExpr(const ConstantExpr *Node);
   void VisitCallExpr(const CallExpr *Node);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149017: [RISCV] Rewrite all found class-based subroutines to functions

2023-08-11 Thread Wang Pengcheng via Phabricator via cfe-commits
wangpc added a comment.

In D149017#4579179 , @zixuan-wu wrote:

> Is it going to commit?

This patch is stuck since the patch to support function/lambda is WIP (I may 
not work on it recently).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149017

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


[PATCH] D140828: [C++] Implement "Deducing this" (P0847R7)

2023-08-11 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin marked 2 inline comments as done.
cor3ntin added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:4330-4331
+ExprResult Res = FixOverloadedFunctionReference(From, Found, Fn);
+if (Res.isInvalid())
+  return ExprError();
 

cor3ntin wrote:
> aaron.ballman wrote:
> > Do you have test coverage for this change or is it an NFC change?
> Before this patch `FixOverloadedFunctionReference` would never fail, now it 
> can, in some places. I think it is covered by tests but I'll double check. 
> The change here is mechanical, the important changes are in 
> `FixOverloadedFunctionReference`
I remember.
Before this patch, taking the address of an overloaded function was always 
valid because lookup would always find either a static function or an implicit 
function.
But now it can find an explicit function which _requires_ a 
nested-name-qualifier (otherwise it is ill-formed), but we can only emit that 
diagnostic once we resolve to a particular function.
https://eel.is/c++draft/expr.unary.op#3.2.sentence-2

This is tested in `test/SemaCXX/cxx2b-deducing-this.cpp` L237 
Because of this new error, `FixOverloadedFunctionReference` can fail - it could 
not before - and so it's modified to return an `ExprResult`, and all call sites 
are modified. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140828

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


[PATCH] D157680: [X86]Support options -mno-gather -mno-scatter

2023-08-11 Thread Wang Pengcheng via Phabricator via cfe-commits
wangpc added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:7527
+  // -mno-gather, -mno-scatter support
+  if (Args.hasArg(options::OPT_mno_gather)) {
+CmdArgs.push_back("-target-feature");

Put these in `clang/lib/Driver/ToolChains/Arch/X86.cpp:getX86TargetFeatures`? 
They are target-specific.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157680

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


[PATCH] D155978: [SPIRV] Add SPIR-V logical triple.

2023-08-11 Thread Nathan Gauër via Phabricator via cfe-commits
Keenuts updated this revision to Diff 549288.
Keenuts added a comment.

Revert "clang-format"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155978

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/SPIR.cpp
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/TargetParser/Triple.h
  llvm/lib/TargetParser/Triple.cpp
  llvm/unittests/TargetParser/TripleTest.cpp

Index: llvm/unittests/TargetParser/TripleTest.cpp
===
--- llvm/unittests/TargetParser/TripleTest.cpp
+++ llvm/unittests/TargetParser/TripleTest.cpp
@@ -325,6 +325,132 @@
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::UnknownOS, T.getOS());
 
+  T = Triple("spirv-unknown-shadermodel-pixel");
+  EXPECT_EQ(Triple::spirv, T.getArch());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::ShaderModel, T.getOS());
+  EXPECT_EQ(Triple::Pixel, T.getEnvironment());
+
+  T = Triple("spirv-unknown-shadermodel-vertex");
+  EXPECT_EQ(Triple::spirv, T.getArch());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::ShaderModel, T.getOS());
+  EXPECT_EQ(Triple::Vertex, T.getEnvironment());
+
+  T = Triple("spirv-unknown-shadermodel-geometry");
+  EXPECT_EQ(Triple::spirv, T.getArch());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::ShaderModel, T.getOS());
+  EXPECT_EQ(Triple::Geometry, T.getEnvironment());
+
+  T = Triple("spirv-unknown-shadermodel-library");
+  EXPECT_EQ(Triple::spirv, T.getArch());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::ShaderModel, T.getOS());
+  EXPECT_EQ(Triple::Library, T.getEnvironment());
+
+  T = Triple("spirv-unknown-shadermodel-raygeneration");
+  EXPECT_EQ(Triple::spirv, T.getArch());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::ShaderModel, T.getOS());
+  EXPECT_EQ(Triple::RayGeneration, T.getEnvironment());
+
+  T = Triple("spirv-unknown-shadermodel-intersection");
+  EXPECT_EQ(Triple::spirv, T.getArch());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::ShaderModel, T.getOS());
+  EXPECT_EQ(Triple::Intersection, T.getEnvironment());
+
+  T = Triple("spirv-unknown-shadermodel-anyhit");
+  EXPECT_EQ(Triple::spirv, T.getArch());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::ShaderModel, T.getOS());
+  EXPECT_EQ(Triple::AnyHit, T.getEnvironment());
+
+  T = Triple("spirv-unknown-shadermodel-closesthit");
+  EXPECT_EQ(Triple::spirv, T.getArch());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::ShaderModel, T.getOS());
+  EXPECT_EQ(Triple::ClosestHit, T.getEnvironment());
+
+  T = Triple("spirv-unknown-shadermodel-miss");
+  EXPECT_EQ(Triple::spirv, T.getArch());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::ShaderModel, T.getOS());
+  EXPECT_EQ(Triple::Miss, T.getEnvironment());
+
+  T = Triple("spirv-unknown-shadermodel-callable");
+  EXPECT_EQ(Triple::spirv, T.getArch());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::ShaderModel, T.getOS());
+  EXPECT_EQ(Triple::Callable, T.getEnvironment());
+
+  T = Triple("spirv-unknown-shadermodel-mesh");
+  EXPECT_EQ(Triple::spirv, T.getArch());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::ShaderModel, T.getOS());
+  EXPECT_EQ(Triple::Mesh, T.getEnvironment());
+
+  T = Triple("spirv-unknown-shadermodel-amplification");
+  EXPECT_EQ(Triple::spirv, T.getArch());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::ShaderModel, T.getOS());
+  EXPECT_EQ(Triple::Amplification, T.getEnvironment());
+
+  T = Triple("spirv1.0-unknown-shadermodel-compute");
+  EXPECT_EQ(Triple::spirv, T.getArch());
+  EXPECT_EQ(Triple::SPIRVSubArch_v10, T.getSubArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::ShaderModel, T.getOS());
+  EXPECT_EQ(Triple::Compute, T.getEnvironment());
+
+  T = Triple("spirv1.1-unknown-shadermodel-compute");
+  EXPECT_EQ(Triple::spirv, T.getArch());
+  EXPECT_EQ(Triple::SPIRVSubArch_v11, T.getSubArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::ShaderModel, T.getOS());
+  EXPECT_EQ(Triple::Compute, T.getEnvironment());
+

[PATCH] D155978: [SPIRV] Add SPIR-V logical triple.

2023-08-11 Thread Nathan Gauër via Phabricator via cfe-commits
Keenuts marked 4 inline comments as done.
Keenuts added a comment.

Thanks for the review 😊
Reverted clang-format patch, and answered inline.




Comment at: llvm/include/llvm/TargetParser/Triple.h:106
+wasm32,  // WebAssembly with 32-bit pointers
+wasm64,  // WebAssembly with 64-bit pointers
 renderscript32, // 32-bit RenderScript

pmatos wrote:
> No need to reindent the whole block to add a single line.
IIRC it I did a clang-format because the buildbot complained the format was not 
right.
Reverted the clang-format commit (which seems better, I agree), and I'll see if 
the bots complains.



Comment at: llvm/unittests/TargetParser/TripleTest.cpp:1307
+  EXPECT_TRUE(T.isSPIRV());
+
   T.setArch(Triple::spirv32);

pmatos wrote:
> I am not well-versed in SPIRV for gfx but if we are using 32bits in SPIRV 
> logical, can't we reuse spirv32? Is there some sort of strong reason not to 
> or adding spirv for logical spirv as an alternative to spirv32 and spirv64 is 
> just easier?
This is a very valid question! And I'm not sure of the best option.
My understanding is: in logical SPIR-V, there are no notion of pointer size, or 
architecture size. We cannot offset pointers by a sizeof(), or do such things.

But the options I had didn't seem to allow this kind of "undefined 
architecture".
I chose 32bits here because the IDs are 32bit. But pointer addresses are not, 
so returning 32bit is not quite right either.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155978

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


[PATCH] D134475: [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute

2023-08-11 Thread Richard Dzenis via Phabricator via cfe-commits
RIscRIpt updated this revision to Diff 549298.
RIscRIpt added a comment.

Rebase onto main (bump)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134475

Files:
  clang/docs/ReleaseNotes.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Basic/Targets/OSTargets.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/AST/ms-constexpr.cpp
  clang/test/Driver/cl-options.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaCXX/ms-constexpr-invalid.cpp
  clang/test/SemaCXX/ms-constexpr-new.cpp
  clang/test/SemaCXX/ms-constexpr.cpp

Index: clang/test/SemaCXX/ms-constexpr.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/ms-constexpr.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fms-compatibility -fms-compatibility-version=19.33 -std=c++20 -verify %s
+// expected-no-diagnostics
+
+[[msvc::constexpr]] int log2(int x) { [[msvc::constexpr]] return x > 1 ? 1 + log2(x / 2) : 0; }
+constexpr bool test_log2() { [[msvc::constexpr]] return log2(32) == 5; }
+static_assert(test_log2());
+
+[[msvc::constexpr]] int get_value(int x)
+{
+  switch (x)
+  {
+case 42: return 1337;
+default:
+ if (x < 0) [[msvc::constexpr]] return log2(-x);
+ else return x;
+  }
+}
+
+constexpr bool test_complex_expr() {
+  [[msvc::constexpr]] return get_value(get_value(42) - 1337 + get_value(-32) - 5 + (get_value(1) ? get_value(0) : get_value(2))) == get_value(0);
+}
+static_assert(test_complex_expr());
+
+constexpr bool get_constexpr_true() { return true; }
+[[msvc::constexpr]] bool get_msconstexpr_true() { return get_constexpr_true(); }
+constexpr bool test_get_msconstexpr_true() { [[msvc::constexpr]] return get_msconstexpr_true(); }
+static_assert(test_get_msconstexpr_true());
+
+/*
+// TODO: Add support for [[msvc::constexpr]] constructor
+struct S2 {
+[[msvc::constexpr]] S2() {}
+[[msvc::constexpr]] bool value() { return true; }
+static constexpr bool check() { [[msvc::constexpr]] return S2{}.value(); }
+};
+static_assert(S2::check());
+*/
Index: clang/test/SemaCXX/ms-constexpr-new.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/ms-constexpr-new.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fms-compatibility -fms-compatibility-version=19.33 -std=c++20 -verify=supported %s
+// RUN: %clang_cc1 -fms-compatibility -fms-compatibility-version=19.32 -std=c++20 -verify=unsupported %s
+// supported-no-diagnostics
+
+[[nodiscard]]
+[[msvc::constexpr]] // unsupported-warning {{unknown attribute 'constexpr' ignored}}
+inline void* __cdecl operator new(decltype(sizeof(void*)), void* p) noexcept { return p; }
+
+namespace std {
+  constexpr int* construct_at(int* p, int v) {
+[[msvc::constexpr]] return ::new (p) int(v); // unsupported-warning {{unknown attribute 'constexpr' ignored}}
+  }
+}
+
+constexpr bool check_construct_at() { int x; return *std::construct_at(&x, 42) == 42; }
+static_assert(check_construct_at());
Index: clang/test/SemaCXX/ms-constexpr-invalid.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/ms-constexpr-invalid.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -fms-compatibility -fms-compatibility-version=19.33 -std=c++20 -verify %s
+// RUN: %clang_cc1 -fms-compatibility -fms-compatibility-version=19.33 -std=c++17 -verify %s
+
+// Check explicitly invalid code
+
+void runtime() {} // expected-note {{declared here}}
+
+[[msvc::constexpr]] void f0() { runtime(); } // expected-error {{[[msvc::constexpr]] function never produces a constant expression}} \
+ // expected-note {{non-constexpr function 'runtime' cannot be used in a constant expression}}
+[[msvc::constexpr]] constexpr void f1() {} // expected-error {{[[msvc::constexpr]] cannot be applied to a constexpr function 'f1'}}
+#if __cplusplus >= 202202L
+[[msvc::constexpr]] consteval void f2() {} // expected-error {{[[msvc::constexpr]] cannot be applied to a consteval function 'f2'}}
+#endif
+
+struct B1 {};
+struct D1 : virtual B1 { // expected-note {{virtual base class declared here}}
+[[msvc::constexpr]] D1() {} // expected-error {{constexpr constructor not allowed in struct with virtual base class}}
+};
+
+struct [[msvc::constexpr]] S2{}; // expected-error {{'constexpr' attribute only applies to functions and statements}}
+
+// Check invalid code mixed with valid code
+
+[[msvc::constexpr]] int f4(int x) { return x > 1 ? 1 + f4(x / 2) : 0; } // expected-note {{non-constexpr function 'f4' can

[PATCH] D157691: [ASTImporter] Remove extranous FunctionTemplateDecl introduced by templated friend

2023-08-11 Thread Ding Fei via Phabricator via cfe-commits
danix800 created this revision.
danix800 added reviewers: balazske, aaron.ballman.
danix800 added a project: clang.
Herald added subscribers: pengfei, martong, kristof.beyls.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: All.
danix800 requested review of this revision.
Herald added a subscriber: cfe-commits.

An extranous `FunctionTemplateDecl` is introduced in the following testcase:

  template  struct A {
template  friend void f();
  };

`From`:

  ClassTemplateDecl 0x55dae7001500  col:30 A
  |-TemplateTypeParmDecl 0x55dae70013b0  col:20 typename depth 
0 index 0 T
  `-CXXRecordDecl 0x55dae7001470  col:30 struct A definition
|-DefinitionData empty aggregate standard_layout trivially_copyable pod 
trivial literal has_constexpr_non_copy_move_ctor can_const_default_init
| |-DefaultConstructor exists trivial constexpr needs_implicit 
defaulted_is_constexpr
| |-CopyConstructor simple trivial has_const_param needs_implicit 
implicit_has_const_param
| |-MoveConstructor exists simple trivial needs_implicit
| |-CopyAssignment simple trivial has_const_param needs_implicit 
implicit_has_const_param
| |-MoveAssignment exists simple trivial needs_implicit
| `-Destructor simple irrelevant trivial needs_implicit
|-CXXRecordDecl 0x55dae7001750  col:30 implicit struct A
`-FriendDecl 0x55dae7001a68  col:69
  `-FunctionTemplateDecl 0x55dae70019a0 parent 0x55dae6f97e28  col:69 f
|-TemplateTypeParmDecl 0x55dae70017e0  col:54 typename 
depth 1 index 0 U
`-FunctionDecl 0x55dae70018e8 parent 0x55dae6f97e28  
col:69 f 'void ()'

`To`:

  ClassTemplateDecl 0x55dae7116618  col:30 A
  |-TemplateTypeParmDecl 0x55dae7116490  col:20 typename depth 
0 index 0 T
  `-CXXRecordDecl 0x55dae7116550  col:30 struct A definition
|-DefinitionData empty aggregate standard_layout trivially_copyable pod 
trivial literal has_constexpr_non_copy_move_ctor can_const_default_init
| |-DefaultConstructor exists trivial constexpr needs_implicit 
defaulted_is_constexpr
| |-CopyConstructor simple trivial has_const_param needs_implicit 
implicit_has_const_param
| |-MoveConstructor exists simple trivial needs_implicit
| |-CopyAssignment simple trivial has_const_param needs_implicit 
implicit_has_const_param
| |-MoveAssignment exists simple trivial needs_implicit
| `-Destructor simple irrelevant trivial needs_implicit
|-FunctionTemplateDecl 0x55dae7116a38 parent 0x55dae6fa2b68  col:69 f// extranous node
| |-TemplateTypeParmDecl 0x55dae7116860  col:54 typename 
depth 1 index 0 U
| `-FunctionDecl 0x55dae7116968 parent 0x55dae6fa2b68  
col:69 f 'void ()'
|-FriendDecl 0x55dae7116aa0  col:69
| `-FunctionTemplateDecl 0x55dae7116a38 parent 0x55dae6fa2b68  col:69 f
|   |-TemplateTypeParmDecl 0x55dae7116860  col:54 typename 
depth 1 index 0 U
|   `-FunctionDecl 0x55dae7116968 parent 0x55dae6fa2b68  
col:69 f 'void ()'
`-CXXRecordDecl 0x55dae7116ae0  col:30 implicit struct A

`clang-import-test` would crash on this case:

  clang-import-test: 
/home/x/Sources/llvm-project-main/clang/lib/AST/ExternalASTMerger.cpp:533: 
auto clang::ExternalASTMerger::FindExternalLexicalDecls(const 
clang::DeclContext *, llvm::function_ref, 
SmallVectorImpl &)::(anonymous 
class)::operator()(clang::ASTImporter &, clang::ASTImporter &, Source) const: Assertion `!(*ImportedDeclOrErr) || 
IsSameDC((*ImportedDeclOrErr)->getDeclContext(), DC)' failed.
  f #0 0x7fec39df812a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
/home/x/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:602:11
   #1 0x7fec39df82db PrintStackTraceSignalHandler(void*) 
/home/x/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:675:1
   #2 0x7fec39df6846 llvm::sys::RunSignalHandlers() 
/home/x/Sources/llvm-project-main/llvm/lib/Support/Signals.cpp:104:5
   #3 0x7fec39df8af5 SignalHandler(int) 
/home/x/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:413:1
   #4 0x7fec3985afd0 (/lib/x86_64-linux-gnu/libc.so.6+0x3bfd0)
   #5 0x7fec398a9d3c __pthread_kill_implementation 
./nptl/pthread_kill.c:44:76
   #6 0x7fec3985af32 raise ./signal/../sysdeps/posix/raise.c:27:6
   #7 0x7fec39845472 abort ./stdlib/abort.c:81:7
   #8 0x7fec39845395 _nl_load_domain ./intl/loadmsgcat.c:1177:9
   #9 0x7fec39853e32 (/lib/x86_64-linux-gnu/libc.so.6+0x34e32)
  #10 0x7fec3c90c203 
clang::ExternalASTMerger::FindExternalLexicalDecls(clang::DeclContext const*, 
llvm::function_ref, 
llvm::SmallVectorImpl&)::$_5::operator()(clang::ASTImporter&, 
clang::ASTImporter&, (anonymous namespace)::Source) 
const 
/home/x/Sources/llvm-project-main/clang/lib/AST/ExternalASTMerger.cpp:532:11
  #11 0x7fec3c9094a7 void 
clang::ExternalASTMerger::ForEachMatchingDC, 
llvm::SmallVectorImpl&)::$_5>(clang::DeclContext const*, 
clang::ExternalASTMerger::FindExternalLexicalDecls

[PATCH] D157693: [clang][doc] Mark _Float16 is support natively when Zfh or Zfhmin is available

2023-08-11 Thread Jianjian Guan via Phabricator via cfe-commits
jacquesguan created this revision.
jacquesguan added reviewers: craig.topper, asb, luismarques, frasercrmck, luke.
Herald added subscribers: s.egerton, simoncook.
Herald added a project: All.
jacquesguan requested review of this revision.
Herald added subscribers: cfe-commits, wangpc.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157693

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -812,6 +812,7 @@
   * AMDGPU (natively)
   * SPIR (natively)
   * X86 (if SSE2 is available; natively if AVX512-FP16 is also available)
+  * RISC-V (natively if Zfh or Zfhmin is available)
 
 * ``__bf16`` is supported on the following targets (currently never natively):
   * 32-bit ARM


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -812,6 +812,7 @@
   * AMDGPU (natively)
   * SPIR (natively)
   * X86 (if SSE2 is available; natively if AVX512-FP16 is also available)
+  * RISC-V (natively if Zfh or Zfhmin is available)
 
 * ``__bf16`` is supported on the following targets (currently never natively):
   * 32-bit ARM
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157693: [clang][doc] Mark _Float16 is support natively when Zfh or Zfhmin is available

2023-08-11 Thread Jianjian Guan via Phabricator via cfe-commits
jacquesguan updated this revision to Diff 549311.
jacquesguan added a comment.

remove zfmin


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157693

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -812,6 +812,7 @@
   * AMDGPU (natively)
   * SPIR (natively)
   * X86 (if SSE2 is available; natively if AVX512-FP16 is also available)
+  * RISC-V (natively if Zfh is available)
 
 * ``__bf16`` is supported on the following targets (currently never natively):
   * 32-bit ARM


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -812,6 +812,7 @@
   * AMDGPU (natively)
   * SPIR (natively)
   * X86 (if SSE2 is available; natively if AVX512-FP16 is also available)
+  * RISC-V (natively if Zfh is available)
 
 * ``__bf16`` is supported on the following targets (currently never natively):
   * 32-bit ARM
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156237: Complete the implementation of P2361 Unevaluated string literals

2023-08-11 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 549314.
cor3ntin added a comment.

Rebase, add C tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156237

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Parser/MicrosoftExtensions.cpp
  clang/test/Parser/c2x-attributes.c
  clang/test/Parser/cxx-attributes.cpp
  clang/test/Parser/cxx0x-attributes.cpp
  clang/test/Sema/MicrosoftExtensions.c
  clang/test/Sema/annotate-type.c
  clang/test/Sema/annotate.c
  clang/test/Sema/attr-assume.c
  clang/test/Sema/attr-btf_tag.c
  clang/test/Sema/attr-btf_type_tag.c
  clang/test/Sema/attr-capabilities.c
  clang/test/Sema/attr-enforce-tcb-errors.cpp
  clang/test/Sema/attr-enforce-tcb-errors.m
  clang/test/Sema/attr-error.c
  clang/test/Sema/attr-handles.cpp
  clang/test/Sema/attr-section.c
  clang/test/Sema/attr-tls_model.c
  clang/test/Sema/attr-unavailable-message.c
  clang/test/Sema/attr-warning.c
  clang/test/Sema/diagnose_if.c
  clang/test/Sema/enable_if.c
  clang/test/SemaCXX/attr-deprecated-replacement-error.cpp
  clang/test/SemaCXX/attr-no-sanitize.cpp
  clang/test/SemaCXX/attr-section.cpp
  clang/test/SemaCXX/attr-weakref.cpp
  clang/test/SemaCXX/suppress.cpp
  clang/test/SemaObjC/attr-swift_bridge.m
  clang/test/SemaObjC/objc-asm-attribute-neg-test.m
  clang/test/SemaObjC/validate-attr-swift_attr.m
  clang/test/SemaTemplate/attributes.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -115,12 +115,7 @@
  
   Unevaluated strings
   https://wg21.link/P2361R6";>P2361R6
-  
-
-  Clang 17 (Partial)
-  Attributes arguments don't yet parse as unevaluated string literals.
-
-  
+  Clang 18
  
  
   Add @, $, and ` to the basic character set
Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -2297,6 +2297,22 @@
  .Default(false);
 }
 
+static bool isStringLiteralArgument(const Record *Arg) {
+  return !Arg->getSuperClasses().empty() &&
+ llvm::StringSwitch(
+ Arg->getSuperClasses().back().first->getName())
+ .Case("StringArgument", true)
+ .Default(false);
+}
+
+static bool isVariadicStringLiteralArgument(const Record *Arg) {
+  return !Arg->getSuperClasses().empty() &&
+ llvm::StringSwitch(
+ Arg->getSuperClasses().back().first->getName())
+ .Case("VariadicStringArgument", true)
+ .Default(false);
+}
+
 static void emitClangAttrVariadicIdentifierArgList(RecordKeeper &Records,
raw_ostream &OS) {
   OS << "#if defined(CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST)\n";
@@ -2317,6 +2333,34 @@
   OS << "#endif // CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST\n\n";
 }
 
+// Emits the list of arguments that shoulkd be parsed as unevaluated string
+// literals for each attributes
+static void emitClangAttrUnevaluatedStringLiteralList(RecordKeeper &Records,
+  raw_ostream &OS) {
+  OS << "#if defined(CLANG_ATTR_STRING_LITERAL_ARG_LIST)\n";
+  std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
+  for (const auto *Attr : Attrs) {
+std::vector Args = Attr->getValueAsListOfDefs("Args");
+uint32_t Bits = 0;
+for (uint32_t N = 0; N < Args.size(); N++) {
+  Bits |= (isStringLiteralArgument(Args[N]) << N);
+  // If we have a variadic string argument, set all the remaining bits to 1
+  if (isVariadicStringLiteralArgument(Args[N])) {
+for (; N < sizeof(uint32_t); N++)
+  Bits |= (1 << N);
+break;
+  }
+}
+if (!Bits)
+  continue;
+// All these spellings have at least one string literal has argument.
+forEachUniqueSpelling(*Attr, [&](const FlattenedSpelling &S) {
+  OS << ".Case(\"" << S.name() << "\", " << Bits << ")\n";
+});
+  }
+  OS << "#endif // CLANG_ATTR_STRING_LITERAL_ARG_LIST\n\n";
+}
+
 // Emits the first-argument-is-identifier property for attributes.
 static void emitClangAttrIdentifierArgList(RecordKeeper &Records, raw_ostream &OS) {
   OS << "#if defined(CLANG_ATTR_IDENTIFIER_ARG_LIST)\n";
@@ -4611,6 +4655,7 @@
   emitSourceFileHeader("Parser-related llvm::StringSwitch cases", OS);
   emitClangAttrArgContextList(Records, OS);
   emitClangAttrIdentifierArgList(Records, OS);
+  emitClangAttrUnevaluatedStringLiteralList(Records, OS);
   emitClangAttrVariadicIdentifierArgList(Records, OS)

[PATCH] D156858: Add Documentation for Execution Results Handling in Clang-REPL

2023-08-11 Thread QuillPusher via Phabricator via cfe-commits
QuillPusher accepted this revision.
QuillPusher added a comment.
This revision is now accepted and ready to land.

accepting current revision, one minor change is still required, adding that 
separately


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156858

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


[clang-tools-extra] 5568f28 - [clang-tidy][NFC] Update gen-static-analyzer-docs.py

2023-08-11 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-11T10:36:45Z
New Revision: 5568f28c868eb13033d64189560ee0e62d745285

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

LOG: [clang-tidy][NFC] Update gen-static-analyzer-docs.py

Update gen-static-analyzer-docs.py to generate more proper documentation
for Clang Static Analyzer checkers.

Fixes: #43715

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py

Removed: 




diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py 
b/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py
index 1e54cd53bc455c..92b89c1c173985 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py
+++ b/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py
@@ -3,7 +3,6 @@
 References Checkers.td to determine what checks exist
 """
 
-import argparse
 import subprocess
 import json
 import os
@@ -12,28 +11,31 @@
 """Get path of script so files are always in correct directory"""
 __location__ = os.path.realpath(os.path.join(os.getcwd(), 
os.path.dirname(__file__)))
 
+default_checkers_td_location = 
"../../../../clang/include/clang/StaticAnalyzer/Checkers/Checkers.td"
+default_checkers_rst_location = "../../../../clang/docs/analyzer/checkers.rst"
+
 """Get dict of checker related info and parse for full check names
 
 Returns:
   checkers: dict of checker info
 """
-
-
-def get_checkers(checkers_td_directory):
+def get_checkers(checkers_td, checkers_rst):
 p = subprocess.Popen(
 [
 "llvm-tblgen",
 "--dump-json",
 "-I",
-checkers_td_directory,
-checkers_td_directory + "Checkers.td",
+os.path.dirname(checkers_td),
+checkers_td,
 ],
 stdout=subprocess.PIPE,
 )
 table_entries = json.loads(p.communicate()[0])
 documentable_checkers = []
 checkers = table_entries["!instanceof"]["Checker"]
-packages = table_entries["!instanceof"]["Package"]
+
+with open(checkers_rst, "r") as f:
+checker_rst_text = f.read()
 
 for checker_ in checkers:
 checker = table_entries[checker_]
@@ -62,7 +64,9 @@ def get_checkers(checkers_td_directory):
 
 if not hidden and "alpha" not in full_package_name.lower():
 checker["FullPackageName"] = full_package_name
+checker["ShortName"] = checker_package_prefix + "." + checker_name
 checker["AnchorUrl"] = anchor_url
+checker["Documentation"] = ".. _%s:" % 
(checker["ShortName"].replace(".","-")) in checker_rst_text
 documentable_checkers.append(checker)
 
 documentable_checkers.sort(key=lambda x: x["FullPackageName"])
@@ -73,17 +77,15 @@ def get_checkers(checkers_td_directory):
 
 Args:
   checker: Checker for which to generate documentation.
-  only_help_text: Generate documentation based off the checker description.
-Used when there is no other documentation to link to.
+  has_documentation: Specify that there is other documentation to link to.
 """
+def generate_documentation(checker, has_documentation):
 
-
-def generate_documentation(checker, only_help_text=False):
 with open(
-os.path.join(__location__, checker["FullPackageName"] + ".rst"), "w"
+os.path.join(__location__, "clang-analyzer", checker["ShortName"] + 
".rst"), "w"
 ) as f:
 f.write(".. title:: clang-tidy - %s\n" % checker["FullPackageName"])
-if not only_help_text:
+if has_documentation:
 f.write(".. meta::\n")
 f.write(
 "   :http-equiv=refresh: 
5;URL=https://clang.llvm.org/docs/analyzer/checkers.html#%s\n";
@@ -92,18 +94,31 @@ def generate_documentation(checker, only_help_text=False):
 f.write("\n")
 f.write("%s\n" % checker["FullPackageName"])
 f.write("=" * len(checker["FullPackageName"]) + "\n")
-f.write("\n")
-if only_help_text:
-f.write("%s\n" % checker["HelpText"])
-else:
+help_text = checker["HelpText"].strip()
+if not help_text.endswith("."):
+help_text += "."
+characters = 80
+for word in help_text.split(" "):
+if characters+len(word)+1 > 80:
+characters = len(word)
+f.write("\n")
+f.write(word)
+else:
+f.write(" ")
+f.write(word)
+characters += len(word) + 1
+f.write("\n\n")
+if has_documentation:
 f.write(
 "The %s check is an alias, please see\n" % 
checker["FullPackageName"]
 )
 f.write(
-"`Clang Static Analyzer Available Checkers 


[PATCH] D156858: Add Documentation for Execution Results Handling in Clang-REPL

2023-08-11 Thread QuillPusher via Phabricator via cfe-commits
QuillPusher requested changes to this revision.
QuillPusher added a comment.
This revision now requires changes to proceed.

Added minor changes requested by Vassil




Comment at: clang/docs/ClangRepl.rst:296
+
+For example, the CPPYY code makes use of this feature to enable running 
+C++ within Python. It enables transporting values/information between C++ 

@Krishna-13-cyber 

Please change CPPYY to cppyy

I just saw they use small caps on their official website



Comment at: clang/docs/ClangRepl.rst:298
+C++ within Python. It enables transporting values/information between C++ 
+and Python.
+

@Krishna-13-cyber 

Please add the following note under this paragraph, as requested by Vassil in 
previous comment:

**Note:** `cppyy`_ is an automatic, run-time, Python-to-C++ bindings 
generator, for calling C++ from Python and Python from C++. It uses LLVM along 
with a C++ interpreter (e.g., Cling) to enable features like run-time 
instantiation of C++ templates, cross-inheritance, callbacks, auto-casting, 
transparent use of smart pointers, etc.

.. _cppyy: https://github.com/wlav/cppyy/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156858

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


[clang-tools-extra] cd9e923 - [clang-tidy][NFC] Update add_new_check.py to handle more proper list.rst

2023-08-11 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-11T11:02:28Z
New Revision: cd9e92309d1733219f439d663ec9a4c3d59e6650

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

LOG: [clang-tidy][NFC] Update add_new_check.py to handle more proper list.rst

Update script to generate list.rst in format that is
in-sync with gen-static-analyzer-docs.py.
Re-generate list.rst.

Added: 


Modified: 
clang-tools-extra/clang-tidy/add_new_check.py
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/add_new_check.py 
b/clang-tools-extra/clang-tidy/add_new_check.py
index c642000eba2283..520212883d9976 100755
--- a/clang-tools-extra/clang-tidy/add_new_check.py
+++ b/clang-tools-extra/clang-tidy/add_new_check.py
@@ -483,7 +483,7 @@ def process_doc(doc_file):
 
 def format_link(doc_file):
 check_name, match = process_doc(doc_file)
-if not match and check_name:
+if not match and check_name and not 
check_name.startswith("clang-analyzer-"):
 return "   `%(check_name)s 
<%(module)s/%(check)s.html>`_,%(autofix)s\n" % {
 "check_name": check_name,
 "module": doc_file[0],
@@ -495,13 +495,13 @@ def format_link(doc_file):
 
 def format_link_alias(doc_file):
 check_name, match = process_doc(doc_file)
-if match and check_name:
+if (match or (check_name.startswith("clang-analyzer-"))) and 
check_name:
 module = doc_file[0]
 check_file = doc_file[1].replace(".rst", "")
-if match.group(1) == 
"https://clang.llvm.org/docs/analyzer/checkers":
+if not match or match.group(1) == 
"https://clang.llvm.org/docs/analyzer/checkers":
 title = "Clang Static Analyzer " + check_file
 # Preserve the anchor in checkers.html from group 2.
-target = match.group(1) + ".html" + match.group(2)
+target = "" if not match else match.group(1) + ".html" + 
match.group(2)
 autofix = ""
 else:
 redirect_parts = re.search("^\.\./([^/]*)/([^/]*)$", 
match.group(1))
@@ -509,18 +509,30 @@ def format_link_alias(doc_file):
 target = redirect_parts[1] + "/" + redirect_parts[2] + ".html"
 autofix = has_auto_fix(title)
 
-# The checker is just a redirect.
-return (
-"   `%(check_name)s <%(module)s/%(check_file)s.html>`_, 
`%(title)s <%(target)s>`_,%(autofix)s\n"
-% {
-"check_name": check_name,
-"module": module,
-"check_file": check_file,
-"target": target,
-"title": title,
-"autofix": autofix,
-}
-)
+if target:
+# The checker is just a redirect.
+return (
+"   `%(check_name)s <%(module)s/%(check_file)s.html>`_, 
`%(title)s <%(target)s>`_,%(autofix)s\n"
+% {
+"check_name": check_name,
+"module": module,
+"check_file": check_file,
+"target": target,
+"title": title,
+"autofix": autofix,
+})
+else:
+# The checker is just a alias without redirect.
+return (
+"   `%(check_name)s <%(module)s/%(check_file)s.html>`_, 
%(title)s,%(autofix)s\n"
+% {
+"check_name": check_name,
+"module": module,
+"check_file": check_file,
+"target": target,
+"title": title,
+"autofix": autofix,
+})
 return ""
 
 checks = map(format_link, doc_files)

diff  --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst 
b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index f4c835247ab9ed..6dfdf34e9d026f 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -165,26 +165,6 @@ Clang-Tidy Checks
`cert-msc51-cpp `_,
`cert-oop57-cpp `_,
`cert-oop58-cpp `_,
-   `clang-analyzer-core.DynamicTypePropagation 
`_,
-   `clang-analyzer-core.uninitialized.CapturedBlockVariable 
`_,
-   `clang-analyzer-cplusplus.InnerPointer 
`_,
-   `clang-analyzer-nullability.NullableReturnedFromNonnull 
`_,
-   `clang-analyzer-optin.osx.OSObjectCStyleCast 
`_,
-   `clang-analyzer-optin.performance.GCDAntipattern 
`_,
-   `clang-analyzer-optin.performance.Padding 
`_,
-   `clang-analyzer-optin.portability.Uni

[PATCH] D157702: [clang][analyzer][NFC] Change PlacementNewChecker into PlacementNew in documentation

2023-08-11 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL created this revision.
Herald added subscribers: manas, steakhal, ASDenysPetrov, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: All.
PiotrZSL requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Check name according to Checkers.td is actually a PlacementNew.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157702

Files:
  clang/docs/analyzer/checkers.rst


Index: clang/docs/analyzer/checkers.rst
===
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -321,9 +321,9 @@
int *p = new int;
  } // warn
 
-.. _cplusplus-PlacementNewChecker:
+.. _cplusplus-PlacementNew:
 
-cplusplus.PlacementNewChecker (C++)
+cplusplus.PlacementNew (C++)
 """
 Check if default placement new is provided with pointers to sufficient storage 
capacity.
 


Index: clang/docs/analyzer/checkers.rst
===
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -321,9 +321,9 @@
int *p = new int;
  } // warn
 
-.. _cplusplus-PlacementNewChecker:
+.. _cplusplus-PlacementNew:
 
-cplusplus.PlacementNewChecker (C++)
+cplusplus.PlacementNew (C++)
 """
 Check if default placement new is provided with pointers to sufficient storage capacity.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157702: [clang][analyzer][NFC] Change PlacementNewChecker into PlacementNew in documentation

2023-08-11 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL updated this revision to Diff 549336.
PiotrZSL added a comment.

Micro fix ("" characters).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157702

Files:
  clang/docs/analyzer/checkers.rst


Index: clang/docs/analyzer/checkers.rst
===
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -321,10 +321,10 @@
int *p = new int;
  } // warn
 
-.. _cplusplus-PlacementNewChecker:
+.. _cplusplus-PlacementNew:
 
-cplusplus.PlacementNewChecker (C++)
-"""
+cplusplus.PlacementNew (C++)
+
 Check if default placement new is provided with pointers to sufficient storage 
capacity.
 
 .. code-block:: cpp


Index: clang/docs/analyzer/checkers.rst
===
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -321,10 +321,10 @@
int *p = new int;
  } // warn
 
-.. _cplusplus-PlacementNewChecker:
+.. _cplusplus-PlacementNew:
 
-cplusplus.PlacementNewChecker (C++)
-"""
+cplusplus.PlacementNew (C++)
+
 Check if default placement new is provided with pointers to sufficient storage capacity.
 
 .. code-block:: cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157680: [X86]Support options -mno-gather -mno-scatter

2023-08-11 Thread Wang, Xin via Phabricator via cfe-commits
XinWang10 updated this revision to Diff 549337.
XinWang10 added a comment.

- mv driver implement to x86 specific code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157680

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-no-gather-no-scatter.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86TargetTransformInfo.cpp
  llvm/lib/Target/X86/X86TargetTransformInfo.h
  llvm/test/CodeGen/X86/x86-prefer-no-gather-no-scatter.ll

Index: llvm/test/CodeGen/X86/x86-prefer-no-gather-no-scatter.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/x86-prefer-no-gather-no-scatter.ll
@@ -0,0 +1,202 @@
+; Check that if option prefer-no-gather/scatter can disable gather/scatter instructions.
+; RUN: llc -mattr=+avx2,+fast-gather %s -o - | FileCheck %s --check-prefixes=GATHER
+; RUN: llc -mattr=+avx2,+fast-gather,+prefer-no-gather %s -o - | FileCheck %s --check-prefixes=NO-GATHER
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu  -mattr=+avx512vl,+avx512dq < %s | FileCheck %s --check-prefix=SCATTER
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu  -mattr=+avx512vl,+avx512dq,+prefer-no-gather < %s | FileCheck %s --check-prefix=SCATTER-NO-GATHER
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu  -mattr=+avx512vl,+avx512dq,+prefer-no-scatter < %s | FileCheck %s --check-prefix=GATHER-NO-SCATTER
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu  -mattr=+avx512vl,+avx512dq,+prefer-no-gather,+prefer-no-scatter < %s | FileCheck %s --check-prefix=NO-SCATTER-GATHER
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@A = global [1024 x i8] zeroinitializer, align 128
+@B = global [1024 x i64] zeroinitializer, align 128
+@C = global [1024 x i64] zeroinitializer, align 128
+
+; This tests the function that if prefer-no-gather can disable lowerMGather
+define void @test() #0 {
+; GATHER-LABEL: test:
+; GATHER: vpgatherdq
+;
+; NO-GATHER-LABEL: test:
+; NO-GATHER-NOT: vpgatherdq
+;
+; GATHER-NO-SCATTER-LABEL: test:
+; GATHER-NO-SCATTER: vpgatherdq
+;
+; NO-SCATTER-GATHER-LABEL: test:
+; NO-SCATTER-GATHER-NOT: vpgatherdq
+iter.check:
+  br i1 false, label %vec.epilog.scalar.ph, label %vector.main.loop.iter.check
+
+vector.main.loop.iter.check:  ; preds = %iter.check
+  br i1 false, label %vec.epilog.ph, label %vector.ph
+
+vector.ph:; preds = %vector.main.loop.iter.check
+  br label %vector.body
+
+vector.body:  ; preds = %vector.body, %vector.ph
+  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
+  %0 = add i64 %index, 0
+  %1 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %0
+  %2 = getelementptr inbounds i8, ptr %1, i32 0
+  %wide.load = load <32 x i8>, ptr %2, align 1
+  %3 = sext <32 x i8> %wide.load to <32 x i64>
+  %4 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, <32 x i64> %3
+  %wide.masked.gather = call <32 x i64> @llvm.masked.gather.v32i64.v32p0(<32 x ptr> %4, i32 8, <32 x i1> , <32 x i64> poison)
+  %5 = getelementptr inbounds [1024 x i64], ptr @C, i64 0, i64 %0
+  %6 = getelementptr inbounds i64, ptr %5, i32 0
+  store <32 x i64> %wide.masked.gather, ptr %6, align 8
+  %index.next = add nuw i64 %index, 32
+  %7 = icmp eq i64 %index.next, 1024
+  br i1 %7, label %middle.block, label %vector.body, !llvm.loop !0
+
+middle.block: ; preds = %vector.body
+  %cmp.n = icmp eq i64 1024, 1024
+  br i1 %cmp.n, label %for.cond.cleanup, label %vec.epilog.iter.check
+
+vec.epilog.iter.check:; preds = %middle.block
+  br i1 true, label %vec.epilog.scalar.ph, label %vec.epilog.ph
+
+vec.epilog.ph:; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
+  %vec.epilog.resume.val = phi i64 [ 1024, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
+  br label %vec.epilog.vector.body
+
+vec.epilog.vector.body:   ; preds = %vec.epilog.vector.body, %vec.epilog.ph
+  %index2 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next5, %vec.epilog.vector.body ]
+  %8 = add i64 %index2, 0
+  %9 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %8
+  %10 = getelementptr inbounds i8, ptr %9, i32 0
+  %wide.load3 = load <16 x i8>, ptr %10, align 1
+  %11 = sext <16 x i8> %wide.load3 to <16 x i64>
+  %12 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, <16 x i64> %11
+  %wide.masked.gather4 = call <16 x i64> @llvm.masked.gather.v16i64.v16p0(<16 x ptr> %12, i32 8, <16 x i1> , <16 x i64> poison)
+  %13 = getelementptr inbounds [1024 x i64], ptr @C, i64 0, i64 %8
+  %14 = getelementptr inbounds i64, ptr %13, i32 0
+  store <16 x i64> %wide.masked.gather4, ptr %14, align 8
+  %index.next5 = add nuw i64 %index2, 16
+

[clang-tools-extra] 0ce056a - [C23] Rename C2x -> C23; NFC

2023-08-11 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-08-11T07:43:43-04:00
New Revision: 0ce056a814f8dbfd8d9b7720ce1df489c6ba5ddb

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

LOG: [C23] Rename C2x -> C23; NFC

This does the rename for most internal uses of C2x, but does not rename
or reword diagnostics (those will be done in a follow-up).

I also updated standards references and citations to the final wording
in the standard.

Added: 


Modified: 
clang-tools-extra/clangd/index/StdLib.cpp
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/ExprCXX.h
clang/include/clang/AST/PrettyPrinter.h
clang/include/clang/AST/Type.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttributeCommonInfo.h
clang/include/clang/Basic/Features.def
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Basic/LangStandard.h
clang/include/clang/Basic/LangStandards.def
clang/include/clang/Basic/Specifiers.h
clang/include/clang/Basic/TokenKinds.def
clang/include/clang/Driver/Options.td
clang/include/clang/Lex/LiteralSupport.h
clang/include/clang/Parse/Parser.h
clang/lib/AST/CommentSema.cpp
clang/lib/AST/Expr.cpp
clang/lib/Basic/Attributes.cpp
clang/lib/Basic/IdentifierTable.cpp
clang/lib/Basic/LangOptions.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Headers/limits.h
clang/lib/Headers/stdint.h
clang/lib/Headers/stdnoreturn.h
clang/lib/Lex/Lexer.cpp
clang/lib/Lex/LiteralSupport.cpp
clang/lib/Lex/PPDirectives.cpp
clang/lib/Lex/PPExpressions.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Parse/ParseInit.cpp
clang/lib/Parse/ParseStmt.cpp
clang/lib/Parse/Parser.cpp
clang/lib/Sema/AnalysisBasedWarnings.cpp
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaType.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/StdLib.cpp 
b/clang-tools-extra/clangd/index/StdLib.cpp
index f12b246255c9f1..477a5d1ebe523f 100644
--- a/clang-tools-extra/clangd/index/StdLib.cpp
+++ b/clang-tools-extra/clangd/index/StdLib.cpp
@@ -59,7 +59,7 @@ LangStandard::Kind standardFromOpts(const LangOptions &LO) {
   return LangStandard::lang_cxx11;
 return LangStandard::lang_cxx98;
   }
-  if (LO.C2x)
+  if (LO.C23)
 return LangStandard::lang_c23;
   // C17 has no new features, so treat {C11,C17} as C17.
   if (LO.C11)

diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 40cadd93158c68..181b3362f7d649 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1693,7 +1693,7 @@ class ASTContext : public RefCountedBase {
   /// Return a ObjCObjectPointerType type for the given ObjCObjectType.
   QualType getObjCObjectPointerType(QualType OIT) const;
 
-  /// C2x feature and GCC extension.
+  /// C23 feature and GCC extension.
   QualType getTypeOfExprType(Expr *E, TypeOfKind Kind) const;
   QualType getTypeOfType(QualType QT, TypeOfKind Kind) const;
 

diff  --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index f5e805257ce5a5..02fa997d674c8c 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -760,7 +760,7 @@ class CXXBoolLiteralExpr : public Expr {
 /// The null pointer literal (C++11 [lex.nullptr])
 ///
 /// Introduced in C++11, the only literal of type \c nullptr_t is \c nullptr.
-/// This also implements the null pointer literal in C2x (C2x 6.4.1) which is
+/// This also implements the null pointer literal in C23 (C23 6.4.1) which is
 /// intended to have the same semantics as the feature in C++.
 class CXXNullPtrLiteralExpr : public Expr {
 public:

diff  --git a/clang/include/clang/AST/PrettyPrinter.h 
b/clang/include/clang/AST/PrettyPrinter.h
index 8a0bc6dfb57b8c..cee3cce7729c30 100644
--- a/clang/include/clang/AST/PrettyPrinter.h
+++ b/clang/include/clang/AST/PrettyPrinter.h
@@ -66,7 +66,7 @@ struct PrintingPolicy {
 SuppressLifetimeQualifiers(false),
 SuppressTemplateArgsInCXXConstructors(false),
 SuppressDefaultTemplateArgs(true), Bool(LO.Bool),
-Nullptr(LO.CPlusPlus11 || LO.C2x), 
NullptrTypeInNamespace(LO.CPlusPlus),
+Nullptr(LO.CPlusPlus11 || LO.C23), 
NullptrTypeInNamespace(LO.CPlusPlus),
 Restrict(LO.C99), Alignof(LO.CPlusPlus11), UnderscoreAlignof(LO.C11),
 

[PATCH] D157651: [RISCV] Rewrite CheckInvalidVLENandLMUL to avoid floating point.

2023-08-11 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat accepted this revision.
4vtomat added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!




Comment at: clang/lib/Sema/SemaChecking.cpp:4484
+  unsigned EGS = EGW / ElemSize;
+  // If EGS is more than our minimum number of elements we're done.
+  if (EGS <= ElemCount)

Does the `EGS` here mean the `ElemCount`?
If it does, can we change the `EGS` in the comment to other name, since when I 
first see this comment, I just thought the `EGS` here means the argument name 
lol~


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157651

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


[PATCH] D155978: [SPIRV] Add SPIR-V logical triple.

2023-08-11 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added inline comments.



Comment at: llvm/include/llvm/TargetParser/Triple.h:106
+wasm32,  // WebAssembly with 32-bit pointers
+wasm64,  // WebAssembly with 64-bit pointers
 renderscript32, // 32-bit RenderScript

Keenuts wrote:
> pmatos wrote:
> > No need to reindent the whole block to add a single line.
> IIRC it I did a clang-format because the buildbot complained the format was 
> not right.
> Reverted the clang-format commit (which seems better, I agree), and I'll see 
> if the bots complains.
I know what you did and it makes sense - I did the same myself while working on 
another backend but lets try not to change such a large amount of lines in a 
patch focused on something else. I think it's certainly better to propose this 
change in a single NFC patch if we think that clang-format output is better 
than the existing formatting.



Comment at: llvm/unittests/TargetParser/TripleTest.cpp:1307
+  EXPECT_TRUE(T.isSPIRV());
+
   T.setArch(Triple::spirv32);

Keenuts wrote:
> pmatos wrote:
> > I am not well-versed in SPIRV for gfx but if we are using 32bits in SPIRV 
> > logical, can't we reuse spirv32? Is there some sort of strong reason not to 
> > or adding spirv for logical spirv as an alternative to spirv32 and spirv64 
> > is just easier?
> This is a very valid question! And I'm not sure of the best option.
> My understanding is: in logical SPIR-V, there are no notion of pointer size, 
> or architecture size. We cannot offset pointers by a sizeof(), or do such 
> things.
> 
> But the options I had didn't seem to allow this kind of "undefined 
> architecture".
> I chose 32bits here because the IDs are 32bit. But pointer addresses are not, 
> so returning 32bit is not quite right either.
> 
> 
This is a tricky one tbh - I would have to do a bit more research to have a 
more insighful reply here. Maybe @mpaszkowski or @Anastasia can add more.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155978

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


[clang] 6e0fc88 - Fix examples after C2x renaming

2023-08-11 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-08-11T08:01:17-04:00
New Revision: 6e0fc88836a8ecc4520f6be09d392c03e21d8b40

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

LOG: Fix examples after C2x renaming

This amends 0ce056a814f8dbfd8d9b7720ce1df489c6ba5ddb and fixes an
example that was not built locally for me.

Added: 


Modified: 
clang/examples/Attribute/Attribute.cpp

Removed: 




diff  --git a/clang/examples/Attribute/Attribute.cpp 
b/clang/examples/Attribute/Attribute.cpp
index 008da2e18e44f2..9d6cf9ae36c6a6 100644
--- a/clang/examples/Attribute/Attribute.cpp
+++ b/clang/examples/Attribute/Attribute.cpp
@@ -29,10 +29,10 @@ struct ExampleAttrInfo : public ParsedAttrInfo {
 // number of arguments. This just illustrates how many arguments a
 // `ParsedAttrInfo` can hold, we will not use that much in this example.
 OptArgs = 15;
-// GNU-style __attribute__(("example")) and C++/C2x-style [[example]] and
+// GNU-style __attribute__(("example")) and C++/C23-style [[example]] and
 // [[plugin::example]] supported.
 static constexpr Spelling S[] = {{ParsedAttr::AS_GNU, "example"},
- {ParsedAttr::AS_C2x, "example"},
+ {ParsedAttr::AS_C23, "example"},
  {ParsedAttr::AS_CXX11, "example"},
  {ParsedAttr::AS_CXX11, 
"plugin::example"}};
 Spellings = S;



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


[PATCH] D157705: [clang][AST] TestNodeDumper learned to output template specialization kind

2023-08-11 Thread Timo Stripf via Phabricator via cfe-commits
strimo378 created this revision.
strimo378 added a reviewer: aaron.ballman.
Herald added a project: All.
strimo378 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157705

Files:
  clang/include/clang/AST/TextNodeDumper.h
  clang/lib/AST/TextNodeDumper.cpp
  clang/test/AST/HLSL/this-reference-template.hlsl
  clang/test/AST/ast-dump-decl.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_reference.cpp
  clang/test/SemaCXX/lambda-conversion-op-cc.cpp
  clang/test/SemaOpenCLCXX/address-space-deduction.clcpp

Index: clang/test/SemaOpenCLCXX/address-space-deduction.clcpp
===
--- clang/test/SemaOpenCLCXX/address-space-deduction.clcpp
+++ clang/test/SemaOpenCLCXX/address-space-deduction.clcpp
@@ -6,7 +6,7 @@
 constexpr int foo = 0;
 
 //CHECK: |-VarDecl {{.*}} foo1 'T' cinit
-//CHECK: `-VarTemplateSpecializationDecl {{.*}} used foo1 '__global long':'__global long' cinit
+//CHECK: `-VarTemplateSpecializationDecl {{.*}} used foo1 '__global long':'__global long' implicit_instantiation cinit
 template 
 T foo1 = 0;
 
Index: clang/test/SemaCXX/lambda-conversion-op-cc.cpp
===
--- clang/test/SemaCXX/lambda-conversion-op-cc.cpp
+++ clang/test/SemaCXX/lambda-conversion-op-cc.cpp
@@ -67,11 +67,11 @@
   //
   // CHECK: FunctionTemplateDecl {{.*}} operator()
   // LIN64: CXXMethodDecl {{.*}} operator() 'auto (auto) const' inline
-  // LIN64: CXXMethodDecl {{.*}} operator() 'void (char) const' inline
-  // LIN64: CXXMethodDecl {{.*}} operator() 'void (int) const' inline
+  // LIN64: CXXMethodDecl {{.*}} operator() 'void (char) const' implicit_instantiation inline
+  // LIN64: CXXMethodDecl {{.*}} operator() 'void (int) const' implicit_instantiation inline
   // WIN32: CXXMethodDecl {{.*}} operator() 'auto (auto) __attribute__((thiscall)) const' inline
-  // WIN32: CXXMethodDecl {{.*}} operator() 'void (char) __attribute__((thiscall)) const' inline
-  // WIN32: CXXMethodDecl {{.*}} operator() 'void (int) __attribute__((thiscall)) const' inline
+  // WIN32: CXXMethodDecl {{.*}} operator() 'void (char) __attribute__((thiscall)) const' implicit_instantiation inline
+  // WIN32: CXXMethodDecl {{.*}} operator() 'void (int) __attribute__((thiscall)) const' implicit_instantiation inline
   //
   // NODEF: FunctionTemplateDecl {{.*}} operator auto (*)(type-parameter-0-0)
   // VECDEF: FunctionTemplateDecl {{.*}} operator auto (*)(type-parameter-0-0) __attribute__((vectorcall))
@@ -108,8 +108,8 @@
   // CHECK: LambdaExpr
   // CHECK: FunctionTemplateDecl {{.*}} operator()
   // CHECK: CXXMethodDecl {{.*}} operator() 'auto (auto) __attribute__((vectorcall)) const' inline
-  // CHECK: CXXMethodDecl {{.*}} operator() 'void (char) __attribute__((vectorcall)) const' inline
-  // CHECK: CXXMethodDecl {{.*}} operator() 'void (int) __attribute__((vectorcall)) const' inline
+  // CHECK: CXXMethodDecl {{.*}} operator() 'void (char) __attribute__((vectorcall)) const' implicit_instantiation inline
+  // CHECK: CXXMethodDecl {{.*}} operator() 'void (int) __attribute__((vectorcall)) const' implicit_instantiation inline
   // CHECK: FunctionTemplateDecl {{.*}} operator auto (*)(type-parameter-0-0) __attribute__((vectorcall))
   // LIN64: CXXConversionDecl {{.*}} operator auto (*)(type-parameter-0-0) __attribute__((vectorcall)) 'auto (*() const noexcept)(auto) __attribute__((vectorcall))'
   // LIN64: CXXConversionDecl {{.*}} operator auto (*)(char) __attribute__((vectorcall)) 'void (*() const noexcept)(char) __attribute__((vectorcall))'
Index: clang/test/AST/ast-dump-openmp-begin-declare-variant_reference.cpp
===
--- clang/test/AST/ast-dump-openmp-begin-declare-variant_reference.cpp
+++ clang/test/AST/ast-dump-openmp-begin-declare-variant_reference.cpp
@@ -184,7 +184,7 @@
 // CHECK-NEXT: | |   `-ReturnStmt [[ADDR_39:0x[a-z0-9]*]] 
 // CHECK-NEXT: | | `-CXXStaticCastExpr [[ADDR_40:0x[a-z0-9]*]]  '_Up':'typename remove_reference<_Tp>::type' xvalue static_cast<_Up &&> 
 // CHECK-NEXT: | |   `-DeclRefExpr [[ADDR_41:0x[a-z0-9]*]]  '_Tp' {{.*}}ParmVar [[ADDR_34]] '__t' '_Tp &&'
-// CHECK-NEXT: | |-FunctionDecl [[ADDR_42:0x[a-z0-9]*]]  line:11:1 used move 'typename remove_reference::type &&(float &)' inline
+// CHECK-NEXT: | |-FunctionDecl [[ADDR_42:0x[a-z0-9]*]]  line:11:1 used move 'typename remove_reference::type &&(float &)' implicit_instantiation inline
 // CHECK-NEXT: | | |-TemplateArgument type 'float &'
 // CHECK-NEXT: | | | `-LValueReferenceType [[ADDR_7]] 'float &'
 // CHECK-NEXT: | | |   `-BuiltinType [[ADDR_8]] 'float'
@@ -201,7 +201,7 @@
 // CHECK-NEXT: | |   `-ReturnStmt [[ADDR_49:0x[a-z0-9]*]] 
 // CHECK-NEXT: | | `-CXXStaticCastExpr [[ADDR_50:0x[a-z0-9]*]]  '_Up':'float' xvalue static_cast<_Up &&> 
 // CHECK-NEXT

[PATCH] D155978: [SPIRV] Add SPIR-V logical triple.

2023-08-11 Thread Nathan Gauër via Phabricator via cfe-commits
Keenuts marked an inline comment as done.
Keenuts added inline comments.



Comment at: llvm/include/llvm/TargetParser/Triple.h:106
+wasm32,  // WebAssembly with 32-bit pointers
+wasm64,  // WebAssembly with 64-bit pointers
 renderscript32, // 32-bit RenderScript

pmatos wrote:
> Keenuts wrote:
> > pmatos wrote:
> > > No need to reindent the whole block to add a single line.
> > IIRC it I did a clang-format because the buildbot complained the format was 
> > not right.
> > Reverted the clang-format commit (which seems better, I agree), and I'll 
> > see if the bots complains.
> I know what you did and it makes sense - I did the same myself while working 
> on another backend but lets try not to change such a large amount of lines in 
> a patch focused on something else. I think it's certainly better to propose 
> this change in a single NFC patch if we think that clang-format output is 
> better than the existing formatting.
Of course. So is the presubmit failure something we can ignore? Or shall I do 
another NFC patch to the format?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155978

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


[PATCH] D157680: [X86]Support options -mno-gather -mno-scatter

2023-08-11 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/include/clang/Driver/Options.td:903-906
+def mno_gather : Flag<["-"], "mno-gather">, Flags<[NoXarchOption]>,
+ HelpText<"Disable generation of gather instructions in 
auto-vectorization(x86 only)">;
+def mno_scatter : Flag<["-"], "mno-scatter">, Flags<[NoXarchOption]>,
+  HelpText<"Disable generation of scatter instructions in 
auto-vectorization(x86 only)">;

Move under "// X86 feature flags"



Comment at: clang/lib/Driver/ToolChains/Arch/X86.cpp:272-277
+  if (Args.hasArg(options::OPT_mno_gather)) {
+Features.push_back("+prefer-no-gather");
+  }
+  if (Args.hasArg(options::OPT_mno_scatter)) {
+Features.push_back("+prefer-no-scatter");
+  }

No need parentheses



Comment at: llvm/test/CodeGen/X86/x86-prefer-no-gather-no-scatter.ll:9-10
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+

Don't need these and is duplicated with RUN line triple.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157680

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


[PATCH] D157708: [Sema] Suppress lookup diagnostics when checking reversed operators

2023-08-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: shafik, rsmith.
Herald added a project: All.
ilya-biryukov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The standard specified that Clang should 'search' for members in this
case, which does not involve full lookup and the corresponding checks.

See `[over.match.oper]p4` and `[basic.lookup.general]p3`.

The added test has an example code that breaks.
The change that exposed this behavior is 
cc1b6668c57170cd440d321037ced89d6a61a9cb 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157708

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/cxx20-reversed-operators-search.cpp


Index: clang/test/SemaCXX/cxx20-reversed-operators-search.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx20-reversed-operators-search.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
+// expected-no-diagnostics
+
+
+namespace members {
+
+struct X {
+  virtual ~X();
+  virtual bool operator ==(X);
+  bool operator !=(X);
+};
+
+struct Y {
+  virtual ~Y();
+  virtual bool operator ==(Y);
+  bool operator !=(Y);
+};
+
+struct Z : X, Y {
+  virtual bool operator==(Z);
+  bool operator==(X) override;
+  bool operator==(Y) override;
+};
+
+void test() {
+  bool b = Z() == Z();
+}
+
+} // namespace members
+
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -950,7 +950,10 @@
 LookupResult Members(S, NotEqOp, OpLoc,
  Sema::LookupNameKind::LookupMemberName);
 S.LookupQualifiedName(Members, RHSRec->getDecl());
-Members.suppressAccessDiagnostics();
+// According to [over.match.oper]p4 we should run "search" and not "lookup"
+// for reversed operators, so suppress diagnostics.
+Members.suppressDiagnostics();
+
 for (NamedDecl *Op : Members)
   if (FunctionsCorrespond(S.Context, EqFD, Op->getAsFunction()))
 return false;


Index: clang/test/SemaCXX/cxx20-reversed-operators-search.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx20-reversed-operators-search.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
+// expected-no-diagnostics
+
+
+namespace members {
+
+struct X {
+  virtual ~X();
+  virtual bool operator ==(X);
+  bool operator !=(X);
+};
+
+struct Y {
+  virtual ~Y();
+  virtual bool operator ==(Y);
+  bool operator !=(Y);
+};
+
+struct Z : X, Y {
+  virtual bool operator==(Z);
+  bool operator==(X) override;
+  bool operator==(Y) override;
+};
+
+void test() {
+  bool b = Z() == Z();
+}
+
+} // namespace members
+
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -950,7 +950,10 @@
 LookupResult Members(S, NotEqOp, OpLoc,
  Sema::LookupNameKind::LookupMemberName);
 S.LookupQualifiedName(Members, RHSRec->getDecl());
-Members.suppressAccessDiagnostics();
+// According to [over.match.oper]p4 we should run "search" and not "lookup"
+// for reversed operators, so suppress diagnostics.
+Members.suppressDiagnostics();
+
 for (NamedDecl *Op : Members)
   if (FunctionsCorrespond(S.Context, EqFD, Op->getAsFunction()))
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155387: [Clang] Fix member lookup so that we don't ignore ambiguous lookups in some cases

2023-08-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

This change seems to expose a bug in Clang in C++20 see godbolt 
.
I believe following code should compile, but it does not:

  struct X {
virtual ~X();
virtual bool operator ==(X);
bool operator !=(X);
  };
  
  struct Y {
virtual ~Y();
virtual bool operator ==(Y);
bool operator !=(Y);
  };
  
  struct Z : X, Y {
virtual bool operator==(Z);
bool operator==(X) override;
bool operator==(Y) override;
  };
  
  int main() {
bool b = Z() == Z(); // Clang errors saying `lookup for operator != is 
ambiguous`
(void)b;
  }

The `operator !=` is coming from checking if we need to add a reversed 
candidates.
I believe this should compile as according to (over.match.oper)p4 
:

> A non-template function or function template F named operator== is a rewrite 
> target with first operand o unless **a search for the name operator!= in the 
> scope S** from the instantiation context of the operator expression finds a 
> function …

And 'search' is defined without any checks for ambiguous bases in 
(basic.lookup.general)p3 

> A single search in a scope S for a name N from a program point P finds all 
> declarations that precede P to which any name that is the same as N 
> ([basic.pre]) is bound in S. If any such declaration is a using-declarator 
> whose terminal name ([expr.prim.id.unqual]) is not dependent 
> ([temp.dep.type]), it is replaced by the declarations named by the 
> using-declarator ([namespace.udecl]).

Clang does a full lookup instead, therefore exposing the errors that it should 
not diagnose.

We actually hit this on real code 

 and found this during integration.

I have sent a fix for review in D157708 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155387

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


[clang] 61c1e92 - Update documentation for C23 attribute spellings

2023-08-11 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-08-11T08:42:49-04:00
New Revision: 61c1e925319e933869b6fe2db4e8d348986880b8

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

LOG: Update documentation for C23 attribute spellings

The spelling was updated in 0ce056a814f8dbfd8d9b7720ce1df489c6ba5ddb
but the documentation changes were missed.

Added: 


Modified: 
clang/docs/InternalsManual.rst

Removed: 




diff  --git a/clang/docs/InternalsManual.rst b/clang/docs/InternalsManual.rst
index 1698e11d7b3e2f..f6fdf57dcf06c8 100644
--- a/clang/docs/InternalsManual.rst
+++ b/clang/docs/InternalsManual.rst
@@ -2863,7 +2863,7 @@ are created implicitly. The following spellings are 
accepted:
   syntax and placement.
   ``CXX11``   Spelled with a C++-style ``[[attr]]`` syntax with an
   optional vendor-specific namespace.
-  ``C2x`` Spelled with a C-style ``[[attr]]`` syntax with an
+  ``C23`` Spelled with a C-style ``[[attr]]`` syntax with an
   optional vendor-specific namespace.
   ``Declspec``Spelled with a Microsoft-style ``__declspec(attr)``
   syntax.
@@ -2895,7 +2895,7 @@ are created implicitly. The following spellings are 
accepted:
 
 The C++ standard specifies that “any [non-standard attribute] that is not
 recognized by the implementation is ignored” (``[dcl.attr.grammar]``).
-The rule for C is similar. This makes ``CXX11`` and ``C2x`` spellings
+The rule for C is similar. This makes ``CXX11`` and ``C23`` spellings
 unsuitable for attributes that affect the type system, that change the
 binary interface of the code, or that have other similar semantic meaning.
 



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


[PATCH] D157708: [Sema] Suppress lookup diagnostics when checking reversed operators

2023-08-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/lib/Sema/SemaOverload.cpp:967
S.getScopeForContext(EqFD->getEnclosingNamespaceContext()));
   NonMembers.suppressAccessDiagnostics();
   for (NamedDecl *Op : NonMembers) {

I believe we should be able to expose the same errorenous behavior here, but I 
did not come up with a test yet, so did not change it yet.
We should update it and come up with a test before the change lands.

But I still wanted to get early feedback on the direction of this patch, so 
sending for review right away.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157708

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


[PATCH] D157479: [Clang][DebugInfo] Emit narrower base types for structured binding declarations that bind to struct bitfields

2023-08-11 Thread Victor Campos via Phabricator via cfe-commits
vhscampos updated this revision to Diff 549359.
vhscampos added a comment.

- Addressed the one comment regarding code.
- Changed the test to use update_cc_test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157479

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGenCXX/debug-info-structured-binding-bitfield.cpp

Index: clang/test/CodeGenCXX/debug-info-structured-binding-bitfield.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-structured-binding-bitfield.cpp
@@ -0,0 +1,557 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-globals --version 2
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple aarch64-arm-none-eabi %s -o - | FileCheck %s
+
+struct S0 {
+  unsigned int x : 16;
+  unsigned int y : 16;
+};
+
+// CHECK-LABEL: define dso_local void @_Z3fS0v
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] !dbg [[DBG5:![0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[S0:%.*]] = alloca [[STRUCT_S0:%.*]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = alloca [[STRUCT_S0]], align 4
+// CHECK-NEXT:call void @llvm.dbg.declare(metadata ptr [[S0]], metadata [[META10:![0-9]+]], metadata !DIExpression()), !dbg [[DBG16:![0-9]+]]
+// CHECK-NEXT:call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[META17:![0-9]+]], metadata !DIExpression()), !dbg [[DBG19:![0-9]+]]
+// CHECK-NEXT:call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[META20:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 2)), !dbg [[DBG21:![0-9]+]]
+// CHECK-NEXT:call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[META22:![0-9]+]], metadata !DIExpression()), !dbg [[DBG23:![0-9]+]]
+// CHECK-NEXT:call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[TMP0]], ptr align 4 [[S0]], i64 4, i1 false), !dbg [[DBG24:![0-9]+]]
+// CHECK-NEXT:ret void, !dbg [[DBG25:![0-9]+]]
+//
+void fS0() {
+  S0 s0;
+  auto [a, b] = s0;
+}
+
+struct S1 {
+  volatile unsigned int x : 16;
+  volatile unsigned int y : 16;
+};
+
+// CHECK-LABEL: define dso_local void @_Z3fS1v
+// CHECK-SAME: () #[[ATTR0]] !dbg [[DBG26:![0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[S1:%.*]] = alloca [[STRUCT_S1:%.*]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = alloca [[STRUCT_S1]], align 4
+// CHECK-NEXT:call void @llvm.dbg.declare(metadata ptr [[S1]], metadata [[META27:![0-9]+]], metadata !DIExpression()), !dbg [[DBG33:![0-9]+]]
+// CHECK-NEXT:call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[META34:![0-9]+]], metadata !DIExpression()), !dbg [[DBG36:![0-9]+]]
+// CHECK-NEXT:call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[META37:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 2)), !dbg [[DBG38:![0-9]+]]
+// CHECK-NEXT:call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[META39:![0-9]+]], metadata !DIExpression()), !dbg [[DBG40:![0-9]+]]
+// CHECK-NEXT:call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[TMP0]], ptr align 4 [[S1]], i64 4, i1 false), !dbg [[DBG41:![0-9]+]]
+// CHECK-NEXT:ret void, !dbg [[DBG42:![0-9]+]]
+//
+void fS1() {
+  S1 s1;
+  auto [a, b] = s1;
+}
+
+struct S2 {
+  unsigned int x : 8;
+  unsigned int y : 8;
+};
+
+// CHECK-LABEL: define dso_local void @_Z3fS2v
+// CHECK-SAME: () #[[ATTR0]] !dbg [[DBG43:![0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[S2:%.*]] = alloca [[STRUCT_S2:%.*]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = alloca [[STRUCT_S2]], align 4
+// CHECK-NEXT:call void @llvm.dbg.declare(metadata ptr [[S2]], metadata [[META44:![0-9]+]], metadata !DIExpression()), !dbg [[DBG49:![0-9]+]]
+// CHECK-NEXT:call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[META50:![0-9]+]], metadata !DIExpression()), !dbg [[DBG52:![0-9]+]]
+// CHECK-NEXT:call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[META53:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 1)), !dbg [[DBG54:![0-9]+]]
+// CHECK-NEXT:call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[META55:![0-9]+]], metadata !DIExpression()), !dbg [[DBG56:![0-9]+]]
+// CHECK-NEXT:call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[TMP0]], ptr align 4 [[S2]], i64 4, i1 false), !dbg [[DBG57:![0-9]+]]
+// CHECK-NEXT:ret void, !dbg [[DBG58:![0-9]+]]
+//
+void fS2() {
+  S2 s2;
+  auto [a, b] = s2;
+}
+
+struct S3 {
+  volatile unsigned int x : 8;
+  volatile unsigned int y : 8;
+};
+
+// CHECK-LABEL: define dso_local void @_Z3fS3v
+// CHECK-SAME: () #[[ATTR0]] !dbg [[DBG59:![0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[S3:%.*]] = alloca [[STRUCT_S3:%.*]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = alloca [[STRUCT_S3]], align 4
+// CHECK-NEXT:call void @llvm.dbg.declare(metadata ptr [[S3]], metadata [[META60:![0-9]+]], metadata !DIExpression()), !dbg [[DBG65:![0-9]+]]
+// CHECK-NEXT:call void @llv

[PATCH] D157479: [Clang][DebugInfo] Emit narrower base types for structured binding declarations that bind to struct bitfields

2023-08-11 Thread Victor Campos via Phabricator via cfe-commits
vhscampos marked 3 inline comments as done.
vhscampos added inline comments.



Comment at: clang/test/CodeGenCXX/debug-info-structured-binding-bitfield.cpp:6
+  unsigned int y : 16;
+};
+

tmatheson wrote:
> This would be easier to check if the structs had meaningful names, e.g. 
> S_16_16
I left naming as it was, but now used your suggested code structure and also 
used update_cc_test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157479

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


[clang] c9335eb - Rename C2x -> C23 in WWW pages

2023-08-11 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-08-11T08:56:01-04:00
New Revision: c9335eb20f45f48b53f1f820334edad71da6f37f

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

LOG: Rename C2x -> C23 in WWW pages

This updates the Open Projects, C status, and C DR status pages to use
C23 instead of C2x. Note, I've renamed the GitHub issue label from
`c2x` to `c23` as part of these change as well.

I left the C23 page anchor named `c2x` in the C status page so that
existing links to it are not broken.

Added: 


Modified: 
clang/www/OpenProjects.html
clang/www/c_dr_status.html
clang/www/c_status.html

Removed: 




diff  --git a/clang/www/OpenProjects.html b/clang/www/OpenProjects.html
index 7a8bdbd3dbbc80..5d0b7aaccd89d2 100755
--- a/clang/www/OpenProjects.html
+++ b/clang/www/OpenProjects.html
@@ -123,7 +123,7 @@ Open Clang Projects
 
 
 
-Continue work on C++20, C++23, C++2c, and C2x support:
+Continue work on C++20, C++23, C++2c, and C23 support:
   There are still several C++20 features to complete, and work has begun on
   supporting the latest language standards. Please see the
   C++ status report page to find out what is

diff  --git a/clang/www/c_dr_status.html b/clang/www/c_dr_status.html
index 1aaff53d7cef44..4fe088e2977505 100644
--- a/clang/www/c_dr_status.html
+++ b/clang/www/c_dr_status.html
@@ -38,7 +38,7 @@ C defect report implementation status
 currently unknown will be marked in magenta.
 
 The https://github.com/llvm/llvm-project/issues/";>LLVM bug 
tracker uses
-the "c", "c99", "c11", "c17", and "c2x" labels to track known bugs with 
Clang's language
+the "c", "c99", "c11", "c17", and "c23" labels to track known bugs with 
Clang's language
 conformance.
 
 

diff  --git a/clang/www/c_status.html b/clang/www/c_status.html
index 9f476c8b013e27..6b84138d36ed9e 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -57,13 +57,13 @@ C Support in Clang
  Maybe?
 
 
- C2x
- -std=c2x
+ C23
+ -std=c23
  Partial
 
 
 
-The implementation status for C99, C11, and C17 are currently under
+The implementation status for C99, C11, C17, and C23 are currently under
 investigation. Any proposal whose status in Clang is currently unknown
 will be marked in magenta.
 
@@ -73,7 +73,7 @@ C Support in Clang
 they become available.
 
 The https://github.com/llvm/llvm-project/issues/";>LLVM bug 
tracker uses
-the "c", "c99", "c11", "c17", and "c2x" labels to track known bugs with 
Clang's language
+the "c", "c99", "c11", "c17", and "c23" labels to track known bugs with 
Clang's language
 conformance.
 
 C89 implementation status
@@ -617,11 +617,12 @@ C17 implementation status
 There are no major changes in this edition, only technical corrections and 
clarifications that are tracked by Defect Report.
 You can use Clang in C17 mode with the -std=c17 or 
-std=c18 options (available in Clang 6 and later).
 
-C2x implementation status
+C23 implementation status
 
-Clang has support for some of the features of the C standard following C17, 
informally referred to as C2x.
+Clang has support for some of the features of the C standard following C17, 
informally referred to as C23.
 
-You can use Clang in C2x mode with the -std=c2x option 
(available in Clang 9 and later).
+You can use Clang in C23 mode with the -std=c23 option 
(available in Clang 18 and later) or with the
+   -std=c2x option (available in Clang 9 and later).
 
 
 List of features and minimum Clang version with support
@@ -629,7 +630,7 @@ C2x implementation status
 
  
 Language Feature
-C2x Proposal
+C23 Proposal
 Available in Clang?
  
 



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


[PATCH] D156737: clang: Add __builtin_elementwise_sqrt

2023-08-11 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

ping


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

https://reviews.llvm.org/D156737

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


[PATCH] D155081: Specify the developer policy around links to external resources

2023-08-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 549365.
aaron.ballman marked 2 inline comments as done.
aaron.ballman added a comment.

Updated based on review comments.


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

https://reviews.llvm.org/D155081

Files:
  llvm/docs/DeveloperPolicy.rst


Index: llvm/docs/DeveloperPolicy.rst
===
--- llvm/docs/DeveloperPolicy.rst
+++ llvm/docs/DeveloperPolicy.rst
@@ -354,14 +354,16 @@
   related commit. This could be as simple as "Revert commit  because it
   caused PR#".
 
-* It is acceptable to add metadata to the commit message to automate processes.
-  If the patch fixes a bug in GitHub Issues, we encourage adding
+* It is acceptable to add metadata to the commit message to automate processes,
+  including for downstream consumers. If the patch fixes a bug in GitHub 
Issues,
+  we encourage adding
   "Fixes https://github.com/llvm/llvm-project/issues/12345"; to automate closing
   the issue in GitHub. If the patch has been reviewed, we encourage adding a
   link to its review page, as shown
   `here `_.
   Other kinds of metadata are also acceptable, including links to resources
-  that are not available to the entire community.
+  that are not available to the entire community. However, such links should
+  not be used in place of making the commit message self-explanatory.
 
 For minor violations of these recommendations, the community normally favors
 reminding the contributor of this policy over reverting. Minor corrections and


Index: llvm/docs/DeveloperPolicy.rst
===
--- llvm/docs/DeveloperPolicy.rst
+++ llvm/docs/DeveloperPolicy.rst
@@ -354,14 +354,16 @@
   related commit. This could be as simple as "Revert commit  because it
   caused PR#".
 
-* It is acceptable to add metadata to the commit message to automate processes.
-  If the patch fixes a bug in GitHub Issues, we encourage adding
+* It is acceptable to add metadata to the commit message to automate processes,
+  including for downstream consumers. If the patch fixes a bug in GitHub Issues,
+  we encourage adding
   "Fixes https://github.com/llvm/llvm-project/issues/12345"; to automate closing
   the issue in GitHub. If the patch has been reviewed, we encourage adding a
   link to its review page, as shown
   `here `_.
   Other kinds of metadata are also acceptable, including links to resources
-  that are not available to the entire community.
+  that are not available to the entire community. However, such links should
+  not be used in place of making the commit message self-explanatory.
 
 For minor violations of these recommendations, the community normally favors
 reminding the contributor of this policy over reverting. Minor corrections and
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155081: Specify the developer policy around links to external resources

2023-08-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D155081#4507579 , @tonic wrote:

> As I mentioned on the Discourse thread, but if this policy change is made, 
> there should be some discussion about if this applies retroactively. Making a 
> note here, because it probably should be included in the changes to Developer 
> Policy if the radar links are not removed but not allowed going forward.

I believe this was sufficiently clarified on the Discourse thread -- this 
policy follows all the same procedures as our other coding style policies. If 
you think the existing policy is unclear in this area, I think that should be 
handled as a separate policy discussion instead of as an ad hoc statement for 
just this change.


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

https://reviews.llvm.org/D155081

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


[PATCH] D156320: [Flang][Driver] Add support for Rpass and related options

2023-08-11 Thread victorkingi via Phabricator via cfe-commits
victorkingi updated this revision to Diff 549367.
victorkingi marked an inline comment as done.
victorkingi added a comment.

addressing comments with code refactoring


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156320

Files:
  flang/include/flang/Frontend/CodeGenOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/Frontend/TextDiagnosticPrinter.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Driver/optimization-remark.f90

Index: flang/test/Driver/optimization-remark.f90
===
--- /dev/null
+++ flang/test/Driver/optimization-remark.f90
@@ -0,0 +1,47 @@
+! This file tests the -Rpass family of flags (-Rpass, -Rpass-missed
+! and -Rpass-analysis)
+! loop-delete isn't enabled at O0 so we use at least O1
+
+! Check that we can override -Rpass= with -Rno-pass.
+! RUN: %flang_fc1 %s -O1 -Rpass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+! RUN: %flang_fc1 %s -O1 -Rpass -Rno-pass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS
+
+! Check "unknown remark option" warning
+! RUN: %flang %s -O1 -R 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS-WARN
+
+! Check "unknown remark option" warning with suggestion
+! RUN: %flang %s -O1 -Rpas 2>&1 | FileCheck %s --check-prefix=CHECK-WARN-SUGGEST
+
+! Check full -Rpass message is emitted
+! RUN: %flang %s -O1 -Rpass 2>&1 | FileCheck %s
+
+! Check full -Rpass-missed message is emitted
+! RUN: %flang %s -O1 -Rpass-missed 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS-MISSED
+
+! Check full -Rpass-analysis message is emitted
+! RUN: %flang %s -O1 -Rpass-analysis 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS-ANALYSIS
+
+! CHECK: optimization-remark.f90:43:5: remark: Loop deleted because it is invariant [-Rpass=loop-delete]
+! CHECK-REMARKS-MISSED: optimization-remark.f90:38:5: remark: loop not vectorized [-Rpass-missed=loop-vectorize]
+! CHECK-REMARKS-ANALYSIS: optimization-remark.f90:40:9: remark: loop not vectorized: call instruction cannot be vectorized [-Rpass-analysis=loop-vectorize]
+! CHECK-REMARKS: remark:
+! CHECK-NO-REMARKS-NOT: remark:
+
+! CHECK-REMARKS-WARN: warning: unknown remark option '-R' [-Wunknown-warning-option]
+! CHECK-WARN-SUGGEST: warning: unknown remark option '-Rpas'; did you mean '-Rpass'? [-Wunknown-warning-option]
+
+program forttest
+implicit none
+real, dimension(1:50) :: aR1
+integer :: n
+
+do n = 1,50
+aR1(n) = n * 1.34
+print *, "hello"
+end do
+
+do n = 1,50
+aR1(n) = n * 1.34
+end do
+
+end program forttest
Index: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -166,6 +166,9 @@
   // Honor color diagnostics.
   flang->getDiagnosticOpts().ShowColors = flang->getFrontendOpts().showColors;
 
+  clang::ProcessWarningOptions(flang->getDiagnostics(),
+   flang->getDiagnosticOpts());
+
   // Create and execute the frontend action.
   std::unique_ptr act(createFrontendAction(*flang));
   if (!act)
Index: flang/lib/Frontend/TextDiagnosticPrinter.cpp
===
--- flang/lib/Frontend/TextDiagnosticPrinter.cpp
+++ flang/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -20,6 +20,10 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
+#include 
+#include 
+#include 
 
 using namespace Fortran::frontend;
 
@@ -29,6 +33,23 @@
 
 TextDiagnosticPrinter::~TextDiagnosticPrinter() {}
 
+// Print any diagnostic option information to a raw_ostream.
+static void printDiagnosticOptions(llvm::raw_ostream &os,
+   clang::DiagnosticsEngine::Level level,
+   const clang::Diagnostic &info,
+   const clang::DiagnosticOptions &diagOpts) {
+  llvm::StringRef opt =
+  clang::DiagnosticIDs::getWarningOptionForDiag(info.getID());
+  if (!opt.empty()) {
+os << " [" << (level == clang::DiagnosticsEngine::Remark ? "-R" : "-W")
+   << opt;
+llvm::StringRef optValue = info.getDiags()->getFlagValue();
+if (!optValue.empty())
+  os << "=" << optValue;
+os << ']';
+  }
+}
+
 void TextDiagnosticPrinter::HandleDiagnostic(
 clang::DiagnosticsEngine::Level level, const clang::Diagnostic &info) {
   // Default implementation (Warnings/errors count).
@@ -40,6 +61,7 @@
   info.FormatDiagnostic(outStr);
 
   llvm::raw_svector_ostream diagMessageStream(outStr);
+  printDiagnosticOptions(diagMessageStream, level, info, *diagOpts);
 
   if (!prefix.empty())
 os << prefix << ": ";
@@ -48,12 +70,46 @@
   a

[PATCH] D155081: Specify the developer policy around links to external resources

2023-08-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 549369.
aaron.ballman added a comment.

Accidentally uploaded a partial diff instead of the full set of changes.


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

https://reviews.llvm.org/D155081

Files:
  llvm/docs/DeveloperPolicy.rst


Index: llvm/docs/DeveloperPolicy.rst
===
--- llvm/docs/DeveloperPolicy.rst
+++ llvm/docs/DeveloperPolicy.rst
@@ -201,6 +201,11 @@
   entire failing program into ``llvm/test`` as this creates a *time-to-test*
   burden on all developers. Please keep them short.
 
+* Avoid adding links to resources that are not available to the entire
+  community, such as links to private bug trackers, internal corporate
+  documentation, etc. Instead, add sufficient comments to the test to provide
+  the context behind such links.
+
 Note that llvm/test and clang/test are designed for regression and small 
feature
 tests only. More extensive test cases (e.g., entire applications, benchmarks,
 etc) should be added to the ``llvm-test`` test suite.  The llvm-test suite is
@@ -256,6 +261,11 @@
the change (more invasive changes require more testing). A reasonable subset
might be something like "``llvm-test/MultiSource/Benchmarks``".
 
+#. Ensure that links in source code and test files are to publicly available
+   resources and are used primarily to add additional information rather than
+   to supply critical context. The surrounding comments should be sufficient
+   to provide the context behind such links.
+
 Additionally, the committer is responsible for addressing any problems found in
 the future that the change is responsible for.  For example:
 
@@ -336,8 +346,6 @@
   code snippets and gory details should be left to bug comments, web
   review or the mailing list.
 
-* If the patch fixes a bug in GitHub Issues, please include the PR# in the 
message.
-
 * Text formatting and spelling should follow the same rules as documentation
   and in-code comments, ex. capitalization, full stop, etc.
 
@@ -346,8 +354,16 @@
   related commit. This could be as simple as "Revert commit  because it
   caused PR#".
 
-* If the patch has been reviewed, add a link to its review page, as shown
+* It is acceptable to add metadata to the commit message to automate processes,
+  including for downstream consumers. If the patch fixes a bug in GitHub 
Issues,
+  we encourage adding
+  "Fixes https://github.com/llvm/llvm-project/issues/12345"; to automate closing
+  the issue in GitHub. If the patch has been reviewed, we encourage adding a
+  link to its review page, as shown
   `here `_.
+  Other kinds of metadata are also acceptable, including links to resources
+  that are not available to the entire community. However, such links should
+  not be used in place of making the commit message self-explanatory.
 
 For minor violations of these recommendations, the community normally favors
 reminding the contributor of this policy over reverting. Minor corrections and


Index: llvm/docs/DeveloperPolicy.rst
===
--- llvm/docs/DeveloperPolicy.rst
+++ llvm/docs/DeveloperPolicy.rst
@@ -201,6 +201,11 @@
   entire failing program into ``llvm/test`` as this creates a *time-to-test*
   burden on all developers. Please keep them short.
 
+* Avoid adding links to resources that are not available to the entire
+  community, such as links to private bug trackers, internal corporate
+  documentation, etc. Instead, add sufficient comments to the test to provide
+  the context behind such links.
+
 Note that llvm/test and clang/test are designed for regression and small feature
 tests only. More extensive test cases (e.g., entire applications, benchmarks,
 etc) should be added to the ``llvm-test`` test suite.  The llvm-test suite is
@@ -256,6 +261,11 @@
the change (more invasive changes require more testing). A reasonable subset
might be something like "``llvm-test/MultiSource/Benchmarks``".
 
+#. Ensure that links in source code and test files are to publicly available
+   resources and are used primarily to add additional information rather than
+   to supply critical context. The surrounding comments should be sufficient
+   to provide the context behind such links.
+
 Additionally, the committer is responsible for addressing any problems found in
 the future that the change is responsible for.  For example:
 
@@ -336,8 +346,6 @@
   code snippets and gory details should be left to bug comments, web
   review or the mailing list.
 
-* If the patch fixes a bug in GitHub Issues, please include the PR# in the message.
-
 * Text formatting and spelling should follow the same rules as documentation
   and in-code comments, ex. capitalization, full stop, etc.
 
@@ -346,8 +354,16 @@
   related commit. This could be as simple as "Revert commit  because it
   c

[PATCH] D155081: Specify the developer policy around links to external resources

2023-08-11 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision.
cor3ntin added a comment.

This seems very reasonable to me




Comment at: llvm/docs/DeveloperPolicy.rst:264
 
+#. Ensure that links in source code and test files are to publicly available
+   resources and are used primarily to add additional information rather than




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

https://reviews.llvm.org/D155081

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


[PATCH] D155081: Specify the developer policy around links to external resources

2023-08-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 549370.
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

Updated based on review feedback.


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

https://reviews.llvm.org/D155081

Files:
  llvm/docs/DeveloperPolicy.rst


Index: llvm/docs/DeveloperPolicy.rst
===
--- llvm/docs/DeveloperPolicy.rst
+++ llvm/docs/DeveloperPolicy.rst
@@ -201,6 +201,11 @@
   entire failing program into ``llvm/test`` as this creates a *time-to-test*
   burden on all developers. Please keep them short.
 
+* Avoid adding links to resources that are not available to the entire
+  community, such as links to private bug trackers, internal corporate
+  documentation, etc. Instead, add sufficient comments to the test to provide
+  the context behind such links.
+
 Note that llvm/test and clang/test are designed for regression and small 
feature
 tests only. More extensive test cases (e.g., entire applications, benchmarks,
 etc) should be added to the ``llvm-test`` test suite.  The llvm-test suite is
@@ -256,6 +261,11 @@
the change (more invasive changes require more testing). A reasonable subset
might be something like "``llvm-test/MultiSource/Benchmarks``".
 
+#. Ensure that links in source code and test files point to publicly available
+   resources and are used primarily to add additional information rather than
+   to supply critical context. The surrounding comments should be sufficient
+   to provide the context behind such links.
+
 Additionally, the committer is responsible for addressing any problems found in
 the future that the change is responsible for.  For example:
 
@@ -336,8 +346,6 @@
   code snippets and gory details should be left to bug comments, web
   review or the mailing list.
 
-* If the patch fixes a bug in GitHub Issues, please include the PR# in the 
message.
-
 * Text formatting and spelling should follow the same rules as documentation
   and in-code comments, ex. capitalization, full stop, etc.
 
@@ -346,8 +354,16 @@
   related commit. This could be as simple as "Revert commit  because it
   caused PR#".
 
-* If the patch has been reviewed, add a link to its review page, as shown
+* It is acceptable to add metadata to the commit message to automate processes,
+  including for downstream consumers. If the patch fixes a bug in GitHub 
Issues,
+  we encourage adding
+  "Fixes https://github.com/llvm/llvm-project/issues/12345"; to automate closing
+  the issue in GitHub. If the patch has been reviewed, we encourage adding a
+  link to its review page, as shown
   `here `_.
+  Other kinds of metadata are also acceptable, including links to resources
+  that are not available to the entire community. However, such links should
+  not be used in place of making the commit message self-explanatory.
 
 For minor violations of these recommendations, the community normally favors
 reminding the contributor of this policy over reverting. Minor corrections and


Index: llvm/docs/DeveloperPolicy.rst
===
--- llvm/docs/DeveloperPolicy.rst
+++ llvm/docs/DeveloperPolicy.rst
@@ -201,6 +201,11 @@
   entire failing program into ``llvm/test`` as this creates a *time-to-test*
   burden on all developers. Please keep them short.
 
+* Avoid adding links to resources that are not available to the entire
+  community, such as links to private bug trackers, internal corporate
+  documentation, etc. Instead, add sufficient comments to the test to provide
+  the context behind such links.
+
 Note that llvm/test and clang/test are designed for regression and small feature
 tests only. More extensive test cases (e.g., entire applications, benchmarks,
 etc) should be added to the ``llvm-test`` test suite.  The llvm-test suite is
@@ -256,6 +261,11 @@
the change (more invasive changes require more testing). A reasonable subset
might be something like "``llvm-test/MultiSource/Benchmarks``".
 
+#. Ensure that links in source code and test files point to publicly available
+   resources and are used primarily to add additional information rather than
+   to supply critical context. The surrounding comments should be sufficient
+   to provide the context behind such links.
+
 Additionally, the committer is responsible for addressing any problems found in
 the future that the change is responsible for.  For example:
 
@@ -336,8 +346,6 @@
   code snippets and gory details should be left to bug comments, web
   review or the mailing list.
 
-* If the patch fixes a bug in GitHub Issues, please include the PR# in the message.
-
 * Text formatting and spelling should follow the same rules as documentation
   and in-code comments, ex. capitalization, full stop, etc.
 
@@ -346,8 +354,16 @@
   related commit. This could be as simple as "Revert commit  be

[PATCH] D155540: [clangd] Remove extra dependancies for clangd

2023-08-11 Thread Lei Huang via Phabricator via cfe-commits
lei updated this revision to Diff 549374.
lei added a comment.

Rebase to ToT


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155540

Files:
  clang-tools-extra/clangd/tool/CMakeLists.txt


Index: clang-tools-extra/clangd/tool/CMakeLists.txt
===
--- clang-tools-extra/clangd/tool/CMakeLists.txt
+++ clang-tools-extra/clangd/tool/CMakeLists.txt
@@ -26,11 +26,7 @@
   clangBasic
   clangFormat
   clangFrontend
-  clangLex
-  clangSema
   clangTooling
-  clangToolingCore
-  clangToolingRefactoring
   clangToolingSyntax
   )
 
@@ -48,11 +44,8 @@
   PRIVATE
   clangAST
   clangBasic
-  clangFormat
-  clangFrontend
   clangLex
   clangSema
-  clangTooling
   clangToolingCore
   clangToolingRefactoring
   clangToolingSyntax


Index: clang-tools-extra/clangd/tool/CMakeLists.txt
===
--- clang-tools-extra/clangd/tool/CMakeLists.txt
+++ clang-tools-extra/clangd/tool/CMakeLists.txt
@@ -26,11 +26,7 @@
   clangBasic
   clangFormat
   clangFrontend
-  clangLex
-  clangSema
   clangTooling
-  clangToolingCore
-  clangToolingRefactoring
   clangToolingSyntax
   )
 
@@ -48,11 +44,8 @@
   PRIVATE
   clangAST
   clangBasic
-  clangFormat
-  clangFrontend
   clangLex
   clangSema
-  clangTooling
   clangToolingCore
   clangToolingRefactoring
   clangToolingSyntax
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] e6f18b7 - [clangd] Remove extra dependancies for clangd

2023-08-11 Thread Lei Huang via cfe-commits

Author: Ahsan Saghir
Date: 2023-08-11T08:57:12-05:00
New Revision: e6f18b75d7ffeb6d5a5cb740a61f38f8f122fee1

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

LOG: [clangd] Remove extra dependancies for clangd

This patch removes dependancies for clangd that were duplicated in
915659bfa1e9fe2e2c748ac84d33881e248f9ad5.
The original patch was added to fix build failure with BUILD_SHARED_LIBS=ON.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/tool/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/tool/CMakeLists.txt 
b/clang-tools-extra/clangd/tool/CMakeLists.txt
index 5c3b566c97364c..6c21175d7687c3 100644
--- a/clang-tools-extra/clangd/tool/CMakeLists.txt
+++ b/clang-tools-extra/clangd/tool/CMakeLists.txt
@@ -26,11 +26,7 @@ clang_target_link_libraries(clangdMain
   clangBasic
   clangFormat
   clangFrontend
-  clangLex
-  clangSema
   clangTooling
-  clangToolingCore
-  clangToolingRefactoring
   clangToolingSyntax
   )
 
@@ -48,11 +44,8 @@ clang_target_link_libraries(clangd
   PRIVATE
   clangAST
   clangBasic
-  clangFormat
-  clangFrontend
   clangLex
   clangSema
-  clangTooling
   clangToolingCore
   clangToolingRefactoring
   clangToolingSyntax



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


[PATCH] D155540: [clangd] Remove extra dependancies for clangd

2023-08-11 Thread Lei Huang 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 rGe6f18b75d7ff: [clangd] Remove extra dependancies for clangd 
(authored by saghir, committed by lei).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155540

Files:
  clang-tools-extra/clangd/tool/CMakeLists.txt


Index: clang-tools-extra/clangd/tool/CMakeLists.txt
===
--- clang-tools-extra/clangd/tool/CMakeLists.txt
+++ clang-tools-extra/clangd/tool/CMakeLists.txt
@@ -26,11 +26,7 @@
   clangBasic
   clangFormat
   clangFrontend
-  clangLex
-  clangSema
   clangTooling
-  clangToolingCore
-  clangToolingRefactoring
   clangToolingSyntax
   )
 
@@ -48,11 +44,8 @@
   PRIVATE
   clangAST
   clangBasic
-  clangFormat
-  clangFrontend
   clangLex
   clangSema
-  clangTooling
   clangToolingCore
   clangToolingRefactoring
   clangToolingSyntax


Index: clang-tools-extra/clangd/tool/CMakeLists.txt
===
--- clang-tools-extra/clangd/tool/CMakeLists.txt
+++ clang-tools-extra/clangd/tool/CMakeLists.txt
@@ -26,11 +26,7 @@
   clangBasic
   clangFormat
   clangFrontend
-  clangLex
-  clangSema
   clangTooling
-  clangToolingCore
-  clangToolingRefactoring
   clangToolingSyntax
   )
 
@@ -48,11 +44,8 @@
   PRIVATE
   clangAST
   clangBasic
-  clangFormat
-  clangFrontend
   clangLex
   clangSema
-  clangTooling
   clangToolingCore
   clangToolingRefactoring
   clangToolingSyntax
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157680: [X86]Support options -mno-gather -mno-scatter

2023-08-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/include/clang/Driver/Options.td:903-906
+def mno_gather : Flag<["-"], "mno-gather">, Flags<[NoXarchOption]>,
+ HelpText<"Disable generation of gather instructions in 
auto-vectorization(x86 only)">;
+def mno_scatter : Flag<["-"], "mno-scatter">, Flags<[NoXarchOption]>,
+  HelpText<"Disable generation of scatter instructions in 
auto-vectorization(x86 only)">;

pengfei wrote:
> Move under "// X86 feature flags"
Also remove `NoXarchOption`

https://maskray.me/blog/2021-03-28-compiler-driver-and-cross-compilation#misc

If an option has the NoXarchOption flag, ClangDriver will emit an error if the 
option is used after -Xarch_* (originally for universal macOS binary, reused by 
offloading purposes -Xarch_host/etc). The error checking only applies to a 
small set of options (e.g. -o) and is not very useful for most options, but 
NoXarchOption was improperly named DriverOption (commit 
aabb0b11a3c1d8a6bb859db80400cffdcc9b336f) and lured some contributors to add 
NoXarchOption to options that should not have the flag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157680

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


[PATCH] D157684: [clang][ASTImporter] Repeated friend templates are partially imported

2023-08-11 Thread Ding Fei via Phabricator via cfe-commits
danix800 updated this revision to Diff 549376.
danix800 added a comment.

Apply git-clang-format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157684

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -4054,6 +4054,25 @@
  ->lookup(ToRecordOfFriend->getDeclName())
  .empty());
   }
+
+  void testRepeatedFriendImport(const char *Code) {
+Decl *ToTu = getToTuDecl(Code, Lang_CXX03);
+Decl *FromTu = getTuDecl(Code, Lang_CXX03, "from.cc");
+
+auto *ToFriend1 = FirstDeclMatcher().match(ToTu, friendDecl());
+auto *ToFriend2 = LastDeclMatcher().match(ToTu, friendDecl());
+auto *FromFriend1 =
+FirstDeclMatcher().match(FromTu, friendDecl());
+auto *FromFriend2 =
+LastDeclMatcher().match(FromTu, friendDecl());
+
+FriendDecl *ToImportedFriend1 = Import(FromFriend1, Lang_CXX03);
+FriendDecl *ToImportedFriend2 = Import(FromFriend2, Lang_CXX03);
+
+EXPECT_NE(ToImportedFriend1, ToImportedFriend2);
+EXPECT_EQ(ToFriend1, ToImportedFriend1);
+EXPECT_EQ(ToFriend2, ToImportedFriend2);
+  }
 };
 
 TEST_P(ImportFriendClasses, ImportOfFriendRecordDoesNotMergeDefinition) {
@@ -4343,21 +4362,7 @@
 friend class X;
   };
   )";
-  Decl *ToTu = getToTuDecl(Code, Lang_CXX03);
-  Decl *FromTu = getTuDecl(Code, Lang_CXX03, "from.cc");
-
-  auto *ToFriend1 = FirstDeclMatcher().match(ToTu, friendDecl());
-  auto *ToFriend2 = LastDeclMatcher().match(ToTu, friendDecl());
-  auto *FromFriend1 =
-  FirstDeclMatcher().match(FromTu, friendDecl());
-  auto *FromFriend2 = LastDeclMatcher().match(FromTu, friendDecl());
-
-  FriendDecl *ToImportedFriend1 = Import(FromFriend1, Lang_CXX03);
-  FriendDecl *ToImportedFriend2 = Import(FromFriend2, Lang_CXX03);
-
-  EXPECT_NE(ToImportedFriend1, ToImportedFriend2);
-  EXPECT_EQ(ToFriend1, ToImportedFriend1);
-  EXPECT_EQ(ToFriend2, ToImportedFriend2);
+  testRepeatedFriendImport(Code);
 }
 
 TEST_P(ImportFriendClasses, ImportOfRepeatedFriendDecl) {
@@ -4368,21 +4373,31 @@
 friend void f();
   };
   )";
-  Decl *ToTu = getToTuDecl(Code, Lang_CXX03);
-  Decl *FromTu = getTuDecl(Code, Lang_CXX03, "from.cc");
-
-  auto *ToFriend1 = FirstDeclMatcher().match(ToTu, friendDecl());
-  auto *ToFriend2 = LastDeclMatcher().match(ToTu, friendDecl());
-  auto *FromFriend1 =
-  FirstDeclMatcher().match(FromTu, friendDecl());
-  auto *FromFriend2 = LastDeclMatcher().match(FromTu, friendDecl());
+  testRepeatedFriendImport(Code);
+}
 
-  FriendDecl *ToImportedFriend1 = Import(FromFriend1, Lang_CXX03);
-  FriendDecl *ToImportedFriend2 = Import(FromFriend2, Lang_CXX03);
+TEST_P(ImportFriendClasses, ImportOfRepeatedFriendFunctionTemplateDecl) {
+  const char *Code =
+  R"(
+template 
+class Container {
+  template  friend void m();
+  template  friend void m();
+};
+  )";
+  testRepeatedFriendImport(Code);
+}
 
-  EXPECT_NE(ToImportedFriend1, ToImportedFriend2);
-  EXPECT_EQ(ToFriend1, ToImportedFriend1);
-  EXPECT_EQ(ToFriend2, ToImportedFriend2);
+TEST_P(ImportFriendClasses, ImportOfRepeatedFriendClassTemplateDecl) {
+  const char *Code =
+  R"(
+template 
+class Container {
+  template  friend class X;
+  template  friend class X;
+};
+  )";
+  testRepeatedFriendImport(Code);
 }
 
 TEST_P(ASTImporterOptionSpecificTestBase, FriendFunInClassTemplate) {
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -4064,22 +4064,32 @@
   unsigned int IndexOfDecl;
 };
 
-template 
-static FriendCountAndPosition getFriendCountAndPosition(
-const FriendDecl *FD,
-llvm::function_ref GetCanTypeOrDecl) {
+static bool IsEquivalentFriend(ASTImporter &Importer, FriendDecl *FD1,
+   FriendDecl *FD2) {
+  if ((!FD1->getFriendType()) != (!FD2->getFriendType()))
+return false;
+
+  if (auto *TSI = FD1->getFriendType())
+return Importer.IsStructurallyEquivalent(
+TSI->getType(), FD2->getFriendType()->getType(), /*Complain=*/false);
+
+  StructuralEquivalenceContext Ctx(
+  Importer.getFromContext(), Importer.getToContext(),
+  Importer.getNonEquivalentDecls(), getStructuralEquivalenceKind(Importer));
+  return Ctx.IsEquivalent(FD1, FD2);
+}
+
+static FriendCountAndPosition getFriendCountAndPosition(ASTImporter &Importer,
+FriendDecl *FD) {
   unsigned int FriendCount = 0;
   std::optional FriendPosition;
   const auto *RD = cast(FD->getLexicalDeclContext());
 
-

[clang] 177ec17 - [libclang] Expose arguments of clang::annotate

2023-08-11 Thread Aaron Ballman via cfe-commits

Author: fridtjof
Date: 2023-08-11T10:03:39-04:00
New Revision: 177ec17944af5fb87445017c3ac9028bbc1d710f

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

LOG: [libclang] Expose arguments of clang::annotate

This enables easy consumption of arbitrary data added
to this annotation in addition to the annotation category,
which was already exposed.

This is a re-application of the changes in
5aa06b18940c9b96cbf1c31da6aee3fbb92183ed which were reverted in
332a34c71e7675ab4e0ebd28b0d2c15302a81a51.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CursorVisitor.h
clang/unittests/libclang/LibclangTest.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 22f7a08ae03c67..c438db074a19b7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -249,6 +249,8 @@ clang-format
 libclang
 
 
+- Exposed arguments of ``clang::annotate``.
+
 Static Analyzer
 ---
 

diff  --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 1bdc0bf742a8ce..ca9467eb1ac23e 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -23,6 +23,7 @@
 #include "CursorVisitor.h"
 #include "clang-c/FatalErrorHandler.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/AttrVisitor.h"
 #include "clang/AST/DeclObjCCommon.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
@@ -575,6 +576,13 @@ bool CursorVisitor::VisitChildren(CXCursor Cursor) {
   A->getInterfaceLoc()->getTypeLoc().getBeginLoc(), TU));
   }
 
+  if (clang_isAttribute(Cursor.kind)) {
+if (const Attr *A = getCursorAttr(Cursor))
+  return Visit(A);
+
+return false;
+  }
+
   // If pointing inside a macro definition, check if the token is an identifier
   // that was ever defined as a macro. In such a case, create a "pseudo" macro
   // expansion cursor for that token.
@@ -2089,7 +2097,8 @@ class MemberRefVisit : public VisitorJob {
 (SourceLocation::UIntTy)(uintptr_t)data[1]);
   }
 };
-class EnqueueVisitor : public ConstStmtVisitor {
+class EnqueueVisitor : public ConstStmtVisitor,
+   public ConstAttrVisitor {
   friend class OMPClauseEnqueue;
   VisitorWorkList &WL;
   CXCursor Parent;
@@ -2231,6 +2240,9 @@ class EnqueueVisitor : public 
ConstStmtVisitor {
   void VisitOMPTargetTeamsDistributeSimdDirective(
   const OMPTargetTeamsDistributeSimdDirective *D);
 
+  // Attributes
+  void VisitAnnotateAttr(const AnnotateAttr *A);
+
 private:
   void AddDeclarationNameInfo(const Stmt *S);
   void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc Qualifier);
@@ -2242,6 +2254,7 @@ class EnqueueVisitor : public 
ConstStmtVisitor {
   void AddTypeLoc(TypeSourceInfo *TI);
   void EnqueueChildren(const Stmt *S);
   void EnqueueChildren(const OMPClause *S);
+  void EnqueueChildren(const AnnotateAttr *A);
 };
 } // namespace
 
@@ -2736,6 +2749,20 @@ void EnqueueVisitor::EnqueueChildren(const OMPClause *S) 
{
   VisitorWorkList::iterator I = WL.begin() + size, E = WL.end();
   std::reverse(I, E);
 }
+
+void EnqueueVisitor::EnqueueChildren(const AnnotateAttr *A) {
+  unsigned size = WL.size();
+  for (const Expr *Arg : A->args()) {
+VisitStmt(Arg);
+  }
+  if (size == WL.size())
+return;
+  // Now reverse the entries we just added.  This will match the DFS
+  // ordering performed by the worklist.
+  VisitorWorkList::iterator I = WL.begin() + size, E = WL.end();
+  std::reverse(I, E);
+}
+
 void EnqueueVisitor::VisitAddrLabelExpr(const AddrLabelExpr *E) {
   WL.push_back(LabelRefVisit(E->getLabel(), E->getLabelLoc(), Parent));
 }
@@ -3008,7 +3035,7 @@ void EnqueueVisitor::VisitOpaqueValueExpr(const 
OpaqueValueExpr *E) {
   // If the opaque value has a source expression, just transparently
   // visit that.  This is useful for (e.g.) pseudo-object expressions.
   if (Expr *SourceExpr = E->getSourceExpr())
-return Visit(SourceExpr);
+return ConstStmtVisitor::Visit(SourceExpr);
 }
 void EnqueueVisitor::VisitLambdaExpr(const LambdaExpr *E) {
   AddStmt(E->getBody());
@@ -3028,7 +3055,7 @@ void EnqueueVisitor::VisitCXXParenListInitExpr(const 
CXXParenListInitExpr *E) {
 }
 void EnqueueVisitor::VisitPseudoObjectExpr(const PseudoObjectExpr *E) {
   // Treat the expression like its syntactic form.
-  Visit(E->getSyntacticForm());
+  ConstStmtVisitor::Visit(E->getSyntacticForm());
 }
 
 void EnqueueVisitor::VisitOMPExecutableDirective(
@@ -3338,9 +3365,28 @@ void 
EnqueueVisitor::VisitOMPTargetTeamsDistributeSimdDirective(
   VisitOMPLoopDirective(D);
 }
 
+void EnqueueVisitor::VisitAnnotateAttr(const AnnotateAttr *A) {
+  EnqueueChildren(A);
+}
+
 

[PATCH] D151373: [libclang] Expose arguments of clang::annotate

2023-08-11 Thread Aaron Ballman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG177ec17944af: [libclang] Expose arguments of clang::annotate 
(authored by fridtjof, committed by aaron.ballman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151373

Files:
  clang/docs/ReleaseNotes.rst
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CursorVisitor.h
  clang/unittests/libclang/LibclangTest.cpp

Index: clang/unittests/libclang/LibclangTest.cpp
===
--- clang/unittests/libclang/LibclangTest.cpp
+++ clang/unittests/libclang/LibclangTest.cpp
@@ -1246,6 +1246,52 @@
   EXPECT_EQ(fromCXString(clang_getCursorSpelling(*staticAssertCsr)), "");
 }
 
+TEST_F(LibclangParseTest, ExposesAnnotateArgs) {
+  const char testSource[] = R"cpp(
+[[clang::annotate("category", 42)]]
+void func() {}
+)cpp";
+  std::string fileName = "main.cpp";
+  WriteFile(fileName, testSource);
+
+  const char *Args[] = {"-xc++"};
+  ClangTU = clang_parseTranslationUnit(Index, fileName.c_str(), Args, 1,
+   nullptr, 0, TUFlags);
+
+  int attrCount = 0;
+
+  Traverse(
+  [&attrCount](CXCursor cursor, CXCursor parent) -> CXChildVisitResult {
+if (cursor.kind == CXCursor_AnnotateAttr) {
+  int childCount = 0;
+  clang_visitChildren(
+  cursor,
+  [](CXCursor child, CXCursor,
+ CXClientData data) -> CXChildVisitResult {
+int *pcount = static_cast(data);
+
+// we only expect one argument here, so bail otherwise
+EXPECT_EQ(*pcount, 0);
+
+auto *result = clang_Cursor_Evaluate(child);
+EXPECT_NE(result, nullptr);
+EXPECT_EQ(clang_EvalResult_getAsInt(result), 42);
+clang_EvalResult_dispose(result);
+
+++*pcount;
+
+return CXChildVisit_Recurse;
+  },
+  &childCount);
+  attrCount++;
+  return CXChildVisit_Continue;
+}
+return CXChildVisit_Recurse;
+  });
+
+  EXPECT_EQ(attrCount, 1);
+}
+
 class LibclangRewriteTest : public LibclangParseTest {
 public:
   CXRewriter Rew = nullptr;
Index: clang/tools/libclang/CursorVisitor.h
===
--- clang/tools/libclang/CursorVisitor.h
+++ clang/tools/libclang/CursorVisitor.h
@@ -276,7 +276,9 @@
   bool IsInRegionOfInterest(CXCursor C);
   bool RunVisitorWorkList(VisitorWorkList &WL);
   void EnqueueWorkList(VisitorWorkList &WL, const Stmt *S);
+  void EnqueueWorkList(VisitorWorkList &WL, const Attr *A);
   LLVM_ATTRIBUTE_NOINLINE bool Visit(const Stmt *S);
+  LLVM_ATTRIBUTE_NOINLINE bool Visit(const Attr *A);
 
 private:
   std::optional handleDeclForVisitation(const Decl *D);
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -23,6 +23,7 @@
 #include "CursorVisitor.h"
 #include "clang-c/FatalErrorHandler.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/AttrVisitor.h"
 #include "clang/AST/DeclObjCCommon.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
@@ -575,6 +576,13 @@
   A->getInterfaceLoc()->getTypeLoc().getBeginLoc(), TU));
   }
 
+  if (clang_isAttribute(Cursor.kind)) {
+if (const Attr *A = getCursorAttr(Cursor))
+  return Visit(A);
+
+return false;
+  }
+
   // If pointing inside a macro definition, check if the token is an identifier
   // that was ever defined as a macro. In such a case, create a "pseudo" macro
   // expansion cursor for that token.
@@ -2089,7 +2097,8 @@
 (SourceLocation::UIntTy)(uintptr_t)data[1]);
   }
 };
-class EnqueueVisitor : public ConstStmtVisitor {
+class EnqueueVisitor : public ConstStmtVisitor,
+   public ConstAttrVisitor {
   friend class OMPClauseEnqueue;
   VisitorWorkList &WL;
   CXCursor Parent;
@@ -2231,6 +2240,9 @@
   void VisitOMPTargetTeamsDistributeSimdDirective(
   const OMPTargetTeamsDistributeSimdDirective *D);
 
+  // Attributes
+  void VisitAnnotateAttr(const AnnotateAttr *A);
+
 private:
   void AddDeclarationNameInfo(const Stmt *S);
   void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc Qualifier);
@@ -2242,6 +2254,7 @@
   void AddTypeLoc(TypeSourceInfo *TI);
   void EnqueueChildren(const Stmt *S);
   void EnqueueChildren(const OMPClause *S);
+  void EnqueueChildren(const AnnotateAttr *A);
 };
 } // namespace
 
@@ -2736,6 +2749,20 @@
   VisitorWorkList::iterator I = WL.begin() + size, E = WL.end();
   std::reverse(I, E);
 }
+
+void EnqueueVisitor::EnqueueChildren(const AnnotateAttr *A) {
+  unsigned size = WL.size();
+  for (const Expr *Arg : A->args()) {
+VisitStmt(Arg);
+  }
+  if (size == WL.size())
+return;
+  // Now reverse t

[PATCH] D151373: [libclang] Expose arguments of clang::annotate

2023-08-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D151373#4578560 , @fridtjof wrote:

> It was the unit test I added - I forgot to properly dispose of the EvalResult 
> there

I've re-landed the changes in 177ec17944af5fb87445017c3ac9028bbc1d710f 
, thank 
you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151373

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


[PATCH] D157649: [clang-tidy] Fix crash when diagnostic is emit with invalid location

2023-08-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157649

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


[clang] 0f73a24 - [clang][Sema] Skip access check on arrays of zero-length element

2023-08-11 Thread via cfe-commits

Author: dingfei
Date: 2023-08-11T22:05:04+08:00
New Revision: 0f73a2406a16f3a69dd6e62f0faa3a4aa05c5d84

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

LOG: [clang][Sema] Skip access check on arrays of zero-length element

Bound check on array of zero-sized element isn't meaningful.

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

Reviewed By: jacquesguan

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

Added: 
clang/test/Sema/array-bounds-zero-length-elem-gh64564.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c438db074a19b7..a80f57d9bb71ac 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -185,6 +185,8 @@ Miscellaneous Clang Crashes Fixed
   terminated. Clang should now also recover better when an @end is missing
   between blocks.
   `Issue 64065 `_
+- Fixed a crash when check array access on zero-length element.
+  `Issue 64564 `_
 
 Target Specific Changes
 ---

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 09696ee73ca38c..984e43c1fcfad5 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -17146,7 +17146,7 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const 
Expr *IndexExpr,
   ASTC.getTypeSizeInCharsIfKnown(EffectiveType);
   // PR50741 - If EffectiveType has unknown size (e.g., if it's a void
   // pointer) bounds-checking isn't meaningful.
-  if (!ElemCharUnits)
+  if (!ElemCharUnits || ElemCharUnits->isZero())
 return;
   llvm::APInt ElemBytes(index.getBitWidth(), ElemCharUnits->getQuantity());
   // If index has more active bits than address space, we already know

diff  --git a/clang/test/Sema/array-bounds-zero-length-elem-gh64564.c 
b/clang/test/Sema/array-bounds-zero-length-elem-gh64564.c
new file mode 100644
index 00..1aaf01d82011bc
--- /dev/null
+++ b/clang/test/Sema/array-bounds-zero-length-elem-gh64564.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin -verify %s
+
+int a[][0]; // expected-warning {{tentative array definition assumed to have 
one element}}
+void gh64564_1(void) {
+  int b = a[0x1][0];
+}
+
+typedef struct {} S;
+S s[]; // expected-warning {{tentative array definition assumed to have one 
element}}
+void gh64564_2(void) {
+  S t = s[0x1];
+}



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


[clang] afff91d - [ASTImporter][NFC] Fix typo in testcase

2023-08-11 Thread via cfe-commits

Author: dingfei
Date: 2023-08-11T22:06:56+08:00
New Revision: afff91de082d1347d81c413a424f0a1b6fb02774

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

LOG: [ASTImporter][NFC] Fix typo in testcase

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

Added: 


Modified: 
clang/unittests/AST/StructuralEquivalenceTest.cpp

Removed: 




diff  --git a/clang/unittests/AST/StructuralEquivalenceTest.cpp 
b/clang/unittests/AST/StructuralEquivalenceTest.cpp
index 319eefe1e6ba3e..092d9cc319a2e5 100644
--- a/clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ b/clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -992,8 +992,8 @@ TEST_F(StructuralEquivalenceRecordContextTest, 
NamespaceInlineVsInline) {
 
 TEST_F(StructuralEquivalenceRecordContextTest, NamespaceInlineTopLevel) {
   auto Decls =
-  makeNamedDecls("inline namespace A { class X; } }",
- "inline namespace B { class X; } }", Lang_CXX17, "X");
+  makeNamedDecls("inline namespace A { class X; }",
+ "inline namespace B { class X; }", Lang_CXX17, "X");
   EXPECT_TRUE(testStructuralMatch(Decls));
 }
 



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


[PATCH] D157584: [clang][Sema] Skip access check on arrays of zero-length element

2023-08-11 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0f73a2406a16: [clang][Sema] Skip access check on arrays of 
zero-length element (authored by dingfei ).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157584

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/array-bounds-zero-length-elem-gh64564.c


Index: clang/test/Sema/array-bounds-zero-length-elem-gh64564.c
===
--- /dev/null
+++ clang/test/Sema/array-bounds-zero-length-elem-gh64564.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin -verify %s
+
+int a[][0]; // expected-warning {{tentative array definition assumed to have 
one element}}
+void gh64564_1(void) {
+  int b = a[0x1][0];
+}
+
+typedef struct {} S;
+S s[]; // expected-warning {{tentative array definition assumed to have one 
element}}
+void gh64564_2(void) {
+  S t = s[0x1];
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -17146,7 +17146,7 @@
   ASTC.getTypeSizeInCharsIfKnown(EffectiveType);
   // PR50741 - If EffectiveType has unknown size (e.g., if it's a void
   // pointer) bounds-checking isn't meaningful.
-  if (!ElemCharUnits)
+  if (!ElemCharUnits || ElemCharUnits->isZero())
 return;
   llvm::APInt ElemBytes(index.getBitWidth(), ElemCharUnits->getQuantity());
   // If index has more active bits than address space, we already know
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -185,6 +185,8 @@
   terminated. Clang should now also recover better when an @end is missing
   between blocks.
   `Issue 64065 `_
+- Fixed a crash when check array access on zero-length element.
+  `Issue 64564 `_
 
 Target Specific Changes
 ---


Index: clang/test/Sema/array-bounds-zero-length-elem-gh64564.c
===
--- /dev/null
+++ clang/test/Sema/array-bounds-zero-length-elem-gh64564.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin -verify %s
+
+int a[][0]; // expected-warning {{tentative array definition assumed to have one element}}
+void gh64564_1(void) {
+  int b = a[0x1][0];
+}
+
+typedef struct {} S;
+S s[]; // expected-warning {{tentative array definition assumed to have one element}}
+void gh64564_2(void) {
+  S t = s[0x1];
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -17146,7 +17146,7 @@
   ASTC.getTypeSizeInCharsIfKnown(EffectiveType);
   // PR50741 - If EffectiveType has unknown size (e.g., if it's a void
   // pointer) bounds-checking isn't meaningful.
-  if (!ElemCharUnits)
+  if (!ElemCharUnits || ElemCharUnits->isZero())
 return;
   llvm::APInt ElemBytes(index.getBitWidth(), ElemCharUnits->getQuantity());
   // If index has more active bits than address space, we already know
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -185,6 +185,8 @@
   terminated. Clang should now also recover better when an @end is missing
   between blocks.
   `Issue 64065 `_
+- Fixed a crash when check array access on zero-length element.
+  `Issue 64564 `_
 
 Target Specific Changes
 ---
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157637: [ASTImporter][NFC] Fix typo in testcase

2023-08-11 Thread Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGafff91de082d: [ASTImporter][NFC] Fix typo in testcase 
(authored by dingfei ).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157637

Files:
  clang/unittests/AST/StructuralEquivalenceTest.cpp


Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -992,8 +992,8 @@
 
 TEST_F(StructuralEquivalenceRecordContextTest, NamespaceInlineTopLevel) {
   auto Decls =
-  makeNamedDecls("inline namespace A { class X; } }",
- "inline namespace B { class X; } }", Lang_CXX17, "X");
+  makeNamedDecls("inline namespace A { class X; }",
+ "inline namespace B { class X; }", Lang_CXX17, "X");
   EXPECT_TRUE(testStructuralMatch(Decls));
 }
 


Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -992,8 +992,8 @@
 
 TEST_F(StructuralEquivalenceRecordContextTest, NamespaceInlineTopLevel) {
   auto Decls =
-  makeNamedDecls("inline namespace A { class X; } }",
- "inline namespace B { class X; } }", Lang_CXX17, "X");
+  makeNamedDecls("inline namespace A { class X; }",
+ "inline namespace B { class X; }", Lang_CXX17, "X");
   EXPECT_TRUE(testStructuralMatch(Decls));
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157680: [X86]Support options -mno-gather -mno-scatter

2023-08-11 Thread Kan Shengchen via Phabricator via cfe-commits
skan added inline comments.



Comment at: llvm/lib/Target/X86/X86.td:437
+: SubtargetFeature<"prefer-no-gather", "PreferGather", "false",
+   "Indicates if gather prefer to be disabled">;
+def FeaturePreferNoScatter

Does "Prefer no gather instructions" sound better?

I think these two should be put under "X86 Subtarget Tuning features"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157680

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


[clang] c52d950 - [AArch64][SVE] Add asm predicate constraint Uph

2023-08-11 Thread Matt Devereau via cfe-commits

Author: Matt Devereau
Date: 2023-08-11T14:48:19Z
New Revision: c52d9509d40d3048914b144618232213e6076e05

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

LOG: [AArch64][SVE] Add asm predicate constraint Uph

Some instructions such as multi-vector LD1 only accept a range
of PN8-PN15 predicate-as-counter. This new constraint allows more
refined parsing and better decision making when parsing these
instructions from ASM, instead of defaulting to Upa which incorrectly
uses the whole range of registers P0-P15 from the register class PPR.

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

Added: 


Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/test/CodeGen/aarch64-sve-inline-asm-datatypes.c
llvm/docs/LangRef.rst
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/CodeGen/AArch64/aarch64-sve-asm.ll

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 7c4cc5fb33f886..6c43c8b592622d 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -1288,8 +1288,9 @@ bool AArch64TargetInfo::validateAsmConstraint(
 Info.setAllowsRegister();
 return true;
   case 'U':
-if (Name[1] == 'p' && (Name[2] == 'l' || Name[2] == 'a')) {
-  // SVE predicate registers ("Upa"=P0-15, "Upl"=P0-P7)
+if (Name[1] == 'p' &&
+(Name[2] == 'l' || Name[2] == 'a' || Name[2] == 'h')) {
+  // SVE predicate registers ("Upa"=P0-15, "Upl"=P0-P7, "Uph"=P8-P15)
   Info.setAllowsRegister();
   Name += 2;
   return true;

diff  --git a/clang/test/CodeGen/aarch64-sve-inline-asm-datatypes.c 
b/clang/test/CodeGen/aarch64-sve-inline-asm-datatypes.c
index 5c1e931a727124..14a29dfac2c7bd 100644
--- a/clang/test/CodeGen/aarch64-sve-inline-asm-datatypes.c
+++ b/clang/test/CodeGen/aarch64-sve-inline-asm-datatypes.c
@@ -168,6 +168,30 @@ SVBOOL_TEST_UPL(__SVInt32_t, s) ;
 SVBOOL_TEST_UPL(__SVInt64_t, d) ;
 // CHECK: call  asm sideeffect "fadd $0.d, $1.d, $2.d, 
$3.d\0A", "=w,@3Upl,w,w"( %in1,  %in2, 
 %in3)
 
+#define SVBOOL_TEST_UPH(DT, KIND)\
+__SVBool_t func_bool_uph_##KIND(__SVBool_t in1, DT in2, DT in3)\
+{\
+  __SVBool_t out;\
+  asm volatile (\
+"fadd %[out]." #KIND ", %[in1]." #KIND ", %[in2]." #KIND ", %[in3]." #KIND 
"\n"\
+: [out] "=w" (out)\
+:  [in1] "Uph" (in1),\
+  [in2] "w" (in2),\
+  [in3] "w" (in3)\
+:);\
+  return out;\
+}
+
+SVBOOL_TEST_UPH(__SVInt8_t, b) ;
+// CHECK: call  asm sideeffect "fadd $0.b, $1.b, $2.b, 
$3.b\0A", "=w,@3Uph,w,w"( %in1,  %in2, 
 %in3)
+SVBOOL_TEST_UPH(__SVInt16_t, h) ;
+// CHECK: call  asm sideeffect "fadd $0.h, $1.h, $2.h, 
$3.h\0A", "=w,@3Uph,w,w"( %in1,  %in2, 
 %in3)
+SVBOOL_TEST_UPH(__SVInt32_t, s) ;
+// CHECK: call  asm sideeffect "fadd $0.s, $1.s, $2.s, 
$3.s\0A", "=w,@3Uph,w,w"( %in1,  %in2, 
 %in3)
+SVBOOL_TEST_UPH(__SVInt64_t, d) ;
+// CHECK: call  asm sideeffect "fadd $0.d, $1.d, $2.d, 
$3.d\0A", "=w,@3Uph,w,w"( %in1,  %in2, 
 %in3)
+
+
 #define SVFLOAT_TEST(DT,KIND)\
 DT func_float_##DT##KIND(DT inout1, DT in2)\
 {\

diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index f024d009966a8d..f7f5cc193a149c 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -4997,7 +4997,8 @@ AArch64:
 - ``w``: A 32, 64, or 128-bit floating-point, SIMD or SVE vector register.
 - ``x``: Like w, but restricted to registers 0 to 15 inclusive.
 - ``y``: Like w, but restricted to SVE vector registers Z0 to Z7 inclusive.
-- ``Upl``: One of the low eight SVE predicate registers (P0 to P7)
+- ``Uph``: One of the upper eight SVE predicate registers (P8 to P15)
+- ``Upl``: One of the lower eight SVE predicate registers (P0 to P7)
 - ``Upa``: Any of the SVE predicate registers (P0 to P15)
 
 AMDGPU:

diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 948419f29b48e9..d0f4789d198058 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -9987,19 +9987,31 @@ const char *AArch64TargetLowering::LowerXConstraint(EVT 
ConstraintVT) const {
   return "r";
 }
 
-enum PredicateConstraint {
-  Upl,
-  Upa,
-  Invalid
-};
+enum PredicateConstraint { Uph, Upl, Upa, Invalid };
 
 static PredicateConstraint parsePredicateConstraint(StringRef Constraint) {
-  PredicateConstraint P = PredicateConstraint::Invalid;
-  if (Constraint == "Upa")
-P = PredicateConstraint::Upa;
-  if (Constraint == "Upl")
-P = PredicateConstraint::Upl;
-  return P;
+  return StringSwitch(Constraint)
+  .Case("Uph", PredicateConstraint::Uph)
+  .Case("Upl", PredicateConstraint::Upl)
+  .Case("Upa", PredicateConstraint::Upa)
+  .Default(PredicateConstraint::Invalid);
+}
+
+static const Tar

[PATCH] D157517: [AArch64][SVE] Add asm predicate constraint Uph

2023-08-11 Thread Matt Devereau via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc52d9509d40d: [AArch64][SVE] Add asm predicate constraint 
Uph (authored by MattDevereau).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157517

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/test/CodeGen/aarch64-sve-inline-asm-datatypes.c
  llvm/docs/LangRef.rst
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/test/CodeGen/AArch64/aarch64-sve-asm.ll

Index: llvm/test/CodeGen/AArch64/aarch64-sve-asm.ll
===
--- llvm/test/CodeGen/AArch64/aarch64-sve-asm.ll
+++ llvm/test/CodeGen/AArch64/aarch64-sve-asm.ll
@@ -68,3 +68,14 @@
   %1 = tail call  asm "incp $0.s, $1", "=w,@3Upa,0"( %Pg,  %Zn)
   ret  %1
 }
+
+; Function Attrs: nounwind readnone
+; CHECK: [[ARG1:%[0-9]+]]:zpr = COPY $z1
+; CHECK: [[ARG2:%[0-9]+]]:zpr = COPY $z0
+; CHECK: [[ARG3:%[0-9]+]]:ppr = COPY $p0
+; CHECK: [[ARG4:%[0-9]+]]:ppr_p8to15 = COPY [[ARG3]]
+; CHECK: INLINEASM {{.*}} [[ARG4]]
+define  @test_svfadd_f16_Uph_constraint( %Pg,  %Zn,  %Zm) {
+  %1 = tail call  asm "fadd $0.h, $1/m, $2.h, $3.h", "=w,@3Uph,w,w"( %Pg,  %Zn,  %Zm)
+  ret  %1
+}
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -9987,19 +9987,31 @@
   return "r";
 }
 
-enum PredicateConstraint {
-  Upl,
-  Upa,
-  Invalid
-};
+enum PredicateConstraint { Uph, Upl, Upa, Invalid };
 
 static PredicateConstraint parsePredicateConstraint(StringRef Constraint) {
-  PredicateConstraint P = PredicateConstraint::Invalid;
-  if (Constraint == "Upa")
-P = PredicateConstraint::Upa;
-  if (Constraint == "Upl")
-P = PredicateConstraint::Upl;
-  return P;
+  return StringSwitch(Constraint)
+  .Case("Uph", PredicateConstraint::Uph)
+  .Case("Upl", PredicateConstraint::Upl)
+  .Case("Upa", PredicateConstraint::Upa)
+  .Default(PredicateConstraint::Invalid);
+}
+
+static const TargetRegisterClass *
+getPredicateRegisterClass(PredicateConstraint Constraint, EVT VT) {
+  if (!VT.isScalableVector() || VT.getVectorElementType() != MVT::i1)
+return nullptr;
+
+  switch (Constraint) {
+  default:
+return nullptr;
+  case PredicateConstraint::Uph:
+return &AArch64::PPR_p8to15RegClass;
+  case PredicateConstraint::Upl:
+return &AArch64::PPR_3bRegClass;
+  case PredicateConstraint::Upa:
+return &AArch64::PPRRegClass;
+  }
 }
 
 // The set of cc code supported is from
@@ -10191,13 +10203,8 @@
 }
   } else {
 PredicateConstraint PC = parsePredicateConstraint(Constraint);
-if (PC != PredicateConstraint::Invalid) {
-  if (!VT.isScalableVector() || VT.getVectorElementType() != MVT::i1)
-return std::make_pair(0U, nullptr);
-  bool restricted = (PC == PredicateConstraint::Upl);
-  return restricted ? std::make_pair(0U, &AArch64::PPR_3bRegClass)
-: std::make_pair(0U, &AArch64::PPRRegClass);
-}
+if (const TargetRegisterClass *RegClass = getPredicateRegisterClass(PC, VT))
+  return std::make_pair(0U, RegClass);
   }
   if (StringRef("{cc}").equals_insensitive(Constraint) ||
   parseConstraintCode(Constraint) != AArch64CC::Invalid)
Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -4997,7 +4997,8 @@
 - ``w``: A 32, 64, or 128-bit floating-point, SIMD or SVE vector register.
 - ``x``: Like w, but restricted to registers 0 to 15 inclusive.
 - ``y``: Like w, but restricted to SVE vector registers Z0 to Z7 inclusive.
-- ``Upl``: One of the low eight SVE predicate registers (P0 to P7)
+- ``Uph``: One of the upper eight SVE predicate registers (P8 to P15)
+- ``Upl``: One of the lower eight SVE predicate registers (P0 to P7)
 - ``Upa``: Any of the SVE predicate registers (P0 to P15)
 
 AMDGPU:
Index: clang/test/CodeGen/aarch64-sve-inline-asm-datatypes.c
===
--- clang/test/CodeGen/aarch64-sve-inline-asm-datatypes.c
+++ clang/test/CodeGen/aarch64-sve-inline-asm-datatypes.c
@@ -168,6 +168,30 @@
 SVBOOL_TEST_UPL(__SVInt64_t, d) ;
 // CHECK: call  asm sideeffect "fadd $0.d, $1.d, $2.d, $3.d\0A", "=w,@3Upl,w,w"( %in1,  %in2,  %in3)
 
+#define SVBOOL_TEST_UPH(DT, KIND)\
+__SVBool_t func_bool_uph_##KIND(__SVBool_t in1, DT in2, DT in3)\
+{\
+  __SVBool_t out;\
+  asm volatile (\
+"fadd %[out]." #KIND ", %[in1]." #KIND ", %[in2]." #KIND ", %[in3]." #KIND "\n"\
+: [out] "=w" (out)\
+:  [in1] "Uph" (in1),\
+  [in2] "w" (in2),\
+  [in3] "w" (in3)\
+:);\
+  return out;\
+}
+
+SVBOOL_TEST_UPH(__SVInt8_t, b) ;
+// CHECK: call  asm sideeffect "fadd $0.b, $1.b, $2.b, $3.b\0A", "=w,@3Uph,w,w"( %in1,  %in2,  %in

[PATCH] D155081: Specify the developer policy around links to external resources

2023-08-11 Thread PoYao Chang via Phabricator via cfe-commits
rZhBoYao added inline comments.



Comment at: llvm/docs/DeveloperPolicy.rst:359
+  If the patch fixes a bug in GitHub Issues, we encourage adding
+  "Fixes https://github.com/llvm/llvm-project/issues/12345"; to automate closing
+  the issue in GitHub. If the patch has been reviewed, we encourage adding a

probinson wrote:
> mehdi_amini wrote:
> > ldionne wrote:
> > > smeenai wrote:
> > > > aaron.ballman wrote:
> > > > > arsenm wrote:
> > > > > > I haven't quite figured out what the exact syntaxes which are 
> > > > > > automatically recognized. It seems to recognize "Fixes #Nxyz"
> > > > > Yup, it does support that form as well. I had heard more than once 
> > > > > during code review that folks seem to prefer the full link because 
> > > > > it's easier to click on that from the commit message than it is to 
> > > > > navigate to the fix from the number alone. That seemed like a pretty 
> > > > > good reason to recommend the full form, but I don't have strong 
> > > > > opinions.
> > > > +1 for encouraging the full link
> > > Perhaps we could encourage using `https://llvm.org/PR12345` instead? Does 
> > > anybody know whether `llvm.org/PRXXX` is something that we intend to keep 
> > > around with the Github transition or not?
> > @arsenm: It's documented 
> > https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
> > And for linking cross-repo: 
> > https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls#issues-and-pull-requests
> > Perhaps we could encourage using `https://llvm.org/PR12345` instead? Does 
> > anybody know whether `llvm.org/PRXXX` is something that we intend to keep 
> > around with the Github transition or not?
> 
> Currently the PRxxx links are to the old bugzillas, not the Github issues. It 
> might be sad to lose that.
If the full link is preferred, can you update the first bullet point in [[ 
https://llvm.org/docs/BugLifeCycle.html#resolving-closing-bugs | the 
Resolving/Closing bugs section of LLVM Bug Life Cycle ]]?


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

https://reviews.llvm.org/D155081

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


[PATCH] D157702: [clang][analyzer][NFC] Change PlacementNewChecker into PlacementNew in documentation

2023-08-11 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

Correct. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157702

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


[PATCH] D157702: [clang][analyzer][NFC] Change PlacementNewChecker into PlacementNew in documentation

2023-08-11 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Do we have other typos like this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157702

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


[PATCH] D157727: [clang] Fix copy-and-paste error in CXXRecordDecl tabledef

2023-08-11 Thread Christian Blichmann via Phabricator via cfe-commits
cblichmann created this revision.
cblichmann added reviewers: clang, rsmith, zahiraam.
cblichmann added a project: clang.
Herald added a project: All.
cblichmann requested review of this revision.
Herald added a subscriber: cfe-commits.

This change just updates the comment in the tabledef, no change in observable 
behavior.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157727

Files:
  clang/include/clang/AST/CXXRecordDeclDefinitionBits.def


Index: clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
===
--- clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
+++ clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
@@ -99,7 +99,7 @@
 /// True when there are protected non-static data members.
 FIELD(HasProtectedFields, 1, NO_MERGE)
 
-/// True when there are private non-static data members.
+/// True when there are public non-static data members.
 FIELD(HasPublicFields, 1, NO_MERGE)
 
 /// True if this class (or any subobject) has mutable fields.


Index: clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
===
--- clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
+++ clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
@@ -99,7 +99,7 @@
 /// True when there are protected non-static data members.
 FIELD(HasProtectedFields, 1, NO_MERGE)
 
-/// True when there are private non-static data members.
+/// True when there are public non-static data members.
 FIELD(HasPublicFields, 1, NO_MERGE)
 
 /// True if this class (or any subobject) has mutable fields.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157702: [clang][analyzer][NFC] Change PlacementNewChecker into PlacementNew in documentation

2023-08-11 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

In D157702#4580310 , @steakhal wrote:

> Do we have other typos like this?

I don't think so, only mess in overall documentation: 
https://github.com/llvm/llvm-project/issues/64614
I updated gen-static-analyzer-docs.py, and it shown me that some documentation 
is missing: https://clang.llvm.org/extra/clang-tidy/checks/list.html.
You can see it, as there are no links for some checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157702

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


[PATCH] D155081: Specify the developer policy around links to external resources

2023-08-11 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

This looks good to me.


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

https://reviews.llvm.org/D155081

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


[PATCH] D141714: Fix ast print of variables with attributes

2023-08-11 Thread Timo Stripf via Phabricator via cfe-commits
strimo378 added a comment.

@aaron.ballman I had today a teams meeting with @giulianobelinassi and we 
discussed both patches as well as that we want to work together in improving 
AST print. Both patches are fine for us since they improve the attribute 
printing. The features of the respective other patch can be easily integrated 
with minimal changes in a subsequent smaller patch. We further think that there 
are a lot more cases of attributes that we need to consider that we do not know 
atm.

I think we should go one with patch that has the higher probability to get 
landed soon. Since this branch had a lot more reviews, I suggest we go further 
with this patch. I further suggest to keep it simple and remove the tblgen part 
and add it in an subsequent patch once we know all cases and requirements. What 
do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141714

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


[PATCH] D157702: [clang][analyzer][NFC] Change PlacementNewChecker into PlacementNew in documentation

2023-08-11 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D157702#4580384 , @PiotrZSL wrote:

> In D157702#4580310 , @steakhal 
> wrote:
>
>> Do we have other typos like this?
>
> I don't think so, only mess in overall documentation: 
> https://github.com/llvm/llvm-project/issues/64614
> I updated gen-static-analyzer-docs.py, and it shown me that some 
> documentation is missing: 
> https://clang.llvm.org/extra/clang-tidy/checks/list.html.
> You can see it, as there are no links for some checks.

Yea, it's a complete mess, I agree.
I have no stakes on the docs, but I know that Ericsson folks do. They might 
wanna chim in. @donat.nagy @Szelethus


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157702

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


[PATCH] D157632: [Profile] Allow online merging with debug info correlation.

2023-08-11 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 549424.
zequanwu marked 3 inline comments as done.
zequanwu added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157632

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  compiler-rt/lib/profile/InstrProfilingMerge.c
  compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c
  compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c
  compiler-rt/test/profile/instrprof-merge-error.c

Index: compiler-rt/test/profile/instrprof-merge-error.c
===
--- compiler-rt/test/profile/instrprof-merge-error.c
+++ compiler-rt/test/profile/instrprof-merge-error.c
@@ -1,11 +1,5 @@
 // RUN: rm -rf %t; mkdir %t
 
-// RUN: %clang_pgogen -o %t/dbg -g -mllvm --debug-info-correlate -mllvm --disable-vp=true %s
-// RUN: env LLVM_PROFILE_FILE=%t/dbg_%m.profdata %run %t/dbg 2>&1 | count 0
-// RUN: env LLVM_PROFILE_FILE=%t/dbg_%m.profdata %run %t/dbg 2>&1 | FileCheck %s --check-prefix=DBG
-
-// DBG: Debug info correlation does not support profile merging at runtime.
-
 // RUN: %clang_pgogen -o %t/timeprof -mllvm -pgo-temporal-instrumentation %s
 // RUN: env LLVM_PROFILE_FILE=%t/timeprof_%m.profdata %run %t/timeprof 2>&1 | count 0
 // RUN: env LLVM_PROFILE_FILE=%t/timeprof_%m.profdata %run %t/timeprof 2>&1 | FileCheck %s --check-prefix=TIMEPROF
Index: compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c
===
--- compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c
+++ compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c
@@ -24,3 +24,29 @@
 // RUN: llvm-profdata merge -o %t.cov.normal.profdata %t.cov.profraw
 
 // RUN: diff <(llvm-profdata show %t.cov.normal.profdata) <(llvm-profdata show %t.cov.profdata)
+
+// Test debug info correlate with online merging.
+
+// RUN: rm -rf %t.profdir && mkdir %t.profdir
+
+// RUN: env LLVM_PROFILE_FILE=%t-1.profraw %run %t.normal
+// RUN: env LLVM_PROFILE_FILE=%t-2.profraw %run %t.normal
+// RUN: llvm-profdata merge -o %t.normal.profdata %t-1.profraw %t-2.profraw
+
+// RUN: %clang_pgogen -o %t -g -mllvm --debug-info-correlate -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
+// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t
+// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t
+// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t %t.profdir/
+
+// RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.profdata)
+// RUN: diff %t.normal.profdata %t.profdata
+
+// RUN: rm -rf %t.profdir && mkdir %t.profdir
+
+// RUN: %clang_pgogen -o %t.cov -g -mllvm --debug-info-correlate -mllvm -pgo-function-entry-coverage -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
+// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.cov.proflite %run %t.cov
+// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.cov.proflite %run %t.cov
+// RUN: llvm-profdata merge -o %t.cov.profdata --debug-info=%t.cov %t.profdir/
+
+// RUN: diff <(llvm-profdata show --all-functions --counts %t.cov.normal.profdata) <(llvm-profdata show --all-functions --counts %t.cov.profdata)
+// RUN: diff %t.cov.normal.profdata %t.cov.profdata
Index: compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c
===
--- compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c
+++ compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c
@@ -18,3 +18,27 @@
 // RUN: llvm-profdata merge -o %t.cov.normal.profdata %t.cov.profraw
 
 // RUN: diff %t.cov.normal.profdata %t.cov.profdata
+
+// Test debug info correlate with online merging.
+
+// RUN: rm -rf %t.profdir && mkdir %t.profdir
+
+// RUN: env LLVM_PROFILE_FILE=%t-1.profraw %run %t.normal
+// RUN: env LLVM_PROFILE_FILE=%t-2.profraw %run %t.normal
+// RUN: llvm-profdata merge -o %t.normal.profdata %t-1.profraw %t-2.profraw
+
+// RUN: %clang_pgogen -o %t -g -mllvm --debug-info-correlate -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
+// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t
+// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t
+// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t.dSYM %t.profdir/
+
+// RUN: diff %t.normal.profdata %t.profdata
+
+// RUN: rm -rf %t.profdir && mkdir %t.profdir
+
+// RUN: %clang_pgogen -o %t.cov -g -mllvm --debug-info-correlate -mllvm -pgo-function-entry-coverage -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
+// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.

[PATCH] D157632: [Profile] Allow online merging with debug info correlation.

2023-08-11 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added inline comments.



Comment at: compiler-rt/lib/profile/InstrProfilingMerge.c:129
+  // enabled.
+  if (Header->DataSize == 0) {
+if (!(__llvm_profile_get_version() & VARIANT_MASK_DBG_CORRELATE)) {

ellis wrote:
> Since we don't have the data section, we need to be confident that existing 
> profile comes from the same binary (so that the counter section is 
> identical). Can we add some extra checks here? I'm thinking we can verify 
> that some fields in the headers match and that the variant flags are 
> identical.
The [[ 
https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/profile/InstrProfiling.h#L105-L107
 | comment ]] says the caller of this function is responsible for the check. 
And we [[ 
https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/profile/InstrProfilingMerge.c#L48
 | verifies ]] that fields in both headers math before merging at 
doProfileMerging.



Comment at: compiler-rt/lib/profile/InstrProfilingMerge.c:134-136
+for (SrcCounter = SrcCountersStart,
+DstCounter = __llvm_profile_begin_counters();
+ SrcCounter < SrcCountersEnd;) {

ellis wrote:
> Can you add a check to make sure src and dst have the same number of counters 
> (`SrcCountersEnd - SrcCountersStart`)?
Added the check at `__llvm_profile_check_compatibility`. 

I use in-memory `__llvm_profile_counter_entry_size()` to calculate in-file 
SrcCountersEnd, because the header only tells number of counters.



Comment at: compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c:26
+// RUN: %clang_pgogen -o %t -g -mllvm --debug-info-correlate -mllvm 
--disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp 
%S/../Inputs/instrprof-debug-info-correlate-foo.cpp
+// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t
+// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t.dSYM %t.profdir/

ellis wrote:
> We need to run this line twice to correctly test 
> `__llvm_profile_merge_from_buffer()`
Added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157632

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


[PATCH] D157104: [analyzer] Improve underflow handling in ArrayBoundV2

2023-08-11 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.

Looks safe and good. I'm interested in the diff though.
Let me know once you have the results.
I wanna have a look before we land this.




Comment at: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp:184
+// symbolic regions on the heap (which may be introduced by checkers that
+// call SValBuilder::getConjuredHeapSymbolVal()) and non-symbolic regions
+// (e.g. a field subregion of a symbolic region) in unknown space.

Such as the MallocChecker.



Comment at: clang/test/Analysis/out-of-bounds.c:176
 }
-

Try not to introduce unrelated hunks, as it might introduce more conflicts for 
downstream users than absolutely necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157104

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


[PATCH] D157632: [Profile] Allow online merging with debug info correlation.

2023-08-11 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

In D157632#4578582 , @ellis wrote:

> I've just published https://reviews.llvm.org/D157664, so you'll want to 
> rebase ontop of it if it lands soon. I would also like to see some more tests 
> added to `instrprof-merge-error.c` to make sure two different binaries can't 
> merge profiles together with `--debug-info-correlate`. I was thinking the 
> test would be something like this.
>
>   // RUN: %clang_pgogen -o %t/a -g -mllvm --debug-info-correlate -mllvm 
> --disable-vp=true %t/main.c
>   // RUN: %clang_pgogen -o %t/b -g -mllvm --debug-info-correlate -mllvm 
> --disable-vp=true %t/main.c %t/foo.c
>   // RUN: env LLVM_PROFILE_FILE=%t/default_%m.profdata %run %t/a
>   // This next line should fail to merge because the counter sections have 
> different sizes
>   // RUN: env LLVM_PROFILE_FILE=%t/default_%m.profdata %run %t/b
>   
>   //--- main.c
>   int main() { return 0; }
>   //--- foo.c
>   int foo() { return 4; }

In this example, `%m` will translated to two different values so they won't be 
merged. As I mentioned in the inline comment, 
`__llvm_profile_check_compatibility` will verify that for us.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157632

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


[clang] a3a66de - [clang][analyzer][NFC] Change PlacementNewChecker into PlacementNew in documentation

2023-08-11 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-11T16:04:15Z
New Revision: a3a66de37fc038d46d7146c9dfe55f26fd3a

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

LOG: [clang][analyzer][NFC] Change PlacementNewChecker into PlacementNew in 
documentation

Check name according to Checkers.td is actually a PlacementNew.

Reviewed By: steakhal

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

Added: 


Modified: 
clang/docs/analyzer/checkers.rst

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index 97b5369ac86c9b..d3a4ebcaf02025 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -321,10 +321,10 @@ Check for memory leaks. Traces memory managed by 
new/delete.
int *p = new int;
  } // warn
 
-.. _cplusplus-PlacementNewChecker:
+.. _cplusplus-PlacementNew:
 
-cplusplus.PlacementNewChecker (C++)
-"""
+cplusplus.PlacementNew (C++)
+
 Check if default placement new is provided with pointers to sufficient storage 
capacity.
 
 .. code-block:: cpp



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


[clang-tools-extra] efd44f8 - [clang-tidy] Fix crash when diagnostic is emit with invalid location

2023-08-11 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-11T16:04:15Z
New Revision: efd44f80a5a8194b9fe26ff3244ce702cd8dab73

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

LOG: [clang-tidy] Fix crash when diagnostic is emit with invalid location

Fix crash when diagnostic is emit with invalid location,
but with attached valid ranges. Diagnostic can contain
invalid location, but SourceManager attached to it still
can be valid, use it in such case or fallback to known
SourceManager.

Fixes: #64602

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 019d9b1f18a5a9..41a210a83a84f3 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -437,8 +437,11 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
 SmallString<100> Message;
 Info.FormatDiagnostic(Message);
 FullSourceLoc Loc;
-if (Info.getLocation().isValid() && Info.hasSourceManager())
+if (Info.hasSourceManager())
   Loc = FullSourceLoc(Info.getLocation(), Info.getSourceManager());
+else if (Context.DiagEngine->hasSourceManager())
+  Loc = FullSourceLoc(Info.getLocation(),
+  Context.DiagEngine->getSourceManager());
 Converter.emitDiagnostic(Loc, DiagLevel, Message, Info.getRanges(),
  Info.getFixItHints());
   }

diff  --git a/clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp 
b/clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp
index c87496292b9db2..547f634a101c58 100644
--- a/clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp
@@ -25,6 +25,7 @@
 // RUN: not clang-tidy -checks='-*,modernize-use-override' 
%T/diagnostics/input.cpp -- -DCOMPILATION_ERROR 2>&1 | FileCheck 
-check-prefix=CHECK6 -implicit-check-not='{{warning:|error:}}' %s
 // RUN: clang-tidy 
-checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- 
-DMACRO_FROM_COMMAND_LINE -std=c++20 | FileCheck -check-prefix=CHECK4 
-implicit-check-not='{{warning:|error:}}' %s
 // RUN: clang-tidy 
-checks='-*,modernize-use-override,clang-diagnostic-macro-redefined,clang-diagnostic-literal-conversion'
 %s -- -DMACRO_FROM_COMMAND_LINE -std=c++20 -Wno-macro-redefined | FileCheck 
--check-prefix=CHECK7 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,modernize-use-override' %s -- -std=c++20 
-DPR64602 | FileCheck -check-prefix=CHECK8 
-implicit-check-not='{{warning:|error:}}' %s
 
 // CHECK1: error: no input files [clang-diagnostic-error]
 // CHECK1: error: no such file or directory: '{{.*}}nonexistent.cpp' 
[clang-diagnostic-error]
@@ -54,3 +55,18 @@ void f(int a) {
   // CHECK6: :[[@LINE-1]]:3: error: cannot take the address of an rvalue of 
type 'int' [clang-diagnostic-error]
 }
 #endif
+
+#ifdef PR64602 // Should not crash
+template 
+struct S
+{
+auto foo(auto);
+};
+
+template <>
+auto S<>::foo(auto)
+{
+return 1;
+}
+// CHECK8: error: template parameter list matching the non-templated nested 
type 'S<>' should be empty ('template<>') [clang-diagnostic-error]
+#endif



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


[PATCH] D157649: [clang-tidy] Fix crash when diagnostic is emit with invalid location

2023-08-11 Thread Piotr Zegar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGefd44f80a5a8: [clang-tidy] Fix crash when diagnostic is emit 
with invalid location (authored by PiotrZSL).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157649

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp


Index: clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp
@@ -25,6 +25,7 @@
 // RUN: not clang-tidy -checks='-*,modernize-use-override' 
%T/diagnostics/input.cpp -- -DCOMPILATION_ERROR 2>&1 | FileCheck 
-check-prefix=CHECK6 -implicit-check-not='{{warning:|error:}}' %s
 // RUN: clang-tidy 
-checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- 
-DMACRO_FROM_COMMAND_LINE -std=c++20 | FileCheck -check-prefix=CHECK4 
-implicit-check-not='{{warning:|error:}}' %s
 // RUN: clang-tidy 
-checks='-*,modernize-use-override,clang-diagnostic-macro-redefined,clang-diagnostic-literal-conversion'
 %s -- -DMACRO_FROM_COMMAND_LINE -std=c++20 -Wno-macro-redefined | FileCheck 
--check-prefix=CHECK7 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,modernize-use-override' %s -- -std=c++20 
-DPR64602 | FileCheck -check-prefix=CHECK8 
-implicit-check-not='{{warning:|error:}}' %s
 
 // CHECK1: error: no input files [clang-diagnostic-error]
 // CHECK1: error: no such file or directory: '{{.*}}nonexistent.cpp' 
[clang-diagnostic-error]
@@ -54,3 +55,18 @@
   // CHECK6: :[[@LINE-1]]:3: error: cannot take the address of an rvalue of 
type 'int' [clang-diagnostic-error]
 }
 #endif
+
+#ifdef PR64602 // Should not crash
+template 
+struct S
+{
+auto foo(auto);
+};
+
+template <>
+auto S<>::foo(auto)
+{
+return 1;
+}
+// CHECK8: error: template parameter list matching the non-templated nested 
type 'S<>' should be empty ('template<>') [clang-diagnostic-error]
+#endif
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -437,8 +437,11 @@
 SmallString<100> Message;
 Info.FormatDiagnostic(Message);
 FullSourceLoc Loc;
-if (Info.getLocation().isValid() && Info.hasSourceManager())
+if (Info.hasSourceManager())
   Loc = FullSourceLoc(Info.getLocation(), Info.getSourceManager());
+else if (Context.DiagEngine->hasSourceManager())
+  Loc = FullSourceLoc(Info.getLocation(),
+  Context.DiagEngine->getSourceManager());
 Converter.emitDiagnostic(Loc, DiagLevel, Message, Info.getRanges(),
  Info.getFixItHints());
   }


Index: clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp
@@ -25,6 +25,7 @@
 // RUN: not clang-tidy -checks='-*,modernize-use-override' %T/diagnostics/input.cpp -- -DCOMPILATION_ERROR 2>&1 | FileCheck -check-prefix=CHECK6 -implicit-check-not='{{warning:|error:}}' %s
 // RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- -DMACRO_FROM_COMMAND_LINE -std=c++20 | FileCheck -check-prefix=CHECK4 -implicit-check-not='{{warning:|error:}}' %s
 // RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined,clang-diagnostic-literal-conversion' %s -- -DMACRO_FROM_COMMAND_LINE -std=c++20 -Wno-macro-redefined | FileCheck --check-prefix=CHECK7 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,modernize-use-override' %s -- -std=c++20 -DPR64602 | FileCheck -check-prefix=CHECK8 -implicit-check-not='{{warning:|error:}}' %s
 
 // CHECK1: error: no input files [clang-diagnostic-error]
 // CHECK1: error: no such file or directory: '{{.*}}nonexistent.cpp' [clang-diagnostic-error]
@@ -54,3 +55,18 @@
   // CHECK6: :[[@LINE-1]]:3: error: cannot take the address of an rvalue of type 'int' [clang-diagnostic-error]
 }
 #endif
+
+#ifdef PR64602 // Should not crash
+template 
+struct S
+{
+auto foo(auto);
+};
+
+template <>
+auto S<>::foo(auto)
+{
+return 1;
+}
+// CHECK8: error: template parameter list matching the non-templated nested type 'S<>' should be empty ('template<>') [clang-diagnostic-error]
+#endif
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ cla

[PATCH] D157702: [clang][analyzer][NFC] Change PlacementNewChecker into PlacementNew in documentation

2023-08-11 Thread Piotr Zegar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa3a66de37fc0: [clang][analyzer][NFC] Change 
PlacementNewChecker into PlacementNew in… (authored by PiotrZSL).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157702

Files:
  clang/docs/analyzer/checkers.rst


Index: clang/docs/analyzer/checkers.rst
===
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -321,10 +321,10 @@
int *p = new int;
  } // warn
 
-.. _cplusplus-PlacementNewChecker:
+.. _cplusplus-PlacementNew:
 
-cplusplus.PlacementNewChecker (C++)
-"""
+cplusplus.PlacementNew (C++)
+
 Check if default placement new is provided with pointers to sufficient storage 
capacity.
 
 .. code-block:: cpp


Index: clang/docs/analyzer/checkers.rst
===
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -321,10 +321,10 @@
int *p = new int;
  } // warn
 
-.. _cplusplus-PlacementNewChecker:
+.. _cplusplus-PlacementNew:
 
-cplusplus.PlacementNewChecker (C++)
-"""
+cplusplus.PlacementNew (C++)
+
 Check if default placement new is provided with pointers to sufficient storage capacity.
 
 .. code-block:: cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 887bece - [clang-tidy][NFC] Update clang-analyzer-cplusplus.PlacementNew doc

2023-08-11 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-11T16:06:45Z
New Revision: 887bece66c80fe2bc3f9010f34f4fccf0a2f964e

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

LOG: [clang-tidy][NFC] Update clang-analyzer-cplusplus.PlacementNew doc

Re-generate documentation for cplusplus.PlacementNew
using gen-static-analyzer-docs.py

Added: 


Modified: 

clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/cplusplus.PlacementNew.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/cplusplus.PlacementNew.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/cplusplus.PlacementNew.rst
index 7f75e2d5315dae..c5d19a7deeb2e8 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/cplusplus.PlacementNew.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/cplusplus.PlacementNew.rst
@@ -1,4 +1,6 @@
 .. title:: clang-tidy - clang-analyzer-cplusplus.PlacementNew
+.. meta::
+   :http-equiv=refresh: 
5;URL=https://clang.llvm.org/docs/analyzer/checkers.html#cplusplus-placementnew
 
 clang-analyzer-cplusplus.PlacementNew
 =
@@ -6,5 +8,7 @@ clang-analyzer-cplusplus.PlacementNew
 Check if default placement new is provided with pointers to sufficient storage
 capacity.
 
-The clang-analyzer-cplusplus.PlacementNew check is an alias of
-Clang Static Analyzer cplusplus.PlacementNew.
+The clang-analyzer-cplusplus.PlacementNew check is an alias, please see
+`Clang Static Analyzer Available Checkers
+`_
+for more information.

diff  --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst 
b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 6dfdf34e9d026f..bbacd7458c6c3d 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -421,7 +421,7 @@ Clang-Tidy Checks
`clang-analyzer-cplusplus.Move `_, 
Clang Static Analyzer cplusplus.Move,
`clang-analyzer-cplusplus.NewDelete 
`_, `Clang Static Analyzer 
cplusplus.NewDelete 
`_,
`clang-analyzer-cplusplus.NewDeleteLeaks 
`_, `Clang Static Analyzer 
cplusplus.NewDeleteLeaks 
`_,
-   `clang-analyzer-cplusplus.PlacementNew 
`_, Clang Static Analyzer 
cplusplus.PlacementNew,
+   `clang-analyzer-cplusplus.PlacementNew 
`_, `Clang Static Analyzer 
cplusplus.PlacementNew 
`_,
`clang-analyzer-cplusplus.PureVirtualCall 
`_, Clang Static Analyzer 
cplusplus.PureVirtualCall,
`clang-analyzer-cplusplus.StringChecker 
`_, `Clang Static Analyzer 
cplusplus.StringChecker 
`_,
`clang-analyzer-deadcode.DeadStores 
`_, `Clang Static Analyzer 
deadcode.DeadStores 
`_,



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


[PATCH] D155081: Specify the developer policy around links to external resources

2023-08-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: llvm/docs/DeveloperPolicy.rst:359
+  If the patch fixes a bug in GitHub Issues, we encourage adding
+  "Fixes https://github.com/llvm/llvm-project/issues/12345"; to automate closing
+  the issue in GitHub. If the patch has been reviewed, we encourage adding a

rZhBoYao wrote:
> probinson wrote:
> > mehdi_amini wrote:
> > > ldionne wrote:
> > > > smeenai wrote:
> > > > > aaron.ballman wrote:
> > > > > > arsenm wrote:
> > > > > > > I haven't quite figured out what the exact syntaxes which are 
> > > > > > > automatically recognized. It seems to recognize "Fixes #Nxyz"
> > > > > > Yup, it does support that form as well. I had heard more than once 
> > > > > > during code review that folks seem to prefer the full link because 
> > > > > > it's easier to click on that from the commit message than it is to 
> > > > > > navigate to the fix from the number alone. That seemed like a 
> > > > > > pretty good reason to recommend the full form, but I don't have 
> > > > > > strong opinions.
> > > > > +1 for encouraging the full link
> > > > Perhaps we could encourage using `https://llvm.org/PR12345` instead? 
> > > > Does anybody know whether `llvm.org/PRXXX` is something that we intend 
> > > > to keep around with the Github transition or not?
> > > @arsenm: It's documented 
> > > https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
> > > And for linking cross-repo: 
> > > https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls#issues-and-pull-requests
> > > Perhaps we could encourage using `https://llvm.org/PR12345` instead? Does 
> > > anybody know whether `llvm.org/PRXXX` is something that we intend to keep 
> > > around with the Github transition or not?
> > 
> > Currently the PRxxx links are to the old bugzillas, not the Github issues. 
> > It might be sad to lose that.
> If the full link is preferred, can you update the first bullet point in [[ 
> https://llvm.org/docs/BugLifeCycle.html#resolving-closing-bugs | the 
> Resolving/Closing bugs section of LLVM Bug Life Cycle ]]?
Given that the RFC was specifically about links and not about bug lifecycle, 
I'd rather change that policy in a different patch (I suspect someone would 
have to make a full RFC to make the change; I don't feel strongly enough to go 
through that process myself). It might make more sense to link to that section 
of the documentation from here instead of spelling out something that may sound 
like a conflicting policy. e.g.,
```
If the patch fixes a bug in GitHub Issues, we encourage adding a reference to 
the issue being closed, as described `here 
`_.
```


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

https://reviews.llvm.org/D155081

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


[PATCH] D152436: [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha.

2023-08-11 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

As I don't use this checker, thus I cannot speak of my experience.
However, the reasons look solid and I'm fine with moving this checker to 
`unix.StdCLibraryFunctions`.
Let some time for other reviewers to object before landing this. Lets say, one 
week from now.
@xazax.hun @NoQ?

As next steps, I'd be glad set the default value of `ModelPOSIX`  to `true`. I 
don't see much harm doing so.
(And maybe getting rid of that checker option entirely.)




Comment at: clang/docs/analyzer/checkers.rst:979-982
+.. _unix-StdCLibraryFunctions:
+
+unix.StdCLibraryFunctions (C)
+"""




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152436

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


[PATCH] D156032: Implement CWG2137 (list-initialization from objects of the same type)

2023-08-11 Thread Mark de Wever via Phabricator via cfe-commits
Mordante accepted this revision as: libc++.
Mordante added a comment.

I only looked at the libc++ changes. The libc++ AIX CI failures are unrelated 
to your patch. LGTM modulo one nit.




Comment at: 
libcxx/test/std/utilities/utility/pairs/pairs.pair/ctor.pair_U_V_move.pass.cpp:134
+ */
+//test_pair_rv();
+static_assert(std::is_constructible,

Please remove this line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156032

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


[PATCH] D157684: [clang][ASTImporter] Repeated friend templates are partially imported

2023-08-11 Thread Ding Fei via Phabricator via cfe-commits
danix800 updated this revision to Diff 549436.
danix800 added a comment.

Turn off `Complain` mode on `IsEquivalentFriend` checking.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157684

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -4054,6 +4054,25 @@
  ->lookup(ToRecordOfFriend->getDeclName())
  .empty());
   }
+
+  void testRepeatedFriendImport(const char *Code) {
+Decl *ToTu = getToTuDecl(Code, Lang_CXX03);
+Decl *FromTu = getTuDecl(Code, Lang_CXX03, "from.cc");
+
+auto *ToFriend1 = FirstDeclMatcher().match(ToTu, friendDecl());
+auto *ToFriend2 = LastDeclMatcher().match(ToTu, friendDecl());
+auto *FromFriend1 =
+FirstDeclMatcher().match(FromTu, friendDecl());
+auto *FromFriend2 =
+LastDeclMatcher().match(FromTu, friendDecl());
+
+FriendDecl *ToImportedFriend1 = Import(FromFriend1, Lang_CXX03);
+FriendDecl *ToImportedFriend2 = Import(FromFriend2, Lang_CXX03);
+
+EXPECT_NE(ToImportedFriend1, ToImportedFriend2);
+EXPECT_EQ(ToFriend1, ToImportedFriend1);
+EXPECT_EQ(ToFriend2, ToImportedFriend2);
+  }
 };
 
 TEST_P(ImportFriendClasses, ImportOfFriendRecordDoesNotMergeDefinition) {
@@ -4343,21 +4362,7 @@
 friend class X;
   };
   )";
-  Decl *ToTu = getToTuDecl(Code, Lang_CXX03);
-  Decl *FromTu = getTuDecl(Code, Lang_CXX03, "from.cc");
-
-  auto *ToFriend1 = FirstDeclMatcher().match(ToTu, friendDecl());
-  auto *ToFriend2 = LastDeclMatcher().match(ToTu, friendDecl());
-  auto *FromFriend1 =
-  FirstDeclMatcher().match(FromTu, friendDecl());
-  auto *FromFriend2 = LastDeclMatcher().match(FromTu, friendDecl());
-
-  FriendDecl *ToImportedFriend1 = Import(FromFriend1, Lang_CXX03);
-  FriendDecl *ToImportedFriend2 = Import(FromFriend2, Lang_CXX03);
-
-  EXPECT_NE(ToImportedFriend1, ToImportedFriend2);
-  EXPECT_EQ(ToFriend1, ToImportedFriend1);
-  EXPECT_EQ(ToFriend2, ToImportedFriend2);
+  testRepeatedFriendImport(Code);
 }
 
 TEST_P(ImportFriendClasses, ImportOfRepeatedFriendDecl) {
@@ -4368,21 +4373,31 @@
 friend void f();
   };
   )";
-  Decl *ToTu = getToTuDecl(Code, Lang_CXX03);
-  Decl *FromTu = getTuDecl(Code, Lang_CXX03, "from.cc");
-
-  auto *ToFriend1 = FirstDeclMatcher().match(ToTu, friendDecl());
-  auto *ToFriend2 = LastDeclMatcher().match(ToTu, friendDecl());
-  auto *FromFriend1 =
-  FirstDeclMatcher().match(FromTu, friendDecl());
-  auto *FromFriend2 = LastDeclMatcher().match(FromTu, friendDecl());
+  testRepeatedFriendImport(Code);
+}
 
-  FriendDecl *ToImportedFriend1 = Import(FromFriend1, Lang_CXX03);
-  FriendDecl *ToImportedFriend2 = Import(FromFriend2, Lang_CXX03);
+TEST_P(ImportFriendClasses, ImportOfRepeatedFriendFunctionTemplateDecl) {
+  const char *Code =
+  R"(
+template 
+class Container {
+  template  friend void m();
+  template  friend void m();
+};
+  )";
+  testRepeatedFriendImport(Code);
+}
 
-  EXPECT_NE(ToImportedFriend1, ToImportedFriend2);
-  EXPECT_EQ(ToFriend1, ToImportedFriend1);
-  EXPECT_EQ(ToFriend2, ToImportedFriend2);
+TEST_P(ImportFriendClasses, ImportOfRepeatedFriendClassTemplateDecl) {
+  const char *Code =
+  R"(
+template 
+class Container {
+  template  friend class X;
+  template  friend class X;
+};
+  )";
+  testRepeatedFriendImport(Code);
 }
 
 TEST_P(ASTImporterOptionSpecificTestBase, FriendFunInClassTemplate) {
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -4064,22 +4064,33 @@
   unsigned int IndexOfDecl;
 };
 
-template 
-static FriendCountAndPosition getFriendCountAndPosition(
-const FriendDecl *FD,
-llvm::function_ref GetCanTypeOrDecl) {
+static bool IsEquivalentFriend(ASTImporter &Importer, FriendDecl *FD1,
+   FriendDecl *FD2) {
+  if ((!FD1->getFriendType()) != (!FD2->getFriendType()))
+return false;
+
+  if (auto *TSI = FD1->getFriendType())
+return Importer.IsStructurallyEquivalent(
+TSI->getType(), FD2->getFriendType()->getType(), /*Complain=*/false);
+
+  StructuralEquivalenceContext Ctx(
+  FD1->getASTContext(), FD2->getASTContext(),
+  Importer.getNonEquivalentDecls(), getStructuralEquivalenceKind(Importer),
+  /* StrictTypeSpelling = */ false, /* Complain = */ false);
+  return Ctx.IsEquivalent(FD1, FD2);
+}
+
+static FriendCountAndPosition getFriendCountAndPosition(ASTImporter &Importer,
+FriendDecl *FD) {
   unsigned int FriendCount = 0;

[PATCH] D157632: [Profile] Allow online merging with debug info correlation.

2023-08-11 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

BTW, I noticed something strange with `-pgo-function-entry-coverage` when 
merging via llvm-profdata.
In this file `compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c`, 
I ran the following:

  // RUN: %clang_pgogen -o %t.cov.normal -mllvm --pgo-function-entry-coverage 
-mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp 
%S/../Inputs/instrprof-debug-info-correlate-foo.cpp
  // RUN: rm -rf %t.dir && mkdir %t.dir
  // RUN: env LLVM_PROFILE_FILE=%t.dir/%m.profraw %run %t.cov.normal
  // RUN: env LLVM_PROFILE_FILE=%t.dir/%m.profraw %run %t.cov.normal
  // RUN: llvm-profdata merge -o %t.cov.normal.profdata %t.dir/
  // RUN: llvm-profdata show --all-functions --counts %t.cov.normal.profdata
  // It shows block counts 1.
  Counters:
main:
  Hash: 0x06d15c67b2c35b9c
  Counters: 1
  Block counts: [1]
_Z3fooi:
  Hash: 0x0209aa3e3852da94
  Counters: 1
  Block counts: [1]
_Z3bari:
  Hash: 0x0209aa3e1d398548
  Counters: 1
  Block counts: [1]
_Z6unusedi:
  Hash: 0x0a4d0ad3efff
  Counters: 1
  Block counts: [0]
  Instrumentation level: IR  entry_first = 0
  Functions shown: 4
  Total functions: 4
  Maximum function count: 1
  Maximum internal block count: 0
  
  // RUN: rm -rf %t.dir && mkdir %t.dir
  // RUN: env LLVM_PROFILE_FILE=%t.dir/%t.cov-1.profraw %run %t.cov.normal
  // RUN: env LLVM_PROFILE_FILE=%t.dir/%t.cov-2.profraw %run %t.cov.normal
  // RUN: llvm-profdata merge -o %t.cov.normal.profdata %t.dir/
  // RUN: llvm-profdata show --all-functions --counts %t.cov.normal.profdata
  // It shows block counts 2, as opposed to 1.
  Counters:
main:
  Hash: 0x06d15c67b2c35b9c
  Counters: 1
  Block counts: [2]
_Z3fooi:
  Hash: 0x0209aa3e3852da94
  Counters: 1
  Block counts: [2]
_Z3bari:
  Hash: 0x0209aa3e1d398548
  Counters: 1
  Block counts: [2]
_Z6unusedi:
  Hash: 0x0a4d0ad3efff
  Counters: 1
  Block counts: [0]
  Instrumentation level: IR  entry_first = 0
  Functions shown: 4
  Total functions: 4
  Maximum function count: 2
  Maximum internal block count: 0


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157632

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


[PATCH] D154603: [analyzer][clangsa] Add new option to alpha.security.cert.InvalidPtrChecker

2023-08-11 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

I'm sorry starting the review of this one only now, but I'm quite booked.
Is it still relevant? If so, I'll continue.




Comment at: clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp:116-117
+const NoteTag *Note =
+C.getNoteTag([Region, FunctionName, Message](PathSensitiveBugReport 
&BR,
+ llvm::raw_ostream &Out) {
+  if (!BR.isInteresting(Region))

`FunctionName` and `Message` will dangle inside the NoteTag.



Comment at: clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp:125
 
-  const NoteTag *Note =
-  C.getNoteTag([SymbolicEnvPtrRegion, FunctionName](
-   PathSensitiveBugReport &BR, llvm::raw_ostream &Out) {
-if (!BR.isInteresting(SymbolicEnvPtrRegion))
-  return;
-Out << '\'' << FunctionName
-<< "' call may invalidate the environment parameter of 'main'";
-  });
+  ExplodedNode *CurrentChainEnd = nullptr;
+

donat.nagy wrote:
> Perhaps add a comment that clarifies that passing a `nullptr` as the 
> ExplodedNode to `addTransition` is equivalent to specifying the current node. 
> I remember this because I was studying its implementation recently, but I 
> would've been surprised and suspicious otherwise.
If `nullptr` is equivalent with `C.getPredecessor()` inside `addTransition()`, 
why not simply initialize it to that value instead of to `nullptr`?



Comment at: clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp:214
+  // Model 'getenv' calls
+  CallDescription GetEnvCall{{"getenv"}, 1};
+  if (GetEnvCall.matches(Call)) {

We should hoist this into a field, to only construct it once.



Comment at: clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp:216-217
+  if (GetEnvCall.matches(Call)) {
+State =
+State->add(Call.getReturnValue().getAsRegion());
+   C.addTransition(State);

What ensures that `Call.getReturnValue().getAsRegion()` is not null?



Comment at: clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp:218
+State->add(Call.getReturnValue().getAsRegion());
+   C.addTransition(State);
+  }

donat.nagy wrote:
> I fear that this state transition will go "sideways" and the later state 
> transitions (which add the note tags) will branch off instead of building 
> onto this. IIUC calling `CheckerContext::addTransition` registers the 
> transition without updating the "current ExplodedNode" field of 
> `CheckerContext`, so you need to explicitly store and pass around the 
> ExplodedNode returned by it if you want to build on it.
> 
> This is an ugly and counter-intuitive API, and I also ran into a very similar 
> issue a few weeks ago (@Szelethus helped me).
I think the usage here is correct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154603

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


[PATCH] D155773: [llvm][MemoryBuiltins] Add alloca support to getInitialValueOfAllocation

2023-08-11 Thread John McIver via Phabricator via cfe-commits
jmciver added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155773

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


[PATCH] D150647: [WIP][analyzer] Fix EnumCastOutOfRangeChecker C++17 handling

2023-08-11 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Isn't D153954  superseded this one? If so, 
consider abandoning it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150647

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


[PATCH] D157610: [include-cleaner][clangd][clang-tidy] Ignore resource dir during include-cleaner analysis.

2023-08-11 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 549443.
VitaNuo marked 4 inline comments as done.
VitaNuo added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157610

Files:
  clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
  clang-tools-extra/include-cleaner/lib/Analysis.cpp
  clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp

Index: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -273,6 +273,30 @@
   EXPECT_THAT(Results.Unused, testing::IsEmpty());
 }
 
+TEST_F(AnalyzeTest, ResourceDirIsIgnored) {
+  Inputs.ExtraArgs.push_back("-resource-dir");
+  Inputs.ExtraArgs.push_back("./resources");
+  Inputs.Code = R"cpp(
+#include "resources/amintrin.h"
+#include "resources/imintrin.h"
+void baz() {
+  bar();
+}
+  )cpp";
+  Inputs.ExtraFiles["resources/amintrin.h"] = "";
+  Inputs.ExtraFiles["resources/emintrin.h"] = guard(R"cpp(
+void bar();
+  )cpp");
+  Inputs.ExtraFiles["resources/imintrin.h"] = guard(R"cpp(
+#include "emintrin.h"
+  )cpp");
+  TestAST AST(Inputs);
+  auto Results = analyze({}, {}, PP.Includes, &PI, AST.sourceManager(),
+ AST.preprocessor().getHeaderSearchInfo());
+  EXPECT_THAT(Results.Unused, testing::IsEmpty());
+  EXPECT_THAT(Results.Missing, testing::IsEmpty());
+}
+
 TEST(FixIncludes, Basic) {
   llvm::StringRef Code = R"cpp(#include "d.h"
 #include "a.h"
Index: clang-tools-extra/include-cleaner/lib/Analysis.cpp
===
--- clang-tools-extra/include-cleaner/lib/Analysis.cpp
+++ clang-tools-extra/include-cleaner/lib/Analysis.cpp
@@ -17,6 +17,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Format/Format.h"
 #include "clang/Lex/HeaderSearch.h"
+#include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -68,12 +69,18 @@
   llvm::StringSet<> Missing;
   if (!HeaderFilter)
 HeaderFilter = [](llvm::StringRef) { return false; };
+  std::string ResourceDir = HS.getHeaderSearchOpts().ResourceDir;
   walkUsed(ASTRoots, MacroRefs, PI, SM,
[&](const SymbolReference &Ref, llvm::ArrayRef Providers) {
  bool Satisfied = false;
  for (const Header &H : Providers) {
-   if (H.kind() == Header::Physical && H.physical() == MainFile)
+   if (H.kind() == Header::Physical &&
+   (H.physical() == MainFile ||
+H.physical()->getLastRef().getDir().getName() ==
+ResourceDir)) {
  Satisfied = true;
+ continue;
+   }
for (const Include *I : Inc.match(H)) {
  Used.insert(I);
  Satisfied = true;
@@ -88,7 +95,8 @@
   AnalysisResults Results;
   for (const Include &I : Inc.all()) {
 if (Used.contains(&I) || !I.Resolved ||
-HeaderFilter(I.Resolved->getFileEntry().tryGetRealPathName()))
+HeaderFilter(I.Resolved->getFileEntry().tryGetRealPathName()) ||
+I.Resolved->getDir().getName() == ResourceDir)
   continue;
 if (PI) {
   if (PI->shouldKeep(*I.Resolved))
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -574,6 +574,29 @@
   EXPECT_THAT(Findings.UnusedIncludes, IsEmpty());
 }
 
+TEST(IncludeCleaner, ResourceDirIsIgnored) {
+  auto TU = TestTU::withCode(R"cpp(
+#include 
+#include 
+void baz() {
+  bar();
+}
+  )cpp");
+  TU.ExtraArgs.push_back("-resource-dir");
+  TU.ExtraArgs.push_back(testPath("resources"));
+  TU.AdditionalFiles["resources/include/amintrin.h"] = "";
+  TU.AdditionalFiles["resources/include/imintrin.h"] = guard(R"cpp(
+#include 
+  )cpp");
+  TU.AdditionalFiles["resources/include/emintrin.h"] = guard(R"cpp(
+void bar();
+  )cpp");
+  auto AST = TU.build();
+  auto Findings = computeIncludeCleanerFindings(AST);
+  EXPECT_THAT(Findings.UnusedIncludes, IsEmpty());
+  EXPECT_THAT(Findings.MissingIncludes, IsEmpty());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
===
--- clang-tools-extra/clangd/test/include-cleaner-ba

[PATCH] D155773: [llvm][MemoryBuiltins] Add alloca support to getInitialValueOfAllocation

2023-08-11 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp:809-811
+  Updater.AddAvailableValue(
+  Alloca.getParent(),
+  getInitialValueOfAllocation(&Alloca, nullptr, VectorTy));

This is very specifically handling alloca, not any random allocation like 
function


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155773

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


[PATCH] D157197: [clang][CodeGen][OpenMP] Fix if-clause for 'target teams loop'

2023-08-11 Thread David Pagan via Phabricator via cfe-commits
ddpagan added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:1570-1575
+  // If we are here with a 'target teams loop' then we are emitting the
+  // 'parallel' region of the 'target teams distribute parallel for'
+  // emitted in place of the 'target teams loop'. Based on the specification
+  // noted above, an if-clause associated with a 'target teams loop', be it
+  // 'if(val)' or an 'if(target:val)', will apply only to 'target' and not
+  // the 'parallel' of the 'target teams distribute parallel for'.

ABataev wrote:
> It does not match the spec. 
> ```
> For a combined or composite construct, if no directive-name-modifier is 
> specified then the if clause applies to all constituent constructs to which 
> an if clause can apply.
> ```
> So, if(val) should be applied to both target and parallel regions, no?
> It does not match the spec. 
> ```
> For a combined or composite construct, if no directive-name-modifier is 
> specified then the if clause applies to all constituent constructs to which 
> an if clause can apply.
> ```
> So, if(val) should be applied to both target and parallel regions, no?

Hi Alexey - Question for you: does revising the comment above at lines 
1570-1575 to the following text help explain in a better way what's being done, 
and why?

  If we are handling a 'target teams distribute parallel for' explicitly written
  in the source, and it has an 'if(val)' clause, the if condition is applied to
  both 'target' and 'parallel' regions according to
  OpenMP 5.2 [3.4, if Clause, Semantics, 15-18].

  However, if we are mapping an explicit 'target teams loop if(val)' onto a
  'target teams distribute parallel for if(val)', to preserve the 'if' semantics
  as specified by the user with the 'target teams loop', we apply it just to
  the 'target' region.


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

https://reviews.llvm.org/D157197

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


[PATCH] D153701: [WIP][Clang] Implement P2718R0 "Lifetime extension in range-based for loops"

2023-08-11 Thread Yurong via Phabricator via cfe-commits
yronglin updated this revision to Diff 549449.
yronglin added a comment.

Only create addational metarialized temporary in for-range-init.
FIXME: Need to handle function default argument, and add more test to make sure 
the generated LLVM IR is correct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153701

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/AST/ast-dump-for-range-lifetime.cpp

Index: clang/test/AST/ast-dump-for-range-lifetime.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-for-range-lifetime.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -std=c++23 -triple x86_64-linux-gnu -fcxx-exceptions -ast-dump %s \
+// RUN: | FileCheck -strict-whitespace %s
+
+namespace p2718r0 {
+struct T {
+  int a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+  T() {}
+  ~T() {}
+  const int *begin() const { return a; }
+  const int *end() const { return a + 10; }
+};
+
+const T &f1(const T &t) { return t; }
+T g() { return T(); }
+
+void foo() {
+  // CHECK: FunctionDecl {{.*}} foo 'void ()'
+  // CHECK: `-CXXForRangeStmt {{.*}}
+  // CHECK-NEXT:|-<<>>
+  // CHECK-NEXT:|-DeclStmt {{.*}}
+  // CHECK-NEXT:| `-VarDecl {{.*}} implicit used __range1 'const T &' cinit
+  // CHECK-NEXT:|   `-ExprWithCleanups {{.*}} 'const T':'const p2718r0::T' lvalue
+  // CHECK-NEXT:| `-CallExpr {{.*}} 'const T':'const p2718r0::T' lvalue
+  // CHECK-NEXT:|   |-ImplicitCastExpr {{.*}} 'const T &(*)(const T &)' 
+  // CHECK-NEXT:|   | `-DeclRefExpr {{.*}} 'const T &(const T &)' lvalue Function {{.*}} 'f1' 'const T &(const T &)'
+  // CHECK-NEXT:|   `-MaterializeTemporaryExpr {{.*}} 'const T':'const p2718r0::T' lvalue extended by Var {{.*}} '__range1' 'const T &'
+  // CHECK-NEXT:| `-ImplicitCastExpr {{.*}} 'const T':'const p2718r0::T' 
+  // CHECK-NEXT:|   `-CXXBindTemporaryExpr {{.*}}  'T':'p2718r0::T' (CXXTemporary {{.*}})
+  // CHECK-NEXT:| `-CallExpr {{.*}} 'T':'p2718r0::T'
+  // CHECK-NEXT:|   `-ImplicitCastExpr {{.*}} 'T (*)()' 
+  // CHECK-NEXT:| `-DeclRefExpr {{.*}} 'T ()' lvalue Function {{.*}} 'g' 'T ()'
+  [[maybe_unused]] int sum = 0;
+  for (auto e : f1(g()))
+sum += e;
+}
+
+struct LockGuard {
+LockGuard(int) {}
+
+~LockGuard() {}
+};
+
+void f() {
+  int v[] = {42, 17, 13};
+  int M = 0;
+
+  // CHECK: FunctionDecl {{.*}} f 'void ()'
+  // CHECK: `-CXXForRangeStmt {{.*}}
+  // CHECK-NEXT:   |-<<>>
+  // CHECK-NEXT:   |-DeclStmt {{.*}}
+  // CHECK-NEXT:   | `-VarDecl {{.*}} col:16 implicit used __range1 'int (&)[3]' cinit
+  // CHECK-NEXT:   |   `-ExprWithCleanups {{.*}} 'int[3]' lvalue
+  // CHECK-NEXT:   | `-BinaryOperator {{.*}} 'int[3]' lvalue ','
+  // CHECK-NEXT:   |   |-CXXStaticCastExpr {{.*}}'void' static_cast 
+  // CHECK-NEXT:   |   | `-MaterializeTemporaryExpr {{.*}} 'LockGuard':'p2718r0::LockGuard' xvalue extended by Var {{.*}} '__range1' 'int (&)[3]'
+  // CHECK-NEXT:   |   |   `-CXXFunctionalCastExpr {{.*}} 'LockGuard':'p2718r0::LockGuard' functional cast to LockGuard 
+  // CHECK-NEXT:   |   | `-CXXBindTemporaryExpr {{.*}} 'LockGuard':'p2718r0::LockGuard' (CXXTemporary {{.*}})
+  // CHECK-NEXT:   |   |   `-CXXConstructExpr {{.*}} 'LockGuard':'p2718r0::LockGuard' 'void (int)'
+  // CHECK-NEXT:   |   | `-ImplicitCastExpr {{.*}} 'int' 
+  // CHECK-NEXT:   |   |   `-DeclRefExpr {{.*}} 'int' lvalue Var {{.*}} 'M' 'int'
+  // CHECK-NEXT:   |   `-DeclRefExpr {{.*}} 'int[3]' lvalue Var {{.*}} 'v' 'int[3]'
+  for (int x : static_cast(LockGuard(M)), v) // lock released in C++ 2020
+  {
+LockGuard guard(M); // OK in C++ 2020, now deadlocks
+  }
+}
+
+} // namespace p2718r0
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -27,6 +27,7 @@
 #include "clang/AST/TypeOrdering.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Sema/EnterExpressionEvaluationContext.h"
 #include "clang/Sema/Initialization.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Ownership.h"
@@ -2529,10 +2530,20 @@
   VarDecl *RangeVar = BuildForRangeVarDecl(*this, RangeLoc,
Context.getAutoRRefDeductType(),
std::string("__range") + DepthStr);
-  if (FinishForRangeVarDecl(*this, RangeVar, Range, RangeLoc,
-diag::err_for_range_deduction_failure)) {
-ActOnInitializerError(LoopVar);
-return StmtError();
+  {
+EnterExpressionEvaluationContext RangeVarContext(
+*this, ExpressionEvaluationContext::P

[PATCH] D157610: [include-cleaner][clangd][clang-tidy] Ignore resource dir during include-cleaner analysis.

2023-08-11 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo added a comment.

Thanks for the comments!




Comment at: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp:122
   llvm::DenseSet SeenSymbols;
+  std::string ResourceDir = HS->getHeaderSearchOpts().ResourceDir;
   // FIXME: Find a way to have less code duplication between include-cleaner

kadircet wrote:
> let's use `HS->getModuleMap().getBuiltinDir()` then we can get away with just 
> comparing that pointer to `H.physical()->getLastRef().getDir()` (same applies 
> to all the other places as well)
This only works in `clangd` code for me. I get `nullptr` for 
`HS->getModuleMap().getBuiltinDir()` in other places (Clang Tidy check and the 
library).



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:309
   continue;
+auto Dir = llvm::StringRef{MFI.Resolved}.rsplit('/').first;
+if (Dir == AST.getPreprocessor()

kadircet wrote:
> let's move this into `mayConsiderUnused`, we also convert this include into a 
> FileEntry in there, so we can directly compare the directory agian.
Ok moved to `mayConsiderUnused` and using the file entry now, but see above 
regarding comparing the directories.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157610

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


[PATCH] D157197: [clang][CodeGen][OpenMP] Fix if-clause for 'target teams loop'

2023-08-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:1570-1575
+  // If we are here with a 'target teams loop' then we are emitting the
+  // 'parallel' region of the 'target teams distribute parallel for'
+  // emitted in place of the 'target teams loop'. Based on the specification
+  // noted above, an if-clause associated with a 'target teams loop', be it
+  // 'if(val)' or an 'if(target:val)', will apply only to 'target' and not
+  // the 'parallel' of the 'target teams distribute parallel for'.

ddpagan wrote:
> ABataev wrote:
> > It does not match the spec. 
> > ```
> > For a combined or composite construct, if no directive-name-modifier is 
> > specified then the if clause applies to all constituent constructs to which 
> > an if clause can apply.
> > ```
> > So, if(val) should be applied to both target and parallel regions, no?
> > It does not match the spec. 
> > ```
> > For a combined or composite construct, if no directive-name-modifier is 
> > specified then the if clause applies to all constituent constructs to which 
> > an if clause can apply.
> > ```
> > So, if(val) should be applied to both target and parallel regions, no?
> 
> Hi Alexey - Question for you: does revising the comment above at lines 
> 1570-1575 to the following text help explain in a better way what's being 
> done, and why?
> 
>   If we are handling a 'target teams distribute parallel for' explicitly 
> written
>   in the source, and it has an 'if(val)' clause, the if condition is applied 
> to
>   both 'target' and 'parallel' regions according to
>   OpenMP 5.2 [3.4, if Clause, Semantics, 15-18].
> 
>   However, if we are mapping an explicit 'target teams loop if(val)' onto a
>   'target teams distribute parallel for if(val)', to preserve the 'if' 
> semantics
>   as specified by the user with the 'target teams loop', we apply it just to
>   the 'target' region.
It does not match the spec. Why we shall handle it this way?


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

https://reviews.llvm.org/D157197

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


  1   2   >