[PATCH] D142328: [clang][Interp] Fix compound assign operator types

2023-01-24 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Thanks!


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

https://reviews.llvm.org/D142328

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


[PATCH] D142500: Fix one of the regressions found in revert of concept sugaring

2023-01-24 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

FYI I tested this patch with libc++ and as expected it does not fix the libc++ 
modular build ICE.


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

https://reviews.llvm.org/D142500

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


[clang-tools-extra] 603c286 - Bump the trunk major version to 17

2023-01-24 Thread Tom Stellard via cfe-commits

Author: Tom Stellard
Date: 2023-01-24T22:57:27-08:00
New Revision: 603c286334b07f568d39f6706c848f576914f323

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

LOG: Bump the trunk major version to 17

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst
clang/docs/ReleaseNotes.rst
clang/docs/analyzer/conf.py
libcxx/docs/ReleaseNotes.rst
libcxx/docs/conf.py
libcxx/include/__config
libunwind/docs/conf.py
lld/docs/ReleaseNotes.rst
llvm/CMakeLists.txt
llvm/docs/ReleaseNotes.rst
llvm/utils/gn/secondary/llvm/version.gni
llvm/utils/lit/lit/__init__.py
openmp/docs/ReleaseNotes.rst
pstl/docs/ReleaseNotes.rst
pstl/include/pstl/internal/pstl_config.h
pstl/test/pstl/version.pass.cpp

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 434dcd955679d..e602fceda6b1f 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -81,8 +81,6 @@ Miscellaneous
 Improvements to clang-doc
 -
 
-- The default executor was changed to standalone to match other tools.
-
 Improvements to clang-query
 ---
 
@@ -96,134 +94,15 @@ The improvements are...
 Improvements to clang-tidy
 --
 
-- Change to Python 3 in the shebang of `add_new_check.py` and 
`rename_check.py`,
-  as the existing code is not compatible with Python 2.
-
-- Fix a minor bug in `add_new_check.py` to only traverse subdirectories
-  when updating the list of checks in the documentation.
-
-- Deprecate the global configuration file option `AnalyzeTemporaryDtors`,
-  which is no longer in use. The option will be fully removed in
-  :program:`clang-tidy` version 18.
-
 New checks
 ^^
 
-- New :doc:`bugprone-suspicious-realloc-usage
-  ` check.
-
-  Finds usages of ``realloc`` where the return value is assigned to the
-  same expression as passed to the first argument.
-
-- New :doc:`cppcoreguidelines-avoid-const-or-ref-data-members
-  ` check.
-
-  Warns when a struct or class uses const or reference (lvalue or rvalue) data 
members.
-
-- New :doc:`cppcoreguidelines-avoid-do-while
-  ` check.
-
-  Warns when using ``do-while`` loops.
-
-- New :doc:`cppcoreguidelines-avoid-reference-coroutine-parameters
-  ` 
check.
-
-  Warns on coroutines that accept reference parameters.
-
-- New :doc:`misc-use-anonymous-namespace
-  ` check.
-
-  Warns when using ``static`` function or variables at global scope, and 
suggests
-  moving them into an anonymous namespace.
-
-- New :doc:`bugprone-standalone-empty 
` check.
-
-  Warns when `empty()` is used on a range and the result is ignored. Suggests 
`clear()`
-  if it is an existing member function.
-
 New check aliases
 ^
 
-- New alias :doc:`cert-msc54-cpp
-  ` to
-  :doc:`bugprone-signal-handler
-  ` was added.
-
-
 Changes in existing checks
 ^^
 
-- Fixed a false positive in :doc:`bugprone-assignment-in-if-condition
-  ` check when there
-  was an assignement in a lambda found in the condition of an ``if``.
-
-- Improved :doc:`bugprone-signal-handler
-  ` check. Partial
-  support for C++14 signal handler rules was added. Bug report generation was
-  improved.
-
-- Fixed a false positive in :doc:`cppcoreguidelines-pro-type-member-init
-  ` when warnings
-  would be emitted for uninitialized members of an anonymous union despite
-  there being an initializer for one of the other members.
-
-- Fixed false positives in :doc:`google-objc-avoid-throwing-exception
-  ` check for 
exceptions
-  thrown by code emitted from macros in system headers.
-
-- Improved :doc:`misc-redundant-expression 
`
-  check.
-
-  The check now skips concept definitions since redundant expressions still 
make sense
-  inside them.
-
-- Improved :doc:`modernize-loop-convert 
`
-  to check for container functions ``begin``/``end`` etc on base classes of 
the container
-  type, instead of only as direct members of the container type itself.
-
-- Improved :doc:`modernize-use-emplace 
`
-  check.
-
-  The check now supports detecting inefficient invocations of ``push`` and
-  ``push_front`` on STL-style containers and replacing them with ``emplace``
-  or ``emplace_front``.
-
-  The check now supports detecting alias cases of ``push_back`` ``push`` and
-  ``push_front`` on STL-style containers and replacing them with 
``emplace_back``,
-  ``emplace`` or ``emplace_front``.
-
-- Improved :doc:`modernize-use-equals-default 
`
-  check.
-
-  The check now skips unions/union-like classes since in this case a default 
constructor
-  with empty body is not equivalent to the explicitly defaulted one, variadic 
constructors
-  since they cannot be 

[libunwind] 603c286 - Bump the trunk major version to 17

2023-01-24 Thread Tom Stellard via cfe-commits

Author: Tom Stellard
Date: 2023-01-24T22:57:27-08:00
New Revision: 603c286334b07f568d39f6706c848f576914f323

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

LOG: Bump the trunk major version to 17

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst
clang/docs/ReleaseNotes.rst
clang/docs/analyzer/conf.py
libcxx/docs/ReleaseNotes.rst
libcxx/docs/conf.py
libcxx/include/__config
libunwind/docs/conf.py
lld/docs/ReleaseNotes.rst
llvm/CMakeLists.txt
llvm/docs/ReleaseNotes.rst
llvm/utils/gn/secondary/llvm/version.gni
llvm/utils/lit/lit/__init__.py
openmp/docs/ReleaseNotes.rst
pstl/docs/ReleaseNotes.rst
pstl/include/pstl/internal/pstl_config.h
pstl/test/pstl/version.pass.cpp

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 434dcd955679d..e602fceda6b1f 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -81,8 +81,6 @@ Miscellaneous
 Improvements to clang-doc
 -
 
-- The default executor was changed to standalone to match other tools.
-
 Improvements to clang-query
 ---
 
@@ -96,134 +94,15 @@ The improvements are...
 Improvements to clang-tidy
 --
 
-- Change to Python 3 in the shebang of `add_new_check.py` and 
`rename_check.py`,
-  as the existing code is not compatible with Python 2.
-
-- Fix a minor bug in `add_new_check.py` to only traverse subdirectories
-  when updating the list of checks in the documentation.
-
-- Deprecate the global configuration file option `AnalyzeTemporaryDtors`,
-  which is no longer in use. The option will be fully removed in
-  :program:`clang-tidy` version 18.
-
 New checks
 ^^
 
-- New :doc:`bugprone-suspicious-realloc-usage
-  ` check.
-
-  Finds usages of ``realloc`` where the return value is assigned to the
-  same expression as passed to the first argument.
-
-- New :doc:`cppcoreguidelines-avoid-const-or-ref-data-members
-  ` check.
-
-  Warns when a struct or class uses const or reference (lvalue or rvalue) data 
members.
-
-- New :doc:`cppcoreguidelines-avoid-do-while
-  ` check.
-
-  Warns when using ``do-while`` loops.
-
-- New :doc:`cppcoreguidelines-avoid-reference-coroutine-parameters
-  ` 
check.
-
-  Warns on coroutines that accept reference parameters.
-
-- New :doc:`misc-use-anonymous-namespace
-  ` check.
-
-  Warns when using ``static`` function or variables at global scope, and 
suggests
-  moving them into an anonymous namespace.
-
-- New :doc:`bugprone-standalone-empty 
` check.
-
-  Warns when `empty()` is used on a range and the result is ignored. Suggests 
`clear()`
-  if it is an existing member function.
-
 New check aliases
 ^
 
-- New alias :doc:`cert-msc54-cpp
-  ` to
-  :doc:`bugprone-signal-handler
-  ` was added.
-
-
 Changes in existing checks
 ^^
 
-- Fixed a false positive in :doc:`bugprone-assignment-in-if-condition
-  ` check when there
-  was an assignement in a lambda found in the condition of an ``if``.
-
-- Improved :doc:`bugprone-signal-handler
-  ` check. Partial
-  support for C++14 signal handler rules was added. Bug report generation was
-  improved.
-
-- Fixed a false positive in :doc:`cppcoreguidelines-pro-type-member-init
-  ` when warnings
-  would be emitted for uninitialized members of an anonymous union despite
-  there being an initializer for one of the other members.
-
-- Fixed false positives in :doc:`google-objc-avoid-throwing-exception
-  ` check for 
exceptions
-  thrown by code emitted from macros in system headers.
-
-- Improved :doc:`misc-redundant-expression 
`
-  check.
-
-  The check now skips concept definitions since redundant expressions still 
make sense
-  inside them.
-
-- Improved :doc:`modernize-loop-convert 
`
-  to check for container functions ``begin``/``end`` etc on base classes of 
the container
-  type, instead of only as direct members of the container type itself.
-
-- Improved :doc:`modernize-use-emplace 
`
-  check.
-
-  The check now supports detecting inefficient invocations of ``push`` and
-  ``push_front`` on STL-style containers and replacing them with ``emplace``
-  or ``emplace_front``.
-
-  The check now supports detecting alias cases of ``push_back`` ``push`` and
-  ``push_front`` on STL-style containers and replacing them with 
``emplace_back``,
-  ``emplace`` or ``emplace_front``.
-
-- Improved :doc:`modernize-use-equals-default 
`
-  check.
-
-  The check now skips unions/union-like classes since in this case a default 
constructor
-  with empty body is not equivalent to the explicitly defaulted one, variadic 
constructors
-  since they cannot be 

[clang] b0daacf - [CodeGen] Use llvm::bit_ceil (NFC)

2023-01-24 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-01-24T22:54:53-08:00
New Revision: b0daacf58f417634f7c7c9496589d723592a8f5a

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

LOG: [CodeGen] Use llvm::bit_ceil (NFC)

If we know that x is nonzero and not a power of 2, then
llvm::findLastSet(x) + 1 is the index of the bit just above the
highest set bit in x.  That is, 1 << (llvm::findLastSet(x) + 1) is the
same as llvm::bit_ceil(x).

Since llvm::bit_ceil is a nop on a power of 2, we can unconditionally
call llvm::bit_ceil.  The end result actually matches the comment.

Added: 


Modified: 
clang/lib/CodeGen/SwiftCallingConv.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/SwiftCallingConv.cpp 
b/clang/lib/CodeGen/SwiftCallingConv.cpp
index 6b868fe84ca68..63d975193c027 100644
--- a/clang/lib/CodeGen/SwiftCallingConv.cpp
+++ b/clang/lib/CodeGen/SwiftCallingConv.cpp
@@ -659,9 +659,7 @@ CharUnits swiftcall::getNaturalAlignment(CodeGenModule 
, llvm::Type *type) {
   // For Swift's purposes, this is always just the store size of the type
   // rounded up to a power of 2.
   auto size = (unsigned long long) getTypeStoreSize(CGM, type).getQuantity();
-  if (!isPowerOf2(size)) {
-size = 1ULL << (llvm::findLastSet(size, llvm::ZB_Undefined) + 1);
-  }
+  size = llvm::bit_ceil(size);
   assert(CGM.getDataLayout().getABITypeAlign(type) <= size);
   return CharUnits::fromQuantity(size);
 }



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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-01-24 Thread Chris Cotter via Phabricator via cfe-commits
ccotter marked an inline comment as done.
ccotter added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp:1
+// RUN: %check_clang_tidy -std=c++14-or-later %s 
cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- 
-fno-delayed-template-parsing
+

carlosgalvezp wrote:
> ccotter wrote:
> > carlosgalvezp wrote:
> > > ccotter wrote:
> > > > ccotter wrote:
> > > > > carlosgalvezp wrote:
> > > > > > You specified C++11 in the LangOpts, but test against C++14 or 
> > > > > > later in the test, maybe change it here to c++11-or-later?
> > > > > The test uses generalize lambda capture, so it needs 14. Should I 
> > > > > split the tests that use C++14 features to a separate file, and 
> > > > > update this test file to use 11?
> > > > Ah, and use of `auto` parameters in other lambdas. So there are a few 
> > > > tests that would need to be split out to a separate file, use an `ifdef 
> > > > __cplusplus` check (I see one other cppcoreguidelines test does this).
> > > Oops I forgot to submit my comment. Yes I think we could keep everything 
> > > in one test file running `c++11-or-later`, and `#ifdef` the C++14 parts.
> > This didn't actually end up working. The test failed looking for expected 
> > CHECK-MESSAGES, e.g.,
> > 
> > ```
> > #if __cplusplus >= 201402L
> > /* bad code */
> > // CHECK-MESSAGES
> > #endif
> > ```
> > 
> > I'll go the separate file route then?
> Hmm right.
> 
> What about 2 `RUN` commands in the same file? One of them you run it for 
> `c++11` and the other for `c++14-or-later`. You can add a `check-prefix` for 
> the C++14 case, then use `CHECK-MESSAGES-SOMEPREFIX` such that it only 
> applies to that test invocation. No need to duplicate `CHECK-MESSAGES` for 
> both runs - if no prefix is specified, it will apply to all runs. 
> 
> Something like:
> 
> ```
> #if __cplusplus >= 201402L
> /* bad code */
> // CHECK-MESSAGES-CXX14
> #endif
> ```
> 
> If it gets too messy maybe a separate test file is the better option, I'm 
> hoping there's not much duplication that needs to be maintaned.
Perfect - I didn't realize the test/checker framework was this flexible. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-01-24 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 491992.
ccotter added a comment.

- Use multiple runs on the same test file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/rvalue-reference-param-not-moved.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
@@ -0,0 +1,293 @@
+// RUN: %check_clang_tidy -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,CXX14 -std=c++14-or-later %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- -fno-delayed-template-parsing
+
+// NOLINTBEGIN
+namespace std {
+template 
+struct remove_reference;
+
+template 
+struct remove_reference {
+  typedef _Tp type;
+};
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &(_Tp &&__t) noexcept;
+
+template 
+constexpr _Tp &&
+forward(typename remove_reference<_Tp>::type &__t) noexcept;
+
+}
+// NOLINTEND
+
+struct Obj {
+  Obj();
+  Obj(const Obj&);
+  Obj& operator=(const Obj&);
+  Obj(Obj&&);
+  Obj& operator=(Obj&&);
+  void member() const;
+};
+
+void consumes_object(Obj);
+
+void never_moves_param(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void copies_object(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  Obj copy = o;
+}
+
+template 
+void never_moves_param_template(Obj&& o, T t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void never_moves_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  // CHECK-MESSAGES: :[[@LINE-2]]:41: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void never_moves_some_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+  Obj other{std::move(o2)};
+}
+
+void never_moves_mixed(Obj o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:38: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value(Obj&& o) {
+  auto f = [o]() {
+consumes_object(std::move(o));
+  };
+  // CHECK-MESSAGES: :[[@LINE-4]]:47: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value_nested(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  auto f = []() {
+auto f_nested = [o]() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f2 = [o]() {
+auto f_nested = []() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f3 = [o]() {
+auto f_nested = []() {
+  auto f_nested_inner = []() {
+consumes_object(std::move(o));
+  };
+};
+  };
+  auto f4 = []() {
+auto f_nested = []() {
+  auto f_nested_inner = [o]() {
+consumes_object(std::move(o));
+  };
+};
+  };
+}
+
+void misc_lambda_checks() {
+  auto never_moves = [](Obj&& o1) {
+Obj other{o1};
+  };
+  // CHECK-MESSAGES: :[[@LINE-3]]:31: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+#if __cplusplus >= 201402L
+  auto never_moves_with_auto_param = [](Obj&& o1, auto& v) {
+Obj other{o1};
+  };
+  // 

[clang-tools-extra] c7575fc - Revert "[clang-tidy] Introduce HeaderFileExtensions and ImplementationFileExtensions options"

2023-01-24 Thread Carlos Galvez via cfe-commits

Author: Carlos Galvez
Date: 2023-01-25T05:17:00Z
New Revision: c7575fcb685a15f5384c137c76913e0bb11d1320

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

LOG: Revert "[clang-tidy] Introduce HeaderFileExtensions and 
ImplementationFileExtensions options"

This reverts commit 4240c9146248ac0a91c45dee421c6ef07709ba74.

The current solution won't work since getLocalOrGlobal does not
support returning a vector. More work needs to be put into
ensuring both the local and global way of setting the options
are available during the transition period.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/clang-tidy/ClangTidyOptions.h
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-include.rst
clang-tools-extra/docs/clang-tidy/checks/google/build-namespaces.rst
clang-tools-extra/docs/clang-tidy/checks/google/global-names-in-headers.rst
clang-tools-extra/docs/clang-tidy/checks/llvm/header-guard.rst
clang-tools-extra/docs/clang-tidy/checks/misc/definitions-in-headers.rst
clang-tools-extra/docs/clang-tidy/checks/misc/unused-using-decls.rst
clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst
clang-tools-extra/docs/clang-tidy/index.rst
clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index 84defccde513e..808929b11f796 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -122,9 +122,6 @@ template <> struct MappingTraits {
 bool Ignored = false;
 IO.mapOptional("Checks", Options.Checks);
 IO.mapOptional("WarningsAsErrors", Options.WarningsAsErrors);
-IO.mapOptional("HeaderFileExtensions", Options.HeaderFileExtensions);
-IO.mapOptional("ImplementationFileExtensions",
-   Options.ImplementationFileExtensions);
 IO.mapOptional("HeaderFilterRegex", Options.HeaderFilterRegex);
 IO.mapOptional("AnalyzeTemporaryDtors", Ignored); // deprecated
 IO.mapOptional("FormatStyle", Options.FormatStyle);
@@ -145,8 +142,6 @@ ClangTidyOptions ClangTidyOptions::getDefaults() {
   ClangTidyOptions Options;
   Options.Checks = "";
   Options.WarningsAsErrors = "";
-  Options.HeaderFileExtensions = {"", "h", "hh", "hpp", "hxx"};
-  Options.ImplementationFileExtensions = {"c", "cc", "cpp", "cxx"};
   Options.HeaderFilterRegex = "";
   Options.SystemHeaders = false;
   Options.FormatStyle = "none";
@@ -183,9 +178,6 @@ ClangTidyOptions ::mergeWith(const 
ClangTidyOptions ,
   unsigned Order) {
   mergeCommaSeparatedLists(Checks, Other.Checks);
   mergeCommaSeparatedLists(WarningsAsErrors, Other.WarningsAsErrors);
-  overrideValue(HeaderFileExtensions, Other.HeaderFileExtensions);
-  overrideValue(ImplementationFileExtensions,
-Other.ImplementationFileExtensions);
   overrideValue(HeaderFilterRegex, Other.HeaderFilterRegex);
   overrideValue(SystemHeaders, Other.SystemHeaders);
   overrideValue(FormatStyle, Other.FormatStyle);

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.h 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
index d0df474bc38e0..4a6cdf097905b 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -71,14 +71,6 @@ struct ClangTidyOptions {
   /// WarningsAsErrors filter.
   std::optional WarningsAsErrors;
 
-  /// File extensions to consider to determine if a given diagnostic is located
-  /// in a header file.
-  std::optional> HeaderFileExtensions;
-
-  /// File extensions to consider to determine if a given diagnostic is located
-  /// is located in an implementation file.
-  std::optional> ImplementationFileExtensions;
-
   /// Output warnings from headers matching this filter. Warnings from
   /// main files will always be displayed.
   std::optional HeaderFilterRegex;

diff  --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp 
b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index e8728c046e334..765b8483561ea 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -46,14 +46,12 @@ Configuration files:
 
 $ clang-tidy -dump-config
 ---
-Checks:   '-*,some-check'
-WarningsAsErrors: ''
-HeaderFileExtensions: ['', 'h','hh','hpp','hxx']
-ImplementationFileExtensions: ['c','cc','cpp','cxx']
-  

[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-01-24 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp:1
+// RUN: %check_clang_tidy -std=c++14-or-later %s 
cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- 
-fno-delayed-template-parsing
+

ccotter wrote:
> carlosgalvezp wrote:
> > ccotter wrote:
> > > ccotter wrote:
> > > > carlosgalvezp wrote:
> > > > > You specified C++11 in the LangOpts, but test against C++14 or later 
> > > > > in the test, maybe change it here to c++11-or-later?
> > > > The test uses generalize lambda capture, so it needs 14. Should I split 
> > > > the tests that use C++14 features to a separate file, and update this 
> > > > test file to use 11?
> > > Ah, and use of `auto` parameters in other lambdas. So there are a few 
> > > tests that would need to be split out to a separate file, use an `ifdef 
> > > __cplusplus` check (I see one other cppcoreguidelines test does this).
> > Oops I forgot to submit my comment. Yes I think we could keep everything in 
> > one test file running `c++11-or-later`, and `#ifdef` the C++14 parts.
> This didn't actually end up working. The test failed looking for expected 
> CHECK-MESSAGES, e.g.,
> 
> ```
> #if __cplusplus >= 201402L
> /* bad code */
> // CHECK-MESSAGES
> #endif
> ```
> 
> I'll go the separate file route then?
Hmm right.

What about 2 `RUN` commands in the same file? One of them you run it for 
`c++11` and the other for `c++14-or-later`. You can add a `check-prefix` for 
the C++14 case, then use `CHECK-MESSAGES-SOMEPREFIX` such that it only applies 
to that test invocation. No need to duplicate `CHECK-MESSAGES` for both runs - 
if no prefix is specified, it will apply to all runs. 

Something like:

```
#if __cplusplus >= 201402L
/* bad code */
// CHECK-MESSAGES-CXX14
#endif
```

If it gets too messy maybe a separate test file is the better option, I'm 
hoping there's not much duplication that needs to be maintaned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

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


[PATCH] D141959: [clang-format] Fix inconsistent identification of operator

2023-01-24 Thread David K Turner via Phabricator via cfe-commits
dkt01 added a comment.

Sounds good.  I don't believe I have permissions to add commits to three repo 
anyway, so someone can add on my behalf after the 16 branch.


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

https://reviews.llvm.org/D141959

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-01-24 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp:1
+// RUN: %check_clang_tidy -std=c++14-or-later %s 
cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- 
-fno-delayed-template-parsing
+

carlosgalvezp wrote:
> ccotter wrote:
> > ccotter wrote:
> > > carlosgalvezp wrote:
> > > > You specified C++11 in the LangOpts, but test against C++14 or later in 
> > > > the test, maybe change it here to c++11-or-later?
> > > The test uses generalize lambda capture, so it needs 14. Should I split 
> > > the tests that use C++14 features to a separate file, and update this 
> > > test file to use 11?
> > Ah, and use of `auto` parameters in other lambdas. So there are a few tests 
> > that would need to be split out to a separate file, use an `ifdef 
> > __cplusplus` check (I see one other cppcoreguidelines test does this).
> Oops I forgot to submit my comment. Yes I think we could keep everything in 
> one test file running `c++11-or-later`, and `#ifdef` the C++14 parts.
This didn't actually end up working. The test failed looking for expected 
CHECK-MESSAGES, e.g.,

```
#if __cplusplus >= 201402L
/* bad code */
// CHECK-MESSAGES
#endif
```

I'll go the separate file route then?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-01-24 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp:1
+// RUN: %check_clang_tidy -std=c++14-or-later %s 
cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- 
-fno-delayed-template-parsing
+

ccotter wrote:
> ccotter wrote:
> > carlosgalvezp wrote:
> > > You specified C++11 in the LangOpts, but test against C++14 or later in 
> > > the test, maybe change it here to c++11-or-later?
> > The test uses generalize lambda capture, so it needs 14. Should I split the 
> > tests that use C++14 features to a separate file, and update this test file 
> > to use 11?
> Ah, and use of `auto` parameters in other lambdas. So there are a few tests 
> that would need to be split out to a separate file, use an `ifdef 
> __cplusplus` check (I see one other cppcoreguidelines test does this).
Oops I forgot to submit my comment. Yes I think we could keep everything in one 
test file running `c++11-or-later`, and `#ifdef` the C++14 parts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-01-24 Thread Chris Cotter via Phabricator via cfe-commits
ccotter marked an inline comment as done.
ccotter added a comment.

In D141569#4048359 , @njames93 wrote:

> What happens with code like this
>
>   void foo(bar&& B) {
> std::move(B);
>   }

https://github.com/isocpp/CppCoreGuidelines/issues/2026#issuecomment-1402454584 
pointed out there's another guideline, ES.56, which a "useless" `move` such as 
this example would violate. I imagine this should be a different clang-tidy 
check though?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-01-24 Thread Chris Cotter via Phabricator via cfe-commits
ccotter marked an inline comment as done.
ccotter added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp:13
+
+#include 
+

carlosgalvezp wrote:
> Not sure if this is allowed in the repo or if we should use something 
> equivalent from ADT.
I was able to replace this with a cleaner solution


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-01-24 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 491989.
ccotter added a comment.

- Use match instead of bespoke traversal


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/rvalue-reference-param-not-moved.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
@@ -0,0 +1,286 @@
+// RUN: %check_clang_tidy -std=c++14-or-later %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- -fno-delayed-template-parsing
+
+// NOLINTBEGIN
+namespace std {
+template 
+struct remove_reference;
+
+template 
+struct remove_reference {
+  typedef _Tp type;
+};
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &(_Tp &&__t) noexcept;
+
+template 
+constexpr _Tp &&
+forward(typename remove_reference<_Tp>::type &__t) noexcept;
+
+}
+// NOLINTEND
+
+struct Obj {
+  Obj();
+  Obj(const Obj&);
+  Obj& operator=(const Obj&);
+  Obj(Obj&&);
+  Obj& operator=(Obj&&);
+  void member() const;
+};
+
+void consumes_object(Obj);
+
+void never_moves_param(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void copies_object(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  Obj copy = o;
+}
+
+template 
+void never_moves_param_template(Obj&& o, T t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void never_moves_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  // CHECK-MESSAGES: :[[@LINE-2]]:41: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void never_moves_some_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+  Obj other{std::move(o2)};
+}
+
+void never_moves_mixed(Obj o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:38: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value(Obj&& o) {
+  auto f = [o]() {
+consumes_object(std::move(o));
+  };
+  // CHECK-MESSAGES: :[[@LINE-4]]:47: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value_nested(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  auto f = []() {
+auto f_nested = [o]() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f2 = [o]() {
+auto f_nested = []() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f3 = [o]() {
+auto f_nested = []() {
+  auto f_nested_inner = []() {
+consumes_object(std::move(o));
+  };
+};
+  };
+  auto f4 = []() {
+auto f_nested = []() {
+  auto f_nested_inner = [o]() {
+consumes_object(std::move(o));
+  };
+};
+  };
+}
+
+void misc_lambda_checks() {
+  auto never_moves = [](Obj&& o1) {
+Obj other{o1};
+  };
+  // CHECK-MESSAGES: :[[@LINE-3]]:31: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+  auto never_moves_with_auto_param = [](Obj&& o1, auto& v) {
+Obj other{o1};
+  };
+  // CHECK-MESSAGES: :[[@LINE-3]]:47: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+template 

[PATCH] D142297: [Clang][OpenMP] Find the type `omp_allocator_handle_t` from identifier table

2023-01-24 Thread Shilei Tian 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 rG5ba8ecb6cc7b: [Clang][OpenMP] Find the type 
`omp_allocator_handle_t` from identifier table (authored by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142297

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/bug54082.c
  clang/test/OpenMP/target_uses_allocators.c
  openmp/runtime/test/parallel/bug54082.c

Index: openmp/runtime/test/parallel/bug54082.c
===
--- /dev/null
+++ openmp/runtime/test/parallel/bug54082.c
@@ -0,0 +1,54 @@
+// This test is adapted from test_parallel_for_allocate.c in SOLLVE V
+// https://github.com/SOLLVE/sollve_vv/blob/master/tests/5.0/parallel_for/test_parallel_for_allocate.c
+// RUN: %libomp-compile-and-run
+#include 
+
+#include 
+#include 
+
+#define N 1024
+
+int main(int argc, char *argv[]) {
+  int errors = 0;
+  int *x;
+  int result[N][N];
+  int successful_alloc = 0;
+
+  omp_memspace_handle_t x_memspace = omp_default_mem_space;
+  omp_alloctrait_t x_traits[1] = {omp_atk_alignment, 64};
+  omp_allocator_handle_t x_alloc = omp_init_allocator(x_memspace, 1, x_traits);
+
+  for (int i = 0; i < N; i++) {
+for (int j = 0; j < N; j++) {
+  result[i][j] = -1;
+}
+  }
+
+#pragma omp parallel for allocate(x_alloc: x) private(x) shared(result)
+  for (int i = 0; i < N; i++) {
+x = (int *)malloc(N * sizeof(int));
+if (x != NULL) {
+#pragma omp simd simdlen(16) aligned(x : 64)
+  for (int j = 0; j < N; j++) {
+x[j] = j * i;
+  }
+  for (int j = 0; j < N; j++) {
+result[i][j] = x[j];
+  }
+  free(x);
+  successful_alloc++;
+}
+  }
+
+  errors += successful_alloc < 1;
+
+  for (int i = 0; i < N; i++) {
+for (int j = 0; j < N; j++) {
+  errors += result[i][j] != i * j;
+}
+  }
+
+  omp_destroy_allocator(x_alloc);
+
+  return errors;
+}
Index: clang/test/OpenMP/target_uses_allocators.c
===
--- clang/test/OpenMP/target_uses_allocators.c
+++ clang/test/OpenMP/target_uses_allocators.c
@@ -6,7 +6,7 @@
 #ifndef HEADER
 #define HEADER
 
-enum omp_allocator_handle_t {
+typedef enum omp_allocator_handle_t {
   omp_null_allocator = 0,
   omp_default_mem_alloc = 1,
   omp_large_cap_mem_alloc = 2,
@@ -17,7 +17,7 @@
   omp_pteam_mem_alloc = 7,
   omp_thread_mem_alloc = 8,
   KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
-};
+} omp_allocator_handle_t;
 
 // CHECK: define {{.*}}[[FIE:@.+]]()
 void fie(void) {
@@ -105,4 +105,4 @@
 // CHECK-NEXT: %.x..void.addr = call ptr @__kmpc_alloc(i32 %[[#R0]], i64 4, ptr inttoptr (i64 8 to ptr))
 // CHECK-NEXT: %[[#R1:]] = load i32, ptr %x.addr, align 4
 // CHECK-NEXT: store i32 %[[#R1]], ptr %.x..void.addr, align 4
-// CHECK-NEXT: call void @__kmpc_free(i32 %[[#R0]], ptr %.x..void.addr, ptr inttoptr (i64 8 to ptr))
\ No newline at end of file
+// CHECK-NEXT: call void @__kmpc_free(i32 %[[#R0]], ptr %.x..void.addr, ptr inttoptr (i64 8 to ptr))
Index: clang/test/OpenMP/bug54082.c
===
--- /dev/null
+++ clang/test/OpenMP/bug54082.c
@@ -0,0 +1,114 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --prefix-filecheck-ir-name _
+// RUN: %clang_cc1 -fopenmp -O1 -x c -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+
+typedef enum omp_allocator_handle_t {
+  omp_null_allocator = 0,
+  omp_default_mem_alloc = 1,
+  omp_large_cap_mem_alloc = 2,
+  omp_const_mem_alloc = 3,
+  omp_high_bw_mem_alloc = 4,
+  omp_low_lat_mem_alloc = 5,
+  omp_cgroup_mem_alloc = 6,
+  omp_pteam_mem_alloc = 7,
+  omp_thread_mem_alloc = 8,
+  KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
+} omp_allocator_handle_t;
+
+typedef enum omp_memspace_handle_t {
+  omp_default_mem_space = 0,
+  omp_large_cap_mem_space = 1,
+  omp_const_mem_space = 2,
+  omp_high_bw_mem_space = 3,
+  omp_low_lat_mem_space = 4,
+  llvm_omp_target_host_mem_space = 100,
+  llvm_omp_target_shared_mem_space = 101,
+  llvm_omp_target_device_mem_space = 102,
+  KMP_MEMSPACE_MAX_HANDLE = __UINTPTR_MAX__
+} omp_memspace_handle_t;
+
+typedef enum {
+  omp_atk_sync_hint = 1,
+  omp_atk_alignment = 2,
+  omp_atk_access = 3,
+  omp_atk_pool_size = 4,
+  omp_atk_fallback = 5,
+  omp_atk_fb_data = 6,
+  omp_atk_pinned = 7,
+  omp_atk_partition = 8
+} omp_alloctrait_key_t;
+
+typedef __UINTPTR_TYPE__ omp_uintptr_t;
+typedef __SIZE_TYPE__ size_t;
+
+typedef struct {
+  omp_alloctrait_key_t key;
+  omp_uintptr_t value;
+} omp_alloctrait_t;
+
+extern omp_allocator_handle_t
+omp_init_allocator(omp_memspace_handle_t memspace, int ntraits,
+   const omp_alloctrait_t traits[]);
+
+#define N 1024

[clang] 5ba8ecb - [Clang][OpenMP] Find the type `omp_allocator_handle_t` from identifier table

2023-01-24 Thread Shilei Tian via cfe-commits

Author: Shilei Tian
Date: 2023-01-24T22:49:05-05:00
New Revision: 5ba8ecb6cc7b76e7124566e53a3bce9393763a20

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

LOG: [Clang][OpenMP] Find the type `omp_allocator_handle_t` from identifier 
table

In Clang, in order to determine the type of `omp_allocator_handle_t`, Clang
checks the type of those predefined allocators. The first one it checks is
`omp_null_allocator`. If the language is C, and the system is 64-bit, what Clang
gets is a `int`, instead of an enum of size 8, given the fact how we define
`omp_allocator_handle_t` in `omp.h`.  If the allocator is captured by a region,
let's say a parallel region, the allocator will be privatized. Because Clang 
deems
`omp_allocator_handle_t` as an `int`, it will first cast the value returned by
the runtime library (for `libomp` it is a `void *`) to `int`, and then in the
outlined function, it casts back to `omp_allocator_handle_t`. This two casts
completely shaves the first 32-bit of the pointer value returned from `libomp`,
and when the private "new" pointer is fed to another runtime function
`__kmpc_allocate()`, it causes segment fault. That is the root cause of PR54082.
I have no idea why `-fno-pic` could hide this bug.

In this patch, we detect `omp_allocator_handle_t` using roughly the same method
as `omp_event_handle_t`, by looking it up into the identifier table.

Fix #54082.

Reviewed By: ABataev

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

Added: 
clang/test/OpenMP/bug54082.c
openmp/runtime/test/parallel/bug54082.c

Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/target_uses_allocators.c

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index eb7bd2642a54e..c767341d922bd 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -3280,13 +3280,15 @@ getAllocatorKind(Sema , DSAStackTy *Stack, Expr 
*Allocator) {
   Allocator->containsUnexpandedParameterPack())
 return OMPAllocateDeclAttr::OMPUserDefinedMemAlloc;
   auto AllocatorKindRes = OMPAllocateDeclAttr::OMPUserDefinedMemAlloc;
+  llvm::FoldingSetNodeID AEId;
   const Expr *AE = Allocator->IgnoreParenImpCasts();
+  AE->IgnoreImpCasts()->Profile(AEId, S.getASTContext(), /*Canonical=*/true);
   for (int I = 0; I < OMPAllocateDeclAttr::OMPUserDefinedMemAlloc; ++I) {
 auto AllocatorKind = static_cast(I);
 const Expr *DefAllocator = Stack->getAllocator(AllocatorKind);
-llvm::FoldingSetNodeID AEId, DAEId;
-AE->Profile(AEId, S.getASTContext(), /*Canonical=*/true);
-DefAllocator->Profile(DAEId, S.getASTContext(), /*Canonical=*/true);
+llvm::FoldingSetNodeID DAEId;
+DefAllocator->IgnoreImpCasts()->Profile(DAEId, S.getASTContext(),
+/*Canonical=*/true);
 if (AEId == DAEId) {
   AllocatorKindRes = AllocatorKind;
   break;
@@ -16496,10 +16498,22 @@ OMPClause *Sema::ActOnOpenMPSimdlenClause(Expr *Len, 
SourceLocation StartLoc,
 /// Tries to find omp_allocator_handle_t type.
 static bool findOMPAllocatorHandleT(Sema , SourceLocation Loc,
 DSAStackTy *Stack) {
-  QualType OMPAllocatorHandleT = Stack->getOMPAllocatorHandleT();
-  if (!OMPAllocatorHandleT.isNull())
+  if (!Stack->getOMPAllocatorHandleT().isNull())
 return true;
-  // Build the predefined allocator expressions.
+
+  // Set the allocator handle type.
+  IdentifierInfo *II = 
().get("omp_allocator_handle_t");
+  ParsedType PT = S.getTypeName(*II, Loc, S.getCurScope());
+  if (!PT.getAsOpaquePtr() || PT.get().isNull()) {
+S.Diag(Loc, diag::err_omp_implied_type_not_found)
+<< "omp_allocator_handle_t";
+return false;
+  }
+  QualType AllocatorHandleEnumTy = PT.get();
+  AllocatorHandleEnumTy.addConst();
+  Stack->setOMPAllocatorHandleT(AllocatorHandleEnumTy);
+
+  // Fill the predefined allocator map.
   bool ErrorFound = false;
   for (int I = 0; I < OMPAllocateDeclAttr::OMPUserDefinedMemAlloc; ++I) {
 auto AllocatorKind = static_cast(I);
@@ -16519,9 +16533,10 @@ static bool findOMPAllocatorHandleT(Sema , 
SourceLocation Loc,
   ErrorFound = true;
   break;
 }
-if (OMPAllocatorHandleT.isNull())
-  OMPAllocatorHandleT = AllocatorType;
-if (!S.getASTContext().hasSameType(OMPAllocatorHandleT, AllocatorType)) {
+Res = S.PerformImplicitConversion(Res.get(), AllocatorHandleEnumTy,
+  Sema::AA_Initializing,
+  /* AllowExplicit */ true);
+if (!Res.isUsable()) {
   ErrorFound = true;
   break;
 }
@@ -16532,8 +16547,7 @@ static bool findOMPAllocatorHandleT(Sema , 
SourceLocation Loc,
 << "omp_allocator_handle_t";
 return 

[clang] 0f07ff8 - [Clang] Fix test that sometimes fails depending on the temp name

2023-01-24 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-01-24T21:12:00-06:00
New Revision: 0f07ff8b71e6c5f899b99b445eccd4323395b33f

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

LOG: [Clang] Fix test that sometimes fails depending on the temp name

Summary:
This test has a negative check for an extra file. it turns out that
sometimes the temp name can match it. Be more specific with it.

Added: 


Modified: 
clang/test/Driver/linker-wrapper-libs.c

Removed: 




diff  --git a/clang/test/Driver/linker-wrapper-libs.c 
b/clang/test/Driver/linker-wrapper-libs.c
index 3f4030d37d1f2..aa82dd5c44b0c 100644
--- a/clang/test/Driver/linker-wrapper-libs.c
+++ b/clang/test/Driver/linker-wrapper-libs.c
@@ -128,5 +128,5 @@ int bar() { return weak; }
 // RUN: | FileCheck %s --check-prefix=LIBRARY-GLOBAL-DEFINED
 
 // LIBRARY-GLOBAL-DEFINED: clang{{.*}} -o {{.*}}.img 
--target=amdgcn-amd-amdhsa -mcpu=gfx1030 {{.*}}.o {{.*}}.o
-// LIBRARY-GLOBAL-DEFINED-NOT: {{.*}}.o
+// LIBRARY-GLOBAL-DEFINED-NOT: {{.*}}gfx1030{{.*}}.o
 // LIBRARY-GLOBAL-DEFINED: clang{{.*}} -o {{.*}}.img 
--target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}.s {{.*}}.o



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


[PATCH] D142412: [clang-format] Put peekNextToken(/*SkipComment=*/true) to good use

2023-01-24 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3592-3601
 case tok::kw_bool:
   // bool is only allowed if it is directly followed by a paren for a cast:
   // concept C = bool(...);
   // and bool is the only type, all other types as cast must be inside a
   // cast to bool an thus are handled by the other cases.
   if (Tokens->peekNextToken()->isNot(tok::l_paren))
 return;

owenpan wrote:
> owenpan wrote:
> > HazardyKnusperkeks wrote:
> > > MyDeveloperDay wrote:
> > > > rymiel wrote:
> > > > > owenpan wrote:
> > > > > > rymiel wrote:
> > > > > > > rymiel wrote:
> > > > > > > > owenpan wrote:
> > > > > > > > > We should pass `true` to `peekNextToken()` on Line 3597 here, 
> > > > > > > > > but removing this entire case would have no effect on the 
> > > > > > > > > existing unit test (Line 23693 in FormatTest.cpp). 
> > > > > > > > > @HazardyKnusperkeks any idea?
> > > > > > > > The peeking is there because of 
> > > > > > > > https://reviews.llvm.org/D134325, it has no format tests, only 
> > > > > > > > an annotator test
> > > > > > > Also, I don't think that function is involved in concept 
> > > > > > > declarations since https://reviews.llvm.org/D140339
> > > > > > So which tests were meant to check the `kw_bool` case here?
> > > > > Well, originally the one you mentioned on line 23693, but since the 
> > > > > code paths have been changed, I think it's really only the one added 
> > > > > in https://reviews.llvm.org/D134325
> > > > I love the new annotator tests, but we should probably always try to 
> > > > add a verifyFormat test as well even if its trivial in the future, just 
> > > > so we have some context as to what type of code warranted the change.
> > > As far as I can see it does not only can be removed, it should be removed.
> > > 
> > > `bool` can not appear on the top level of a requires clause. As @rymiel 
> > > said it is there for the concepts, which are now handled differently.
> > @rymiel @HazardyKnusperkeks thanks for the explanations. Can we remove the 
> > `kw_bool` case then?
> > As far as I can see it does not only can be removed, it should be removed.
> 
> Okay, I will leave it to you or @rymiel then. :)
> As far as I can see it does not only can be removed, it should be removed.

You are right! I forgot the fact that this only ever applied for concepts, and 
the bug fix only ever worked around that. I had it backwards in my head because 
the bug affected requires clauses too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142412

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


[PATCH] D129008: [Clang][OpenMP] Fix the issue that globalization doesn't work with byval struct function argument

2023-01-24 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a subscriber: aaron.ballman.
tianshilei1992 added inline comments.



Comment at: clang/lib/CodeGen/CGDecl.cpp:2501
+  LValue Src = MakeAddrLValue(Arg.getIndirectAddress(), Ty);
+  callCStructCopyConstructor(Dst, Src);
+  PushCleanupIfNeeded(Arg.getIndirectAddress());

Hi @aaron.ballman, is it possible to invoke the copy constructor of a 
struct/class here, either it is user defined or default one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129008

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


[PATCH] D142412: [clang-format] Put peekNextToken(/*SkipComment=*/true) to good use

2023-01-24 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3592-3601
 case tok::kw_bool:
   // bool is only allowed if it is directly followed by a paren for a cast:
   // concept C = bool(...);
   // and bool is the only type, all other types as cast must be inside a
   // cast to bool an thus are handled by the other cases.
   if (Tokens->peekNextToken()->isNot(tok::l_paren))
 return;

owenpan wrote:
> HazardyKnusperkeks wrote:
> > MyDeveloperDay wrote:
> > > rymiel wrote:
> > > > owenpan wrote:
> > > > > rymiel wrote:
> > > > > > rymiel wrote:
> > > > > > > owenpan wrote:
> > > > > > > > We should pass `true` to `peekNextToken()` on Line 3597 here, 
> > > > > > > > but removing this entire case would have no effect on the 
> > > > > > > > existing unit test (Line 23693 in FormatTest.cpp). 
> > > > > > > > @HazardyKnusperkeks any idea?
> > > > > > > The peeking is there because of https://reviews.llvm.org/D134325, 
> > > > > > > it has no format tests, only an annotator test
> > > > > > Also, I don't think that function is involved in concept 
> > > > > > declarations since https://reviews.llvm.org/D140339
> > > > > So which tests were meant to check the `kw_bool` case here?
> > > > Well, originally the one you mentioned on line 23693, but since the 
> > > > code paths have been changed, I think it's really only the one added in 
> > > > https://reviews.llvm.org/D134325
> > > I love the new annotator tests, but we should probably always try to add 
> > > a verifyFormat test as well even if its trivial in the future, just so we 
> > > have some context as to what type of code warranted the change.
> > As far as I can see it does not only can be removed, it should be removed.
> > 
> > `bool` can not appear on the top level of a requires clause. As @rymiel 
> > said it is there for the concepts, which are now handled differently.
> @rymiel @HazardyKnusperkeks thanks for the explanations. Can we remove the 
> `kw_bool` case then?
> As far as I can see it does not only can be removed, it should be removed.

Okay, I will leave it to you or @rymiel then. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142412

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


[PATCH] D142412: [clang-format] Put peekNextToken(/*SkipComment=*/true) to good use

2023-01-24 Thread Owen Pan 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 rG56313f65cce7: [clang-format] Put 
peekNextToken(/*SkipComment=*/true) to good use (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142412

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3444,6 +3444,13 @@
"\n"
"private:\n"
"  int c;\n"
+   "};\n"
+   "class B {\n"
+   "public:\n"
+   "  std::unique_ptr b() { return nullptr; 
}\n"
+   "\n"
+   "private:\n"
+   "  int c;\n"
"};");
 }
 
@@ -9637,6 +9644,19 @@
"  return a;\n"
"}",
Style);
+  verifyFormat("byte *\n"
+   "f(a)\n"
+   "byte /* K C */ a[];\n"
+   "{\n"
+   "  return a;\n"
+   "}\n"
+   "byte *\n"
+   "g(p)\n"
+   "byte /* K C */ *p;\n"
+   "{\n"
+   "  return p;\n"
+   "}",
+   Style);
   verifyFormat("bool f(int a, int) override;\n"
"Bar g(int a, Bar) final;\n"
"Bar h(a, Bar) final;",
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1906,7 +1906,9 @@
   // declaration.
   if (!IsTopLevel || !Style.isCpp() || !Previous || eof())
 break;
-  if (isC78ParameterDecl(FormatTok, Tokens->peekNextToken(), Previous)) {
+  if (isC78ParameterDecl(FormatTok,
+ Tokens->peekNextToken(/*SkipComment=*/true),
+ Previous)) {
 addUnwrappedLine();
 return;
   }
@@ -2376,7 +2378,7 @@
   if (FormatTok->is(tok::l_square))
 return false;
   if (FormatTok->is(tok::r_square)) {
-const FormatToken *Next = Tokens->peekNextToken();
+const FormatToken *Next = Tokens->peekNextToken(/*SkipComment=*/true);
 if (Next->is(tok::greater))
   return false;
   }


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3444,6 +3444,13 @@
"\n"
"private:\n"
"  int c;\n"
+   "};\n"
+   "class B {\n"
+   "public:\n"
+   "  std::unique_ptr b() { return nullptr; }\n"
+   "\n"
+   "private:\n"
+   "  int c;\n"
"};");
 }
 
@@ -9637,6 +9644,19 @@
"  return a;\n"
"}",
Style);
+  verifyFormat("byte *\n"
+   "f(a)\n"
+   "byte /* K C */ a[];\n"
+   "{\n"
+   "  return a;\n"
+   "}\n"
+   "byte *\n"
+   "g(p)\n"
+   "byte /* K C */ *p;\n"
+   "{\n"
+   "  return p;\n"
+   "}",
+   Style);
   verifyFormat("bool f(int a, int) override;\n"
"Bar g(int a, Bar) final;\n"
"Bar h(a, Bar) final;",
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1906,7 +1906,9 @@
   // declaration.
   if (!IsTopLevel || !Style.isCpp() || !Previous || eof())
 break;
-  if (isC78ParameterDecl(FormatTok, Tokens->peekNextToken(), Previous)) {
+  if (isC78ParameterDecl(FormatTok,
+ Tokens->peekNextToken(/*SkipComment=*/true),
+ Previous)) {
 addUnwrappedLine();
 return;
   }
@@ -2376,7 +2378,7 @@
   if (FormatTok->is(tok::l_square))
 return false;
   if (FormatTok->is(tok::r_square)) {
-const FormatToken *Next = Tokens->peekNextToken();
+const FormatToken *Next = Tokens->peekNextToken(/*SkipComment=*/true);
 if (Next->is(tok::greater))
   return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 56313f6 - [clang-format] Put peekNextToken(/*SkipComment=*/true) to good use

2023-01-24 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2023-01-24T18:40:14-08:00
New Revision: 56313f65cce71366fdc659d1d08e0eeaa5d40b63

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

LOG: [clang-format] Put peekNextToken(/*SkipComment=*/true) to good use

To prevent potential bugs in situations where we want to peek the next
non-comment token.

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 6d5b92c61c78b..3e58b6f90559b 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1906,7 +1906,9 @@ void UnwrappedLineParser::parseStructuralElement(
   // declaration.
   if (!IsTopLevel || !Style.isCpp() || !Previous || eof())
 break;
-  if (isC78ParameterDecl(FormatTok, Tokens->peekNextToken(), Previous)) {
+  if (isC78ParameterDecl(FormatTok,
+ Tokens->peekNextToken(/*SkipComment=*/true),
+ Previous)) {
 addUnwrappedLine();
 return;
   }
@@ -2376,7 +2378,7 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
   if (FormatTok->is(tok::l_square))
 return false;
   if (FormatTok->is(tok::r_square)) {
-const FormatToken *Next = Tokens->peekNextToken();
+const FormatToken *Next = Tokens->peekNextToken(/*SkipComment=*/true);
 if (Next->is(tok::greater))
   return false;
   }

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index b7d0a398dd432..6530e2005e4c4 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -3444,6 +3444,13 @@ TEST_F(FormatTest, UnderstandsAccessSpecifiers) {
"\n"
"private:\n"
"  int c;\n"
+   "};\n"
+   "class B {\n"
+   "public:\n"
+   "  std::unique_ptr b() { return nullptr; 
}\n"
+   "\n"
+   "private:\n"
+   "  int c;\n"
"};");
 }
 
@@ -9637,6 +9644,19 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
"  return a;\n"
"}",
Style);
+  verifyFormat("byte *\n"
+   "f(a)\n"
+   "byte /* K C */ a[];\n"
+   "{\n"
+   "  return a;\n"
+   "}\n"
+   "byte *\n"
+   "g(p)\n"
+   "byte /* K C */ *p;\n"
+   "{\n"
+   "  return p;\n"
+   "}",
+   Style);
   verifyFormat("bool f(int a, int) override;\n"
"Bar g(int a, Bar) final;\n"
"Bar h(a, Bar) final;",



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


[PATCH] D142437: [clang] Add the check of membership in decltype for the issue #58674

2023-01-24 Thread Liming Liu via Phabricator via cfe-commits
lime updated this revision to Diff 491981.
lime added a comment.

Updated as suggested.


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

https://reviews.llvm.org/D142437

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/lib/AST/CXXInheritance.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/decltype.cpp

Index: clang/test/SemaCXX/decltype.cpp
===
--- clang/test/SemaCXX/decltype.cpp
+++ clang/test/SemaCXX/decltype.cpp
@@ -101,6 +101,44 @@
   template void foo(decltype(T(LP1{ .p1 = g1, .p1.x[1] = 'x' }))) {}
 }
 
+namespace GH58674 {
+  struct Foo {
+float value_;
+struct nested {
+  float value_;
+};
+  };
+
+  template 
+  struct TemplateFoo {
+float value_;
+  };
+
+  float bar;
+
+  template 
+  struct Animal{};
+
+  template 
+  class Cat : Animal {
+using okay = decltype(Foo::value_);
+using also_okay = decltype(bar);
+using okay2 = decltype(Foo::nested::value_);
+using okay3 = decltype(TemplateFoo::value_);
+  public:
+void meow() {
+  using okay = decltype(Foo::value_);
+  using also_okay = decltype(bar);
+  using okay2 = decltype(Foo::nested::value_);
+  using okay3 = decltype(TemplateFoo::value_);
+}
+  };
+
+  void baz() {
+  Cat{}.meow();
+  }
+}
+
 template
 class conditional {
 };
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2693,20 +2693,36 @@
   // to get this right here so that we don't end up making a
   // spuriously dependent expression if we're inside a dependent
   // instance method.
+  //
+  // We also don't need to do this if R resolved to a member in another
+  // class, which can happen in an unevaluated operand:
+  //
+  // C++ [expr.prim.id]p3.3:
+  //   If that id-expression denotes a non-static data member and it
+  //   appears in an unevaluated operand.
   if (!R.empty() && (*R.begin())->isCXXClassMember()) {
-bool MightBeImplicitMember;
-if (!IsAddressOfOperand)
-  MightBeImplicitMember = true;
-else if (!SS.isEmpty())
-  MightBeImplicitMember = false;
-else if (R.isOverloadedResult())
-  MightBeImplicitMember = false;
-else if (R.isUnresolvableResult())
-  MightBeImplicitMember = true;
-else
-  MightBeImplicitMember = isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl());
+bool MightBeImplicitMember = true, CheckField = true;
+if (IsAddressOfOperand) {
+  MightBeImplicitMember = SS.isEmpty() && !R.isOverloadedResult();
+  CheckField = !R.isUnresolvableResult();
+}
+if (MightBeImplicitMember && CheckField) {
+  if (R.isSingleResult() &&
+  isa(R.getFoundDecl())) {
+auto Class = cast((*R.begin())->getDeclContext());
+for (auto Curr = S->getLookupEntity(); Curr && !Curr->isFileContext();
+ Curr = Curr->getParent()) {
+  if (auto ThisClass = dyn_cast_if_present(Curr)) {
+if ((MightBeImplicitMember =
+ ThisClass->Equals(Class) ||
+ ThisClass->isDerivedFrom(Class,
+  /*LookupIndependent=*/true)))
+  break;
+  }
+}
+  } else if (IsAddressOfOperand)
+MightBeImplicitMember = false;
+}
 
 if (MightBeImplicitMember)
   return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
Index: clang/lib/AST/CXXInheritance.cpp
===
--- clang/lib/AST/CXXInheritance.cpp
+++ clang/lib/AST/CXXInheritance.cpp
@@ -64,14 +64,16 @@
   std::swap(DetectedVirtual, Other.DetectedVirtual);
 }
 
-bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base) const {
+bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
+  bool LookupIndependent) const {
   CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/false,
  /*DetectVirtual=*/false);
-  return isDerivedFrom(Base, Paths);
+  return isDerivedFrom(Base, Paths, LookupIndependent);
 }
 
 bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
-  CXXBasePaths ) const {
+  CXXBasePaths ,
+  bool LookupIndependent) const {
   if (getCanonicalDecl() == Base->getCanonicalDecl())
 return false;
 
@@ -80,9 +82,10 @@
   const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
   return lookupInBases(
   [BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath ) {
-return FindBaseClass(Specifier, Path, BaseDecl);
+return Specifier->getType()->getAsRecordDecl() &&
+   FindBaseClass(Specifier, Path, BaseDecl);
   },
-  Paths);
+  Paths, 

[PATCH] D142412: [clang-format] Put peekNextToken(/*SkipComment=*/true) to good use

2023-01-24 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3592-3601
 case tok::kw_bool:
   // bool is only allowed if it is directly followed by a paren for a cast:
   // concept C = bool(...);
   // and bool is the only type, all other types as cast must be inside a
   // cast to bool an thus are handled by the other cases.
   if (Tokens->peekNextToken()->isNot(tok::l_paren))
 return;

HazardyKnusperkeks wrote:
> MyDeveloperDay wrote:
> > rymiel wrote:
> > > owenpan wrote:
> > > > rymiel wrote:
> > > > > rymiel wrote:
> > > > > > owenpan wrote:
> > > > > > > We should pass `true` to `peekNextToken()` on Line 3597 here, but 
> > > > > > > removing this entire case would have no effect on the existing 
> > > > > > > unit test (Line 23693 in FormatTest.cpp). @HazardyKnusperkeks any 
> > > > > > > idea?
> > > > > > The peeking is there because of https://reviews.llvm.org/D134325, 
> > > > > > it has no format tests, only an annotator test
> > > > > Also, I don't think that function is involved in concept declarations 
> > > > > since https://reviews.llvm.org/D140339
> > > > So which tests were meant to check the `kw_bool` case here?
> > > Well, originally the one you mentioned on line 23693, but since the code 
> > > paths have been changed, I think it's really only the one added in 
> > > https://reviews.llvm.org/D134325
> > I love the new annotator tests, but we should probably always try to add a 
> > verifyFormat test as well even if its trivial in the future, just so we 
> > have some context as to what type of code warranted the change.
> As far as I can see it does not only can be removed, it should be removed.
> 
> `bool` can not appear on the top level of a requires clause. As @rymiel said 
> it is there for the concepts, which are now handled differently.
@rymiel @HazardyKnusperkeks thanks for the explanations. Can we remove the 
`kw_bool` case then?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142412

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-01-24 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 491978.
ccotter added a comment.

- Fix universal reference check; move diagnostic location to parameter name


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/rvalue-reference-param-not-moved.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
@@ -0,0 +1,286 @@
+// RUN: %check_clang_tidy -std=c++14-or-later %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- -fno-delayed-template-parsing
+
+// NOLINTBEGIN
+namespace std {
+template 
+struct remove_reference;
+
+template 
+struct remove_reference {
+  typedef _Tp type;
+};
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &(_Tp &&__t) noexcept;
+
+template 
+constexpr _Tp &&
+forward(typename remove_reference<_Tp>::type &__t) noexcept;
+
+}
+// NOLINTEND
+
+struct Obj {
+  Obj();
+  Obj(const Obj&);
+  Obj& operator=(const Obj&);
+  Obj(Obj&&);
+  Obj& operator=(Obj&&);
+  void member() const;
+};
+
+void consumes_object(Obj);
+
+void never_moves_param(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void copies_object(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  Obj copy = o;
+}
+
+template 
+void never_moves_param_template(Obj&& o, T t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void never_moves_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  // CHECK-MESSAGES: :[[@LINE-2]]:41: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void never_moves_some_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+  Obj other{std::move(o2)};
+}
+
+void never_moves_mixed(Obj o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:38: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value(Obj&& o) {
+  auto f = [o]() {
+consumes_object(std::move(o));
+  };
+  // CHECK-MESSAGES: :[[@LINE-4]]:47: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value_nested(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  auto f = []() {
+auto f_nested = [o]() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f2 = [o]() {
+auto f_nested = []() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f3 = [o]() {
+auto f_nested = []() {
+  auto f_nested_inner = []() {
+consumes_object(std::move(o));
+  };
+};
+  };
+  auto f4 = []() {
+auto f_nested = []() {
+  auto f_nested_inner = [o]() {
+consumes_object(std::move(o));
+  };
+};
+  };
+}
+
+void misc_lambda_checks() {
+  auto never_moves = [](Obj&& o1) {
+Obj other{o1};
+  };
+  // CHECK-MESSAGES: :[[@LINE-3]]:31: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+  auto never_moves_with_auto_param = [](Obj&& o1, auto& v) {
+Obj other{o1};
+  };
+  // CHECK-MESSAGES: :[[@LINE-3]]:47: warning: rvalue reference parameter is never moved from inside the function body 

[PATCH] D142297: [Clang][OpenMP] Find the type `omp_allocator_handle_t` from identifier table

2023-01-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142297

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


[PATCH] D142477: [X86] Ensure the _mm_test_all_ones macro does not reuse argument (PR60006)

2023-01-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper 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/D142477/new/

https://reviews.llvm.org/D142477

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


[PATCH] D142297: [Clang][OpenMP] Find the type `omp_allocator_handle_t` from identifier table

2023-01-24 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 491976.
tianshilei1992 added a comment.

use compiler builtin for types


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142297

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/bug54082.c
  clang/test/OpenMP/target_uses_allocators.c
  openmp/runtime/test/parallel/bug54082.c

Index: openmp/runtime/test/parallel/bug54082.c
===
--- /dev/null
+++ openmp/runtime/test/parallel/bug54082.c
@@ -0,0 +1,54 @@
+// This test is adapted from test_parallel_for_allocate.c in SOLLVE V
+// https://github.com/SOLLVE/sollve_vv/blob/master/tests/5.0/parallel_for/test_parallel_for_allocate.c
+// RUN: %libomp-compile-and-run
+#include 
+
+#include 
+#include 
+
+#define N 1024
+
+int main(int argc, char *argv[]) {
+  int errors = 0;
+  int *x;
+  int result[N][N];
+  int successful_alloc = 0;
+
+  omp_memspace_handle_t x_memspace = omp_default_mem_space;
+  omp_alloctrait_t x_traits[1] = {omp_atk_alignment, 64};
+  omp_allocator_handle_t x_alloc = omp_init_allocator(x_memspace, 1, x_traits);
+
+  for (int i = 0; i < N; i++) {
+for (int j = 0; j < N; j++) {
+  result[i][j] = -1;
+}
+  }
+
+#pragma omp parallel for allocate(x_alloc: x) private(x) shared(result)
+  for (int i = 0; i < N; i++) {
+x = (int *)malloc(N * sizeof(int));
+if (x != NULL) {
+#pragma omp simd simdlen(16) aligned(x : 64)
+  for (int j = 0; j < N; j++) {
+x[j] = j * i;
+  }
+  for (int j = 0; j < N; j++) {
+result[i][j] = x[j];
+  }
+  free(x);
+  successful_alloc++;
+}
+  }
+
+  errors += successful_alloc < 1;
+
+  for (int i = 0; i < N; i++) {
+for (int j = 0; j < N; j++) {
+  errors += result[i][j] != i * j;
+}
+  }
+
+  omp_destroy_allocator(x_alloc);
+
+  return errors;
+}
Index: clang/test/OpenMP/target_uses_allocators.c
===
--- clang/test/OpenMP/target_uses_allocators.c
+++ clang/test/OpenMP/target_uses_allocators.c
@@ -6,7 +6,7 @@
 #ifndef HEADER
 #define HEADER
 
-enum omp_allocator_handle_t {
+typedef enum omp_allocator_handle_t {
   omp_null_allocator = 0,
   omp_default_mem_alloc = 1,
   omp_large_cap_mem_alloc = 2,
@@ -17,7 +17,7 @@
   omp_pteam_mem_alloc = 7,
   omp_thread_mem_alloc = 8,
   KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
-};
+} omp_allocator_handle_t;
 
 // CHECK: define {{.*}}[[FIE:@.+]]()
 void fie(void) {
@@ -105,4 +105,4 @@
 // CHECK-NEXT: %.x..void.addr = call ptr @__kmpc_alloc(i32 %[[#R0]], i64 4, ptr inttoptr (i64 8 to ptr))
 // CHECK-NEXT: %[[#R1:]] = load i32, ptr %x.addr, align 4
 // CHECK-NEXT: store i32 %[[#R1]], ptr %.x..void.addr, align 4
-// CHECK-NEXT: call void @__kmpc_free(i32 %[[#R0]], ptr %.x..void.addr, ptr inttoptr (i64 8 to ptr))
\ No newline at end of file
+// CHECK-NEXT: call void @__kmpc_free(i32 %[[#R0]], ptr %.x..void.addr, ptr inttoptr (i64 8 to ptr))
Index: clang/test/OpenMP/bug54082.c
===
--- /dev/null
+++ clang/test/OpenMP/bug54082.c
@@ -0,0 +1,114 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --prefix-filecheck-ir-name _
+// RUN: %clang_cc1 -fopenmp -O1 -x c -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+
+typedef enum omp_allocator_handle_t {
+  omp_null_allocator = 0,
+  omp_default_mem_alloc = 1,
+  omp_large_cap_mem_alloc = 2,
+  omp_const_mem_alloc = 3,
+  omp_high_bw_mem_alloc = 4,
+  omp_low_lat_mem_alloc = 5,
+  omp_cgroup_mem_alloc = 6,
+  omp_pteam_mem_alloc = 7,
+  omp_thread_mem_alloc = 8,
+  KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
+} omp_allocator_handle_t;
+
+typedef enum omp_memspace_handle_t {
+  omp_default_mem_space = 0,
+  omp_large_cap_mem_space = 1,
+  omp_const_mem_space = 2,
+  omp_high_bw_mem_space = 3,
+  omp_low_lat_mem_space = 4,
+  llvm_omp_target_host_mem_space = 100,
+  llvm_omp_target_shared_mem_space = 101,
+  llvm_omp_target_device_mem_space = 102,
+  KMP_MEMSPACE_MAX_HANDLE = __UINTPTR_MAX__
+} omp_memspace_handle_t;
+
+typedef enum {
+  omp_atk_sync_hint = 1,
+  omp_atk_alignment = 2,
+  omp_atk_access = 3,
+  omp_atk_pool_size = 4,
+  omp_atk_fallback = 5,
+  omp_atk_fb_data = 6,
+  omp_atk_pinned = 7,
+  omp_atk_partition = 8
+} omp_alloctrait_key_t;
+
+typedef __UINTPTR_TYPE__ omp_uintptr_t;
+typedef __SIZE_TYPE__ size_t;
+
+typedef struct {
+  omp_alloctrait_key_t key;
+  omp_uintptr_t value;
+} omp_alloctrait_t;
+
+extern omp_allocator_handle_t
+omp_init_allocator(omp_memspace_handle_t memspace, int ntraits,
+   const omp_alloctrait_t traits[]);
+
+#define N 1024
+
+void foo() {
+  int *x;
+
+  omp_memspace_handle_t x_memspace = omp_default_mem_space;
+  omp_alloctrait_t x_traits[1] = {omp_atk_alignment, 64};
+  

[PATCH] D142297: [Clang][OpenMP] Find the type `omp_allocator_handle_t` from identifier table

2023-01-24 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 marked an inline comment as done.
tianshilei1992 added inline comments.



Comment at: clang/test/OpenMP/target_uses_allocators.c:108
 // CHECK-NEXT: store i32 %[[#R1]], ptr %.x..void.addr, align 4
-// CHECK-NEXT: call void @__kmpc_free(i32 %[[#R0]], ptr %.x..void.addr, ptr 
inttoptr (i64 8 to ptr))
\ No newline at end of file
+// CHECK-NEXT: call void @__kmpc_free(i32 %[[#R0]], ptr %.x..void.addr, ptr 
inttoptr (i64 8 to ptr))

ABataev wrote:
> ABataev wrote:
> > Would be good to have a test that shows the difference.
> A unit test with the difference? This test does not show anything.
I added a front end test above. It shows the key difference when call 
`__kmpc_alloc`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142297

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


[PATCH] D142297: [Clang][OpenMP] Find the type `omp_allocator_handle_t` from identifier table

2023-01-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/test/OpenMP/target_uses_allocators.c:108
 // CHECK-NEXT: store i32 %[[#R1]], ptr %.x..void.addr, align 4
-// CHECK-NEXT: call void @__kmpc_free(i32 %[[#R0]], ptr %.x..void.addr, ptr 
inttoptr (i64 8 to ptr))
\ No newline at end of file
+// CHECK-NEXT: call void @__kmpc_free(i32 %[[#R0]], ptr %.x..void.addr, ptr 
inttoptr (i64 8 to ptr))

ABataev wrote:
> Would be good to have a test that shows the difference.
A unit test with the difference? This test does not show anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142297

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


[PATCH] D142297: [Clang][OpenMP] Find the type `omp_allocator_handle_t` from identifier table

2023-01-24 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 491972.
tianshilei1992 added a comment.

rebase and fix comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142297

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/bug54082.c
  clang/test/OpenMP/target_uses_allocators.c
  openmp/runtime/test/parallel/bug54082.c

Index: openmp/runtime/test/parallel/bug54082.c
===
--- /dev/null
+++ openmp/runtime/test/parallel/bug54082.c
@@ -0,0 +1,54 @@
+// This test is adapted from test_parallel_for_allocate.c in SOLLVE V
+// https://github.com/SOLLVE/sollve_vv/blob/master/tests/5.0/parallel_for/test_parallel_for_allocate.c
+// RUN: %libomp-compile-and-run
+#include 
+
+#include 
+#include 
+
+#define N 1024
+
+int main(int argc, char *argv[]) {
+  int errors = 0;
+  int *x;
+  int result[N][N];
+  int successful_alloc = 0;
+
+  omp_memspace_handle_t x_memspace = omp_default_mem_space;
+  omp_alloctrait_t x_traits[1] = {omp_atk_alignment, 64};
+  omp_allocator_handle_t x_alloc = omp_init_allocator(x_memspace, 1, x_traits);
+
+  for (int i = 0; i < N; i++) {
+for (int j = 0; j < N; j++) {
+  result[i][j] = -1;
+}
+  }
+
+#pragma omp parallel for allocate(x_alloc: x) private(x) shared(result)
+  for (int i = 0; i < N; i++) {
+x = (int *)malloc(N * sizeof(int));
+if (x != NULL) {
+#pragma omp simd simdlen(16) aligned(x : 64)
+  for (int j = 0; j < N; j++) {
+x[j] = j * i;
+  }
+  for (int j = 0; j < N; j++) {
+result[i][j] = x[j];
+  }
+  free(x);
+  successful_alloc++;
+}
+  }
+
+  errors += successful_alloc < 1;
+
+  for (int i = 0; i < N; i++) {
+for (int j = 0; j < N; j++) {
+  errors += result[i][j] != i * j;
+}
+  }
+
+  omp_destroy_allocator(x_alloc);
+
+  return errors;
+}
Index: clang/test/OpenMP/target_uses_allocators.c
===
--- clang/test/OpenMP/target_uses_allocators.c
+++ clang/test/OpenMP/target_uses_allocators.c
@@ -6,7 +6,7 @@
 #ifndef HEADER
 #define HEADER
 
-enum omp_allocator_handle_t {
+typedef enum omp_allocator_handle_t {
   omp_null_allocator = 0,
   omp_default_mem_alloc = 1,
   omp_large_cap_mem_alloc = 2,
@@ -17,7 +17,7 @@
   omp_pteam_mem_alloc = 7,
   omp_thread_mem_alloc = 8,
   KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
-};
+} omp_allocator_handle_t;
 
 // CHECK: define {{.*}}[[FIE:@.+]]()
 void fie(void) {
@@ -105,4 +105,4 @@
 // CHECK-NEXT: %.x..void.addr = call ptr @__kmpc_alloc(i32 %[[#R0]], i64 4, ptr inttoptr (i64 8 to ptr))
 // CHECK-NEXT: %[[#R1:]] = load i32, ptr %x.addr, align 4
 // CHECK-NEXT: store i32 %[[#R1]], ptr %.x..void.addr, align 4
-// CHECK-NEXT: call void @__kmpc_free(i32 %[[#R0]], ptr %.x..void.addr, ptr inttoptr (i64 8 to ptr))
\ No newline at end of file
+// CHECK-NEXT: call void @__kmpc_free(i32 %[[#R0]], ptr %.x..void.addr, ptr inttoptr (i64 8 to ptr))
Index: clang/test/OpenMP/bug54082.c
===
--- /dev/null
+++ clang/test/OpenMP/bug54082.c
@@ -0,0 +1,114 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --prefix-filecheck-ir-name _
+// RUN: %clang_cc1 -fopenmp -O1 -x c -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+
+typedef enum omp_allocator_handle_t {
+  omp_null_allocator = 0,
+  omp_default_mem_alloc = 1,
+  omp_large_cap_mem_alloc = 2,
+  omp_const_mem_alloc = 3,
+  omp_high_bw_mem_alloc = 4,
+  omp_low_lat_mem_alloc = 5,
+  omp_cgroup_mem_alloc = 6,
+  omp_pteam_mem_alloc = 7,
+  omp_thread_mem_alloc = 8,
+  KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
+} omp_allocator_handle_t;
+
+typedef enum omp_memspace_handle_t {
+  omp_default_mem_space = 0,
+  omp_large_cap_mem_space = 1,
+  omp_const_mem_space = 2,
+  omp_high_bw_mem_space = 3,
+  omp_low_lat_mem_space = 4,
+  llvm_omp_target_host_mem_space = 100,
+  llvm_omp_target_shared_mem_space = 101,
+  llvm_omp_target_device_mem_space = 102,
+  KMP_MEMSPACE_MAX_HANDLE = __UINTPTR_MAX__
+} omp_memspace_handle_t;
+
+typedef enum {
+  omp_atk_sync_hint = 1,
+  omp_atk_alignment = 2,
+  omp_atk_access = 3,
+  omp_atk_pool_size = 4,
+  omp_atk_fallback = 5,
+  omp_atk_fb_data = 6,
+  omp_atk_pinned = 7,
+  omp_atk_partition = 8
+} omp_alloctrait_key_t;
+
+typedef unsigned long long omp_uintptr_t;
+typedef unsigned long long size_t;
+
+typedef struct {
+  omp_alloctrait_key_t key;
+  omp_uintptr_t value;
+} omp_alloctrait_t;
+
+extern omp_allocator_handle_t
+omp_init_allocator(omp_memspace_handle_t memspace, int ntraits,
+   const omp_alloctrait_t traits[]);
+
+#define N 1024
+
+void foo() {
+  int *x;
+
+  omp_memspace_handle_t x_memspace = omp_default_mem_space;
+  omp_alloctrait_t x_traits[1] = {omp_atk_alignment, 64};
+  

[PATCH] D138337: Add support for kcfi-seal optimization with LTO

2023-01-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Is https://reviews.llvm.org/D142163 a blocker for this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138337

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-01-24 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp:1
+// RUN: %check_clang_tidy -std=c++14-or-later %s 
cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- 
-fno-delayed-template-parsing
+

ccotter wrote:
> carlosgalvezp wrote:
> > You specified C++11 in the LangOpts, but test against C++14 or later in the 
> > test, maybe change it here to c++11-or-later?
> The test uses generalize lambda capture, so it needs 14. Should I split the 
> tests that use C++14 features to a separate file, and update this test file 
> to use 11?
Ah, and use of `auto` parameters in other lambdas. So there are a few tests 
that would need to be split out to a separate file, use an `ifdef __cplusplus` 
check (I see one other cppcoreguidelines test does this).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

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


[PATCH] D140179: [-Wunsafe-buffer-usage] Add unsafe buffer checking opt-out pragmas

2023-01-24 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 491960.
ziqingluo-90 retitled this revision from "[WIP][-Wunsafe-buffer-usage] Add 
unsafe buffer checking opt-out pragmas" to "[-Wunsafe-buffer-usage] Add unsafe 
buffer checking opt-out pragmas".
ziqingluo-90 added reviewers: aaron.ballman, xazax.hun, gribozavr, ymandel, 
sgatev.
ziqingluo-90 added a comment.
Herald added a subscriber: rnkovacs.

Put the implementation of the opt-out pragma completely in Preprocessor.
Add an opt-out pragma test for fix-its.


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

https://reviews.llvm.org/D140179

Files:
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Lex/Pragma.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma-fixit.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma-misuse.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma.h

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma.h
===
--- /dev/null
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma.h
@@ -0,0 +1,14 @@
+#ifdef _INCLUDE_NO_WARN
+// the snippet will be included in an opt-out region
+p1++;
+
+#undef _INCLUDE_NO_WARN
+
+#elif defined(_INCLUDE_WARN)
+// the snippet will be included in a location where warnings are expected
+p2++; // expected-note{{used in pointer arithmetic here}}
+#undef _INCLUDE_WARN
+
+#else
+
+#endif
Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma.cpp
@@ -0,0 +1,100 @@
+// RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -Wno-unused-value -verify %s
+
+void basic(int * x) {// expected-warning{{'x' is an unsafe pointer used for buffer access}}
+  int *p1 = new int[10]; // not to warn
+  int *p2 = new int[10]; // expected-warning{{'p2' is an unsafe pointer used for buffer access}}
+
+#pragma clang unsafe_buffer_usage begin
+  p1[5];  // not to warn
+
+#define _INCLUDE_NO_WARN
+#include "warn-unsafe-buffer-usage-pragma.h" // increment p1 in header
+
+  int *p3 = new int[10]; // expected-warning{{'p3' is an unsafe pointer used for buffer access}}
+
+#pragma clang unsafe_buffer_usage end
+  p2[5]; //expected-note{{used in buffer access here}}
+  p3[5]; //expected-note{{used in buffer access here}}
+  x++;   //expected-note{{used in pointer arithmetic here}}
+#define _INCLUDE_WARN
+#include "warn-unsafe-buffer-usage-pragma.h" // increment p2 in header
+}
+
+
+void withDiagnosticWarning() {
+  int *p1 = new int[10]; // not to warn
+  int *p2 = new int[10]; // expected-warning{{'p2' is an unsafe pointer used for buffer access}}
+
+  // diagnostics in opt-out region
+#pragma clang unsafe_buffer_usage begin
+  p1[5];  // not to warn
+  p2[5];  // not to warn
+#pragma clang diagnostic push
+#pragma clang diagnostic warning "-Wunsafe-buffer-usage"
+  p1[5];  // not to warn
+  p2[5];  // not to warn
+#pragma clang diagnostic warning "-Weverything"
+  p1[5];  // not to warn expected-warning{{expression result unused}}
+  p2[5];  // not to warn expected-warning{{expression result unused}}
+#pragma clang diagnostic pop
+#pragma clang unsafe_buffer_usage end
+
+  // opt-out region under diagnostic warning
+#pragma clang diagnostic push
+#pragma clang diagnostic warning "-Wunsafe-buffer-usage"
+#pragma clang unsafe_buffer_usage begin
+  p1[5];  // not to warn
+  p2[5];  // not to warn
+#pragma clang unsafe_buffer_usage end
+#pragma clang diagnostic pop
+
+  p2[5]; // expected-note{{used in buffer access here}}
+}
+
+
+void withDiagnosticIgnore() {
+  int *p1 = new int[10]; // not to warn
+  int *p2 = new int[10]; // expected-warning{{'p2' is an unsafe pointer used for buffer access}}
+  int *p3 = new int[10]; // expected-warning{{'p3' is an unsafe pointer used for buffer access}}
+
+#pragma clang unsafe_buffer_usage begin
+  p1[5];  // not to warn
+  p2[5];  // not to warn
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
+  p1[5];  // not to warn
+  p2[5];  // not to warn
+#pragma clang diagnostic ignored "-Weverything"
+  p1[5];  // not to warn
+  p2[5];  // not to warn
+#pragma clang diagnostic pop
+#pragma clang unsafe_buffer_usage end
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
+#pragma clang unsafe_buffer_usage begin
+  p1[5];  // not to warn
+  p2[5];  // not to warn
+#pragma clang unsafe_buffer_usage end
+#pragma clang diagnostic pop
+
+  p2[5]; // expected-note{{used in buffer access here}}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"

[clang] 92b4946 - [CodeGen] bugfix: add REQUIRES target triple in test

2023-01-24 Thread usama hameed via cfe-commits

Author: usama hameed
Date: 2023-01-24T16:28:01-08:00
New Revision: 92b4946aa2f6e061bf0ab9803fc6a0657d9ce969

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

LOG: [CodeGen] bugfix: add REQUIRES target triple in test

Added: 


Modified: 
clang/test/CodeGenObjC/objc-arc-ubsan-debugging.m

Removed: 




diff  --git a/clang/test/CodeGenObjC/objc-arc-ubsan-debugging.m 
b/clang/test/CodeGenObjC/objc-arc-ubsan-debugging.m
index 531f0fdf9..04c8d69a7bc39 100644
--- a/clang/test/CodeGenObjC/objc-arc-ubsan-debugging.m
+++ b/clang/test/CodeGenObjC/objc-arc-ubsan-debugging.m
@@ -1,4 +1,5 @@
 // RUN: %clang -x objective-c -target arm64-apple-macos12.0 -fobjc-arc 
-std=gnu99  -O0 -fsanitize=undefined -fsanitize=nullability -c %s -v -g
+// REQUIRES: aarch64-registered-target
 
 @interface NSString
 @end



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


[PATCH] D142065: [SVE] Fix incorrect lowering of predicate permute builtins.

2023-01-24 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm added inline comments.



Comment at: llvm/lib/Target/AArch64/SVEInstrFormats.td:6361
+  def : SVE_2_Op_Pat(NAME # 
_S)>;
+  def : SVE_2_Op_Pat(NAME # 
_D)>;
 }

peterwaller-arm wrote:
> Out of interest, is there a good reason to handle the nxv16 pattern case 
> differently in the `I` multiclass args? Written this way at a glance it looks 
> like it is missing.
My reasoning was the pattern within the instruction class is mandatory for the 
correct clang builtin support so I figured that should take priority.  That 
means extra patterns are only required for the unpacked cases, which are 
optional based on them having value during code generation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142065

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


[PATCH] D142048: [Phabricator] Fix __ptr32 arguments passed to builtins

2023-01-24 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

It sounds to me that the logic from b919c7d should have been restricted to 
actual LLVM intrinsics that are overloaded on the pointer args ( e.g. 
llvm.memcpy which was the test in that commit). Builtins that are just library 
calls with known semantics probably need the cast even for opencl?




Comment at: clang/test/CodeGen/address-space-ptr32.c:54
+  // CHECK-NEXT:   ret i64 %call
+   return strlen ( s );
+}

Maybe use `__builtin_strlen` here instead to avoid the declaration?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142048

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


[PATCH] D139737: [-Wunsafe-buffer-usage] Initiate Fix-it generation for local variable declarations

2023-01-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Awesome, we're getting closer to producing our first fix!

I think the most important thing right now is to add a lot of 
`SourceLocation::isMacroID()` checks everywhere, so that to *never* try to fix 
code that's fully or partially expanded from macros. I suspect that we can do 
that "after the fact": just scan the list of emitted fixits for any source 
ranges that start or end in macros, and if even one such range is found, 
abandon the fix. Might be worth double-checking that the compiler doesn't 
already do that automatically for all emitted fixits.

I see that the patch doesn't touch `handleFixableVariable()`. Do we still 
attach fixits to the warning, or did we already change it to be attached to a 
note associated with the warning? Because fixits with placeholders aren't 
allowed on warnings, we should make sure it's attached to note before landing 
this patch.




Comment at: clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h:42
+  /// Returns the text indicating that the user needs to provide input there:
+  static std::string
+  getUserFillPlaceHolder(const StringRef  = "placeholder") {

Do we really want this method in the public interface? If the idea is to let 
people the user override it, maybe let's actually allow that by dropping 
`static` and adding `virtual`? I think this is actually a good idea, maybe if 
somebody uses our analysis outside of the `clang` binary, they may want a 
different placeholder.



Comment at: clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h:43
+  static std::string
+  getUserFillPlaceHolder(const StringRef  = "placeholder") {
+std::string s = std::string("<# ");

`const StringRef &` seems redundant given that `StringRef` is already a "Ref". 
Just pass by value.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:408
+auto BaseIsArrayOrPtrDRE =
+hasBase(ignoringParenImpCasts(allOf(declRefExpr(), ArrayOrPtr)));
+auto Target =

A bit more concise.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:637
 
-static Strategy
-getNaiveStrategy(const llvm::SmallVectorImpl ) {

Hmm, did this need to be moved? I don't think you're calling this function from 
the new code.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:726
+template 
+static std::optional getPassedLoc(const NodeTy *Node,
+  const SourceManager ,

(https://www.oxfordinternationalenglish.com/passed-vs-past-whats-the-difference/,
 looks like "Passed` is always a verb)



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:768
+if (const Expr *Ext = CxxNew->getArraySize().value_or(nullptr)) {
+  if (!Ext->HasSideEffects(Ctx))
+ExtentText =

Excellent observation!



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:771
+getExprTextOr(Ext, SM, LangOpts, StringRef(DefaultExtentTxt));
+} else if (!CxxNew->isArray())
+  ExtentText = One;

I wonder how do we end up in such situation. If it's not array new, this means 
it's also not a buffer of multiple elements. But I guess the pointer can be 
reassigned later. Yeah I think you're right, this is the correct solution. 
Maybe let's leave a comment explaining how this could happen?



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:773-774
+  ExtentText = One;
+  } else if (auto CArrTy = dyn_cast(
+ Init->IgnoreImpCasts()->getType().getTypePtr())) {
+// In cases `Init` is of an array type after stripping off implicit casts,

That's another case where `.getTypePtr()` is unnecessary: 
`dyn_cast(QT.getTypePtr())` is equivalent to`QT->getAs()` where `->` is 
`QualType`'s overloaded operator and `getAs` is `Type::getAs`.

Additionally, array types are special - see doxygen comments for 
`ASTContext::getAsArrayType()`. For some reason you're suppposed to consult 
ASTContext when casting them, which I did in the suggested fix. I'm not sure if 
it matters in this case when we just want to extract the size.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:780-781
+  } else {
+// In cases `Init` is of the form `` after stripping of implicit
+// casts, where `&` is the built-in operator, the extent is 1.
+if (auto AddrOfExpr = dyn_cast(Init->IgnoreImpCasts()))

```lang=c
int x = 1;
char *ptr =  // std::span ptr { , 4 };
```
This is valid code. I suspect we want to check types as well, to see that type 
sizes match.

Most of the time code like this violates strict aliasing, but `char` is 
exceptional, and even if it did violate strict aliasing, people can compile 
with `-fno-strict-aliasing` to define away the UB, so we have to respect that.



Comment at: 

[clang] 0245dcc - [clang][test] Remove check that fails if SOURCE_DATE_EPOCH is set globally

2023-01-24 Thread Ben Langmuir via cfe-commits

Author: Ben Langmuir
Date: 2023-01-24T16:00:56-08:00
New Revision: 0245dcc000faf4f6dea9552a44106c8921df841e

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

LOG: [clang][test] Remove check that fails if SOURCE_DATE_EPOCH is set globally

The check for "no SOURCE_DATE_EPOCH" wasn't especially interesting, and
I am not aware of a _portable_ way to unset and environment variable in
a lit test. So remove it since it can fail if the build environment has
SOURCE_DATE_EPOCH set globally.

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

Added: 


Modified: 
clang/test/Driver/SOURCE_DATE_EPOCH.c

Removed: 




diff  --git a/clang/test/Driver/SOURCE_DATE_EPOCH.c 
b/clang/test/Driver/SOURCE_DATE_EPOCH.c
index 69c0e1e7c3b3..c2e88f5e6b3b 100644
--- a/clang/test/Driver/SOURCE_DATE_EPOCH.c
+++ b/clang/test/Driver/SOURCE_DATE_EPOCH.c
@@ -1,5 +1,2 @@
-// RUN: %clang -E %s -### 2>&1 | FileCheck %s -check-prefix=NO_EPOCH
-// NO_EPOCH-NOT: "-source-date-epoch"
-
 // RUN: env SOURCE_DATE_EPOCH=123 %clang -E %s -### 2>&1 | FileCheck %s
 // CHECK: "-source-date-epoch" "123"



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


[PATCH] D142511: [clang][test] Remove check that fails if SOURCE_DATE_EPOCH is set globally

2023-01-24 Thread Ben Langmuir 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 rG0245dcc000fa: [clang][test] Remove check that fails if 
SOURCE_DATE_EPOCH is set globally (authored by benlangmuir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142511

Files:
  clang/test/Driver/SOURCE_DATE_EPOCH.c


Index: clang/test/Driver/SOURCE_DATE_EPOCH.c
===
--- clang/test/Driver/SOURCE_DATE_EPOCH.c
+++ clang/test/Driver/SOURCE_DATE_EPOCH.c
@@ -1,5 +1,2 @@
-// RUN: %clang -E %s -### 2>&1 | FileCheck %s -check-prefix=NO_EPOCH
-// NO_EPOCH-NOT: "-source-date-epoch"
-
 // RUN: env SOURCE_DATE_EPOCH=123 %clang -E %s -### 2>&1 | FileCheck %s
 // CHECK: "-source-date-epoch" "123"


Index: clang/test/Driver/SOURCE_DATE_EPOCH.c
===
--- clang/test/Driver/SOURCE_DATE_EPOCH.c
+++ clang/test/Driver/SOURCE_DATE_EPOCH.c
@@ -1,5 +1,2 @@
-// RUN: %clang -E %s -### 2>&1 | FileCheck %s -check-prefix=NO_EPOCH
-// NO_EPOCH-NOT: "-source-date-epoch"
-
 // RUN: env SOURCE_DATE_EPOCH=123 %clang -E %s -### 2>&1 | FileCheck %s
 // CHECK: "-source-date-epoch" "123"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142511: [clang][test] Remove check that fails if SOURCE_DATE_EPOCH is set globally

2023-01-24 Thread Tom Stellard via Phabricator via cfe-commits
tstellar accepted this revision.
tstellar added a comment.
This revision is now accepted and ready to land.

LGTM. Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142511

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


[PATCH] D136717: [clang] Move getenv call for SOURCE_DATE_EPOCH out of frontend NFC

2023-01-24 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added inline comments.



Comment at: clang/test/Driver/SOURCE_DATE_EPOCH.c:2
+// RUN: %clang -E %s -### 2>&1 | FileCheck %s -check-prefix=NO_EPOCH
+// NO_EPOCH-NOT: "-source-date-epoch"
+

tstellar wrote:
> Hi @benlangmuir, this test fails in our build environment, because we have 
> the SOURCE_DATE_EPOCH env variable set globally.  Is there any way to update 
> the test to handle this scenario?
I'm not aware of a portable way to unset environment variables (`env -u` 
doesn't work on some of our platforms) and this first check is low-value 
anyway, so I'm fine with just dropping it and only having the ones below that 
explicitly set a value.  https://reviews.llvm.org/D142511


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136717

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


[PATCH] D142511: [clang][test] Remove check that fails if SOURCE_DATE_EPOCH is set globally

2023-01-24 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added a reviewer: tstellar.
Herald added a project: All.
benlangmuir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The check for "no SOURCE_DATE_EPOCH" wasn't especially interesting, and I am 
not aware of a _portable_ way to unset and environment variable in a lit test. 
So remove it since it can fail if the build environment has SOURCE_DATE_EPOCH 
set globally.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142511

Files:
  clang/test/Driver/SOURCE_DATE_EPOCH.c


Index: clang/test/Driver/SOURCE_DATE_EPOCH.c
===
--- clang/test/Driver/SOURCE_DATE_EPOCH.c
+++ clang/test/Driver/SOURCE_DATE_EPOCH.c
@@ -1,5 +1,2 @@
-// RUN: %clang -E %s -### 2>&1 | FileCheck %s -check-prefix=NO_EPOCH
-// NO_EPOCH-NOT: "-source-date-epoch"
-
 // RUN: env SOURCE_DATE_EPOCH=123 %clang -E %s -### 2>&1 | FileCheck %s
 // CHECK: "-source-date-epoch" "123"


Index: clang/test/Driver/SOURCE_DATE_EPOCH.c
===
--- clang/test/Driver/SOURCE_DATE_EPOCH.c
+++ clang/test/Driver/SOURCE_DATE_EPOCH.c
@@ -1,5 +1,2 @@
-// RUN: %clang -E %s -### 2>&1 | FileCheck %s -check-prefix=NO_EPOCH
-// NO_EPOCH-NOT: "-source-date-epoch"
-
 // RUN: env SOURCE_DATE_EPOCH=123 %clang -E %s -### 2>&1 | FileCheck %s
 // CHECK: "-source-date-epoch" "123"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138546: Clangd: Preserve target flags in system includes extractor

2023-01-24 Thread Christopher Sauer via Phabricator via cfe-commits
cpsauer added a comment.

Thanks, Nathan. Makes sense; sounds good.

@kadircet, I think this one is ready for you, whenever you want it. Lmk how 
you'd like to proceed.


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

https://reviews.llvm.org/D138546

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


[PATCH] D142243: [CodeGen] bugfix: ApplyDebugLocation goes out of scope before intended

2023-01-24 Thread Usama Hameed 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 rG5b6dbdecba0b: [CodeGen] bugfix: ApplyDebugLocation goes out 
of scope before intended (authored by usama54321).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142243

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGenObjC/objc-arc-ubsan-debugging.m


Index: clang/test/CodeGenObjC/objc-arc-ubsan-debugging.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/objc-arc-ubsan-debugging.m
@@ -0,0 +1,14 @@
+// RUN: %clang -x objective-c -target arm64-apple-macos12.0 -fobjc-arc 
-std=gnu99  -O0 -fsanitize=undefined -fsanitize=nullability -c %s -v -g
+
+@interface NSString
+@end
+
+struct A {
+NSString *a;
+};
+
+NSString* _Nonnull foo()
+{
+struct A a;
+return 0;
+}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -361,17 +361,18 @@
   bool HasOnlyLifetimeMarkers =
   HasCleanups && EHStack.containsOnlyLifetimeMarkers(PrologueCleanupDepth);
   bool EmitRetDbgLoc = !HasCleanups || HasOnlyLifetimeMarkers;
+
+  std::optional OAL;
   if (HasCleanups) {
 // Make sure the line table doesn't jump back into the body for
 // the ret after it's been at EndLoc.
-std::optional AL;
 if (CGDebugInfo *DI = getDebugInfo()) {
   if (OnlySimpleReturnStmts)
 DI->EmitLocation(Builder, EndLoc);
   else
 // We may not have a valid end location. Try to apply it anyway, and
 // fall back to an artificial location if needed.
-AL = ApplyDebugLocation::CreateDefaultArtificial(*this, EndLoc);
+OAL = ApplyDebugLocation::CreateDefaultArtificial(*this, EndLoc);
 }
 
 PopCleanupBlocks(PrologueCleanupDepth);


Index: clang/test/CodeGenObjC/objc-arc-ubsan-debugging.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/objc-arc-ubsan-debugging.m
@@ -0,0 +1,14 @@
+// RUN: %clang -x objective-c -target arm64-apple-macos12.0 -fobjc-arc -std=gnu99  -O0 -fsanitize=undefined -fsanitize=nullability -c %s -v -g
+
+@interface NSString
+@end
+
+struct A {
+NSString *a;
+};
+
+NSString* _Nonnull foo()
+{
+struct A a;
+return 0;
+}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -361,17 +361,18 @@
   bool HasOnlyLifetimeMarkers =
   HasCleanups && EHStack.containsOnlyLifetimeMarkers(PrologueCleanupDepth);
   bool EmitRetDbgLoc = !HasCleanups || HasOnlyLifetimeMarkers;
+
+  std::optional OAL;
   if (HasCleanups) {
 // Make sure the line table doesn't jump back into the body for
 // the ret after it's been at EndLoc.
-std::optional AL;
 if (CGDebugInfo *DI = getDebugInfo()) {
   if (OnlySimpleReturnStmts)
 DI->EmitLocation(Builder, EndLoc);
   else
 // We may not have a valid end location. Try to apply it anyway, and
 // fall back to an artificial location if needed.
-AL = ApplyDebugLocation::CreateDefaultArtificial(*this, EndLoc);
+OAL = ApplyDebugLocation::CreateDefaultArtificial(*this, EndLoc);
 }
 
 PopCleanupBlocks(PrologueCleanupDepth);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5b6dbde - [CodeGen] bugfix: ApplyDebugLocation goes out of scope before intended

2023-01-24 Thread usama hameed via cfe-commits

Author: usama hameed
Date: 2023-01-24T15:31:07-08:00
New Revision: 5b6dbdecba0b033e6a64593062cf87cd6c8a66ee

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

LOG: [CodeGen] bugfix: ApplyDebugLocation goes out of scope before intended

rdar://103570533

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

Added: 
clang/test/CodeGenObjC/objc-arc-ubsan-debugging.m

Modified: 
clang/lib/CodeGen/CodeGenFunction.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index 55464e1b1636b..8cbe2a5407440 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -361,17 +361,18 @@ void CodeGenFunction::FinishFunction(SourceLocation 
EndLoc) {
   bool HasOnlyLifetimeMarkers =
   HasCleanups && EHStack.containsOnlyLifetimeMarkers(PrologueCleanupDepth);
   bool EmitRetDbgLoc = !HasCleanups || HasOnlyLifetimeMarkers;
+
+  std::optional OAL;
   if (HasCleanups) {
 // Make sure the line table doesn't jump back into the body for
 // the ret after it's been at EndLoc.
-std::optional AL;
 if (CGDebugInfo *DI = getDebugInfo()) {
   if (OnlySimpleReturnStmts)
 DI->EmitLocation(Builder, EndLoc);
   else
 // We may not have a valid end location. Try to apply it anyway, and
 // fall back to an artificial location if needed.
-AL = ApplyDebugLocation::CreateDefaultArtificial(*this, EndLoc);
+OAL = ApplyDebugLocation::CreateDefaultArtificial(*this, EndLoc);
 }
 
 PopCleanupBlocks(PrologueCleanupDepth);

diff  --git a/clang/test/CodeGenObjC/objc-arc-ubsan-debugging.m 
b/clang/test/CodeGenObjC/objc-arc-ubsan-debugging.m
new file mode 100644
index 0..531f0fdf9
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc-arc-ubsan-debugging.m
@@ -0,0 +1,14 @@
+// RUN: %clang -x objective-c -target arm64-apple-macos12.0 -fobjc-arc 
-std=gnu99  -O0 -fsanitize=undefined -fsanitize=nullability -c %s -v -g
+
+@interface NSString
+@end
+
+struct A {
+NSString *a;
+};
+
+NSString* _Nonnull foo()
+{
+struct A a;
+return 0;
+}



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


[PATCH] D142144: [RISCV][Driver] Add -mrvv-vector-bits= option similar to -msve-vector-bits=

2023-01-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 491935.
craig.topper added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142144

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/riscv-rvv-vector-bits.c

Index: clang/test/Driver/riscv-rvv-vector-bits.c
===
--- /dev/null
+++ clang/test/Driver/riscv-rvv-vector-bits.c
@@ -0,0 +1,45 @@
+// -
+// Tests for the -msve-vector-bits flag
+// -
+
+// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc_zve64x \
+// RUN:  -mrvv-vector-bits=128 2>&1 | FileCheck --check-prefix=CHECK-128 %s
+// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc_zve64x \
+// RUN:  -mrvv-vector-bits=256 2>&1 | FileCheck --check-prefix=CHECK-256 %s
+// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc_zve64x \
+// RUN:  -mrvv-vector-bits=512 2>&1 | FileCheck --check-prefix=CHECK-512 %s
+// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc_zve64x \
+// RUN:  -mrvv-vector-bits=1024 2>&1 | FileCheck --check-prefix=CHECK-1024 %s
+// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc_zve64x \
+// RUN:  -mrvv-vector-bits=2048 2>&1 | FileCheck --check-prefix=CHECK-2048 %s
+// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc_zve64x \
+// RUN:  -mrvv-vector-bits=scalable 2>&1 | FileCheck --check-prefix=CHECK-SCALABLE %s
+
+// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gcv_zvl256b \
+// RUN:  -mrvv-vector-bits=zvl 2>&1 | FileCheck --check-prefix=CHECK-256 %s
+// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gcv_zvl512b \
+// RUN:  -mrvv-vector-bits=zvl 2>&1 | FileCheck --check-prefix=CHECK-512 %s
+
+// CHECK-128: "-mvscale-max=2" "-mvscale-min=2"
+// CHECK-256: "-mvscale-max=4" "-mvscale-min=4"
+// CHECK-512: "-mvscale-max=8" "-mvscale-min=8"
+// CHECK-1024: "-mvscale-max=16" "-mvscale-min=16"
+// CHECK-2048: "-mvscale-max=32" "-mvscale-min=32"
+
+// CHECK-SCALABLE-NOT: "-mvscale-min=
+// CHECK-SCALABLE-NOT: "-mvscale-max=
+
+// Error out if an unsupported value is passed to -mrvv-vector-bits.
+// -
+// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc_zve64x \
+// RUN:  -mrvv-vector-bits=16 2>&1 | FileCheck --check-prefix=CHECK-BAD-VALUE-ERROR %s
+// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc_zve64x \
+// RUN:  -mrvv-vector-bits=A 2>&1 | FileCheck --check-prefix=CHECK-BAD-VALUE-ERROR %s
+// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc_zve64x \
+// RUN:  -mrvv-vector-bits=131072 2>&1 | FileCheck --check-prefix=CHECK-BAD-VALUE-ERROR %s
+// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc \
+// RUN:  -mrvv-vector-bits=zvl 2>&1 | FileCheck --check-prefix=CHECK-BAD-VALUE-ERROR %s
+// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gcv \
+// RUN:  -mrvv-vector-bits=64 2>&1 | FileCheck --check-prefix=CHECK-BAD-VALUE-ERROR %s
+
+// CHECK-BAD-VALUE-ERROR: error: unsupported argument '{{.*}}' to option '-mrvv-vector-bits='
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -49,11 +49,14 @@
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Compression.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
+#include "llvm/Support/RISCVISAInfo.h"
 #include "llvm/Support/YAMLParser.h"
+#include "llvm/TargetParser/RISCVTargetParser.h"
 #include 
 
 using namespace clang::driver;
@@ -2106,6 +2109,50 @@
 else
   CmdArgs.push_back(A->getValue());
   }
+
+  // Handle -mrvv-vector-bits=
+  if (Arg *A = Args.getLastArg(options::OPT_mrvv_vector_bits_EQ)) {
+StringRef Val = A->getValue();
+const Driver  = getToolChain().getDriver();
+
+// Get minimum VLen from march.
+unsigned MinVLen = 0;
+StringRef Arch = riscv::getRISCVArch(Args, Triple);
+auto ISAInfo = llvm::RISCVISAInfo::parseArchString(
+Arch, /*EnableExperimentalExtensions*/ true);
+if (!ISAInfo) {
+  // Ignore parsing error.
+  consumeError(ISAInfo.takeError());
+} else {
+  MinVLen = (*ISAInfo)->getMinVLen();
+}
+
+// If the value is "zvl", use MinVLen from march. Otherwise, try to parse
+// as integer as long as we have a MinVLen.
+unsigned Bits = 0;
+if (Val.equals("zvl") && MinVLen >= 

[clang] 7532e88 - [Clang] Add missing requires directives for new test

2023-01-24 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-01-24T17:09:18-06:00
New Revision: 7532e88f38a417d3713cb179dc974948c30f0336

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

LOG: [Clang] Add missing requires directives for new test

Summary:
Forgot to add this.

Added: 


Modified: 
clang/test/Driver/linker-wrapper-libs.c

Removed: 




diff  --git a/clang/test/Driver/linker-wrapper-libs.c 
b/clang/test/Driver/linker-wrapper-libs.c
index 3d5a76a23c5c..3f4030d37d1f 100644
--- a/clang/test/Driver/linker-wrapper-libs.c
+++ b/clang/test/Driver/linker-wrapper-libs.c
@@ -1,3 +1,7 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+// REQUIRES: amdgpu-registered-target
+
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.elf.o
 
 #if defined(RESOLVES)



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


[clang] 5d1dc9f - [OpenMP] Do not link the bitcode OpenMP runtime when targeting AMDGPU.

2023-01-24 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-01-24T17:01:37-06:00
New Revision: 5d1dc9fa043f8ee239cbc16347025a4f0831e132

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

LOG: [OpenMP] Do not link the bitcode OpenMP runtime when targeting AMDGPU.

The AMDGPU target can only emit LLVM-IR, so we can always rely on LTO to
link the static version of the runtime optimally. Using the static
library only has a few advantages. Namely, it avoids several known bugs
and allows us to optimize out more functions. This is legal since the
changes in D142486 and D142484

Depends on D142486 D142484

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
clang/test/Driver/amdgpu-openmp-toolchain.c
openmp/libomptarget/test/lit.cfg

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp 
b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
index ceef7b8cc8eee..1a8e4294713c3 100644
--- a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -66,8 +66,6 @@ void AMDGPUOpenMPToolChain::addClangTargetOptions(
   // Link the bitcode library late if we're using device LTO.
   if (getDriver().isUsingLTO(/* IsOffload */ true))
 return;
-
-  addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, GPUArch, getTriple());
 }
 
 llvm::opt::DerivedArgList *AMDGPUOpenMPToolChain::TranslateArgs(

diff  --git a/clang/test/Driver/amdgpu-openmp-toolchain.c 
b/clang/test/Driver/amdgpu-openmp-toolchain.c
index 77ea2a7ec38f1..3fcb3aa94bc0c 100644
--- a/clang/test/Driver/amdgpu-openmp-toolchain.c
+++ b/clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -9,7 +9,7 @@
 
 // verify the tools invocations
 // CHECK: "-cc1" "-triple" 
"x86_64-unknown-linux-gnu"{{.*}}"-emit-llvm-bc"{{.*}}"-x" "c"
-// CHECK: "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" 
"x86_64-unknown-linux-gnu"{{.*}}"-target-cpu" 
"gfx906"{{.*}}"-fcuda-is-device"{{.*}}"-mlink-builtin-bitcode" 
"{{.*}}libomptarget-amdgpu-gfx906.bc"
+// CHECK: "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" 
"x86_64-unknown-linux-gnu"{{.*}}"-target-cpu" 
"gfx906"{{.*}}"-fcuda-is-device"{{.*}}
 // CHECK: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-emit-obj"
 // CHECK: clang-linker-wrapper{{.*}}"--"{{.*}} "-o" "a.out"
 
@@ -30,13 +30,6 @@
 // CHECK-PHASES: 12: assembler, {11}, object, (host-openmp)
 // CHECK-PHASES: 13: clang-linker-wrapper, {12}, image, (host-openmp)
 
-// handling of --libomptarget-amdgpu-bc-path
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp 
-fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa 
-march=gfx803 
--libomptarget-amdgpu-bc-path=%S/Inputs/hip_dev_lib/libomptarget-amdgpu-gfx803.bc
 %s 2>&1 | FileCheck %s --check-prefix=CHECK-LIBOMPTARGET
-// CHECK-LIBOMPTARGET: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" 
"gfx803" "-fcuda-is-device" 
"-mlink-builtin-bitcode"{{.*}}Inputs/hip_dev_lib/libomptarget-amdgpu-gfx803.bc"{{.*}}
-
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp 
-fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa 
-march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOGPULIB
-// CHECK-NOGPULIB-NOT: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" 
"gfx803" "-fcuda-is-device" 
"-mlink-builtin-bitcode"{{.*}}libomptarget-amdgpu-gfx803.bc"{{.*}}
-
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings 
-fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa 
-march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-BINDINGS
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings 
-fopenmp -fopenmp-targets=amdgcn-amd-amdhsa --offload-arch=gfx803 -nogpulib %s 
2>&1 | FileCheck %s --check-prefix=CHECK-BINDINGS
 // CHECK-BINDINGS: "x86_64-unknown-linux-gnu" - "clang", inputs: 
["[[INPUT:.+]]"], output: "[[HOST_BC:.+]]"

diff  --git a/openmp/libomptarget/test/lit.cfg 
b/openmp/libomptarget/test/lit.cfg
index a3e0e25db5aae..a76f5828ae798 100644
--- a/openmp/libomptarget/test/lit.cfg
+++ b/openmp/libomptarget/test/lit.cfg
@@ -115,8 +115,6 @@ else: # Unices
 if config.cuda_libdir:
 config.test_flags += " -Wl,-rpath," + config.cuda_libdir
 if config.libomptarget_current_target.startswith('amdgcn'):
-config.test_flags += " --libomptarget-amdgcn-bc-path=" + 
config.library_dir
-if config.libomptarget_current_target.startswith('nvptx'):
 config.test_flags += " --libomptarget-nvptx-bc-path=" + 
config.library_dir
 if config.libomptarget_current_target.endswith('-LTO'):
 config.test_flags += " -foffload-lto"



___
cfe-commits mailing 

[PATCH] D142491: [OpenMP] Do not link the bitcode OpenMP runtime when targeting AMDGPU.

2023-01-24 Thread Joseph Huber 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 rG5d1dc9fa043f: [OpenMP] Do not link the bitcode OpenMP 
runtime when targeting AMDGPU. (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142491

Files:
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/test/Driver/amdgpu-openmp-toolchain.c
  openmp/libomptarget/test/lit.cfg


Index: openmp/libomptarget/test/lit.cfg
===
--- openmp/libomptarget/test/lit.cfg
+++ openmp/libomptarget/test/lit.cfg
@@ -115,8 +115,6 @@
 if config.cuda_libdir:
 config.test_flags += " -Wl,-rpath," + config.cuda_libdir
 if config.libomptarget_current_target.startswith('amdgcn'):
-config.test_flags += " --libomptarget-amdgcn-bc-path=" + 
config.library_dir
-if config.libomptarget_current_target.startswith('nvptx'):
 config.test_flags += " --libomptarget-nvptx-bc-path=" + 
config.library_dir
 if config.libomptarget_current_target.endswith('-LTO'):
 config.test_flags += " -foffload-lto"
Index: clang/test/Driver/amdgpu-openmp-toolchain.c
===
--- clang/test/Driver/amdgpu-openmp-toolchain.c
+++ clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -9,7 +9,7 @@
 
 // verify the tools invocations
 // CHECK: "-cc1" "-triple" 
"x86_64-unknown-linux-gnu"{{.*}}"-emit-llvm-bc"{{.*}}"-x" "c"
-// CHECK: "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" 
"x86_64-unknown-linux-gnu"{{.*}}"-target-cpu" 
"gfx906"{{.*}}"-fcuda-is-device"{{.*}}"-mlink-builtin-bitcode" 
"{{.*}}libomptarget-amdgpu-gfx906.bc"
+// CHECK: "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" 
"x86_64-unknown-linux-gnu"{{.*}}"-target-cpu" 
"gfx906"{{.*}}"-fcuda-is-device"{{.*}}
 // CHECK: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-emit-obj"
 // CHECK: clang-linker-wrapper{{.*}}"--"{{.*}} "-o" "a.out"
 
@@ -30,13 +30,6 @@
 // CHECK-PHASES: 12: assembler, {11}, object, (host-openmp)
 // CHECK-PHASES: 13: clang-linker-wrapper, {12}, image, (host-openmp)
 
-// handling of --libomptarget-amdgpu-bc-path
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp 
-fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa 
-march=gfx803 
--libomptarget-amdgpu-bc-path=%S/Inputs/hip_dev_lib/libomptarget-amdgpu-gfx803.bc
 %s 2>&1 | FileCheck %s --check-prefix=CHECK-LIBOMPTARGET
-// CHECK-LIBOMPTARGET: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" 
"gfx803" "-fcuda-is-device" 
"-mlink-builtin-bitcode"{{.*}}Inputs/hip_dev_lib/libomptarget-amdgpu-gfx803.bc"{{.*}}
-
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp 
-fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa 
-march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOGPULIB
-// CHECK-NOGPULIB-NOT: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" 
"gfx803" "-fcuda-is-device" 
"-mlink-builtin-bitcode"{{.*}}libomptarget-amdgpu-gfx803.bc"{{.*}}
-
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings 
-fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa 
-march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-BINDINGS
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings 
-fopenmp -fopenmp-targets=amdgcn-amd-amdhsa --offload-arch=gfx803 -nogpulib %s 
2>&1 | FileCheck %s --check-prefix=CHECK-BINDINGS
 // CHECK-BINDINGS: "x86_64-unknown-linux-gnu" - "clang", inputs: 
["[[INPUT:.+]]"], output: "[[HOST_BC:.+]]"
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -66,8 +66,6 @@
   // Link the bitcode library late if we're using device LTO.
   if (getDriver().isUsingLTO(/* IsOffload */ true))
 return;
-
-  addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, GPUArch, getTriple());
 }
 
 llvm::opt::DerivedArgList *AMDGPUOpenMPToolChain::TranslateArgs(


Index: openmp/libomptarget/test/lit.cfg
===
--- openmp/libomptarget/test/lit.cfg
+++ openmp/libomptarget/test/lit.cfg
@@ -115,8 +115,6 @@
 if config.cuda_libdir:
 config.test_flags += " -Wl,-rpath," + config.cuda_libdir
 if config.libomptarget_current_target.startswith('amdgcn'):
-config.test_flags += " --libomptarget-amdgcn-bc-path=" + config.library_dir
-if config.libomptarget_current_target.startswith('nvptx'):
 config.test_flags += " --libomptarget-nvptx-bc-path=" + config.library_dir
 if config.libomptarget_current_target.endswith('-LTO'):
 config.test_flags += " -foffload-lto"
Index: clang/test/Driver/amdgpu-openmp-toolchain.c

[PATCH] D142506: [AMDGCN] Fix device lib test to work with lib64

2023-01-24 Thread Siu Chi Chan via Phabricator via cfe-commits
scchan added a comment.

In D142506#4078402 , @arsenm wrote:

> The resource directory should be strictly controlled. why would lib64 ever be 
> used here?

The intention is to eventually move the device libs into the library directory 
inside clang's resource directory, which its name is affected 
LLVM_LIBDIR_SUFFIX.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142506

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


[PATCH] D142486: [OpenMP] Unconditionally link the OpenMP device RTL static library

2023-01-24 Thread Joseph Huber 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 rGdc60f7aa0435: [OpenMP] Unconditionally link the OpenMP 
device RTL static library (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142486

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/openmp-offload-gpu.c


Index: clang/test/Driver/openmp-offload-gpu.c
===
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -341,6 +341,11 @@
 
 // CHECK-LTO-LIBRARY: {{.*}}-lomptarget{{.*}}-lomptarget.devicertl
 
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp 
--offload-arch=sm_52 \
+// RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-NO-LTO-LIBRARY %s
+
+// CHECK-NO-LTO-LIBRARY: {{.*}}-lomptarget{{.*}}-lomptarget.devicertl
+
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp 
--offload-arch=sm_52 -nogpulib \
 // RUN: -foffload-lto %s 2>&1 | FileCheck --check-prefix=CHECK-NO-LIBRARY 
%s
 
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -873,8 +873,7 @@
   if (IsOffloadingHost)
 CmdArgs.push_back("-lomptarget");
 
-  if (IsOffloadingHost && TC.getDriver().isUsingLTO(/* IsOffload */ true) &&
-  !Args.hasArg(options::OPT_nogpulib))
+  if (IsOffloadingHost && !Args.hasArg(options::OPT_nogpulib))
 CmdArgs.push_back("-lomptarget.devicertl");
 
   addArchSpecificRPath(TC, Args, CmdArgs);


Index: clang/test/Driver/openmp-offload-gpu.c
===
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -341,6 +341,11 @@
 
 // CHECK-LTO-LIBRARY: {{.*}}-lomptarget{{.*}}-lomptarget.devicertl
 
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=sm_52 \
+// RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-NO-LTO-LIBRARY %s
+
+// CHECK-NO-LTO-LIBRARY: {{.*}}-lomptarget{{.*}}-lomptarget.devicertl
+
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=sm_52 -nogpulib \
 // RUN: -foffload-lto %s 2>&1 | FileCheck --check-prefix=CHECK-NO-LIBRARY %s
 
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -873,8 +873,7 @@
   if (IsOffloadingHost)
 CmdArgs.push_back("-lomptarget");
 
-  if (IsOffloadingHost && TC.getDriver().isUsingLTO(/* IsOffload */ true) &&
-  !Args.hasArg(options::OPT_nogpulib))
+  if (IsOffloadingHost && !Args.hasArg(options::OPT_nogpulib))
 CmdArgs.push_back("-lomptarget.devicertl");
 
   addArchSpecificRPath(TC, Args, CmdArgs);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] dc60f7a - [OpenMP] Unconditionally link the OpenMP device RTL static library

2023-01-24 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-01-24T17:01:35-06:00
New Revision: dc60f7aa0435a4e4778cfbf22f4fcb52c97427c0

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

LOG: [OpenMP] Unconditionally link the OpenMP device RTL static library

Currently we have two versions of the static library. One is built as
individual bitcode files and linked via `-mlink-builtin-bitcode`. The
other is built as a single static archive `omptarget.devicertl.a` and is
linked via `-lomptarget.devicertl` and handled by the linker wrapper
during LTO. We use the former in the case that we are not performing
LTO, because linking the library late wouldn't allow us to optimize the
runtime library effectively. The support in D142484 allows us to
unconditionally link this library, so it will only be pulled in if
needed. That is, if we linked already via `-mlink-builtin-bitcode` then
we will not pull in the static library even if it's linked on the
command line.

Depends on D142484

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/openmp-offload-gpu.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 822a60c151ff0..0883631dfe98f 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -873,8 +873,7 @@ bool tools::addOpenMPRuntime(ArgStringList , const 
ToolChain ,
   if (IsOffloadingHost)
 CmdArgs.push_back("-lomptarget");
 
-  if (IsOffloadingHost && TC.getDriver().isUsingLTO(/* IsOffload */ true) &&
-  !Args.hasArg(options::OPT_nogpulib))
+  if (IsOffloadingHost && !Args.hasArg(options::OPT_nogpulib))
 CmdArgs.push_back("-lomptarget.devicertl");
 
   addArchSpecificRPath(TC, Args, CmdArgs);

diff  --git a/clang/test/Driver/openmp-offload-gpu.c 
b/clang/test/Driver/openmp-offload-gpu.c
index b1e1954a93594..da8ebd6ac5624 100644
--- a/clang/test/Driver/openmp-offload-gpu.c
+++ b/clang/test/Driver/openmp-offload-gpu.c
@@ -341,6 +341,11 @@
 
 // CHECK-LTO-LIBRARY: {{.*}}-lomptarget{{.*}}-lomptarget.devicertl
 
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp 
--offload-arch=sm_52 \
+// RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-NO-LTO-LIBRARY %s
+
+// CHECK-NO-LTO-LIBRARY: {{.*}}-lomptarget{{.*}}-lomptarget.devicertl
+
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp 
--offload-arch=sm_52 -nogpulib \
 // RUN: -foffload-lto %s 2>&1 | FileCheck --check-prefix=CHECK-NO-LIBRARY 
%s
 



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


[clang] 1964c33 - [LinkerWrapper] Only import static libraries with needed symbols

2023-01-24 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-01-24T17:01:33-06:00
New Revision: 1964c334782e7c5961772fbdcdcc0029cba3a7fa

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

LOG: [LinkerWrapper] Only import static libraries with needed symbols

Currently, we pull in every single static archive member as long as we
have an offloading architecture that requires it. This goes against the
standard sematnics of static libraries that only pull in symbols that
define currently undefined symbols. In order to support this we roll
some custom symbol resolution logic to check if a static library is
needed. Because of offloading semantics, this requires an extra check
for externally visibile symbols. E.g. if a static member defines a
kernel we should import it.

The main benefit to this is that we can now link against the
`libomptarget.devicertl.a` library unconditionally. This removes the
requirement for users to specify LTO on the link command. This will also
allow us to stop using the `amdgcn` bitcode versions of the libraries.

```
clang foo.c -fopenmp --offload-arch=gfx1030 -foffload-lto -c
clang foo.o -fopenmp --offload-arch=gfx1030 -foffload-lto
```

Reviewed By: tra

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

Added: 
clang/test/Driver/linker-wrapper-libs.c

Modified: 
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Removed: 




diff  --git a/clang/test/Driver/linker-wrapper-libs.c 
b/clang/test/Driver/linker-wrapper-libs.c
new file mode 100644
index 0..3d5a76a23c5c0
--- /dev/null
+++ b/clang/test/Driver/linker-wrapper-libs.c
@@ -0,0 +1,128 @@
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.elf.o
+
+#if defined(RESOLVES)
+int __attribute__((visibility("hidden"))) sym;
+#elif defined(GLOBAL)
+int __attribute__((visibility("protected"))) global;
+#elif defined(WEAK)
+int __attribute__((visibility("hidden"))) weak;
+#elif defined(HIDDEN)
+int __attribute__((visibility("hidden"))) hidden;
+#else
+extern int sym;
+
+extern int __attribute__((weak)) weak;
+
+int foo() { return sym; }
+int bar() { return weak; }
+#endif
+
+//
+// Check that we extract a static library defining an undefined symbol.
+//
+// RUN: %clang -cc1 %s -triple nvptx64-nvidia-cuda -emit-llvm-bc -DRESOLVES -o 
%t.nvptx.resolves.bc
+// RUN: %clang -cc1 %s -triple amdgcn-amd-amdhsa -emit-llvm-bc -DRESOLVES -o 
%t.amdgpu.resolves.bc
+// RUN: clang-offload-packager -o %t-lib.out \
+// RUN:   
--image=file=%t.nvptx.resolves.bc,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
 \
+// RUN:   
--image=file=%t.amdgpu.resolves.bc,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx1030
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t-lib.out
+// RUN: llvm-ar rcs %t.a %t.o
+// RUN: clang-offload-packager -o %t.out \
+// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
+// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx1030
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t.out
+// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
+// RUN:   --linker-path=/usr/bin/ld -- %t.o %t.a -o a.out 2>&1 \
+// RUN: | FileCheck %s --check-prefix=LIBRARY-RESOLVES
+
+// LIBRARY-RESOLVES: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa 
-mcpu=gfx1030 {{.*}}.o {{.*}}.o
+// LIBRARY-RESOLVES: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda 
-march=sm_70 {{.*}}.s {{.*}}.o
+
+//
+// Check that we extract a static library that defines a global visibile to the
+// host.
+//
+// RUN: %clang -cc1 %s -triple nvptx64-nvidia-cuda -emit-llvm-bc -DGLOBAL -o 
%t.nvptx.global.bc
+// RUN: %clang -cc1 %s -triple amdgcn-amd-amdhsa -emit-llvm-bc -DGLOBAL -o 
%t.amdgpu.global.bc
+// RUN: clang-offload-packager -o %t-lib.out \
+// RUN:   
--image=file=%t.nvptx.global.bc,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
 \
+// RUN:   
--image=file=%t.amdgpu.global.bc,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx1030
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t-lib.out
+// RUN: llvm-ar rcs %t.a %t.o
+// RUN: clang-offload-packager -o %t.out \
+// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
+// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx1030
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t.out
+// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
+// RUN:   --linker-path=/usr/bin/ld -- %t.o %t.a -o a.out 2>&1 \
+// RUN: | FileCheck %s --check-prefix=LIBRARY-GLOBAL
+
+// LIBRARY-GLOBAL: clang{{.*}} -o {{.*}}.img 

[PATCH] D142484: [LinkerWrapper] Only import static libraries with needed symbols

2023-01-24 Thread Joseph Huber via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
jhuber6 marked an inline comment as done.
Closed by commit rG1964c334782e: [LinkerWrapper] Only import static libraries 
with needed symbols (authored by jhuber6).

Changed prior to commit:
  https://reviews.llvm.org/D142484?vs=491883=491925#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142484

Files:
  clang/test/Driver/linker-wrapper-libs.c
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -1136,9 +1136,125 @@
   return searchLibraryBaseName(Input, Root, SearchPaths);
 }
 
-/// Search the input files and libraries for embedded device offloading code and
-/// add it to the list of files to be linked. Files coming from static libraries
-/// are only added to the input if they are used by an existing input file.
+/// Common redeclaration of needed symbol flags.
+enum Symbol : uint32_t {
+  Sym_None = 0,
+  Sym_Undefined = 1U << 1,
+  Sym_Weak = 1U << 2,
+};
+
+/// Scan the symbols from a BitcodeFile \p Buffer and record if we need to
+/// extract any symbols from it.
+Expected getSymbolsFromBitcode(MemoryBufferRef Buffer, StringSaver ,
+ DenseMap ) {
+  Expected IRSymtabOrErr = readIRSymtab(Buffer);
+  if (!IRSymtabOrErr)
+return IRSymtabOrErr.takeError();
+
+  bool ShouldExtract = false;
+  for (unsigned I = 0; I != IRSymtabOrErr->Mods.size(); ++I) {
+for (const auto  : IRSymtabOrErr->TheReader.module_symbols(I)) {
+  if (Sym.isFormatSpecific() || !Sym.isGlobal())
+continue;
+
+  bool NewSymbol = Syms.count(Sym.getName()) == 0;
+  auto  = Syms[Saver.save(Sym.getName())];
+
+  // We will extract if it defines a currenlty undefined non-weak symbol.
+  bool ResolvesStrongReference =
+  ((OldSym & Sym_Undefined && !(OldSym & Sym_Weak)) &&
+   !Sym.isUndefined());
+  // We will extract if it defines a new global symbol visible to the host.
+  bool NewGlobalSymbol =
+  ((NewSymbol || (OldSym & Sym_Undefined)) && !Sym.isUndefined() &&
+   !Sym.canBeOmittedFromSymbolTable() &&
+   (Sym.getVisibility() != GlobalValue::HiddenVisibility));
+  ShouldExtract |= ResolvesStrongReference | NewGlobalSymbol;
+
+  // Update this symbol in the "table" with the new information.
+  if (OldSym & Sym_Undefined && !Sym.isUndefined())
+OldSym = static_cast(OldSym & ~Sym_Undefined);
+  if (Sym.isUndefined() && NewSymbol)
+OldSym = static_cast(OldSym | Sym_Undefined);
+  if (Sym.isWeak())
+OldSym = static_cast(OldSym | Sym_Weak);
+}
+  }
+
+  return ShouldExtract;
+}
+
+/// Scan the symbols from an ObjectFile \p Obj and record if we need to extract
+/// any symbols from it.
+Expected getSymbolsFromObject(const ObjectFile , StringSaver ,
+DenseMap ) {
+  bool ShouldExtract = false;
+  for (SymbolRef Sym : Obj.symbols()) {
+auto FlagsOrErr = Sym.getFlags();
+if (!FlagsOrErr)
+  return FlagsOrErr.takeError();
+
+if (!(*FlagsOrErr & SymbolRef::SF_Global) ||
+(*FlagsOrErr & SymbolRef::SF_FormatSpecific))
+  continue;
+
+auto NameOrErr = Sym.getName();
+if (!NameOrErr)
+  return NameOrErr.takeError();
+
+bool NewSymbol = Syms.count(*NameOrErr) == 0;
+auto  = Syms[Saver.save(*NameOrErr)];
+
+// We will extract if it defines a currenlty undefined non-weak symbol.
+bool ResolvesStrongReference = (OldSym & Sym_Undefined) &&
+   !(OldSym & Sym_Weak) &&
+   !(*FlagsOrErr & SymbolRef::SF_Undefined);
+
+// We will extract if it defines a new global symbol visible to the host.
+bool NewGlobalSymbol = ((NewSymbol || (OldSym & Sym_Undefined)) &&
+!(*FlagsOrErr & SymbolRef::SF_Undefined) &&
+!(*FlagsOrErr & SymbolRef::SF_Hidden));
+ShouldExtract |= ResolvesStrongReference | NewGlobalSymbol;
+
+// Update this symbol in the "table" with the new information.
+if (OldSym & Sym_Undefined && !(*FlagsOrErr & SymbolRef::SF_Undefined))
+  OldSym = static_cast(OldSym & ~Sym_Undefined);
+if (*FlagsOrErr & SymbolRef::SF_Undefined && NewSymbol)
+  OldSym = static_cast(OldSym | Sym_Undefined);
+if (*FlagsOrErr & SymbolRef::SF_Weak)
+  OldSym = static_cast(OldSym | Sym_Weak);
+  }
+  return ShouldExtract;
+}
+
+/// Attempt to 'resolve' symbols found in input files. We use this to
+/// determine if an archive member needs to be extracted. An archive member
+/// will be extracted 

[PATCH] D118493: Set rpath on openmp executables

2023-01-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D118493#4075970 , @JonChesterfield 
wrote:

> That works if you have one toolchain installed globally or you are happy to 
> cobble together a working system using environment variables. If you have 
> multiple toolchains, they can't all sit in the global directory. If you don't 
> have root, you can't install them there.
>
> Previously we required people to set LD_LIBRARY_PATH to use openmp at all. 
> That's an inherently poor UX and interacted especially poorly with module 
> setup systems found in HPC.
>
> We could make this opt-in, at the cost of new users seeing that openmp just 
> doesn't work out of the box and other ones having to modify build scripts. In 
> exchange we get - consistency with other tools that fail to work without 
> global installation or extra user burden.

Well, if you have a toolchain at a non-standard location (I do this a lot 
myself), you can go an extra mile by specifying `-Wl,-rpath=... in a Clang 
configuration file.
Gentoo has a nice summary of the feature 
https://blogs.gentoo.org/mgorny/2022/10/07/clang-in-gentoo-now-sets-default-runtimes-via-config-file/
libc++, libc++abi, libunwind, and compiler-rt don't add the extra DT_RUNPATH. 
Some build systems want to handle DT_RUNPATH themselves (e.g. 
`CMAKE_INSTALL_RPATH`).
I don't think it is a good idea for openmp to diverge and introduce an opt-out 
`-fno-openmp-implicit-rpath`.

> In my opinion dynamically linking language runtimes is a bad default. It wins 
> us an awful lot of failure modes. I've also argued against being able to swap 
> out individual components via environment variables as way too error prone 
> for a user facing interface. This is what the community consensus went for. 
> The combination of dynamically substitutable and requiring LD_LIBRARY_PATH 
> was especially sharp.

Well, some distributions have policies against DT_RUNPATH and this change is 
causing trouble. While a patch like D142174  
can mitigate the problem, the hard-coded paths are ugly and may not work for 
another Linux distribution or another ELF-based operating system.

You don't necessarily use `LD_LIBRARY_PATH`. You can use `-Wl,-rpath=...`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118493

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


[PATCH] D141414: [clang] add warning on shifting boolean type

2023-01-24 Thread Angelo Matni via Phabricator via cfe-commits
angelomatnigoogle updated this revision to Diff 491923.
angelomatnigoogle added a comment.

Consolidated shift-bool warning; fixed relevant unit tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141414

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/Interp/shifts.cpp
  clang/test/Analysis/svalbuilder-simplify-no-crash.c
  clang/test/CXX/over/over.built/p18.cpp
  clang/test/Sema/warn-shift-bool.cpp


Index: clang/test/Sema/warn-shift-bool.cpp
===
--- /dev/null
+++ clang/test/Sema/warn-shift-bool.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int f(int x) {
+  const bool b = 1;
+  const bool c = b << x; // expected-warning {{left shifting 'bool' will 
implicitly cast to 'int'; consider 'bool && (shift_count | desired_type_width - 
1)' to avoid implicitly relying on the width of 'int'}}
+  const bool d = b >> x; // expected-warning {{right shifting 'bool' will 
implicitly cast to 'int'; consider 'bool & !shift_count' to avoid implicitly 
relying on the width of 'int'}}
+  return 0;
+}
Index: clang/test/CXX/over/over.built/p18.cpp
===
--- clang/test/CXX/over/over.built/p18.cpp
+++ clang/test/CXX/over/over.built/p18.cpp
@@ -56,7 +56,7 @@
 
   (void)(i << 3);
   (void)(f << 3);  // expected-error {{invalid operands}}
-  (void)(b << 3);
+  (void)(b << 3);  // expected-warning {{left shifting 'bool' will implicitly 
cast to 'int'; consider 'bool && (shift_count | desired_type_width - 1)' to 
avoid implicitly relying on the width of 'int'}}
   (void)(pi << 3); // expected-error {{invalid operands}}
   (void)(pt << 3); // FIXME
   (void)(t << 3);
@@ -69,7 +69,7 @@
 
   (void)(i >> 3);
   (void)(f >> 3);  // expected-error {{invalid operands}}
-  (void)(b >> 3);
+  (void)(b >> 3);  // expected-warning {{right shifting 'bool' will implicitly 
cast to 'int'; consider 'bool & !shift_count' to avoid implicitly relying on 
the width of 'int'}}
   (void)(pi >> 3); // expected-error {{invalid operands}}
   (void)(pt >> 3); // FIXME
   (void)(t >> 3);
Index: clang/test/Analysis/svalbuilder-simplify-no-crash.c
===
--- clang/test/Analysis/svalbuilder-simplify-no-crash.c
+++ clang/test/Analysis/svalbuilder-simplify-no-crash.c
@@ -9,5 +9,6 @@
 void crashing(long a, _Bool b) {
   (void)(a & 1 && 0);
   b = a & 1;
-  (void)(b << 1); // expected-warning{{core.UndefinedBinaryOperatorResult}}
+  (void)(b << 1); // expected-warning{{core.UndefinedBinaryOperatorResult}} \
+  // expected-warning {{left shifting 'bool' will implicitly 
cast to 'int'; consider 'bool && (shift_count | desired_type_width - 1)' to 
avoid implicitly relying on the width of 'int'}}
 }
Index: clang/test/AST/Interp/shifts.cpp
===
--- clang/test/AST/Interp/shifts.cpp
+++ clang/test/AST/Interp/shifts.cpp
@@ -109,7 +109,13 @@
   static_assert(m == 1, "");
   constexpr unsigned char c = 0 << 8;
   static_assert(c == 0, "");
-  static_assert(true << 1, "");
+
+  constexpr unsigned b = true << 1; // expected-warning {{left shifting 'bool' 
will implicitly cast to 'int'; consider 'bool && (shift_count | 
desired_type_width - 1)' to avoid implicitly relying on the width of 'int'}} \
+// cxx17-warning {{left shifting 'bool' 
will implicitly cast to 'int'; consider 'bool && (shift_count | 
desired_type_width - 1)' to avoid implicitly relying on the width of 'int'}} \
+// ref-warning {{left shifting 'bool' will 
implicitly cast to 'int'; consider 'bool && (shift_count | desired_type_width - 
1)' to avoid implicitly relying on the width of 'int'}} \
+// ref-cxx17-warning {{left shifting 
'bool' will implicitly cast to 'int'; consider 'bool && (shift_count | 
desired_type_width - 1)' to avoid implicitly relying on the width of 'int'}}
+  static_assert(b, ""); 
+
   static_assert(1 << (__INT_WIDTH__ +1) == 0, "");  // expected-error {{not an 
integral constant expression}} \
 // expected-note {{>= 
width of type 'int'}} \
 // cxx17-error {{not an 
integral constant expression}} \
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -11950,6 +11950,10 @@
   SourceLocation Loc, BinaryOperatorKind Opc,
   bool IsCompAssign) {
   checkArithmeticNull(*this, LHS, RHS, Loc, /*IsCompare=*/false);
+  if (LHS.get()->IgnoreParenImpCasts()->getType()->isBooleanType())

[PATCH] D141959: [clang-format] Fix inconsistent identification of operator

2023-01-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

There is part of me that feels we should not rush this in to get it into 16 
(which was due to branch today), I feel it might be a good idea to commit this 
after branching, and let it live in 'main' so we can take for a real test drive


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

https://reviews.llvm.org/D141959

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


[PATCH] D140250: Define NULL in its own header

2023-01-24 Thread Ian Anderson via Phabricator via cfe-commits
iana added inline comments.



Comment at: 
llvm/test/DebugInfo/Generic/assignment-tracking/sroa/unspecified-var-size.ll:37
 !7 = !DIFile(filename: "clang/12.0.0/include/__stddef_max_align_t.h", 
directory: "/")
-!8 = !DICompositeType(tag: DW_TAG_structure_type, file: !7, line: 19, size: 
256, flags: DIFlagFwdDecl, identifier: "_ZTS11max_align_t")
-!9 = !DIFile(filename: "include/c++/7.5.0/cstddef", directory: "")
-!10 = !{i32 7, !"Dwarf Version", i32 4}
-!11 = !{i32 2, !"Debug Info Version", i32 3}
-!12 = !{i32 1, !"wchar_size", i32 4}
-!13 = !{!"clang version 12.0.0"}
-!14 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funDn", scope: !1, 
file: !1, line: 20, type: !15, scopeLine: 20, flags: DIFlagPrototyped | 
DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: 
!0, retainedNodes: !20)
-!15 = !DISubroutineType(types: !16)
-!16 = !{null, !17}
-!17 = !DIDerivedType(tag: DW_TAG_typedef, name: "nullptr_t", scope: !5, file: 
!18, line: 235, baseType: !19)
-!18 = !DIFile(filename: "include/x86_64-linux-gnu/c++/7.5.0/bits/c++config.h", 
directory: "")
-!19 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)")
-!20 = !{!21}
-!21 = !DILocalVariable(arg: 1, scope: !14, file: !1, line: 20, type: !17)
-!22 = distinct !DIAssignID()
-!23 = !DILocation(line: 0, scope: !14)
-!28 = distinct !DIAssignID()
-!29 = !DILocation(line: 20, column: 27, scope: !14)
+!8 = !DIFile(filename: "clang/12.0.0/include/__stddef_null.h", directory: "/")
+!9 = !DICompositeType(tag: DW_TAG_structure_type, file: !7, line: 19, size: 
256, flags: DIFlagFwdDecl, identifier: "_ZTS11max_align_t")

dblaikie wrote:
> aaron.ballman wrote:
> > iana wrote:
> > > Adding this line is the only reason I changed this file. I'm not familiar 
> > > at all with how these tests work, so I don't really know if it's 
> > > necessary. The test passes with and without these changes.
> > CC @dblaikie and @echristo for questions about whether we should be 
> > updating this debug info test or not.
> Don't think there's any reason/need to - what motivated changing this file?
I found it when I was checking for places that handled `__stddef_max_align_t.h` 
specially. I'm not sure if that's in here to check `_ZTS11max_align_t` under 
it, or if it's just there because stddef.h includes it. __stddef_null.h doesn't 
define any types like that, so maybe it's fine to just revert this file?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140250

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


[PATCH] D142486: [OpenMP] Unconditionally link the OpenMP device RTL static library

2023-01-24 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142486

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


[PATCH] D142354: [analyzer] Create a stub for an std::variant checker

2023-01-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Interesting, what specific goals do you have here? Are you planning to find 
specific bugs (eg. force-unwrap to a wrong type) or just to model the 
semantics? In the latter case, have you explored the possibility of 
force-inlining the class instead, like I suggested in the thread? Have you 
found a reasonable amount of code that uses `std::variant`, to test your 
checker on?




Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:312
+
 } // end "alpha.core"
 

Maybe `alpha.cplusplus`?


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

https://reviews.llvm.org/D142354

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


[PATCH] D142484: [LinkerWrapper] Only import static libraries with needed symbols

2023-01-24 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

> I'm somewhat hoping to get this in before the fork that happens in a few 
> hours.

OK. We can fix it later if it turns out that we've missed something.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142484

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


[PATCH] D139737: [-Wunsafe-buffer-usage] Initiate Fix-it generation for local variable declarations

2023-01-24 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 491917.
ziqingluo-90 added a comment.

Addressed the minor comments


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

https://reviews.llvm.org/D139737

Files:
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
@@ -0,0 +1,96 @@
+// RUN: cp %s %t.cpp
+// RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -fixit %t.cpp
+// RUN: grep -v CHECK %t.cpp | FileCheck %s
+typedef int * Int_ptr_t;
+typedef int Int_t;
+
+void local_array_subscript_simple() {
+  int tmp;
+// CHECK: std::span p {new int[10], 10};
+// CHECK: std::span q {new int[10], 10};
+// CHECK: tmp = p[5];
+// CHECK: tmp = q[5];
+  int *p = new int[10];
+  const int *q = new int[10];
+  tmp = p[5];
+  tmp = q[5];
+
+// CHECK: std::span x {new int[10], 10};
+// CHECK: std::span y {new int, 1};
+// CHECK: std::span z {new int[10], 10};
+// CHECK: std::span w {new Int_t[10], 10};
+
+  Int_ptr_t x = new int[10];
+  Int_ptr_t y = new int;
+  Int_t * z = new int[10];
+  Int_t * w = new Int_t[10];
+
+  // CHECK: tmp = x[5];
+  tmp = x[5];
+  // CHECK: tmp = y[5];
+  tmp = y[5]; // y[5] will crash after being span
+  // CHECK: tmp = z[5];
+  tmp = z[5];
+  // CHECK: tmp = w[5];
+  tmp = w[5];
+}
+
+void local_array_subscript_auto() {
+  int tmp;
+// CHECK: std::span p {new int[10], 10};
+// CHECK: tmp = p[5];
+  auto p = new int[10];
+  tmp = p[5];
+}
+
+void local_array_subscript_variable_extent() {
+  int n = 10;
+  int tmp;
+
+  // CHECK: std::span p {new int[n], n};
+  // CHECK: std::span q {new int[n++], <# placeholder #>};
+  // CHECK: tmp = p[5];
+  // CHECK: tmp = q[5];
+  int *p = new int[n];
+  // If the extent expression does not have a constant value, we cannot fill the extent for users...
+  int *q = new int[n++];
+  tmp = p[5];
+  tmp = q[5];
+}
+
+
+void local_ptr_to_array() {
+  int tmp;
+  int n = 10;
+  int a[10];
+  int b[n];  // If the extent expression does not have a constant value, we cannot fill the extent for users...
+  // CHECK: std::span p {a, 10};
+  // CHECK: std::span q {b, <# placeholder #>};
+  // CHECK: tmp = p[5];
+  // CHECK: tmp = q[5];
+  int *p = a;
+  int *q = b;
+  tmp = p[5];
+  tmp = q[5];
+}
+
+void local_ptr_addrof_init() {
+  int var;
+// CHECK: std::span q {, 1};
+// CHECK: var = q[5];
+  int * q = 
+  // This expression involves unsafe buffer accesses, which will crash
+  // at runtime after applying the fix-it,
+  var = q[5];
+}
+
+void decl_without_init() {
+  int tmp;
+  // CHECK: std::span p;
+  int * p;
+  // CHECK: std::span q;
+  Int_ptr_t q;
+
+  tmp = p[5];
+  tmp = q[5];
+}
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -9,6 +9,7 @@
 #include "clang/Analysis/Analyses/UnsafeBufferUsage.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
 #include "llvm/ADT/SmallVector.h"
 #include 
 #include 
@@ -115,6 +116,21 @@
   MatchDescendantVisitor Visitor(, Finder, Builder, ASTMatchFinder::BK_All);  
   return Visitor.findMatch(DynTypedNode::create(Node));
 }
+
+AST_MATCHER_P(CastExpr, castSubExpr, internal::Matcher, innerMatcher) {
+  return innerMatcher.matches(*Node.getSubExpr(), Finder, Builder);
+}
+
+// Returns a matcher that matches any expression 'e' such that `innerMatcher`
+// matches 'e' and 'e' is in an Unspecified Lvalue Context.
+static auto isInUnspecifiedLvalueContext(internal::Matcher innerMatcher) {
+  auto isLvalueToRvalueCast = [](internal::Matcher M) {
+return implicitCastExpr(hasCastKind(CastKind::CK_LValueToRValue),
+castSubExpr(M));
+  };
+  //FIXME: add assignmentTo context...
+  return isLvalueToRvalueCast(innerMatcher);
+}
 } // namespace clang::ast_matchers
 
 namespace {
@@ -282,7 +298,7 @@
 /// Array subscript expressions on raw pointers as if they're arrays. Unsafe as
 /// it doesn't have any bounds checks for the array.
 class ArraySubscriptGadget : public WarningGadget {
-  static constexpr const char *const ArraySubscrTag = "arraySubscr";
+  static constexpr const char *const ArraySubscrTag = "ArraySubscript";
   const ArraySubscriptExpr *ASE;
 
 public:
@@ -366,6 +382,47 @@
   // FIXME: pointer adding zero should be fine
   //FIXME: this gadge will need a fix-it
 };
+
+// Represents expressions of the form `DRE[*]` in the Unspecified Lvalue
+// Context (see `isInUnspecifiedLvalueContext`).
+// Note here `[]` is the built-in subscript 

[PATCH] D142484: [LinkerWrapper] Only import static libraries with needed symbols

2023-01-24 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 marked an inline comment as done.
jhuber6 added a comment.

In D142484#4078377 , @tra wrote:

> LGTM. Please wait a bit before landing it, in case @MaskRay has something to 
> say.

I'm somewhat hoping to get this in before the fork that happens in a few hours.




Comment at: clang/test/Driver/linker-wrapper-libs.c:38-39
+
+// LIBRARY-RESOLVES: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa 
-mcpu=gfx1030 {{.*}}.o {{.*}}.o
+// LIBRARY-RESOLVES: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda 
-march=sm_70 {{.*}}.s {{.*}}.o
+

tra wrote:
> I'm puzzled about how exactly we're checking the `that we extract a static 
> library defining an undefined symbol` part here.
> 
> Presumably the trailing .o would be the object extracted from the library. 
> I'm not sure where the first .o/.s argument come from? Is that the 'main' GPU 
> object/executable embedded in the host object?
> 
Yes, if we extract it we'll have two object files. The `.s` comes from the fact 
that I deliberately made the main binary an ELF while the library is a `.bc`. 
This is why we get a `.s` for Nvidia, it's PTX.



Comment at: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:1213
+
+// We will extract if it defines a new global symbol visible to the host.
+bool NewGlobalSymbol = ((NewSymbol || (OldSym & Sym_Undefined)) &&

tra wrote:
> Nit: perhaps we should rename `Resolved` -> `ShouldExtractObject`, it would 
> be a better match. After all, defining/including a new symbol is not quite 
> the same as resolving a reference.
Good point, I'll change it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142484

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


[PATCH] D142491: [OpenMP] Do not link the bitcode OpenMP runtime when targeting AMDGPU.

2023-01-24 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D142491#4078400 , @arsenm wrote:

> Well the library still doesn't 100% work unless using -mlink-builtin-bitcode. 
> It's taking forever to make progress on fixing that

This is the OpenMP DeviceRTL, the AMD one is still shoved into each TU via 
`-mlink-builtin-bitcode`. I'm still interested in addressing that however, my 
ultimate desire is for linking on the device to be sane and match the host 
pretty closely.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142491

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


[PATCH] D142506: [AMDGCN] Fix device lib test to work with lib64

2023-01-24 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

The resource directory should be strictly controlled. why would lib64 ever be 
used here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142506

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


[PATCH] D142491: [OpenMP] Do not link the bitcode OpenMP runtime when targeting AMDGPU.

2023-01-24 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

Well the library still doesn't 100% work unless using -mlink-builtin-bitcode. 
It's taking forever to make progress on fixing that


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142491

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


[PATCH] D142506: [AMDGCN] Fix device lib test to work with lib64

2023-01-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142506

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


[PATCH] D142506: [AMDGCN] Fix device lib test to work with lib64

2023-01-24 Thread Siu Chi Chan via Phabricator via cfe-commits
scchan created this revision.
scchan added reviewers: yaxunl, mgorny.
Herald added subscribers: kosarev, jvesely.
Herald added a project: All.
scchan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change fixes an issue introduced by
https://reviews.llvm.org/D140315.  A new unit test was added to validate
the search for the device libraries being placed in Clang's resource
directory; however, the test didn't take into account that certain
platforms use lib64 for 64-bit library directory.

Change-Id: I8b2ae01899214aef63f4e593c3a509dbf54582ef


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142506

Files:
  clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/asanrtl.bc
  clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/hip.bc
  clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/ockl.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/oclc_abi_version_400.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/oclc_abi_version_500.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/oclc_daz_opt_off.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/oclc_daz_opt_on.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/oclc_finite_only_off.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/oclc_finite_only_on.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/oclc_isa_version_1010.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/oclc_isa_version_1011.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/oclc_isa_version_1012.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/oclc_isa_version_803.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/oclc_isa_version_900.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/oclc_isa_version_908.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/oclc_unsafe_math_off.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/oclc_unsafe_math_on.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/oclc_wavefrontsize64_off.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/oclc_wavefrontsize64_on.bc
  clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/ocml.bc
  clang/test/Driver/Inputs/rocm_resource_dir/lib64/amdgcn/bitcode/opencl.bc
  clang/test/Driver/hip-device-libs.hip


Index: clang/test/Driver/hip-device-libs.hip
===
--- clang/test/Driver/hip-device-libs.hip
+++ clang/test/Driver/hip-device-libs.hip
@@ -203,7 +203,7 @@
 // ALL-NOT: error:
 // ALL: {{"[^"]*clang[^"]*"}}
 
-// RESDIR-SAME: "-mlink-builtin-bitcode" 
"[[DEVICELIB_DIR:[^"]+(/|)rocm_resource_dir(/|)lib(/|)amdgcn(/|).*]]hip.bc"
+// RESDIR-SAME: "-mlink-builtin-bitcode" 
"[[DEVICELIB_DIR:[^"]+(/|)rocm_resource_dir(/|)lib(64)?(/|)amdgcn(/|).*]]hip.bc"
 // ROCMDIR-SAME: "-mlink-builtin-bitcode" 
"[[DEVICELIB_DIR:[^"]+(/|)rocm(/|)amdgcn(/|).*]]hip.bc"
 
 // ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]ocml.bc"


Index: clang/test/Driver/hip-device-libs.hip
===
--- clang/test/Driver/hip-device-libs.hip
+++ clang/test/Driver/hip-device-libs.hip
@@ -203,7 +203,7 @@
 // ALL-NOT: error:
 // ALL: {{"[^"]*clang[^"]*"}}
 
-// RESDIR-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR:[^"]+(/|)rocm_resource_dir(/|)lib(/|)amdgcn(/|).*]]hip.bc"
+// RESDIR-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR:[^"]+(/|)rocm_resource_dir(/|)lib(64)?(/|)amdgcn(/|).*]]hip.bc"
 // ROCMDIR-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR:[^"]+(/|)rocm(/|)amdgcn(/|).*]]hip.bc"
 
 // ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]ocml.bc"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142484: [LinkerWrapper] Only import static libraries with needed symbols

2023-01-24 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM. Please wait a bit before landing it, in case @MaskRay has something to 
say.




Comment at: clang/test/Driver/linker-wrapper-libs.c:38-39
+
+// LIBRARY-RESOLVES: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa 
-mcpu=gfx1030 {{.*}}.o {{.*}}.o
+// LIBRARY-RESOLVES: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda 
-march=sm_70 {{.*}}.s {{.*}}.o
+

I'm puzzled about how exactly we're checking the `that we extract a static 
library defining an undefined symbol` part here.

Presumably the trailing .o would be the object extracted from the library. I'm 
not sure where the first .o/.s argument come from? Is that the 'main' GPU 
object/executable embedded in the host object?




Comment at: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:1213
+
+// We will extract if it defines a new global symbol visible to the host.
+bool NewGlobalSymbol = ((NewSymbol || (OldSym & Sym_Undefined)) &&

Nit: perhaps we should rename `Resolved` -> `ShouldExtractObject`, it would be 
a better match. After all, defining/including a new symbol is not quite the 
same as resolving a reference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142484

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


[PATCH] D135495: [clang-tidy] handle pointers in `ExceptionAnalyzer`

2023-01-24 Thread Domján Dániel via Phabricator via cfe-commits
isuckatcs added a comment.

> E.g., instead of asserting true/false, checking if the assignment would 
> compile.

This is actually biased. If the result of the compilation is different from the 
result we get from this function, it can also mean a bug in the compiler.

Take a look at this example on godbolt . The 
snippet here is only valid from C++20, but GCC compiles it even in C++17.




Comment at: clang/include/clang/AST/ASTContext.h:2828
 
+  static bool isQualificationConvertiblePointer(QualType From, QualType To,
+LangOptions LangOpts,

erichkeane wrote:
> Please document what this is doing...
This was actually documented, but at the definition. My bad.



Comment at: clang/include/clang/AST/ASTContext.h:2829
+  static bool isQualificationConvertiblePointer(QualType From, QualType To,
+LangOptions LangOpts,
+unsigned CurrentLevel = 0,

erichkeane wrote:
> Why is this static if you need lang-opts?  This should be retrieved by the 
> ASTContext itself.
By taking the language options externally, we might be able to produce more 
descriptive warning messages in the future. 
E.g.: `This conversion is only valid from C++20`, etc.

Also calling this function doesn't depend on `ASTContext` any other way, so it 
can be called even if we don't have access to the `ASTContext` for some reason.

I don't know however if it makes sense to worry about these uses at all.




Comment at: clang/include/clang/AST/ASTContext.h:2831
+unsigned CurrentLevel = 0,
+bool IsToConstSoFar = false);
+

erichkeane wrote:
> What does this name mean here?  It isn't clear to me.
This is documented at the use site of this variable. I couldn't come up with a 
better name for it.
```lang=c++
  // If at the current level To is more cv-qualified than From [...],
  // then there must be a 'const' at every single level (other than level zero)
  // of To up until the current level
  bool MoreCVQualified =
  To.getQualifiers().isStrictSupersetOf(From.getQualifiers());
  if (MoreCVQualified)
Convertible &= IsToConstSoFar;
```



Comment at: clang/include/clang/AST/Type.h:7364
+  else if (isArrayType())
+return getAsArrayTypeUnsafe()->getElementType();
+

erichkeane wrote:
> This changes the meaning here, and this is a commonly used thing.  Why are 
> you doing this?
I missed that it changes the meaning. Though I need this use case, so I 
reverted these changes and created a static global function instead.



Comment at: clang/lib/AST/ASTContext.cpp:13465
+//
+// The function should only be called in C++ mode.
+bool ASTContext::isQualificationConvertiblePointer(QualType From, QualType To,

erichkeane wrote:
> Perhaps this should be asserted on!
I personally don't want to assert it, as it won't crash in C mode, it's just 
the fact that some rules here are different in C.
E.g.  (from [[ 
https://en.cppreference.com/w/cpp/language/implicit_conversion#Qualification_conversions
 | cppreference ]]):
```lang=c++
char** p = 0;
const char* const * p2 = p; // error in C, OK in C++
```

(The example above is checked properly but I didn't dig deeper into the other C 
rules, that's why I said that it shouldn't be called)



Comment at: clang/lib/AST/ASTContext.cpp:13466
+// The function should only be called in C++ mode.
+bool ASTContext::isQualificationConvertiblePointer(QualType From, QualType To,
+   LangOptions LangOpts,

erichkeane wrote:
> I find myself shocked we don't have something like this already, but what do 
> we mean by 'qualification convertible'?  Is that a term of art I'm missing?
> 
> 
I didn't come up with this name. It is what this conversion is called by the 
standard.

It is §7.3.5 in [[ 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/n4849.pdf | N4849 ]] 
and you can also find it under the same name on [[ 
https://en.cppreference.com/w/cpp/language/implicit_conversion#Qualification_conversions
 | cppreference ]].





Comment at: clang/lib/AST/ASTContext.cpp:13485
+
+if (!To->isPointerType() ||
+!(From->canDecayToPointerType() || From->isPointerType()))

erichkeane wrote:
> I would expect at least the 'to' here to assert as well.  Passing a 'not 
> pointer' as the 'two' when youre testing 'convertible pointer' is odd and a 
> mistake?
Well, technically `MemberPointerType` is also accepted and it's not derived 
from `PointerType`. Though I added an assertion here, but I left the check so 
that we don't crash in release mode.



Comment at: 

[PATCH] D135495: [clang-tidy] handle pointers in `ExceptionAnalyzer`

2023-01-24 Thread Domján Dániel via Phabricator via cfe-commits
isuckatcs updated this revision to Diff 491910.
isuckatcs marked 9 inline comments as done.
isuckatcs added a comment.

Addressed comments
Updated tests


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

https://reviews.llvm.org/D135495

Files:
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/AST/PointerConversionTest.cpp

Index: clang/unittests/AST/PointerConversionTest.cpp
===
--- /dev/null
+++ clang/unittests/AST/PointerConversionTest.cpp
@@ -0,0 +1,285 @@
+//===- unittests/AST/PointerConversionTest.cpp - Pointer conversion tests -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains tests for ASTContext::isQualificationConvertiblePointer(),
+// which checks if one pointer can be converted to the other.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/Tooling.h"
+#include "clang/Frontend/FrontendActions.h"
+
+namespace clang {
+
+auto DeclMatcher = ast_matchers::declaratorDecl(ast_matchers::unless(ast_matchers::parmVarDecl())).bind("id");
+
+class TypeExtractor : public ast_matchers::MatchFinder::MatchCallback {
+  int MatchCount = 0;
+
+public:
+  QualType T1, T2;
+
+  void run(const ast_matchers::MatchFinder::MatchResult ) override {
+if (const auto *VD = Result.Nodes.getNodeAs("id")) {
+  if (MatchCount == 0)
+T1 = VD->getType();
+  else {
+assert(VD->hasInit() && "Second declaration must be initialized because of compiler error messages.");
+T2 = VD->getType();
+  }
+
+  ++MatchCount;
+} else if (const auto *FD =
+   Result.Nodes.getNodeAs("id")) {
+  if (MatchCount == 0)
+T1 = FD->getType();
+  else
+T2 = FD->getType();
+
+  ++MatchCount;
+}
+  }
+};
+
+void prepareArgAndLangOptionsFromStd(LangStandard Std, std::string , LangOptions ) {
+  Arg = "-std=";
+  Arg += Std.getName();
+
+  std::vector Tmp;
+  LangOptions::setLangDefaults(Opts, Std.Language, {}, Tmp,
+   Std.getLangKind(Std.getName()));
+}
+
+bool CheckIfCompiles(llvm::StringRef Source, LangStandard Std) {
+  std::string StdArg;
+  LangOptions Opts;
+  prepareArgAndLangOptionsFromStd(Std, StdArg, Opts);
+
+  return tooling::runToolOnCodeWithArgs(tooling::newFrontendActionFactory().get()->create(), Source, {StdArg});
+}
+
+bool CheckConvertible(llvm::StringRef Source, LangStandard Std) {
+  TypeExtractor Extractor;
+  ast_matchers::MatchFinder Finder;
+
+  Finder.addMatcher(DeclMatcher, );
+  std::unique_ptr Factory(
+  tooling::newFrontendActionFactory());
+
+  std::string StdArg;
+  LangOptions Opts;
+  prepareArgAndLangOptionsFromStd(Std, StdArg, Opts);
+
+  tooling::runToolOnCodeWithArgs(Factory->create(), Source, {StdArg});
+
+  return ASTContext::isQualificationConvertiblePointer(Extractor.T1,
+   Extractor.T2, Opts);
+}
+
+#define TEST_CONVERSION(ASSERTION, SNIPPET, LANG) { const char* Snippet = SNIPPET; \
+  ASSERTION(CheckConvertible(Snippet, LANG));  \
+  ASSERTION(CheckIfCompiles(Snippet, LANG)); }
+
+const LangStandard & StdCXX98 = LangStandard::getLangStandardForKind(LangStandard::lang_cxx98);
+const LangStandard & StdCXX17 = LangStandard::getLangStandardForKind(LangStandard::lang_cxx17);
+const LangStandard & StdCXX20 = LangStandard::getLangStandardForKind(LangStandard::lang_cxx20);
+const LangStandard & StdCXX2b = LangStandard::getLangStandardForKind(LangStandard::lang_cxx2b);
+
+
+TEST(QualificationConversion, builtin) {
+  TEST_CONVERSION(ASSERT_FALSE, R"cpp(char **p; const char **p1 = p;)cpp", StdCXX98);
+}
+
+TEST(QualificationConversion, builtin2) {
+  TEST_CONVERSION(ASSERT_TRUE, R"cpp(char **p; const char* const * p2 = p;)cpp", StdCXX98);
+}
+
+TEST(QualificationConversion, builtin3) {
+  TEST_CONVERSION(ASSERT_TRUE, R"cpp(char **p; volatile char * const * p3 = p;)cpp", StdCXX98);
+}
+
+TEST(QualificationConversion, builtin4) {
+  TEST_CONVERSION(ASSERT_TRUE, R"cpp(char **p; volatile const char* const* p4 = p;)cpp", StdCXX98);
+}
+
+TEST(QualificationConversion, builtin5) {
+  TEST_CONVERSION(ASSERT_TRUE, R"cpp(double *a[2][3]; double const * const (*ap)[3] = a;)cpp", StdCXX98);
+}
+

[PATCH] D142396: [AArch64] Add the Ampere1A core

2023-01-24 Thread Philipp Tomsich 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 rGfb0af89193a9: [AArch64] Add the Ampere1A core (authored by 
philipp.tomsich).

Changed prior to commit:
  https://reviews.llvm.org/D142396?vs=491840=491900#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142396

Files:
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/include/llvm/TargetParser/AArch64TargetParser.h
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/TargetParser/Host.cpp
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/neon-dot-product.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/AArch64/armv8.3a-rcpc.s
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/unittests/TargetParser/Host.cpp
  llvm/unittests/TargetParser/TargetParserTest.cpp

Index: llvm/unittests/TargetParser/TargetParserTest.cpp
===
--- llvm/unittests/TargetParser/TargetParserTest.cpp
+++ llvm/unittests/TargetParser/TargetParserTest.cpp
@@ -1339,6 +1339,16 @@
 AArch64::AEK_AES | AArch64::AEK_I8MM | AArch64::AEK_SSBS |
 AArch64::AEK_SB | AArch64::AEK_RAND,
 "8.6-A"),
+ARMCPUTestParams(
+"ampere1a", "armv8.6-a", "crypto-neon-fp-armv8",
+AArch64::AEK_CRC | AArch64::AEK_FP | AArch64::AEK_FP16 |
+AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE |
+AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
+AArch64::AEK_SM4 | AArch64::AEK_SHA3 | AArch64::AEK_BF16 |
+AArch64::AEK_SHA2 | AArch64::AEK_AES | AArch64::AEK_I8MM |
+AArch64::AEK_SSBS | AArch64::AEK_SB | AArch64::AEK_RAND |
+AArch64::AEK_MTE,
+"8.6-A"),
 ARMCPUTestParams(
 "neoverse-512tvb", "armv8.4-a", "crypto-neon-fp-armv8",
 AArch64::AEK_RAS | AArch64::AEK_SVE | AArch64::AEK_SSBS |
@@ -1399,7 +1409,7 @@
  "8.2-A")));
 
 // Note: number of CPUs includes aliases.
-static constexpr unsigned NumAArch64CPUArchs = 61;
+static constexpr unsigned NumAArch64CPUArchs = 62;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/unittests/TargetParser/Host.cpp
===
--- llvm/unittests/TargetParser/Host.cpp
+++ llvm/unittests/TargetParser/Host.cpp
@@ -117,6 +117,9 @@
   EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0xc0\n"
   "CPU part: 0xac3"),
 "ampere1");
+  EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0xc0\n"
+  "CPU part: 0xac4"),
+"ampere1a");
 
   // MSM8992/4 weirdness
   StringRef MSM8992ProcCpuInfo = R"(
Index: llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
===
--- llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
+++ llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
@@ -13,6 +13,7 @@
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n2 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=ampere1 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=ampere1a --disassemble < %s | FileCheck %s
 
 # CHECK: ldaprb w0, [x0]
 # CHECK: ldaprh w0, [x0]
Index: llvm/test/MC/AArch64/armv8.3a-rcpc.s
===
--- llvm/test/MC/AArch64/armv8.3a-rcpc.s
+++ llvm/test/MC/AArch64/armv8.3a-rcpc.s
@@ -7,6 +7,7 @@
 // RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mcpu=neoverse-n1 < %s 2>&1 | FileCheck %s
 // RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mcpu=neoverse-n2 < %s 2>&1 | FileCheck %s
 // RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mcpu=ampere1 < %s 2>&1 | FileCheck %s
+// RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mcpu=ampere1a < %s 2>&1 | FileCheck %s
 // RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mattr=+v8.2a -mattr=+rcpc < %s 2>&1 | FileCheck %s
 // RUN: not llvm-mc -triple aarch64-none-linux-gnu -mattr=+v8.2a < %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-REQ %s < %t
Index: llvm/test/MC/AArch64/armv8.2a-dotprod.s
===
--- llvm/test/MC/AArch64/armv8.2a-dotprod.s
+++ llvm/test/MC/AArch64/armv8.2a-dotprod.s
@@ -14,6 +14,7 @@
 // RUN: llvm-mc -triple aarch64 -mcpu=cortex-r82 

[clang] fb0af89 - [AArch64] Add the Ampere1A core

2023-01-24 Thread Philipp Tomsich via cfe-commits

Author: Philipp Tomsich
Date: 2023-01-24T22:36:39+01:00
New Revision: fb0af89193a9ea0f92eaffb454341987f897f0c7

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

LOG: [AArch64] Add the Ampere1A core

The Ampere1A core improves on the Ampere1 with key differences being:
 * memory tagging is supported
 * SM3/SM4 are supported
 * adds a new fusion pair for (A+B+1 and A-B-1)
   (added in a later commit)

Depends on D142395

Reviewed By: dmgreen

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

Added: 


Modified: 
clang/test/Misc/target-invalid-cpu-note.c
llvm/include/llvm/TargetParser/AArch64TargetParser.h
llvm/lib/Target/AArch64/AArch64.td
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
llvm/lib/Target/AArch64/AArch64Subtarget.h
llvm/lib/TargetParser/Host.cpp
llvm/test/CodeGen/AArch64/cpus.ll
llvm/test/CodeGen/AArch64/neon-dot-product.ll
llvm/test/CodeGen/AArch64/remat.ll
llvm/test/MC/AArch64/armv8.2a-dotprod.s
llvm/test/MC/AArch64/armv8.3a-rcpc.s
llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
llvm/unittests/TargetParser/Host.cpp
llvm/unittests/TargetParser/TargetParserTest.cpp

Removed: 




diff  --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 60f926c9ee637..1f205163a966e 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -5,11 +5,11 @@
 
 // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix AARCH64
 // AARCH64: error: unknown target CPU 'not-a-cpu'
-// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, cortex-a65ae, 
cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, 
cortex-a78, cortex-a78c, cortex-a710, cortex-a715, cortex-r82, cortex-x1, 
cortex-x1c, cortex-x2, cortex-x3, neoverse-e1, neoverse-n1, neoverse-n2, 
neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, 
apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, 
apple-a16, apple-m1, apple-m2, apple-s4, apple-s5, exynos-m3, exynos-m4, 
exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, 
thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, 
grace{{$}}
+// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, cortex-a65ae, 
cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, 
cortex-a78, cortex-a78c, cortex-a710, cortex-a715, cortex-r82, cortex-x1, 
cortex-x1c, cortex-x2, cortex-x3, neoverse-e1, neoverse-n1, neoverse-n2, 
neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, 
apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, 
apple-a16, apple-m1, apple-m2, apple-s4, apple-s5, exynos-m3, exynos-m4, 
exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, 
thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, 
ampere1a, grace{{$}}
 
 // RUN: not %clang_cc1 -triple arm64--- -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE_AARCH64
 // TUNE_AARCH64: error: unknown target CPU 'not-a-cpu'
-// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, 
cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, 
cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, 
cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-a715, cortex-r82, 
cortex-x1, cortex-x1c, cortex-x2, cortex-x3, neoverse-e1, neoverse-n1, 
neoverse-n2, neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, 
apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, 
apple-a15, apple-a16,  apple-m1, apple-m2, apple-s4, apple-s5, exynos-m3, 
exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, 
thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, 
ampere1, grace{{$}}
+// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, 
cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, 
cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, 
cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-a715, cortex-r82, 
cortex-x1, cortex-x1c, cortex-x2, cortex-x3, neoverse-e1, neoverse-n1, 
neoverse-n2, neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, 
apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, 
apple-a15, apple-a16,  apple-m1, apple-m2, apple-s4, apple-s5, exynos-m3, 
exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, 
thunderx, 

[PATCH] D139454: [CMake] Replace clang binary if using clang-bolt target

2023-01-24 Thread Amir Ayupov via Phabricator via cfe-commits
Amir added a comment.

Ping @phosek @MaskRay


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139454

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


[PATCH] D142499: [Clang][AMDGPU] Set LTO CG opt level based on Clang option

2023-01-24 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a comment.

In D142499#4078177 , @arsenm wrote:

> Making this target specific doesn’t make sense

I don't know how else to resolve others wanting the default to be the 
`CGOptLevel = clamp(ltoOptLevel, 2, 3)` behavior and AMDGPU wanting the default 
to be `CGOptLevel = ltoOptLevel`. Maybe that isn't actually the default we 
want? We can ask users to specify `-Xoffload-linker --lto-CGO#`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142499

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


[clang] 25b03ae - Fix C++11 warnings in RangeSetTest.cpp

2023-01-24 Thread Philipp Tomsich via cfe-commits

Author: Philipp Tomsich
Date: 2023-01-24T22:13:44+01:00
New Revision: 25b03ae78ff368f77d548fddea327f3b802799f3

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

LOG: Fix C++11 warnings in RangeSetTest.cpp

This change fixes the following warnings:
   llvm/clang/unittests/StaticAnalyzer/RangeSetTest.cpp:727:55: warning: ISO 
C++11 requires at least one argument for the "..." in a variadic macro
 727 | TYPED_TEST_SUITE(RangeSetCastToNoopTest, NoopCastTypes);
 |   ^
   llvm/clang/unittests/StaticAnalyzer/RangeSetTest.cpp:728:65: warning: ISO 
C++11 requires at least one argument for the "..." in a variadic macro
 728 | TYPED_TEST_SUITE(RangeSetCastToPromotionTest, PromotionCastTypes);
 | ^
   llvm/clang/unittests/StaticAnalyzer/RangeSetTest.cpp:729:67: warning: ISO 
C++11 requires at least one argument for the "..." in a variadic macro
 729 | TYPED_TEST_SUITE(RangeSetCastToTruncationTest, TruncationCastTypes);
 |   ^
   llvm/clang/unittests/StaticAnalyzer/RangeSetTest.cpp:730:67: warning: ISO 
C++11 requires at least one argument for the "..." in a variadic macro
 730 | TYPED_TEST_SUITE(RangeSetCastToConversionTest, ConversionCastTypes);
 |   ^
   llvm/clang/unittests/StaticAnalyzer/RangeSetTest.cpp:732:46: warning: ISO 
C++11 requires at least one argument for the "..." in a variadic macro
 732 |  PromotionConversionCastTypes);
 |  ^
   llvm/clang/unittests/StaticAnalyzer/RangeSetTest.cpp:734:47: warning: ISO 
C++11 requires at least one argument for the "..." in a variadic macro
 734 |  TruncationConversionCastTypes);
 |   ^

Reviewed By: steakhal

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

Added: 


Modified: 
clang/unittests/StaticAnalyzer/RangeSetTest.cpp

Removed: 




diff  --git a/clang/unittests/StaticAnalyzer/RangeSetTest.cpp 
b/clang/unittests/StaticAnalyzer/RangeSetTest.cpp
index 892c1ac23f92f..318877c562568 100644
--- a/clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ b/clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -724,14 +724,14 @@ using TruncationConversionCastTypes =
  CastType, CastType,
  CastType, CastType>;
 
-TYPED_TEST_SUITE(RangeSetCastToNoopTest, NoopCastTypes);
-TYPED_TEST_SUITE(RangeSetCastToPromotionTest, PromotionCastTypes);
-TYPED_TEST_SUITE(RangeSetCastToTruncationTest, TruncationCastTypes);
-TYPED_TEST_SUITE(RangeSetCastToConversionTest, ConversionCastTypes);
+TYPED_TEST_SUITE(RangeSetCastToNoopTest, NoopCastTypes, );
+TYPED_TEST_SUITE(RangeSetCastToPromotionTest, PromotionCastTypes, );
+TYPED_TEST_SUITE(RangeSetCastToTruncationTest, TruncationCastTypes, );
+TYPED_TEST_SUITE(RangeSetCastToConversionTest, ConversionCastTypes, );
 TYPED_TEST_SUITE(RangeSetCastToPromotionConversionTest,
- PromotionConversionCastTypes);
+ PromotionConversionCastTypes, );
 TYPED_TEST_SUITE(RangeSetCastToTruncationConversionTest,
- TruncationConversionCastTypes);
+ TruncationConversionCastTypes, );
 
 TYPED_TEST(RangeSetCastToNoopTest, RangeSetCastToNoopTest) {
   // Just to reduce the verbosity.



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


[PATCH] D142439: Fix C++11 warnings in RangeSetTest.cpp

2023-01-24 Thread Philipp Tomsich 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 rG25b03ae78ff3: Fix C++11 warnings in RangeSetTest.cpp 
(authored by philipp.tomsich).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142439

Files:
  clang/unittests/StaticAnalyzer/RangeSetTest.cpp


Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -724,14 +724,14 @@
  CastType, CastType,
  CastType, CastType>;
 
-TYPED_TEST_SUITE(RangeSetCastToNoopTest, NoopCastTypes);
-TYPED_TEST_SUITE(RangeSetCastToPromotionTest, PromotionCastTypes);
-TYPED_TEST_SUITE(RangeSetCastToTruncationTest, TruncationCastTypes);
-TYPED_TEST_SUITE(RangeSetCastToConversionTest, ConversionCastTypes);
+TYPED_TEST_SUITE(RangeSetCastToNoopTest, NoopCastTypes, );
+TYPED_TEST_SUITE(RangeSetCastToPromotionTest, PromotionCastTypes, );
+TYPED_TEST_SUITE(RangeSetCastToTruncationTest, TruncationCastTypes, );
+TYPED_TEST_SUITE(RangeSetCastToConversionTest, ConversionCastTypes, );
 TYPED_TEST_SUITE(RangeSetCastToPromotionConversionTest,
- PromotionConversionCastTypes);
+ PromotionConversionCastTypes, );
 TYPED_TEST_SUITE(RangeSetCastToTruncationConversionTest,
- TruncationConversionCastTypes);
+ TruncationConversionCastTypes, );
 
 TYPED_TEST(RangeSetCastToNoopTest, RangeSetCastToNoopTest) {
   // Just to reduce the verbosity.


Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -724,14 +724,14 @@
  CastType, CastType,
  CastType, CastType>;
 
-TYPED_TEST_SUITE(RangeSetCastToNoopTest, NoopCastTypes);
-TYPED_TEST_SUITE(RangeSetCastToPromotionTest, PromotionCastTypes);
-TYPED_TEST_SUITE(RangeSetCastToTruncationTest, TruncationCastTypes);
-TYPED_TEST_SUITE(RangeSetCastToConversionTest, ConversionCastTypes);
+TYPED_TEST_SUITE(RangeSetCastToNoopTest, NoopCastTypes, );
+TYPED_TEST_SUITE(RangeSetCastToPromotionTest, PromotionCastTypes, );
+TYPED_TEST_SUITE(RangeSetCastToTruncationTest, TruncationCastTypes, );
+TYPED_TEST_SUITE(RangeSetCastToConversionTest, ConversionCastTypes, );
 TYPED_TEST_SUITE(RangeSetCastToPromotionConversionTest,
- PromotionConversionCastTypes);
+ PromotionConversionCastTypes, );
 TYPED_TEST_SUITE(RangeSetCastToTruncationConversionTest,
- TruncationConversionCastTypes);
+ TruncationConversionCastTypes, );
 
 TYPED_TEST(RangeSetCastToNoopTest, RangeSetCastToNoopTest) {
   // Just to reduce the verbosity.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142501: [clang][deps] Fix modulemap file path for implementation of module

2023-01-24 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: clang/test/ClangScanDeps/modules-implementation-vfs.m:67-68
+#import 
+struct A { float x; }; // expected-error {{incompatible definitions}} 
expected-note {{type 'float' here}}
+// expected-note@frameworks/A.framework/Headers/A.h:1 {{type 'int' here}}
+

benlangmuir wrote:
> jansvoboda11 wrote:
> > What purpose does this check serve?
> Added a comment to explain this check.
Makes sense now, thanks!


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

https://reviews.llvm.org/D142501

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


[PATCH] D140250: Define NULL in its own header

2023-01-24 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: 
llvm/test/DebugInfo/Generic/assignment-tracking/sroa/unspecified-var-size.ll:37
 !7 = !DIFile(filename: "clang/12.0.0/include/__stddef_max_align_t.h", 
directory: "/")
-!8 = !DICompositeType(tag: DW_TAG_structure_type, file: !7, line: 19, size: 
256, flags: DIFlagFwdDecl, identifier: "_ZTS11max_align_t")
-!9 = !DIFile(filename: "include/c++/7.5.0/cstddef", directory: "")
-!10 = !{i32 7, !"Dwarf Version", i32 4}
-!11 = !{i32 2, !"Debug Info Version", i32 3}
-!12 = !{i32 1, !"wchar_size", i32 4}
-!13 = !{!"clang version 12.0.0"}
-!14 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funDn", scope: !1, 
file: !1, line: 20, type: !15, scopeLine: 20, flags: DIFlagPrototyped | 
DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: 
!0, retainedNodes: !20)
-!15 = !DISubroutineType(types: !16)
-!16 = !{null, !17}
-!17 = !DIDerivedType(tag: DW_TAG_typedef, name: "nullptr_t", scope: !5, file: 
!18, line: 235, baseType: !19)
-!18 = !DIFile(filename: "include/x86_64-linux-gnu/c++/7.5.0/bits/c++config.h", 
directory: "")
-!19 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)")
-!20 = !{!21}
-!21 = !DILocalVariable(arg: 1, scope: !14, file: !1, line: 20, type: !17)
-!22 = distinct !DIAssignID()
-!23 = !DILocation(line: 0, scope: !14)
-!28 = distinct !DIAssignID()
-!29 = !DILocation(line: 20, column: 27, scope: !14)
+!8 = !DIFile(filename: "clang/12.0.0/include/__stddef_null.h", directory: "/")
+!9 = !DICompositeType(tag: DW_TAG_structure_type, file: !7, line: 19, size: 
256, flags: DIFlagFwdDecl, identifier: "_ZTS11max_align_t")

aaron.ballman wrote:
> iana wrote:
> > Adding this line is the only reason I changed this file. I'm not familiar 
> > at all with how these tests work, so I don't really know if it's necessary. 
> > The test passes with and without these changes.
> CC @dblaikie and @echristo for questions about whether we should be updating 
> this debug info test or not.
Don't think there's any reason/need to - what motivated changing this file?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140250

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


[PATCH] D141717: [Clang] Only emit textual LLVM-IR in device only mode

2023-01-24 Thread Joseph Huber 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 rGd50dacd7c3c2: [Clang] Only emit textual LLVM-IR in device 
only mode (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141717

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/openmp-offload-gpu.c


Index: clang/test/Driver/openmp-offload-gpu.c
===
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -304,9 +304,16 @@
 // CHECK-IR: "x86_64-unknown-linux-gnu" - "clang", inputs: 
["[[INPUT_IR:.+]]"], output: "[[OBJECT:.+]]"
 // CHECK-IR: "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: 
["[[OBJECT]]"], output: "a.out"
 
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S 
-fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 -nogpulib %s 2>&1 | FileCheck 
%s --check-prefix=CHECK-EMIT-LLVM-IR
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S 
-fopenmp=libomp --offload-device-only \
+// RUN: -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 -nogpulib %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR
 // CHECK-EMIT-LLVM-IR: "-cc1"{{.*}}"-triple" 
"nvptx64-nvidia-cuda"{{.*}}"-emit-llvm"
 
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S 
-fopenmp=libomp \
+// RUN: -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 -nogpulib %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR-BC
+// CHECK-EMIT-LLVM-IR-BC: "-cc1"{{.*}}"-triple" 
"nvptx64-nvidia-cuda"{{.*}}"-emit-llvm-bc"
+
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target=nvptx64-nvida-cuda -march=sm_70 \
 // RUN:  
--libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-new-nvptx-test.bc
 \
 // RUN:  -nogpulib %s -o openmp-offload-gpu 2>&1 \
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4634,7 +4634,14 @@
false) ||
   TargetDeviceOffloadKind == Action::OFK_OpenMP))) {
   types::ID Output =
-  Args.hasArg(options::OPT_S) ? types::TY_LLVM_IR : types::TY_LLVM_BC;
+  Args.hasArg(options::OPT_S) &&
+  (TargetDeviceOffloadKind == Action::OFK_None ||
+   offloadDeviceOnly() ||
+   (TargetDeviceOffloadKind == Action::OFK_HIP &&
+!Args.hasFlag(options::OPT_offload_new_driver,
+  options::OPT_no_offload_new_driver, false)))
+  ? types::TY_LLVM_IR
+  : types::TY_LLVM_BC;
   return C.MakeAction(Input, Output);
 }
 return C.MakeAction(Input, types::TY_PP_Asm);


Index: clang/test/Driver/openmp-offload-gpu.c
===
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -304,9 +304,16 @@
 // CHECK-IR: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT_IR:.+]]"], output: "[[OBJECT:.+]]"
 // CHECK-IR: "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["[[OBJECT]]"], output: "a.out"
 
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp=libomp --offload-device-only \
+// RUN: -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 -nogpulib %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR
 // CHECK-EMIT-LLVM-IR: "-cc1"{{.*}}"-triple" "nvptx64-nvidia-cuda"{{.*}}"-emit-llvm"
 
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp=libomp \
+// RUN: -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 -nogpulib %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR-BC
+// CHECK-EMIT-LLVM-IR-BC: "-cc1"{{.*}}"-triple" "nvptx64-nvidia-cuda"{{.*}}"-emit-llvm-bc"
+
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvida-cuda -march=sm_70 \
 // RUN:  --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-new-nvptx-test.bc \
 // RUN:  -nogpulib %s -o openmp-offload-gpu 2>&1 \
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4634,7 

[clang] d50dacd - [Clang] Only emit textual LLVM-IR in device only mode

2023-01-24 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-01-24T15:11:30-06:00
New Revision: d50dacd7c3c2ce489df6ed1ccde71bba390fe5e2

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

LOG: [Clang] Only emit textual LLVM-IR in device only mode

Currently, we embed device code into the host to perform
multi-architecture linking and handling of device code. If the user
specified `-S -emit-llvm` then the embedded output will be textual
LLVM-IR. This is a problem because it can't be used by the LTO backend
and it makes reading the file confusing.

This patch changes the behaviour to only emit textual device IR if we
are in device only mode, that is, if the device code is presented
directly to the user instead of being embedded. Otherwise we should
always embed device bitcode instead.

Reviewed By: tra

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

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/test/Driver/openmp-offload-gpu.c

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 49faa193fb7b1..661d9977fbc51 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4634,7 +4634,14 @@ Action *Driver::ConstructPhaseAction(
false) ||
   TargetDeviceOffloadKind == Action::OFK_OpenMP))) {
   types::ID Output =
-  Args.hasArg(options::OPT_S) ? types::TY_LLVM_IR : types::TY_LLVM_BC;
+  Args.hasArg(options::OPT_S) &&
+  (TargetDeviceOffloadKind == Action::OFK_None ||
+   offloadDeviceOnly() ||
+   (TargetDeviceOffloadKind == Action::OFK_HIP &&
+!Args.hasFlag(options::OPT_offload_new_driver,
+  options::OPT_no_offload_new_driver, false)))
+  ? types::TY_LLVM_IR
+  : types::TY_LLVM_BC;
   return C.MakeAction(Input, Output);
 }
 return C.MakeAction(Input, types::TY_PP_Asm);

diff  --git a/clang/test/Driver/openmp-offload-gpu.c 
b/clang/test/Driver/openmp-offload-gpu.c
index 9a05dafc16e96..b1e1954a93594 100644
--- a/clang/test/Driver/openmp-offload-gpu.c
+++ b/clang/test/Driver/openmp-offload-gpu.c
@@ -304,9 +304,16 @@
 // CHECK-IR: "x86_64-unknown-linux-gnu" - "clang", inputs: 
["[[INPUT_IR:.+]]"], output: "[[OBJECT:.+]]"
 // CHECK-IR: "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: 
["[[OBJECT]]"], output: "a.out"
 
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S 
-fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 -nogpulib %s 2>&1 | FileCheck 
%s --check-prefix=CHECK-EMIT-LLVM-IR
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S 
-fopenmp=libomp --offload-device-only \
+// RUN: -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 -nogpulib %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR
 // CHECK-EMIT-LLVM-IR: "-cc1"{{.*}}"-triple" 
"nvptx64-nvidia-cuda"{{.*}}"-emit-llvm"
 
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S 
-fopenmp=libomp \
+// RUN: -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 -nogpulib %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR-BC
+// CHECK-EMIT-LLVM-IR-BC: "-cc1"{{.*}}"-triple" 
"nvptx64-nvidia-cuda"{{.*}}"-emit-llvm-bc"
+
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target=nvptx64-nvida-cuda -march=sm_70 \
 // RUN:  
--libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-new-nvptx-test.bc
 \
 // RUN:  -nogpulib %s -o openmp-offload-gpu 2>&1 \



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


[PATCH] D142501: [clang][deps] Fix modulemap file path for implementation of module

2023-01-24 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir marked an inline comment as done.
benlangmuir added inline comments.



Comment at: clang/test/ClangScanDeps/modules-implementation-vfs.m:67-68
+#import 
+struct A { float x; }; // expected-error {{incompatible definitions}} 
expected-note {{type 'float' here}}
+// expected-note@frameworks/A.framework/Headers/A.h:1 {{type 'int' here}}
+

jansvoboda11 wrote:
> What purpose does this check serve?
Added a comment to explain this check.


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

https://reviews.llvm.org/D142501

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


[PATCH] D142454: [analyzer] Update satest dependencies

2023-01-24 Thread Manas Gupta 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 rGa037b85f3097: [analyzer] Update satest dependencies 
(authored by manas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142454

Files:
  clang/utils/analyzer/Dockerfile


Index: clang/utils/analyzer/Dockerfile
===
--- clang/utils/analyzer/Dockerfile
+++ clang/utils/analyzer/Dockerfile
@@ -31,8 +31,8 @@
 
 # symengine dependencies
 RUN apt-get install -y \
-libgmp10=2:6.1.2+dfsg-2 \
-libgmp-dev=2:6.1.2+dfsg-2
+libgmp10=2:6.1.2+dfsg-2ubuntu0.1 \
+libgmp-dev=2:6.1.2+dfsg-2ubuntu0.1
 
 # simbody dependencies
 RUN apt-get install -y \


Index: clang/utils/analyzer/Dockerfile
===
--- clang/utils/analyzer/Dockerfile
+++ clang/utils/analyzer/Dockerfile
@@ -31,8 +31,8 @@
 
 # symengine dependencies
 RUN apt-get install -y \
-libgmp10=2:6.1.2+dfsg-2 \
-libgmp-dev=2:6.1.2+dfsg-2
+libgmp10=2:6.1.2+dfsg-2ubuntu0.1 \
+libgmp-dev=2:6.1.2+dfsg-2ubuntu0.1
 
 # simbody dependencies
 RUN apt-get install -y \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a037b85 - [analyzer] Update satest dependencies

2023-01-24 Thread via cfe-commits

Author: Manas
Date: 2023-01-25T02:37:16+05:30
New Revision: a037b85f30970cb2dc51e8ab66f2e157bfb28c19

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

LOG: [analyzer] Update satest dependencies

A couple of packages were out-dated while building satest docker image.
This patch updates those.

Reviewed By: steakhal

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

Added: 


Modified: 
clang/utils/analyzer/Dockerfile

Removed: 




diff  --git a/clang/utils/analyzer/Dockerfile b/clang/utils/analyzer/Dockerfile
index b92bac6796501..cc73ed973b811 100644
--- a/clang/utils/analyzer/Dockerfile
+++ b/clang/utils/analyzer/Dockerfile
@@ -31,8 +31,8 @@ RUN apt-get install -y \
 
 # symengine dependencies
 RUN apt-get install -y \
-libgmp10=2:6.1.2+dfsg-2 \
-libgmp-dev=2:6.1.2+dfsg-2
+libgmp10=2:6.1.2+dfsg-2ubuntu0.1 \
+libgmp-dev=2:6.1.2+dfsg-2ubuntu0.1
 
 # simbody dependencies
 RUN apt-get install -y \



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


[PATCH] D142501: [clang][deps] Fix modulemap file path for implementation of module

2023-01-24 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir updated this revision to Diff 491886.

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

https://reviews.llvm.org/D142501

Files:
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/modules-implementation-vfs.m

Index: clang/test/ClangScanDeps/modules-implementation-vfs.m
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-implementation-vfs.m
@@ -0,0 +1,156 @@
+// Ensure we get the virtual module map path for a module whose implementation
+// file we are compiling.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+//--- real/A.modulemap
+framework module A { umbrella header "A.h" }
+//--- real/A.private.modulemap
+framework module A_Private { umbrella header "A_Private.h" }
+
+//--- frameworks/A.framework/Headers/A.h
+struct A { int x; };
+//--- frameworks/A.framework/PrivateHeaders/A_Private.h
+#import 
+
+//--- frameworks/B.framework/Headers/B.h
+#import 
+//--- frameworks/B.framework/Modules/module.modulemap
+framework module B { umbrella header "B.h" }
+
+//--- overlay.json.template
+{
+  "case-sensitive": "false",
+  "version": 0,
+  "roots": [
+{
+  "external-contents": "DIR/real/A.modulemap",
+  "name": "DIR/frameworks/A.framework/Modules/module.modulemap",
+  "type": "file"
+},
+{
+  "external-contents": "DIR/real/A.private.modulemap",
+  "name": "DIR/frameworks/A.framework/Modules/module.private.modulemap",
+  "type": "file"
+},
+  ]
+}
+
+//--- cdb.json.template
+[
+{
+  "file": "DIR/tu1.m",
+  "directory": "DIR",
+  "command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A -ivfsoverlay DIR/overlay.json -F DIR/frameworks -fsyntax-only DIR/tu1.m"
+},
+{
+  "file": "DIR/tu2.m",
+  "directory": "DIR",
+  "command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A -ivfsoverlay DIR/overlay.json -F DIR/frameworks -fsyntax-only DIR/tu2.m"
+},
+{
+  "file": "DIR/tu3.m",
+  "directory": "DIR",
+  "command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A -ivfsoverlay DIR/overlay.json -F DIR/frameworks -fsyntax-only DIR/tu3.m"
+}
+]
+
+//--- tu1.m
+#import 
+
+//--- tu2.m
+#import 
+
+//--- tu3.m
+#import 
+// The following code triggers a note diagnostic pointing to A.h which is
+// resolved relative to the module base directory, which is affected by the
+// modulemap path.
+struct A { float x; }; // expected-error {{incompatible definitions}} expected-note {{type 'float' here}}
+// expected-note@frameworks/A.framework/Headers/A.h:1 {{type 'int' here}}
+
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
+// RUN: sed -e "s|DIR|%/t|g" %t/overlay.json.template > %t/overlay.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -j 1 > %t/result.json
+// RUN: cat %t/result.json | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t
+// CHECK:  {
+// CHECK:"modules": [
+// CHECK:  {
+// CHECK:"clang-module-deps": []
+// CHECK:"command-line": [
+// CHECK:  "-x"
+// CHECK-NEXT: "objective-c"
+// CHECK-NEXT: "[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
+// CHECK:]
+// CHECK:"name": "A"
+// CHECK:  }
+// CHECK:  {
+// CHECK:"clang-module-deps": [
+// CHECK:  {
+// CHECK:"module-name": "A"
+// CHECK:  }
+// CHECK:]
+// CHECK:"command-line": [
+// CHECK:  "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap",
+// CHECK:  "-x"
+// CHECK-NEXT: "objective-c"
+// CHECK-NEXT: "[[PREFIX]]/frameworks/B.framework/Modules/module.modulemap"
+// CHECK:]
+// CHECK:"name": "B"
+// CHECK:  }
+
+// CHECK:"translation-units": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "commands": [
+// CHECK:  {
+// CHECK:"command-line": [
+// CHECK:  "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
+// CHECK:  "-fmodule-name=A"
+// CHECK:],
+// CHECK:"input-file": "[[PREFIX]]/tu1.m"
+// CHECK-NEXT: }
+// CHECK:]
+// CHECK:  }
+// CHECK-NEXT: {
+// CHECK-NEXT:   "commands": [
+// CHECK:  {
+// CHECK:"command-line": [
+// CHECK:  "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
+// CHECK:  "-fmodule-name=A"
+// CHECK:],
+// CHECK:"input-file": "[[PREFIX]]/tu2.m"
+// CHECK-NEXT: }
+// CHECK:]
+// CHECK:  }
+// CHECK-NEXT: {
+// CHECK-NEXT:   "commands": [
+// CHECK:  {
+// CHECK:"clang-module-deps": [
+// CHECK:  {
+// CHECK:

[PATCH] D142499: [Clang][AMDGPU] Set LTO CG opt level based on Clang option

2023-01-24 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

Making this target specific doesn’t make sense


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142499

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


[PATCH] D140086: [analyzer][solver] Improve reasoning for not equal to operator

2023-01-24 Thread Manas Gupta via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5f02ad880e42: [analyzer][solver] Improve reasoning for not 
equal to operator (authored by manas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140086

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constant-folding.c


Index: clang/test/Analysis/constant-folding.c
===
--- clang/test/Analysis/constant-folding.c
+++ clang/test/Analysis/constant-folding.c
@@ -303,7 +303,8 @@
 
   if (s1 < 0 && s1 > -4 && u1 > UINT_MAX - 4 && u1 < UINT_MAX - 1) {
 // s1: [-3, -1], u1: [UINT_MAX - 3, UINT_MAX - 2]
-clang_analyzer_eval(u1 != s1); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval(u1 != s1); // expected-warning{{TRUE}}
+clang_analyzer_eval(s1 != u1); // expected-warning{{TRUE}}
   }
 
   if (s1 < 1 && s1 > -6 && s1 != -4 && s1 != -3 &&
@@ -400,12 +401,10 @@
 clang_analyzer_eval(uch != sch); // expected-warning{{UNKNOWN}}
   }
 
-  // FIXME: Casting smaller signed types to unsigned one may leave us with
-  // overlapping values, falsely indicating UNKNOWN, where it is possible to
-  // assert TRUE.
   if (uch > 1 && sch < 1) {
 // uch: [2, UCHAR_MAX], sch: [SCHAR_MIN, 0]
-clang_analyzer_eval(uch != sch); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval(uch != sch); // expected-warning{{TRUE}}
+clang_analyzer_eval(sch != uch); // expected-warning{{TRUE}}
   }
 
   if (uch <= 1 && uch >= 1 && sch <= 1 && sch >= 1) {
@@ -419,10 +418,9 @@
 clang_analyzer_eval(ush != ssh); // expected-warning{{UNKNOWN}}
   }
 
-  // FIXME: Casting leave us with overlapping values. Should be TRUE.
   if (ush > 1 && ssh < 1) {
 // ush: [2, USHRT_MAX], ssh: [SHRT_MIN, 0]
-clang_analyzer_eval(ush != ssh); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval(ush != ssh); // expected-warning{{TRUE}}
   }
 
   if (ush <= 1 && ush >= 1 && ssh <= 1 && ssh >= 1) {
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1622,7 +1622,33 @@
   if (LHS.getAPSIntType() == RHS.getAPSIntType()) {
 if (intersect(RangeFactory, LHS, RHS).isEmpty())
   return getTrueRange(T);
+
   } else {
+// We can only lose information if we are casting smaller signed type to
+// bigger unsigned type. For e.g.,
+//LHS (unsigned short): [2, USHRT_MAX]
+//RHS   (signed short): [SHRT_MIN, 0]
+//
+// Casting RHS to LHS type will leave us with overlapping values
+//CastedRHS : [0, 0] U [SHRT_MAX + 1, USHRT_MAX]
+//
+// We can avoid this by checking if signed type's maximum value is lesser
+// than unsigned type's minimum value.
+
+// If both have different signs then only we can get more information.
+if (LHS.isUnsigned() != RHS.isUnsigned()) {
+  if (LHS.isUnsigned() && (LHS.getBitWidth() >= RHS.getBitWidth())) {
+if (RHS.getMaxValue().isNegative() ||
+LHS.getAPSIntType().convert(RHS.getMaxValue()) < LHS.getMinValue())
+  return getTrueRange(T);
+
+  } else if (RHS.isUnsigned() && (LHS.getBitWidth() <= RHS.getBitWidth())) 
{
+if (LHS.getMaxValue().isNegative() ||
+RHS.getAPSIntType().convert(LHS.getMaxValue()) < RHS.getMinValue())
+  return getTrueRange(T);
+  }
+}
+
 // Both RangeSets should be casted to bigger unsigned type.
 APSIntType CastingType(std::max(LHS.getBitWidth(), RHS.getBitWidth()),
LHS.isUnsigned() || RHS.isUnsigned());
@@ -2151,7 +2177,6 @@
   RangeSet::Factory 
 };
 
-
 bool ConstraintAssignor::assignSymExprToConst(const SymExpr *Sym,
   const llvm::APSInt ) {
   llvm::SmallSet SimplifiedClasses;


Index: clang/test/Analysis/constant-folding.c
===
--- clang/test/Analysis/constant-folding.c
+++ clang/test/Analysis/constant-folding.c
@@ -303,7 +303,8 @@
 
   if (s1 < 0 && s1 > -4 && u1 > UINT_MAX - 4 && u1 < UINT_MAX - 1) {
 // s1: [-3, -1], u1: [UINT_MAX - 3, UINT_MAX - 2]
-clang_analyzer_eval(u1 != s1); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval(u1 != s1); // expected-warning{{TRUE}}
+clang_analyzer_eval(s1 != u1); // expected-warning{{TRUE}}
   }
 
   if (s1 < 1 && s1 > -6 && s1 != -4 && s1 != -3 &&
@@ -400,12 +401,10 @@
 clang_analyzer_eval(uch != sch); // expected-warning{{UNKNOWN}}
   }
 
-  // FIXME: Casting smaller signed types to unsigned one may leave us with
-  // overlapping values, falsely indicating UNKNOWN, where it is possible to
-  // assert TRUE.
   if (uch > 1 && sch < 1) {
 // uch: [2, 

[clang] 5f02ad8 - [analyzer][solver] Improve reasoning for not equal to operator

2023-01-24 Thread via cfe-commits

Author: Manas
Date: 2023-01-25T02:32:55+05:30
New Revision: 5f02ad880e423a33f903299f0123e9d8a59bbe8d

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

LOG: [analyzer][solver] Improve reasoning for not equal to operator

This patch fixes certain cases where solver was not able to infer
disequality due to overlapping of values in rangeset. This case was
casting from lower signed type to bigger unsigned type.

Reviewed By: steakhal

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
clang/test/Analysis/constant-folding.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index 3725e4939b2c6..1017dff2b0f34 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1622,7 +1622,33 @@ RangeSet 
SymbolicRangeInferrer::VisitBinaryOperator(RangeSet LHS,
   if (LHS.getAPSIntType() == RHS.getAPSIntType()) {
 if (intersect(RangeFactory, LHS, RHS).isEmpty())
   return getTrueRange(T);
+
   } else {
+// We can only lose information if we are casting smaller signed type to
+// bigger unsigned type. For e.g.,
+//LHS (unsigned short): [2, USHRT_MAX]
+//RHS   (signed short): [SHRT_MIN, 0]
+//
+// Casting RHS to LHS type will leave us with overlapping values
+//CastedRHS : [0, 0] U [SHRT_MAX + 1, USHRT_MAX]
+//
+// We can avoid this by checking if signed type's maximum value is lesser
+// than unsigned type's minimum value.
+
+// If both have 
diff erent signs then only we can get more information.
+if (LHS.isUnsigned() != RHS.isUnsigned()) {
+  if (LHS.isUnsigned() && (LHS.getBitWidth() >= RHS.getBitWidth())) {
+if (RHS.getMaxValue().isNegative() ||
+LHS.getAPSIntType().convert(RHS.getMaxValue()) < LHS.getMinValue())
+  return getTrueRange(T);
+
+  } else if (RHS.isUnsigned() && (LHS.getBitWidth() <= RHS.getBitWidth())) 
{
+if (LHS.getMaxValue().isNegative() ||
+RHS.getAPSIntType().convert(LHS.getMaxValue()) < RHS.getMinValue())
+  return getTrueRange(T);
+  }
+}
+
 // Both RangeSets should be casted to bigger unsigned type.
 APSIntType CastingType(std::max(LHS.getBitWidth(), RHS.getBitWidth()),
LHS.isUnsigned() || RHS.isUnsigned());
@@ -2151,7 +2177,6 @@ class ConstraintAssignor : public 
ConstraintAssignorBase {
   RangeSet::Factory 
 };
 
-
 bool ConstraintAssignor::assignSymExprToConst(const SymExpr *Sym,
   const llvm::APSInt ) {
   llvm::SmallSet SimplifiedClasses;

diff  --git a/clang/test/Analysis/constant-folding.c 
b/clang/test/Analysis/constant-folding.c
index f0598d4ae948b..620adcd82c66b 100644
--- a/clang/test/Analysis/constant-folding.c
+++ b/clang/test/Analysis/constant-folding.c
@@ -303,7 +303,8 @@ void testDisequalityRules(unsigned int u1, unsigned int u2, 
unsigned int u3,
 
   if (s1 < 0 && s1 > -4 && u1 > UINT_MAX - 4 && u1 < UINT_MAX - 1) {
 // s1: [-3, -1], u1: [UINT_MAX - 3, UINT_MAX - 2]
-clang_analyzer_eval(u1 != s1); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval(u1 != s1); // expected-warning{{TRUE}}
+clang_analyzer_eval(s1 != u1); // expected-warning{{TRUE}}
   }
 
   if (s1 < 1 && s1 > -6 && s1 != -4 && s1 != -3 &&
@@ -400,12 +401,10 @@ void testDisequalityRules(unsigned int u1, unsigned int 
u2, unsigned int u3,
 clang_analyzer_eval(uch != sch); // expected-warning{{UNKNOWN}}
   }
 
-  // FIXME: Casting smaller signed types to unsigned one may leave us with
-  // overlapping values, falsely indicating UNKNOWN, where it is possible to
-  // assert TRUE.
   if (uch > 1 && sch < 1) {
 // uch: [2, UCHAR_MAX], sch: [SCHAR_MIN, 0]
-clang_analyzer_eval(uch != sch); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval(uch != sch); // expected-warning{{TRUE}}
+clang_analyzer_eval(sch != uch); // expected-warning{{TRUE}}
   }
 
   if (uch <= 1 && uch >= 1 && sch <= 1 && sch >= 1) {
@@ -419,10 +418,9 @@ void testDisequalityRules(unsigned int u1, unsigned int 
u2, unsigned int u3,
 clang_analyzer_eval(ush != ssh); // expected-warning{{UNKNOWN}}
   }
 
-  // FIXME: Casting leave us with overlapping values. Should be TRUE.
   if (ush > 1 && ssh < 1) {
 // ush: [2, USHRT_MAX], ssh: [SHRT_MIN, 0]
-clang_analyzer_eval(ush != ssh); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval(ush != ssh); // expected-warning{{TRUE}}
   }
 
   if (ush <= 1 && ush >= 1 && ssh <= 1 && ssh >= 1) {



___
cfe-commits 

[PATCH] D142484: [LinkerWrapper] Only import static libraries with needed symbols

2023-01-24 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 491883.
jhuber6 added a comment.

Adding test and making the logic a bit more readable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142484

Files:
  clang/test/Driver/linker-wrapper-libs.c
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -1136,9 +1136,125 @@
   return searchLibraryBaseName(Input, Root, SearchPaths);
 }
 
-/// Search the input files and libraries for embedded device offloading code and
-/// add it to the list of files to be linked. Files coming from static libraries
-/// are only added to the input if they are used by an existing input file.
+/// Common redeclaration of needed symbol flags.
+enum Symbol : uint32_t {
+  Sym_None = 0,
+  Sym_Undefined = 1U << 1,
+  Sym_Weak = 1U << 2,
+};
+
+/// Scan the symbols from a BitcodeFile \p Buffer and record if we need to
+/// extract any symbols from it.
+Expected getSymbolsFromBitcode(MemoryBufferRef Buffer, StringSaver ,
+ DenseMap ) {
+  Expected IRSymtabOrErr = readIRSymtab(Buffer);
+  if (!IRSymtabOrErr)
+return IRSymtabOrErr.takeError();
+
+  bool Resolved = false;
+  for (unsigned I = 0; I != IRSymtabOrErr->Mods.size(); ++I) {
+for (const auto  : IRSymtabOrErr->TheReader.module_symbols(I)) {
+  if (Sym.isFormatSpecific() || !Sym.isGlobal())
+continue;
+
+  bool NewSymbol = Syms.count(Sym.getName()) == 0;
+  auto  = Syms[Saver.save(Sym.getName())];
+
+  // We will extract if it defines a currenlty undefined non-weak symbol.
+  bool ResolvesStrongReference =
+  ((OldSym & Sym_Undefined && !(OldSym & Sym_Weak)) &&
+   !Sym.isUndefined());
+  // We will extract if it defines a new global symbol visible to the host.
+  bool NewGlobalSymbol =
+  ((NewSymbol || (OldSym & Sym_Undefined)) && !Sym.isUndefined() &&
+   !Sym.canBeOmittedFromSymbolTable() &&
+   (Sym.getVisibility() != GlobalValue::HiddenVisibility));
+  Resolved |= ResolvesStrongReference | NewGlobalSymbol;
+
+  // Update this symbol in the "table" with the new information.
+  if (OldSym & Sym_Undefined && !Sym.isUndefined())
+OldSym = static_cast(OldSym & ~Sym_Undefined);
+  if (Sym.isUndefined() && NewSymbol)
+OldSym = static_cast(OldSym | Sym_Undefined);
+  if (Sym.isWeak())
+OldSym = static_cast(OldSym | Sym_Weak);
+}
+  }
+
+  return Resolved;
+}
+
+/// Scan the symbols from an ObjectFile \p Obj and record if we need to extract
+/// any symbols from it.
+Expected getSymbolsFromObject(const ObjectFile , StringSaver ,
+DenseMap ) {
+  bool Resolved = false;
+  for (SymbolRef Sym : Obj.symbols()) {
+auto FlagsOrErr = Sym.getFlags();
+if (!FlagsOrErr)
+  return FlagsOrErr.takeError();
+
+if (!(*FlagsOrErr & SymbolRef::SF_Global) ||
+(*FlagsOrErr & SymbolRef::SF_FormatSpecific))
+  continue;
+
+auto NameOrErr = Sym.getName();
+if (!NameOrErr)
+  return NameOrErr.takeError();
+
+bool NewSymbol = Syms.count(*NameOrErr) == 0;
+auto  = Syms[Saver.save(*NameOrErr)];
+
+// We will extract if it defines a currenlty undefined non-weak symbol.
+bool ResolvesStrongReference = (OldSym & Sym_Undefined) &&
+   !(OldSym & Sym_Weak) &&
+   !(*FlagsOrErr & SymbolRef::SF_Undefined);
+
+// We will extract if it defines a new global symbol visible to the host.
+bool NewGlobalSymbol = ((NewSymbol || (OldSym & Sym_Undefined)) &&
+!(*FlagsOrErr & SymbolRef::SF_Undefined) &&
+!(*FlagsOrErr & SymbolRef::SF_Hidden));
+Resolved |= ResolvesStrongReference | NewGlobalSymbol;
+
+// Update this symbol in the "table" with the new information.
+if (OldSym & Sym_Undefined && !(*FlagsOrErr & SymbolRef::SF_Undefined))
+  OldSym = static_cast(OldSym & ~Sym_Undefined);
+if (*FlagsOrErr & SymbolRef::SF_Undefined && NewSymbol)
+  OldSym = static_cast(OldSym | Sym_Undefined);
+if (*FlagsOrErr & SymbolRef::SF_Weak)
+  OldSym = static_cast(OldSym | Sym_Weak);
+  }
+  return Resolved;
+}
+
+/// Attempt to 'resolve' symbols found in input files. We use this to
+/// determine if an archive member needs to be extracted. An archive member
+/// will be extracted if any of the following is true.
+///   1) It defines an undefined symbol in a regular object filie.
+///   2) It defines a global symbol without hidden visibility that has not
+///  yet been defined.
+Expected getSymbols(StringRef Image, StringSaver ,
+  

[clang] 8700bee - Revert "[15/15][Clang][RISCV][NFC] Set data member under Policy as constants"

2023-01-24 Thread Douglas Yung via cfe-commits

Author: Douglas Yung
Date: 2023-01-24T12:59:15-08:00
New Revision: 8700beee9367fdf95d146c810855125a51006063

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

LOG: Revert "[15/15][Clang][RISCV][NFC] Set data member under Policy as 
constants"

This reverts commit 2b807336ad385e64a7d182d5fb67bdfe449707a3.

This change is causing Windows builds to hang and out of memory errors with 
clang-15:
 - https://lab.llvm.org/buildbot/#/builders/17/builds/33129
 - https://lab.llvm.org/buildbot/#/builders/174/builds/17069
 - https://lab.llvm.org/buildbot/#/builders/83/builds/28484
 - https://lab.llvm.org/buildbot/#/builders/172/builds/22803
 - https://lab.llvm.org/buildbot/#/builders/216/builds/16210

Added: 


Modified: 
clang/include/clang/Support/RISCVVIntrinsicUtils.h
clang/lib/Support/RISCVVIntrinsicUtils.cpp

Removed: 




diff  --git a/clang/include/clang/Support/RISCVVIntrinsicUtils.h 
b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
index 1ae74284c4c99..fc53d70019c55 100644
--- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -92,22 +92,15 @@ enum class TypeModifier : uint8_t {
   LLVM_MARK_AS_BITMASK_ENUM(LMUL1),
 };
 
-class Policy {
-public:
+struct Policy {
+  bool IsUnspecified = false;
   enum PolicyType {
 Undisturbed,
 Agnostic,
   };
-
-private:
-  const bool IsUnspecified = false;
-  // The default assumption for an RVV instruction is TAMA, as an undisturbed
-  // policy generally will affect the performance of an out-of-order core.
-  const PolicyType TailPolicy = Agnostic;
-  const PolicyType MaskPolicy = Agnostic;
+  PolicyType TailPolicy = Agnostic;
+  PolicyType MaskPolicy = Agnostic;
   bool HasTailPolicy, HasMaskPolicy;
-
-public:
   Policy(bool HasTailPolicy, bool HasMaskPolicy)
   : IsUnspecified(true), HasTailPolicy(HasTailPolicy),
 HasMaskPolicy(HasMaskPolicy) {}
@@ -429,6 +422,7 @@ class RVVIntrinsic {
 return IntrinsicTypes;
   }
   Policy getPolicyAttrs() const {
+assert(PolicyAttrs.IsUnspecified == false);
 return PolicyAttrs;
   }
   unsigned getPolicyAttrsBits() const {
@@ -437,6 +431,8 @@ class RVVIntrinsic {
 // The 1st bit simulates the `vma` of RVV
 // int PolicyAttrs = 0;
 
+assert(PolicyAttrs.IsUnspecified == false);
+
 if (PolicyAttrs.isTUMAPolicy())
   return 2;
 if (PolicyAttrs.isTAMAPolicy())

diff  --git a/clang/lib/Support/RISCVVIntrinsicUtils.cpp 
b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
index db78d8316c2bc..25084dd98e5c2 100644
--- a/clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -1017,6 +1017,7 @@ void RVVIntrinsic::updateNamesAndPolicy(bool IsMasked, 
bool HasPolicy,
   };
 
   if (PolicyAttrs.isUnspecified()) {
+PolicyAttrs.IsUnspecified = false;
 if (IsMasked) {
   Name += "_m";
   if (HasPolicy)



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


[PATCH] D142501: [clang][deps] Fix modulemap file path for implementation of module

2023-01-24 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/test/ClangScanDeps/modules-implementation-vfs.m:67-68
+#import 
+struct A { float x; }; // expected-error {{incompatible definitions}} 
expected-note {{type 'float' here}}
+// expected-note@frameworks/A.framework/Headers/A.h:1 {{type 'int' here}}
+

What purpose does this check serve?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142501

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


[PATCH] D142499: [Clang][AMDGPU] Set LTO CG opt level based on Clang option

2023-01-24 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added reviewers: arsenm, yaxunl, scchan, pcc, MaskRay, 
mehdi_amini, respindola, ruiu, aheejin, sbc100.
scott.linder added a comment.

(Just adding everyone from the parent review, feel free to remove yourself as 
reviewer if you aren't interested!)

It isn't ideal, but as only AMDGCN wants the 1:1 mapping for LTO->CG opt level 
to be the default I implemented it here. Thoughts?

I can move the missing `claim` call to another patch, it just seemed like a 
small enough change to include inline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142499

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


[PATCH] D141959: [clang-format] Fix inconsistent identification of operator

2023-01-24 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a reviewer: rymiel.
HazardyKnusperkeks added a comment.
This revision is now accepted and ready to land.

Looks good to me, but please wait until another one has given their blessing, 
or at least no veto for a few days.


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

https://reviews.llvm.org/D141959

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


[PATCH] D142501: [clang][deps] Fix modulemap file path for implementation of module

2023-01-24 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added a reviewer: jansvoboda11.
Herald added a project: All.
benlangmuir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Use the name "as requested" for the path of the implemented module's modulemap 
file, just as we do for other modulemap file paths. This fixes fatal errors 
with modules where we tried to find framework headers relative to the wrong 
directory when imported by an implementation file of the same module.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142501

Files:
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/modules-implementation-vfs.m

Index: clang/test/ClangScanDeps/modules-implementation-vfs.m
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-implementation-vfs.m
@@ -0,0 +1,153 @@
+// Ensure we get the virtual module map path for a module whose implementation
+// file we are compiling.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+//--- real/A.modulemap
+framework module A { umbrella header "A.h" }
+//--- real/A.private.modulemap
+framework module A_Private { umbrella header "A_Private.h" }
+
+//--- frameworks/A.framework/Headers/A.h
+struct A { int x; };
+//--- frameworks/A.framework/PrivateHeaders/A_Private.h
+#import 
+
+//--- frameworks/B.framework/Headers/B.h
+#import 
+//--- frameworks/B.framework/Modules/module.modulemap
+framework module B { umbrella header "B.h" }
+
+//--- overlay.json.template
+{
+  "case-sensitive": "false",
+  "version": 0,
+  "roots": [
+{
+  "external-contents": "DIR/real/A.modulemap",
+  "name": "DIR/frameworks/A.framework/Modules/module.modulemap",
+  "type": "file"
+},
+{
+  "external-contents": "DIR/real/A.private.modulemap",
+  "name": "DIR/frameworks/A.framework/Modules/module.private.modulemap",
+  "type": "file"
+},
+  ]
+}
+
+//--- cdb.json.template
+[
+{
+  "file": "DIR/tu1.m",
+  "directory": "DIR",
+  "command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A -ivfsoverlay DIR/overlay.json -F DIR/frameworks -fsyntax-only DIR/tu1.m"
+},
+{
+  "file": "DIR/tu2.m",
+  "directory": "DIR",
+  "command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A -ivfsoverlay DIR/overlay.json -F DIR/frameworks -fsyntax-only DIR/tu2.m"
+},
+{
+  "file": "DIR/tu3.m",
+  "directory": "DIR",
+  "command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A -ivfsoverlay DIR/overlay.json -F DIR/frameworks -fsyntax-only DIR/tu3.m"
+}
+]
+
+//--- tu1.m
+#import 
+
+//--- tu2.m
+#import 
+
+//--- tu3.m
+#import 
+struct A { float x; }; // expected-error {{incompatible definitions}} expected-note {{type 'float' here}}
+// expected-note@frameworks/A.framework/Headers/A.h:1 {{type 'int' here}}
+
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
+// RUN: sed -e "s|DIR|%/t|g" %t/overlay.json.template > %t/overlay.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -j 1 > %t/result.json
+// RUN: cat %t/result.json | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t
+// CHECK:  {
+// CHECK:"modules": [
+// CHECK:  {
+// CHECK:"clang-module-deps": []
+// CHECK:"command-line": [
+// CHECK:  "-x"
+// CHECK-NEXT: "objective-c"
+// CHECK-NEXT: "[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
+// CHECK:]
+// CHECK:"name": "A"
+// CHECK:  }
+// CHECK:  {
+// CHECK:"clang-module-deps": [
+// CHECK:  {
+// CHECK:"module-name": "A"
+// CHECK:  }
+// CHECK:]
+// CHECK:"command-line": [
+// CHECK:  "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap",
+// CHECK:  "-x"
+// CHECK-NEXT: "objective-c"
+// CHECK-NEXT: "[[PREFIX]]/frameworks/B.framework/Modules/module.modulemap"
+// CHECK:]
+// CHECK:"name": "B"
+// CHECK:  }
+
+// CHECK:"translation-units": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "commands": [
+// CHECK:  {
+// CHECK:"command-line": [
+// CHECK:  "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
+// CHECK:  "-fmodule-name=A"
+// CHECK:],
+// CHECK:"input-file": "[[PREFIX]]/tu1.m"
+// CHECK-NEXT: }
+// CHECK:]
+// CHECK:  }
+// CHECK-NEXT: {
+// CHECK-NEXT:   "commands": [
+// CHECK:  {
+// CHECK:"command-line": [
+// CHECK:  "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
+// CHECK:  "-fmodule-name=A"
+// CHECK:],
+// CHECK:

[PATCH] D142412: [clang-format] Put peekNextToken(/*SkipComment=*/true) to good use

2023-01-24 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3592-3601
 case tok::kw_bool:
   // bool is only allowed if it is directly followed by a paren for a cast:
   // concept C = bool(...);
   // and bool is the only type, all other types as cast must be inside a
   // cast to bool an thus are handled by the other cases.
   if (Tokens->peekNextToken()->isNot(tok::l_paren))
 return;

MyDeveloperDay wrote:
> rymiel wrote:
> > owenpan wrote:
> > > rymiel wrote:
> > > > rymiel wrote:
> > > > > owenpan wrote:
> > > > > > We should pass `true` to `peekNextToken()` on Line 3597 here, but 
> > > > > > removing this entire case would have no effect on the existing unit 
> > > > > > test (Line 23693 in FormatTest.cpp). @HazardyKnusperkeks any idea?
> > > > > The peeking is there because of https://reviews.llvm.org/D134325, it 
> > > > > has no format tests, only an annotator test
> > > > Also, I don't think that function is involved in concept declarations 
> > > > since https://reviews.llvm.org/D140339
> > > So which tests were meant to check the `kw_bool` case here?
> > Well, originally the one you mentioned on line 23693, but since the code 
> > paths have been changed, I think it's really only the one added in 
> > https://reviews.llvm.org/D134325
> I love the new annotator tests, but we should probably always try to add a 
> verifyFormat test as well even if its trivial in the future, just so we have 
> some context as to what type of code warranted the change.
As far as I can see it does not only can be removed, it should be removed.

`bool` can not appear on the top level of a requires clause. As @rymiel said it 
is there for the concepts, which are now handled differently.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142412

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


[PATCH] D142499: [Clang][AMDGPU] Set LTO CG opt level based on Clang option

2023-01-24 Thread Scott Linder via Phabricator via cfe-commits
scott.linder created this revision.
Herald added subscribers: kosarev, inglorion, tpr, dstuttard, yaxunl, kzhuravl.
Herald added a project: All.
scott.linder requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, wdng.
Herald added a project: clang.

For AMDGCN default to mapping --lto-O# to --lto-CGO# in a 1:1 manner
(i.e. clang -O implies --lto-O and --lto-CGO).

Ensure there is a means to override this via -Xoffload-linker and begin
to claim these arguments to avoid incorrect warnings that they are not
used.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142499

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/test/Driver/hip-toolchain-opt.hip


Index: clang/test/Driver/hip-toolchain-opt.hip
===
--- clang/test/Driver/hip-toolchain-opt.hip
+++ clang/test/Driver/hip-toolchain-opt.hip
@@ -57,6 +57,14 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck --check-prefixes=ALL,Og %s
 
+// RUN: %clang -### -O0 \
+// RUN:   -Xoffload-linker --lto-CGO2 \
+// RUN:   --target=x86_64-unknown-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx900 \
+// RUN:   -c -nogpulib \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck --check-prefixes=ALL,O0-CGO2 %s
+
 // ALL: "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // DEFAULT-NOT: "-O{{.}}"
 // O0-SAME: "-O0"
@@ -66,6 +74,8 @@
 // Os-SAME: "-Os"
 // Oz-SAME: "-Oz"
 // Og-SAME: "-Og"
+// O0-CGO2-SAME: "-O0"
+// O0-CGO2-NOT: "--lto-CGO2"
 
 // ALL-NOT: "{{.*}}opt"
 
@@ -74,12 +84,22 @@
 // ALL: "{{.*}}lld{{.*}}" {{.*}} "-plugin-opt=mcpu=gfx900"
 // DEFAULT-NOT: "-plugin-opt=O{{.*}}"
 // O0-SAME: "-plugin-opt=O0"
+// O0-SAME: "--lto-CGO0"
 // O1-SAME: "-plugin-opt=O1"
+// O1-SAME: "--lto-CGO1"
 // O2-SAME: "-plugin-opt=O2"
+// O2-SAME: "--lto-CGO2"
 // O3-SAME: "-plugin-opt=O3"
+// O3-SAME: "--lto-CGO3"
 // Os-SAME: "-plugin-opt=O2"
+// Os-SAME: "--lto-CGO2"
 // Oz-SAME: "-plugin-opt=O2"
+// Oz-SAME: "--lto-CGO2"
 // Og-SAME: "-plugin-opt=O1"
+// Og-SAME: "--lto-CGO1"
+// O0-CGO2-SAME: "-plugin-opt=O0"
+// O0-CGO2-SAME: "--lto-CGO0"
+// O0-CGO2-SAME: "--lto-CGO2"
 
 // ALL: "-cc1" "-triple" "x86_64-unknown-linux-gnu"
 // DEFAULT-NOT: "-O{{.}}"
@@ -90,3 +110,5 @@
 // Os-SAME: "-Os"
 // Oz-SAME: "-Oz"
 // Og-SAME: "-Og"
+// O0-CGO2-SAME: "-O0"
+// O0-CGO2-NOT: "--lto-CGO2"
Index: clang/lib/Driver/ToolChains/HIPAMD.cpp
===
--- clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -152,8 +152,10 @@
 
   addLinkerCompressDebugSectionsOption(TC, Args, LldArgs);
 
-  for (auto *Arg : Args.filtered(options::OPT_Xoffload_linker))
+  for (auto *Arg : Args.filtered(options::OPT_Xoffload_linker)) {
 LldArgs.push_back(Arg->getValue(1));
+Arg->claim();
+  }
 
   LldArgs.append({"-o", Output.getFilename()});
   for (auto Input : Inputs)
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -567,6 +567,7 @@
   ArgStringList , const InputInfo ,
   const InputInfo , bool IsThinLTO) {
   const bool IsOSAIX = ToolChain.getTriple().isOSAIX();
+  const bool IsAMDGCN = ToolChain.getTriple().isAMDGCN();
   const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
   const Driver  = ToolChain.getDriver();
   if (llvm::sys::path::filename(Linker) != "ld.lld" &&
@@ -631,9 +632,12 @@
 OOpt = "2";
 } else if (A->getOption().matches(options::OPT_O0))
   OOpt = "0";
-if (!OOpt.empty())
+if (!OOpt.empty()) {
   CmdArgs.push_back(
   Args.MakeArgString(Twine(PluginOptPrefix) + ExtraDash + "O" + OOpt));
+  if (IsAMDGCN)
+CmdArgs.push_back(Args.MakeArgString(Twine("--lto-CGO") + OOpt));
+}
   }
 
   if (Args.hasArg(options::OPT_gsplit_dwarf))


Index: clang/test/Driver/hip-toolchain-opt.hip
===
--- clang/test/Driver/hip-toolchain-opt.hip
+++ clang/test/Driver/hip-toolchain-opt.hip
@@ -57,6 +57,14 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck --check-prefixes=ALL,Og %s
 
+// RUN: %clang -### -O0 \
+// RUN:   -Xoffload-linker --lto-CGO2 \
+// RUN:   --target=x86_64-unknown-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx900 \
+// RUN:   -c -nogpulib \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck --check-prefixes=ALL,O0-CGO2 %s
+
 // ALL: "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // DEFAULT-NOT: "-O{{.}}"
 // O0-SAME: "-O0"
@@ -66,6 +74,8 @@
 // Os-SAME: "-Os"
 // Oz-SAME: "-Oz"
 // Og-SAME: "-Og"
+// O0-CGO2-SAME: "-O0"
+// O0-CGO2-NOT: "--lto-CGO2"
 
 // ALL-NOT: "{{.*}}opt"
 
@@ -74,12 +84,22 @@
 // ALL: "{{.*}}lld{{.*}}" {{.*}} 

[PATCH] D131632: [clang] Enable output of SARIF diagnostics

2023-01-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/Frontend/sarif-diagnostics.cpp:8
+// Omit filepath to llvm project directory
+// CHECK: 
clang/test/Frontend/sarif-diagnostics.cpp"},"mimeType":"text/plain","roles":["resultFile"]}],"columnKind":"unicodeCodePoints","results":[{"level":"error","locations":[{"physicalLocation":{"artifactLocation":{"index":0},"region":{"endColumn":1,"startColumn":1,"startLine":12}}}],"message":{"text":"'main'
 must return 
'int'"},"ruleId":"3465","ruleIndex":0},{"level":"error","locations":[{"physicalLocation":{"artifactLocation":{"index":0},"region":{"endColumn":11,"startColumn":11,"startLine":13}}}],"message":{"text":"use
 of undeclared identifier 
'hello'"},"ruleId":"4604","ruleIndex":1},{"level":"error","locations":[{"physicalLocation":{"artifactLocation":{"index":0},"region":{"endColumn":17,"startColumn":17,"startLine":15}}}],"message":{"text":"invalid
 digit 'a' in decimal 
constant"},"ruleId":"898","ruleIndex":2},{"level":"warning","locations":[{"physicalLocation":{"artifactLocation":{"index":0},"region":{"endColumn":5,"startColumn":5,"startLine":19}}}],"message":{"text":"misleading
 indentation; statement is not part of the previous 
'if'"},"ruleId":"1806","ruleIndex":3},{"level":"note","locations":[{"physicalLocation":{"artifactLocation":{"index":0},"region":{"endColumn":3,"startColumn":3,"startLine":17}}}],"message":{"text":"previous
 statement is 
here"},"ruleId":"1730","ruleIndex":4},{"level":"warning","locations":[{"physicalLocation":{"artifactLocation":{"index":0},"region":{"endColumn":10,"startColumn":10,"startLine":18}}}],"message":{"text":"unused
 variable 
'Yes'"},"ruleId":"6539","ruleIndex":5},{"level":"error","locations":[{"physicalLocation":{"artifactLocation":{"index":0},"region":{"endColumn":12,"startColumn":12,"startLine":21}}}],"message":{"text":"use
 of undeclared identifier 
'hi'"},"ruleId":"4604","ruleIndex":6},{"level":"error","locations":[{"physicalLocation":{"artifactLocation":{"index":0},"region":{"endColumn":1,"startColumn":1,"startLine":23}}}],"message":{"text":"extraneous
 closing brace 
('}')"},"ruleId":"1399","ruleIndex":7},{"level":"error","locations":[{"physicalLocation":{"artifactLocation":{"index":0},"region":{"endColumn":6,"endLine":27,"startColumn":5,"startLine":27}}},{"physicalLocation":{"artifactLocation":{"index":0},"region":{"endColumn":10,"endLine":27,"startColumn":9,"startLine":27}}},{"physicalLocation":{"artifactLocation":{"index":0},"region":{"endColumn":7,"startColumn":7,"startLine":27}}}],"message":{"text":"invalid
 operands to binary expression ('t1' and 
't1')"},"ruleId":"4539","ruleIndex":8}],"tool":{"driver":{"fullName":"","informationUri":"https://clang.llvm.org/docs/UsersManual.html","language":"en-US","name":"clang","rules":[{"defaultConfiguration":{"enabled":true,"level":"error","rank":50},"fullDescription":{"text":""},"id":"3465","name":""},{"defaultConfiguration":{"enabled":true,"level":"error","rank":50},"fullDescription":{"text":""},"id":"4604","name":""},{"defaultConfiguration":{"enabled":true,"level":"error","rank":50},"fullDescription":{"text":""},"id":"898","name":""},{"defaultConfiguration":{"enabled":true,"level":"warning","rank":-1},"fullDescription":{"text":""},"id":"1806","name":""},{"defaultConfiguration":{"enabled":true,"level":"note","rank":-1},"fullDescription":{"text":""},"id":"1730","name":""},{"defaultConfiguration":{"enabled":true,"level":"warning","rank":-1},"fullDescription":{"text":""},"id":"6539","name":""},{"defaultConfiguration":{"enabled":true,"level":"error","rank":50},"fullDescription":{"text":""},"id":"4604","name":""},{"defaultConfiguration":{"enabled":true,"level":"error","rank":50},"fullDescription":{"text":""},"id":"1399","name":""},{"defaultConfiguration":{"enabled":true,"level":"error","rank":50},"fullDescription":{"text":""},"id":"4539","name":""}],"version":"16.0.0"}}}],"version":"2.1.0"}
+// CHECK: 2 warnings and 6 errors generated.

aaron.ballman wrote:
> tstellar wrote:
> > aaron.ballman wrote:
> > > uabelho wrote:
> > > > dyung wrote:
> > > > > dyung wrote:
> > > > > > Can this CHECK line be broken into smaller pieces? This test is 
> > > > > > failing on our internal bot, and I'm going crosseyed trying to 
> > > > > > figure out what the difference is because the line is 3741 
> > > > > > characters long!
> > > > > Is there any significance to the "ruleId" and "Id" values in this 
> > > > > test? If not, can we just use a regex to check for a number? Our 
> > > > > internal build with private changes is failing due to slightly 
> > > > > different numbers in some of the "ruleId" fields
> > > > +1 on this. We also get different "ruleId" and "Id" values downstream 
> > > > and it's quite painful trying to figure out where the diffs are in a 
> > > > +3700 character CHECK.
> > > I ran into this problem this morning as well. I've improved the situation 
> > > somewhat in b345be177d03166add391f090fd0288a23413934, but I think we 
> > 

[clang] 0647f4a - Drop a path component from the sarif diagnostics test; NFC

2023-01-24 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-01-24T15:37:53-05:00
New Revision: 0647f4a77a2f9aab84c961982193bea1a9eb1585

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

LOG: Drop a path component from the sarif diagnostics test; NFC

The test currently expects to be run in a directory named 'clang' but
that's not valid for our release tarballs. We don't actually care what
base directory the test is run from, so this removes the path component
entirely.

Added: 


Modified: 
clang/test/Frontend/sarif-diagnostics.cpp

Removed: 




diff  --git a/clang/test/Frontend/sarif-diagnostics.cpp 
b/clang/test/Frontend/sarif-diagnostics.cpp
index 3a35131cdb004..9a4e686389a2e 100644
--- a/clang/test/Frontend/sarif-diagnostics.cpp
+++ b/clang/test/Frontend/sarif-diagnostics.cpp
@@ -32,7 +32,7 @@ void f1(t1 x, t1 y) {
 // Omit exact length of this file
 // CHECK: ,"location":{"index":0,"uri":"file://
 // Omit filepath to llvm project directory
-// CHECK: 
clang/test/Frontend/sarif-diagnostics.cpp"},"mimeType":"text/plain","roles":["resultFile"]}],"columnKind":"unicodeCodePoints","results":
+// CHECK: 
test/Frontend/sarif-diagnostics.cpp"},"mimeType":"text/plain","roles":["resultFile"]}],"columnKind":"unicodeCodePoints","results":
 // CHECK: 
[{"level":"error","locations":[{"physicalLocation":{"artifactLocation":{"index":0,"uri":"file://
 // CHECK: 
{"endColumn":1,"startColumn":1,"startLine":12}}}],"message":{"text":"'main' 
must return 'int'"},"ruleId":"{{[0-9]+}}","ruleIndex":0},
 // CHECK: 
{"level":"error","locations":[{"physicalLocation":{"artifactLocation":{"index":0,"uri":"file://



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


  1   2   3   4   >