[PATCH] D113250: [clang][driver] Add -fplugin-arg- to pass arguments to plugins

2021-11-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.

Thanks!


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

https://reviews.llvm.org/D113250

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


[PATCH] D110618: [HIPSPV][2/4] Add HIPSPV tool chain

2021-11-24 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki added a comment.

In D110618#3148501 , @Anastasia wrote:

> Could you please clarify the interface to SPIRV-LLVM-Translator tool, 
> specifically:
>
> - Does clang lookup the path to the translator or assume any default path?

HIPSPV primarily relies on the system’s PATH for locating the translator.

Additionally, the translator is sought in the same directory where the Clang 
driver is installed in. This is rather a side-effect than a feature. The 
directory is added to Clang’s internal search paths for looking up the 
`clang-offload-bundler` tool required by the HIPSPV tool chain.

> - Is there any diagnostic provided if the translator not installed/found?

Clang displays the following standard error if the translator is not found:

  error: unable to execute command: Executable "llvm-spirv" doesn't exist!



> - How does clang synchronize with the translator versions i.e. some LLVM IR 
> might not be ingested by certain version of the translator. Would this 
> results in the translator ICE or error in the translator, or is it something 
> that can be diagnosed early by clang or during clang build/installation?

A version mismatch may result in an error in the translator. This is a known 
issue and a reason we want to switch to the SPIR-V backend when it lands on the 
LLVM - **the translator is meant to be used temporarily by the HIPSPV**. The 
synchronization could be improved by having the Clang to seek a SPIR-V 
Translator binary that is named with the LLVM version it has been built against 
- e.g. “llvm-spirv-14” for the next LLVM release.

AFAIK, Clang’s infrastructure does not support early diagnosis on external 
tools. The diagnosis during Clang’s build and installation probably won’t 
matter much if the Clang is distributed as binary to other systems - the 
destination system might not have the required translator version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110618

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


[PATCH] D113250: [clang][driver] Add -fplugin-arg- to pass arguments to plugins

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

Hey @MaskRay, I know you've already approved but just to be sure: does the last 
round of changes look good?

Thanks


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

https://reviews.llvm.org/D113250

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


[PATCH] D114058: [clangd] Add ObjC method support to prepareCallHierarchy

2021-11-24 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D114058#3150606 , @kadircet wrote:

> thanks, lgtm! let me know of your email address (for commit attribution) if 
> you want me to land this for you.

While I don't see it surfaced anywhere in the Phabricator UI, there is in fact 
an email address associated with this changeset, and it shows up in the commit 
created by `arc patch D114058`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114058

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


[PATCH] D114025: [clang][NFC] Inclusive terms: replace some uses of sanity in clang

2021-11-24 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

@ZarkoCA If you are planning to do a lot of this, it might be good to write a 
script (or a clang-tidy check even) that we can add to CI, so these terms don't 
get re-introduced.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114025

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


[PATCH] D111100: enable plugins for clang-tidy

2021-11-24 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

This is probably just a draft, but please let me know what you think


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D00

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


[PATCH] D111100: enable plugins for clang-tidy

2021-11-24 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 389658.
vtjnash added a comment.

enable help


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D00

Files:
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,9 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
+
+# Plugins (loadable modules)
+if config.has_plugins and config.llvm_plugin_ext:
+config.available_features.add('plugins')
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,50 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext | FileCheck %s
+// CHECK: Enabled checks:
+// CHECK-NEXT:mytest
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  //void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  //void check(const ast_matchers::MatchFinder::MatchResult ) override;
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck("mytest");
+  }
+};
+} // namespace
+
+namespace clang {
+namespace tidy {
+
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTestModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/test/CMakeLists.txt
===
--- clang-tools-extra/test/CMakeLists.txt
+++ clang-tools-extra/test/CMakeLists.txt
@@ -17,6 +17,7 @@
 
 llvm_canonicalize_cmake_booleans(
   CLANG_TIDY_ENABLE_STATIC_ANALYZER
+  LLVM_ENABLE_PLUGINS
   )
 
 configure_lit_site_cfg(
@@ -89,3 +90,17 @@
 add_lit_testsuites(CLANG-EXTRA ${CMAKE_CURRENT_SOURCE_DIR}
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
   )
+
+llvm_add_library(
+CTTestTidyModule
+MODULE clang-tidy/CTTestTidyModule.cpp
+PLUGIN_TOOL clang-tidy
+DEPENDS clang-tidy-headers)
+
+target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}")
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  set(LLVM_LINK_COMPONENTS
+Support
+  )
+endif()
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -218,6 +218,14 @@
 --list-checks  -
   

[PATCH] D111100: enable plugins for clang-tidy

2021-11-24 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 389656.
vtjnash added a comment.

oops


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D00

Files:
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,9 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
+
+# Plugins (loadable modules)
+if config.has_plugins and config.llvm_plugin_ext:
+config.available_features.add('plugins')
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,50 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext | FileCheck %s
+// CHECK: Enabled checks:
+// CHECK-NEXT:mytest
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  //void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  //void check(const ast_matchers::MatchFinder::MatchResult ) override;
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck("mytest");
+  }
+};
+} // namespace
+
+namespace clang {
+namespace tidy {
+
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTestModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/test/CMakeLists.txt
===
--- clang-tools-extra/test/CMakeLists.txt
+++ clang-tools-extra/test/CMakeLists.txt
@@ -17,6 +17,7 @@
 
 llvm_canonicalize_cmake_booleans(
   CLANG_TIDY_ENABLE_STATIC_ANALYZER
+  LLVM_ENABLE_PLUGINS
   )
 
 configure_lit_site_cfg(
@@ -89,3 +90,17 @@
 add_lit_testsuites(CLANG-EXTRA ${CMAKE_CURRENT_SOURCE_DIR}
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
   )
+
+llvm_add_library(
+CTTestTidyModule
+MODULE clang-tidy/CTTestTidyModule.cpp
+PLUGIN_TOOL clang-tidy
+DEPENDS clang-tidy-headers)
+
+target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}")
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  set(LLVM_LINK_COMPONENTS
+Support
+  )
+endif()
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -218,6 +218,14 @@
 --list-checks  -
  

[PATCH] D111100: enable plugins for clang-tidy

2021-11-24 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 389655.
vtjnash added a comment.

oops


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D00

Files:
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,9 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
+
+# Plugins (loadable modules)
+if config.has_plugins and config.llvm_plugin_ext:
+config.available_features.add('plugins')
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,50 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext | FileCheck %s
+// CHECK: Enabled checks:
+// CHECK-NEXT:mytest
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  //void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  //void check(const ast_matchers::MatchFinder::MatchResult ) override;
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck("mytest");
+  }
+};
+} // namespace
+
+namespace clang {
+namespace tidy {
+
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTestModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/test/CMakeLists.txt
===
--- clang-tools-extra/test/CMakeLists.txt
+++ clang-tools-extra/test/CMakeLists.txt
@@ -17,6 +17,7 @@
 
 llvm_canonicalize_cmake_booleans(
   CLANG_TIDY_ENABLE_STATIC_ANALYZER
+  LLVM_ENABLE_PLUGINS
   )
 
 configure_lit_site_cfg(
@@ -89,3 +90,17 @@
 add_lit_testsuites(CLANG-EXTRA ${CMAKE_CURRENT_SOURCE_DIR}
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
   )
+
+llvm_add_library(
+CTTestTidyModule
+MODULE clang-tidy/CTTestTidyModule.cpp
+PLUGIN_TOOL clang-tidy
+DEPENDS clang-tidy-headers)
+
+target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}")
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  set(LLVM_LINK_COMPONENTS
+Support
+  )
+endif()
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -218,6 +218,14 @@
 --list-checks  -
  List all enabled checks and exit. Use with
  

[PATCH] D111100: enable plugins for clang-tidy

2021-11-24 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 389653.
vtjnash added a comment.

add release notes, docs mention, and test example


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D00

Files:
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,5 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,50 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext | FileCheck %s
+// CHECK: Enabled checks:
+// CHECK-NEXT:mytest
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  //void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  //void check(const ast_matchers::MatchFinder::MatchResult ) override;
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck("mytest");
+  }
+};
+} // namespace
+
+namespace clang {
+namespace tidy {
+
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTestModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/test/CMakeLists.txt
===
--- clang-tools-extra/test/CMakeLists.txt
+++ clang-tools-extra/test/CMakeLists.txt
@@ -17,6 +17,7 @@
 
 llvm_canonicalize_cmake_booleans(
   CLANG_TIDY_ENABLE_STATIC_ANALYZER
+  LLVM_ENABLE_PLUGINS
   )
 
 configure_lit_site_cfg(
@@ -89,3 +90,17 @@
 add_lit_testsuites(CLANG-EXTRA ${CMAKE_CURRENT_SOURCE_DIR}
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
   )
+
+llvm_add_library(
+CTTestTidyModule
+MODULE clang-tidy/CTTestTidyModule.cpp
+PLUGIN_TOOL clang-tidy
+DEPENDS clang-tidy-headers)
+
+target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}")
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  set(LLVM_LINK_COMPONENTS
+Support
+  )
+endif()
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -218,6 +218,14 @@
 --list-checks  -
  List all enabled checks and exit. Use with
 

[PATCH] D111100: enable plugins for clang-tidy

2021-11-24 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 389652.
vtjnash added a comment.
Herald added a subscriber: arphaman.

add release notes, docs mention, and test example


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D00

Files:
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,5 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,50 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext | FileCheck %s
+// CHECK: Enabled checks:
+// CHECK-NEXT:mytest
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  //void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  //void check(const ast_matchers::MatchFinder::MatchResult ) override;
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck("mytest");
+  }
+};
+} // namespace
+
+namespace clang {
+namespace tidy {
+
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTestModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/test/CMakeLists.txt
===
--- clang-tools-extra/test/CMakeLists.txt
+++ clang-tools-extra/test/CMakeLists.txt
@@ -17,6 +17,7 @@
 
 llvm_canonicalize_cmake_booleans(
   CLANG_TIDY_ENABLE_STATIC_ANALYZER
+  LLVM_ENABLE_PLUGINS
   )
 
 configure_lit_site_cfg(
@@ -89,3 +90,17 @@
 add_lit_testsuites(CLANG-EXTRA ${CMAKE_CURRENT_SOURCE_DIR}
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
   )
+
+llvm_add_library(
+CTTestTidyModule
+MODULE clang-tidy/CTTestTidyModule.cpp
+PLUGIN_TOOL clang-tidy
+DEPENDS clang-tidy-headers)
+
+target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}")
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  set(LLVM_LINK_COMPONENTS
+Support
+  )
+endif()
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -218,6 +218,14 @@
 --list-checks  -
  List all enabled checks and exit. Use with
  -checks=* to list all available checks.
+

[PATCH] D114571: add release notes, docs mention, and test example

2021-11-24 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash created this revision.
Herald added subscribers: arphaman, mgorny.
vtjnash requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114571

Files:
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,5 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,50 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext | FileCheck %s
+// CHECK: Enabled checks:
+// CHECK-NEXT:mytest
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  //void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  //void check(const ast_matchers::MatchFinder::MatchResult ) override;
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck("mytest");
+  }
+};
+} // namespace
+
+namespace clang {
+namespace tidy {
+
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTestModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/test/CMakeLists.txt
===
--- clang-tools-extra/test/CMakeLists.txt
+++ clang-tools-extra/test/CMakeLists.txt
@@ -17,6 +17,7 @@
 
 llvm_canonicalize_cmake_booleans(
   CLANG_TIDY_ENABLE_STATIC_ANALYZER
+  LLVM_ENABLE_PLUGINS
   )
 
 configure_lit_site_cfg(
@@ -89,3 +90,17 @@
 add_lit_testsuites(CLANG-EXTRA ${CMAKE_CURRENT_SOURCE_DIR}
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
   )
+
+llvm_add_library(
+CTTestTidyModule
+MODULE clang-tidy/CTTestTidyModule.cpp
+PLUGIN_TOOL clang-tidy
+DEPENDS clang-tidy-headers)
+
+target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}")
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  set(LLVM_LINK_COMPONENTS
+Support
+  )
+endif()
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -218,6 +218,14 @@
 --list-checks  -
  List all enabled checks and exit. Use with
  -checks=* to list all available checks.
+-load= -
+  

[PATCH] D114505: [clang][unittests] Fix a clang unittest linking issue

2021-11-24 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 389650.
SixWeining retitled this revision from "[clang][unittests]Fix a clang 
unittest linking issue" to "[clang][unittests] Fix a clang unittest linking 
issue".
SixWeining edited the summary of this revision.
SixWeining added a comment.
Herald added a subscriber: pengfei.

Modify the summary to be more descriptive.


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

https://reviews.llvm.org/D114505

Files:
  clang/unittests/Basic/CMakeLists.txt


Index: clang/unittests/Basic/CMakeLists.txt
===
--- clang/unittests/Basic/CMakeLists.txt
+++ clang/unittests/Basic/CMakeLists.txt
@@ -18,5 +18,9 @@
   clangAST
   clangBasic
   clangLex
-  LLVMTestingSupport
   )
+
+target_link_libraries(BasicTests
+  PRIVATE
+  LLVMTestingSupport
+)


Index: clang/unittests/Basic/CMakeLists.txt
===
--- clang/unittests/Basic/CMakeLists.txt
+++ clang/unittests/Basic/CMakeLists.txt
@@ -18,5 +18,9 @@
   clangAST
   clangBasic
   clangLex
-  LLVMTestingSupport
   )
+
+target_link_libraries(BasicTests
+  PRIVATE
+  LLVMTestingSupport
+)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114569: [PowerPC] Require htm feature for HTM builtins

2021-11-24 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf created this revision.
qiucf added reviewers: nemanjai, jsji, kbarton, PowerPC.
Herald added a subscriber: shchenz.
qiucf requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114569

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-htm.c

Index: clang/test/CodeGen/builtins-ppc-htm.c
===
--- clang/test/CodeGen/builtins-ppc-htm.c
+++ clang/test/CodeGen/builtins-ppc-htm.c
@@ -1,62 +1,88 @@
 // REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -target-feature +altivec -target-feature +htm -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: not %clang_cc1 -target-feature +altivec -target-feature -htm -triple powerpc64-unknown-unknown -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=ERROR
 
 void test1(long int *r, int code, long int *a, long int *b) {
 // CHECK-LABEL: define{{.*}} void @test1
 
   r[0] = __builtin_tbegin (0);
 // CHECK: @llvm.ppc.tbegin
+// ERROR: error: this builtin requires HTM to be enabled
   r[1] = __builtin_tbegin (1);
 // CHECK: @llvm.ppc.tbegin
+// ERROR: error: this builtin requires HTM to be enabled
   r[2] = __builtin_tend (0);
 // CHECK: @llvm.ppc.tend
+// ERROR: error: this builtin requires HTM to be enabled
   r[3] = __builtin_tendall ();
 // CHECK: @llvm.ppc.tendall
+// ERROR: error: this builtin requires HTM to be enabled
 
   r[4] = __builtin_tabort (code);
 // CHECK: @llvm.ppc.tabort
+// ERROR: error: this builtin requires HTM to be enabled
   r[5] = __builtin_tabort (0x1);
 // CHECK: @llvm.ppc.tabort
+// ERROR: error: this builtin requires HTM to be enabled
   r[6] = __builtin_tabortdc (0xf, a[0], b[0]);
 // CHECK: @llvm.ppc.tabortdc
+// ERROR: error: this builtin requires HTM to be enabled
   r[7] = __builtin_tabortdci (0xf, a[1], 0x1);
 // CHECK: @llvm.ppc.tabortdc
+// ERROR: error: this builtin requires HTM to be enabled
   r[8] = __builtin_tabortwc (0xf, a[2], b[2]);
 // CHECK: @llvm.ppc.tabortwc
+// ERROR: error: this builtin requires HTM to be enabled
   r[9] = __builtin_tabortwci (0xf, a[3], 0x1);
 // CHECK: @llvm.ppc.tabortwc
+// ERROR: error: this builtin requires HTM to be enabled
 
   r[10] = __builtin_tcheck ();
 // CHECK: @llvm.ppc.tcheck
+// ERROR: error: this builtin requires HTM to be enabled
   r[11] = __builtin_trechkpt ();
 // CHECK: @llvm.ppc.trechkpt
+// ERROR: error: this builtin requires HTM to be enabled
   r[12] = __builtin_treclaim (0);
 // CHECK: @llvm.ppc.treclaim
+// ERROR: error: this builtin requires HTM to be enabled
   r[13] = __builtin_tresume ();
 // CHECK: @llvm.ppc.tresume
+// ERROR: error: this builtin requires HTM to be enabled
   r[14] = __builtin_tsuspend ();
 // CHECK: @llvm.ppc.tsuspend
+// ERROR: error: this builtin requires HTM to be enabled
   r[15] = __builtin_tsr (0);
 // CHECK: @llvm.ppc.tsr
+// ERROR: error: this builtin requires HTM to be enabled
 
   r[16] = __builtin_ttest ();
 // CHECK: @llvm.ppc.ttest
+// ERROR: error: this builtin requires HTM to be enabled
 
   r[17] = __builtin_get_texasr ();
 // CHECK: @llvm.ppc.get.texasr
+// ERROR: error: this builtin requires HTM to be enabled
   r[18] = __builtin_get_texasru ();
 // CHECK: @llvm.ppc.get.texasru
+// ERROR: error: this builtin requires HTM to be enabled
   r[19] = __builtin_get_tfhar ();
 // CHECK: @llvm.ppc.get.tfhar
+// ERROR: error: this builtin requires HTM to be enabled
   r[20] = __builtin_get_tfiar ();
 // CHECK: @llvm.ppc.get.tfiar
+// ERROR: error: this builtin requires HTM to be enabled
 
   __builtin_set_texasr (a[21]);
 // CHECK: @llvm.ppc.set.texasr
+// ERROR: error: this builtin requires HTM to be enabled
   __builtin_set_texasru (a[22]);
 // CHECK: @llvm.ppc.set.texasru
+// ERROR: error: this builtin requires HTM to be enabled
   __builtin_set_tfhar (a[23]);
 // CHECK: @llvm.ppc.set.tfhar
+// ERROR: error: this builtin requires HTM to be enabled
   __builtin_set_tfiar (a[24]);
 // CHECK: @llvm.ppc.set.tfiar
+// ERROR: error: this builtin requires HTM to be enabled
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3496,14 +3496,43 @@
   case PPC::BI__builtin_altivec_dss:
 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 3);
   case PPC::BI__builtin_tbegin:
-  case PPC::BI__builtin_tend: i = 0; l = 0; u = 1; break;
-  case PPC::BI__builtin_tsr: i = 0; l = 0; u = 7; break;
+  case PPC::BI__builtin_tend:
+return SemaBuiltinConstantArgRange(TheCall, 0, 0, 1) ||
+   SemaFeatureCheck(*this, TheCall, "htm",
+diag::err_ppc_builtin_requires_htm);
+  case PPC::BI__builtin_tsr:
+return SemaBuiltinConstantArgRange(TheCall, 0, 0, 7) ||
+   SemaFeatureCheck(*this, TheCall, "htm",
+

[PATCH] D114143: [OpenMP][IRBuilder] Fix createSections

2021-11-24 Thread Shraiysh via Phabricator via cfe-commits
shraiysh added a comment.

Ping!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114143

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


[PATCH] D114522: [clangd] Add canonical type to hover

2021-11-24 Thread liu hui via Phabricator via cfe-commits
lh123 added a comment.

Related discussions: D72498 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114522

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


[PATCH] D114522: [clangd] Add canonical type to hover

2021-11-24 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 389638.
lh123 added a comment.

format code and add testcase for template.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114522

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -46,7 +46,9 @@
  HI.Documentation = "Best foo ever.";
  HI.Definition = "void foo()";
  HI.ReturnType = "void";
+ HI.CanonicalReturnType = "void";
  HI.Type = "void ()";
+ HI.CanonicalType = "void ()";
  HI.Parameters.emplace();
}},
   // Inside namespace
@@ -63,7 +65,9 @@
  HI.Documentation = "Best foo ever.";
  HI.Definition = "void foo()";
  HI.ReturnType = "void";
+ HI.CanonicalReturnType = "void";
  HI.Type = "void ()";
+ HI.CanonicalType = "void ()";
  HI.Parameters.emplace();
}},
   // Field
@@ -82,6 +86,7 @@
  HI.Kind = index::SymbolKind::Field;
  HI.Definition = "char bar";
  HI.Type = "char";
+ HI.CanonicalType = "char";
  HI.Offset = 0;
  HI.Size = 1;
  HI.Padding = 7;
@@ -101,6 +106,7 @@
  HI.Kind = index::SymbolKind::Field;
  HI.Definition = "char bar";
  HI.Type = "char";
+ HI.CanonicalType = "char";
  HI.Size = 1;
  HI.Padding = 15;
  HI.AccessSpecifier = "public";
@@ -119,6 +125,7 @@
  HI.Kind = index::SymbolKind::Field;
  HI.Definition = "int x : 1";
  HI.Type = "int";
+ HI.CanonicalType = "int";
  HI.AccessSpecifier = "public";
}},
   // Local to class method.
@@ -138,6 +145,7 @@
  HI.Kind = index::SymbolKind::Variable;
  HI.Definition = "int bar";
  HI.Type = "int";
+ HI.CanonicalType = "int";
}},
   // Anon namespace and local scope.
   {R"cpp(
@@ -154,6 +162,7 @@
  HI.Kind = index::SymbolKind::Field;
  HI.Definition = "char bar";
  HI.Type = "char";
+ HI.CanonicalType = "char";
  HI.Offset = 0;
  HI.Size = 1;
  HI.AccessSpecifier = "public";
@@ -180,6 +189,7 @@
  HI.Kind = index::SymbolKind::Variable;
  HI.Definition = "Foo foo = Foo(5)";
  HI.Type = "Foo";
+ HI.CanonicalType = "Foo";
}},
   // Implicit template instantiation
   {R"cpp(
@@ -212,11 +222,16 @@
 class Foo {})cpp";
  HI.TemplateParameters = {
  {std::string("template  class"),
+  std::string("template  class"),
   std::string("C"), llvm::None},
- {std::string("typename"), llvm::None, std::string("char")},
- {std::string("int"), llvm::None, std::string("0")},
- {std::string("bool"), std::string("Q"), std::string("false")},
- {std::string("class..."), std::string("Ts"), llvm::None},
+ {std::string("typename"), std::string("typename"), llvm::None,
+  std::string("char")},
+ {std::string("int"), std::string("int"), llvm::None,
+  std::string("0")},
+ {std::string("bool"), std::string("bool"), std::string("Q"),
+  std::string("false")},
+ {std::string("class..."), std::string("class..."),
+  std::string("Ts"), llvm::None},
  };
}},
   // Function template
@@ -238,7 +253,9 @@
  HI.Kind = index::SymbolKind::Function;
  HI.Definition = "template <> void foo>()";
  HI.ReturnType = "void";
+ HI.CanonicalReturnType = "void";
  HI.Type = "void ()";
+ HI.CanonicalType = "void ()";
  HI.Parameters.emplace();
}},
   // Function decl
@@ -256,10 +273,13 @@
  HI.Kind = index::SymbolKind::Function;
  HI.Definition = "Foo foo(int, bool T = false)";
  HI.ReturnType = "Foo";
+ HI.CanonicalReturnType = "Foo";
  HI.Type = "Foo (int, bool)";
+ HI.CanonicalType = "Foo (int, bool)";
  HI.Parameters = {
- {std::string("int"), llvm::None, llvm::None},
- {std::string("bool"), std::string("T"), std::string("false")},
+ {std::string("int"), std::string("int"), llvm::None, llvm::None},
+ {std::string("bool"), std::string("bool"), std::string("T"),
+  std::string("false")},
  };
}},
   // Pointers to lambdas
@@ -277,10 +297,14 @@
  HI.Kind = index::SymbolKind::Variable;
  HI.Definition = "auto *c = ";
  HI.Type = "(lambda) **";
+ HI.CanonicalType = "(lambda) **";
 

[PATCH] D113925: [HIP] Add HIP scope atomic operations

2021-11-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:5587
 // the GNU atomics specification, but we enforce it, because if we didn't 
it
 // would be very confusing. FIXME:  For whom? How so?
 Diag(ExprRange.getBegin(), diag::err_atomic_op_needs_trivial_copy)

gandhi21299 wrote:
> gandhi21299 wrote:
> > rjmccall wrote:
> > > I'm confused about what's happening here.  You're editing comments to 
> > > make more tendentious claims, and then adding FIXMEs to make charged 
> > > questions about your own claims?  Did you consider just not editing the 
> > > comments?
> > Ahh I totally missed this, my apologies. I will revert this patch and get 
> > rid of this comment. Thanks for pointing it out.
> Actually, this comes from a different patch: 
> https://reviews.llvm.org/D114025#change-dkrDg1ZRTmhm
Ah, Phabricator is just being weird, then; sorry for the noise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113925

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


[PATCH] D114025: [clang][NFC] Inclusive terms: replace some uses of sanity in clang

2021-11-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added subscribers: rsmith, rjmccall.
rjmccall added a comment.

If you aren't sure what a comment means, please feel free to CC Richard or me, 
and we might be able to help.




Comment at: clang/include/clang/Analysis/CFG.h:520
 /// to keep receiving compiler warnings when we don't cover all enum values
 /// in a switch.
 NumKindsMinusOne = VirtualBaseBranch

Proper translation here is probably "assertions".   A "validity check" sounds 
like a semantic restriction on the source language.



Comment at: clang/lib/Sema/SemaChecking.cpp:5536
+// GCC does not enforce these rules for GNU atomics, but we do, because if
+// we didn't it would be very confusing [For whom? How so?]
 auto IsAllowedValueType = [&](QualType ValType) {

aaron.ballman wrote:
> 
Perhaps "but we do to help catch trivial type errors."



Comment at: clang/lib/Sema/SemaChecking.cpp:5578
+// the GNU atomics specification, but we enforce it, because if we didn't 
it
+// would be very confusing [For whom? How so?]
 Diag(ExprRange.getBegin(), diag::err_atomic_op_needs_trivial_copy)

aaron.ballman wrote:
> 
We enforce this for consistency with other atomics, which generally all require 
a trivially-copyable type because atomics just copy bits.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:9176
   // Don't check the implicit member of the anonymous union type.
-  // This is technically non-conformant, but sanity demands it.
+  // This is technically non-conformant, but validation tests demand it.
   return false;

Quuxplusone wrote:
> ZarkoCA wrote:
> > Quuxplusone wrote:
> > > Quuxplusone wrote:
> > > > Quuxplusone wrote:
> > > > > This comment seems incorrectly translated.
> > > > This comment //still// seems incorrectly translated.
> > > > Things we do "for sanity's sake" aren't necessarily //required//, 
> > > > technically; but we're doing them anyway, for sanity.
> > > "Don't check ... but check it anyway"?
> > Right, that didn't make sense :). I noticed that there were warnings for 
> > this case in SemaDecl.cpp AFAIU so edited the comment to state that. Should 
> > be better now? 
> Well, this version of the comment now gives the //impression// that it must 
> be clear to //someone//. ;) I don't understand its implications, but I also 
> don't know the code.
> 
> Specifically, I don't know what "This" refers to (grammatically) — "Anonymous 
> union types aren't conforming, but we support them anyway, and this is the 
> right thing to do with them"? "Our behavior in this case isn't conforming, 
> but it wouldn't make sense to do the conforming thing [wat]"? or something 
> else?
> 
> More fundamentally to //my// confusion (but not to that hypothetical other 
> someone), I don't know what "the implicit member of the anonymous union type" 
> actually means (in terms of the arcane details of C++), i.e., I personally 
> don't know when this codepath is hit or what its effect is when it does get 
> hit.
@rsmith probably has a better idea.  I think it's saying that we shouldn't fall 
down into the generic path for the implicit field created for an anonymous 
union, presumably because we do special-case checks on the members of the 
anonymous union just above this point.  I guess this isn't explicitly 
sanctioned by the standard but is the only sensible approach.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:12260
   // even if hidden by ordinary names, *except* in a dependent context
-  // where it's important for the sanity of two-phase lookup.
+  // where it's important for the validation of two-phase lookup.
   if (!IsInstantiation)

Quuxplusone wrote:
> Quuxplusone wrote:
> > This comment seems incorrectly translated.
> Perhaps just `// where they may be used by two-phase lookup.` (But this is 
> now just a nit.)
This comment seems to be missing something — I think the previous comment was 
implying that the language rule really needs tags to be hidden when 
instantiating a `using` declaration.  I don't know why that would be true, 
though; @rsmith might.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:1510-1511
 
-  // There doesn't seem to be an explicit rule against this but sanity demands
-  // we only construct objects with object types.
+  // There doesn't seem to be an explicit rule against this but validation
+  // testing demands we only construct objects with object types.
   if (Ty->isFunctionType())

Quuxplusone wrote:
> This comment is incorrectly translated. I'm not sure I understand what's 
> going on on this codepath, but it seems like the right comment is just
> `// Functions aren't objects, so they can't take initializers.`
> The original commenter would have added, `The Standard doesn't seem to say 
> this anywhere, but it makes sense, right?` However, I'm sure there must be 

[PATCH] D114326: Update the list of CUDA versions up to 11.5

2021-11-24 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:131
+  std::initializer_list Versions = {
+  "11.5", "11.4", "11.3", "11.2", "11.1", "11.0", "10.2", "10.1",
+  "10.0", "9.2",  "9.1",  "9.0",  "8.0",  "7.5",  "7.0"};

carlosgalvezp wrote:
> mojca wrote:
> > tra wrote:
> > > tra wrote:
> > > > mojca wrote:
> > > > > carlosgalvezp wrote:
> > > > > > mojca wrote:
> > > > > > > tra wrote:
> > > > > > > > tra wrote:
> > > > > > > > > mojca wrote:
> > > > > > > > > > kadircet wrote:
> > > > > > > > > > > looks like the list is getting big and hard to maintain. 
> > > > > > > > > > > considering that this is done only once per compiler 
> > > > > > > > > > > invocation (and we check for existence of directories 
> > > > > > > > > > > down in the loop anyway). what about throwing in an extra 
> > > > > > > > > > > directory listing to base-directories mentioned down 
> > > > > > > > > > > below and populate `Candidates` while preserving the 
> > > > > > > > > > > newest-version-first order?
> > > > > > > > > > I totally agree with the sentiment, and that was my initial 
> > > > > > > > > > thought as well, but with zero experience I was too scared 
> > > > > > > > > > to make any more significant changes.
> > > > > > > > > > 
> > > > > > > > > > I can try to come up with a new patch (that doesn't need 
> > > > > > > > > > further maintenance whenever a new CUDA version gets 
> > > > > > > > > > released) if that's what you are suggesting. I would 
> > > > > > > > > > nevertheless merge this one, and prepare a new more 
> > > > > > > > > > advanced patch separately, but that's finally your call.
> > > > > > > > > > 
> > > > > > > > > > What's your suggestion about D.SysRoot + "Program 
> > > > > > > > > > Files/..."? At the time when this function gets called it 
> > > > > > > > > > looks like D.SysRoot is empty (or at least my debugger says 
> > > > > > > > > > so) and in my case it resolves to D: while the CUDA support 
> > > > > > > > > > is installed under C:.
> > > > > > > > > > 
> > > > > > > > > > Is there any special LLVM-specific/preferrable way to 
> > > > > > > > > > iterate through directories?
> > > > > > > > > > 
> > > > > > > > > > (What I also miss a bit in the whole process in an option 
> > > > > > > > > > to simply say "I want CUDA 11.1" without the need to 
> > > > > > > > > > explicitly spell out the full path.)
> > > > > > > > > > 
> > > > > > > > > > If you provide me give some general guidelines, I'll 
> > > > > > > > > > prepare another, hopefully more future-proof patch.
> > > > > > > > > > 
> > > > > > > > > > (Side note: I'm not sure if I'm calling clang-format 
> > > > > > > > > > correctly, but if I call it, it keeps reformatting the rest 
> > > > > > > > > > of this file.)
> > > > > > > > > This whole list may no longer be particularly useful. The 
> > > > > > > > > most common use case on Linux, AFAICT, is to install only one 
> > > > > > > > > CUDA version using system-provided package manager.
> > > > > > > > > E.g. 
> > > > > > > > > https://packages.ubuntu.com/focal/amd64/nvidia-cuda-toolkit/filelist
> > > > > > > > > 
> > > > > > > > > TBH, I'm tempted to limit autodetection to only that one 
> > > > > > > > > system-default version and require user to use --cuda-path if 
> > > > > > > > > they need something else.
> > > > > > > > I think on windows (I mean the windows environment itself, not 
> > > > > > > > WSL), CUDA installer sets an environment variable which could 
> > > > > > > > be used to detect the default CUDA version, so it may warrant a 
> > > > > > > > windows-specific way to find it. 
> > > > > > > On Windows this is certainly not the case. Unless the 
> > > > > > > installation is changed manually, one always gets the new version 
> > > > > > > installed into a new directory.
> > > > > > > 
> > > > > > > I really do need multiple versions on Windows (and the ability to 
> > > > > > > pick an older one) if I want to compile a binary that works on 
> > > > > > > someone else's computer (if I compile against the latest CUDA, 
> > > > > > > users need "the latest" drivers that may sometimes not even be 
> > > > > > > available for their machine).
> > > > > > > 
> > > > > > > (That said, at least when using CMake, the selection needs to be 
> > > > > > > done by CMake anyway, and maybe CMake could be forced to specify 
> > > > > > > the correct flag automatically.)
> > > > > > > 
> > > > > > > So even if the functionality gets removed from non-Windows 
> > > > > > > platforms, it would be really nice to keep it for Windows.
> > > > > > > 
> > > > > > > Now, there are three "conflicting" feedbacks/suggestions above. I 
> > > > > > > can try to improve support, but it would be really helpful to 
> > > > > > > reach the consensus of what needs to be done before coding it.
> > > > > > > one always gets the new version installed into a new directory.
> > > > > > A similar thing happens on Linux.
> > > > 

[PATCH] D114411: [WIP][modules] Avoid deserializing Decls from hidden (sub)modules.

2021-11-24 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 389630.
vsapsai added a comment.

Switch from checking module visibility to checking if a module is imported.

Required to handle not re-exported modules - allow to deserialize decls from
them even if the modules aren't visible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114411

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Sema/SemaModule.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/Modules/ambiguous-enum-lookup.m

Index: clang/test/Modules/ambiguous-enum-lookup.m
===
--- /dev/null
+++ clang/test/Modules/ambiguous-enum-lookup.m
@@ -0,0 +1,42 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache -F %t/Frameworks %t/test.m
+
+//--- Frameworks/NonModular.framework/Headers/NonModular.h
+#ifndef NonModular_NonModular_h
+#define NonModular_NonModular_h
+struct SomeStruct {
+int x;
+};
+
+enum SomeEnum {
+kEnumValue = 1,
+};
+#endif
+
+//--- Frameworks/PiecewiseVisible.framework/Headers/InitiallyVisible.h
+// empty
+
+//--- Frameworks/PiecewiseVisible.framework/Headers/InitiallyHidden.h
+#include 
+
+//--- Frameworks/PiecewiseVisible.framework/Modules/module.modulemap
+framework module PiecewiseVisible {
+  header "InitiallyVisible.h"
+  export *
+
+  explicit module HiddenPiece {
+header "InitiallyHidden.h"
+export *
+  }
+}
+
+//--- test.m
+#include 
+#include 
+#include 
+
+void test() {
+struct SomeStruct s;
+s.x = kEnumValue;
+}
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -269,6 +269,7 @@
 }
 
 void ASTDeclWriter::Visit(Decl *D) {
+  Record.push_back(Writer.getSubmoduleID(D->getOwningModule()));
   DeclVisitor::Visit(D);
 
   // Source locations require array (variable-length) abbreviations.  The
@@ -1911,6 +1912,7 @@
   // Abbreviation for DECL_FIELD
   Abv = std::make_shared();
   Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD));
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
   // Decl
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
   Abv->Add(BitCodeAbbrevOp(0));   // LexicalDeclContext
@@ -1944,6 +1946,7 @@
   // Abbreviation for DECL_OBJC_IVAR
   Abv = std::make_shared();
   Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR));
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
   // Decl
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
   Abv->Add(BitCodeAbbrevOp(0));   // LexicalDeclContext
@@ -1980,6 +1983,7 @@
   // Abbreviation for DECL_ENUM
   Abv = std::make_shared();
   Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM));
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
   // Redeclarable
   Abv->Add(BitCodeAbbrevOp(0));   // No redeclaration
   // Decl
@@ -2030,6 +2034,7 @@
   // Abbreviation for DECL_RECORD
   Abv = std::make_shared();
   Abv->Add(BitCodeAbbrevOp(serialization::DECL_RECORD));
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
   // Redeclarable
   Abv->Add(BitCodeAbbrevOp(0));   // No redeclaration
   // Decl
@@ -2092,6 +2097,7 @@
   // Abbreviation for DECL_PARM_VAR
   Abv = std::make_shared();
   Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR));
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
   // Redeclarable
   Abv->Add(BitCodeAbbrevOp(0));   // No redeclaration
   // Decl
@@ -2140,6 +2146,7 @@
   // Abbreviation for DECL_TYPEDEF
   Abv = std::make_shared();
   Abv->Add(BitCodeAbbrevOp(serialization::DECL_TYPEDEF));
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
   // Redeclarable
   Abv->Add(BitCodeAbbrevOp(0));   // No redeclaration
   // Decl
@@ -2169,6 +2176,7 @@
   // Abbreviation for DECL_VAR
   Abv = std::make_shared();
   Abv->Add(BitCodeAbbrevOp(serialization::DECL_VAR));
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
   // Redeclarable
   Abv->Add(BitCodeAbbrevOp(0));   // No redeclaration
   // Decl
@@ -2221,6 +2229,7 @@
   // Abbreviation for DECL_CXX_METHOD
   Abv = std::make_shared();
   Abv->Add(BitCodeAbbrevOp(serialization::DECL_CXX_METHOD));
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
   // RedeclarableDecl
   Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl
   // Decl
Index: 

[PATCH] D114430: [clang-format] NFC - recent changes caused clang-format to no longer be clang-formatted.

2021-11-24 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D114430#3152609 , 
@HazardyKnusperkeks wrote:

> In D114430#3151082 , @klimek wrote:
>
>> Thanks for cleaning up after me, and sorry for the mess - do y'all have 
>> clang-format set up as a presubmit or do you just remember to format 
>> manually?
>
> I think one "problem" is that it did not go through review, otherwise the 
> there were notes in the review. ;)

+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114430

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


[PATCH] D114025: [clang][NFC] Inclusive terms: replace some uses of sanity in clang

2021-11-24 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:5536
+// GCC does not enforce these rules for GNU atomics, but we do, because if
+// we didn't it would be very confusing. FIXME:  For whom? How so?
 auto IsAllowedValueType = [&](QualType ValType) {

Is this change really necessary? It is a confusing comment and probably not too 
helpful for the developers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114025

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


[PATCH] D113925: [HIP] Add HIP scope atomic operations

2021-11-24 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:5587
 // the GNU atomics specification, but we enforce it, because if we didn't 
it
 // would be very confusing. FIXME:  For whom? How so?
 Diag(ExprRange.getBegin(), diag::err_atomic_op_needs_trivial_copy)

gandhi21299 wrote:
> rjmccall wrote:
> > I'm confused about what's happening here.  You're editing comments to make 
> > more tendentious claims, and then adding FIXMEs to make charged questions 
> > about your own claims?  Did you consider just not editing the comments?
> Ahh I totally missed this, my apologies. I will revert this patch and get rid 
> of this comment. Thanks for pointing it out.
Actually, this comes from a different patch: 
https://reviews.llvm.org/D114025#change-dkrDg1ZRTmhm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113925

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


[PATCH] D113925: [HIP] Add HIP scope atomic operations

2021-11-24 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:5587
 // the GNU atomics specification, but we enforce it, because if we didn't 
it
 // would be very confusing. FIXME:  For whom? How so?
 Diag(ExprRange.getBegin(), diag::err_atomic_op_needs_trivial_copy)

rjmccall wrote:
> I'm confused about what's happening here.  You're editing comments to make 
> more tendentious claims, and then adding FIXMEs to make charged questions 
> about your own claims?  Did you consider just not editing the comments?
Ahh I totally missed this, my apologies. I will revert this patch and get rid 
of this comment. Thanks for pointing it out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113925

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


[PATCH] D114564: Fix the use of -fno-approx-func along with -Ofast or -ffast-math

2021-11-24 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added a comment.

Thanks for the patch! This looks mostly good. I have just a few suggestions.

Could you add test cases in clang/test/Driver/clang_f_opts.c to verify that the 
various driver inputs get overridden in the expected way? Without such a test, 
this behavior is likely to be broken in the future.




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2760
 case options::OPT_fno_honor_nans:   HonorNaNs = false;break;
 case options::OPT_fapprox_func: ApproxFunc = true;break;
 case options::OPT_fno_approx_func:  ApproxFunc = false;   break;

Should this also imply "MathErrno = false"?



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2762
 case options::OPT_fno_approx_func:  ApproxFunc = false;   break;
 case options::OPT_fmath_errno:  MathErrno = true; break;
 case options::OPT_fno_math_errno:   MathErrno = false;break;

Should this conflict with -fapprox-func?



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2880
   break;
 case options::OPT_fno_unsafe_math_optimizations:
   AssociativeMath = false;

I think you need "AppoxFunc = false" here.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2937
   // subsequent options conflict then emit warning diagnostic.
   if (HonorINFs && HonorNaNs && !AssociativeMath && !ReciprocalMath &&
   SignedZeros && TrappingMath && RoundingFPMath &&

You need a check for "!ApproxFunc" here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114564

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


[PATCH] D114430: [clang-format] NFC - recent changes caused clang-format to no longer be clang-formatted.

2021-11-24 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D114430#3151082 , @klimek wrote:

> Thanks for cleaning up after me, and sorry for the mess - do y'all have 
> clang-format set up as a presubmit or do you just remember to format manually?

I think one "problem" is that it did not go through review, otherwise the there 
were notes in the review. ;)
I use QtCreator with its clang-format integration and the changed lines get 
formatted as soon as I press `;` or `}`. Additionally I can format the current 
line(s).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114430

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


[PATCH] D114562: [clang][docs] Inclusive language: remove use of sanity check in option description

2021-11-24 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments.



Comment at: clang/docs/ThreadSafetyAnalysis.rst:471
 
-  + ``-Wthread-safety-attributes``: Sanity checks on attribute syntax.
+  + ``-Wthread-safety-attributes``: Validation checks on attribute syntax.
   + ``-Wthread-safety-analysis``: The core analysis.

Quuxplusone wrote:
> I'd just say "Rejects invalid attribute syntax." But also
> - surely this is totally obvious, that invalid syntax causes an error? why do 
> we even need to write this?
> - line 469 says "three" but then there are four bullet points
It's more about semantics than syntax, i.e. something like “this attribute 
doesn't make sense on such a declaration.” The full (current) list of warning 
messages is on 
https://clang.llvm.org/docs/DiagnosticsReference.html#wthread-safety-attributes.
 (Even “ignoring //A// attribute because its argument is invalid” is actually 
just saying that we don't understand the AST.)

"Validation checks" feels like a hendiadys and doesn't really add anything. 
Indeed something like “Semantic (checks|validation) for thread safety 
attributes” would be most accurate. Though maybe @aaron.ballman has a better 
idea.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114562

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


[PATCH] D113917: Add infrastructure to support matcher names.

2021-11-24 Thread James King via Phabricator via cfe-commits
jcking1034 added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:152
+  }
+MAKE_MATCHER_NAME_FROM_TYPE(TemplateArgument)
+MAKE_MATCHER_NAME_FROM_TYPE(TemplateArgumentLoc)

hokein wrote:
> These are types that are not covered in the above gen .inc files. I wonder is 
> there a way to verify this list is complete? 
I compared this list to other portions of the code where a similar pattern was 
used, and have just added specializations for OMP-related nodes. In these other 
portions of code, I didn't notice anything that verifies completeness, but I 
agree that this would be preferable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113917

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


[PATCH] D113917: Add infrastructure to support matcher names.

2021-11-24 Thread James King via Phabricator via cfe-commits
jcking1034 updated this revision to Diff 389620.
jcking1034 marked 3 inline comments as done.
jcking1034 added a comment.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113917

Files:
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/include/clang/ASTMatchers/ASTMatchersMacros.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
@@ -20,6 +20,30 @@
 namespace ast_matchers {
 using internal::DynTypedMatcher;
 
+TEST(GetNameTest, ReturnsCorrectName) {
+  // Node
+  EXPECT_EQ(typeLoc().getName(), "`TypeLoc` Node");
+  EXPECT_EQ(typeLoc(pointerTypeLoc()).getName(), "`TypeLoc` Node");
+  EXPECT_EQ(pointerTypeLoc(hasPointeeLoc(typeLoc())).getName(),
+"`PointerTypeLoc` Node");
+  EXPECT_EQ(varDecl(hasInitializer(expr()), hasTypeLoc(typeLoc())).getName(),
+"`VarDecl` Node");
+  EXPECT_EQ(ompDefaultClause().getName(), "`OMPDefaultClause` Node");
+
+  // Narrowing
+  EXPECT_EQ(isConst().getName(), "isConst");
+
+  // Traversal
+  EXPECT_EQ(hasLoopVariable(varDecl()).getName(), "hasLoopVariable");
+
+  // Polymorphic
+  EXPECT_EQ(internal::Matcher(hasLHS(expr())).getName(),
+"hasLHS");
+
+  // Bound
+  EXPECT_EQ((typeLoc().bind("TL")).getName(), "`TypeLoc` Node");
+}
+
 #if GTEST_HAS_DEATH_TEST
 TEST(HasNameDeathTest, DiesOnEmptyName) {
   ASSERT_DEBUG_DEATH({
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -115,15 +115,20 @@
 template 
 class VariadicMatcher : public DynMatcherInterface {
 public:
-  VariadicMatcher(std::vector InnerMatchers)
-  : InnerMatchers(std::move(InnerMatchers)) {}
+  VariadicMatcher(std::string MatcherName,
+  std::vector InnerMatchers)
+  : MatcherName(std::move(MatcherName)),
+InnerMatchers(std::move(InnerMatchers)) {}
 
   bool dynMatches(const DynTypedNode , ASTMatchFinder *Finder,
   BoundNodesTreeBuilder *Builder) const override {
 return Func(DynNode, Finder, Builder, InnerMatchers);
   }
 
+  std::string getName() const override { return MatcherName; }
+
 private:
+  const std::string MatcherName;
   std::vector InnerMatchers;
 };
 
@@ -144,11 +149,40 @@
 return InnerMatcher->TraversalKind();
   }
 
+  std::string getName() const override { return InnerMatcher->getName(); }
+
 private:
   const std::string ID;
   const IntrusiveRefCntPtr InnerMatcher;
 };
 
+/// A matcher that specifies a particular name.
+///
+/// The name provided to the constructor overrides any name that may be
+/// specified by the `InnerMatcher`.
+class NameMatcherImpl : public DynMatcherInterface {
+public:
+  NameMatcherImpl(std::string MatcherName,
+  IntrusiveRefCntPtr InnerMatcher)
+  : MatcherName(std::move(MatcherName)),
+InnerMatcher(std::move(InnerMatcher)) {}
+
+  bool dynMatches(const DynTypedNode , ASTMatchFinder *Finder,
+  BoundNodesTreeBuilder *Builder) const override {
+return InnerMatcher->dynMatches(DynNode, Finder, Builder);
+  }
+
+  std::string getName() const override { return MatcherName; }
+
+  llvm::Optional TraversalKind() const override {
+return InnerMatcher->TraversalKind();
+  }
+
+private:
+  const std::string MatcherName;
+  const IntrusiveRefCntPtr InnerMatcher;
+};
+
 /// A matcher that always returns true.
 class TrueMatcherImpl : public DynMatcherInterface {
 public:
@@ -158,6 +192,8 @@
   BoundNodesTreeBuilder *) const override {
 return true;
   }
+
+  std::string getName() const override { return "TrueMatcher"; }
 };
 
 /// A matcher that specifies a particular \c TraversalKind.
@@ -180,6 +216,8 @@
 return TK;
   }
 
+  std::string getName() const override { return InnerMatcher->getName(); }
+
 private:
   clang::TraversalKind TK;
   IntrusiveRefCntPtr InnerMatcher;
@@ -219,31 +257,31 @@
   RestrictKind =
   ASTNodeKind::getMostDerivedType(RestrictKind, IM.RestrictKind);
 }
-return DynTypedMatcher(
-SupportedKind, RestrictKind,
-new VariadicMatcher(std::move(InnerMatchers)));
+return DynTypedMatcher(SupportedKind, RestrictKind,
+   new VariadicMatcher(
+   "allOf", std::move(InnerMatchers)));
 
   case VO_AnyOf:
-return DynTypedMatcher(
-SupportedKind, RestrictKind,
-new VariadicMatcher(std::move(InnerMatchers)));
+return 

[PATCH] D114564: Fix the use of -fno-approx-func along with -Ofast or -ffast-math

2021-11-24 Thread Masoud Ataei via Phabricator via cfe-commits
masoud.ataei created this revision.
masoud.ataei added reviewers: andrew.w.kaylor, aaron.ballman, erichkeane, 
bmahjour.
masoud.ataei added a project: clang.
masoud.ataei requested review of this revision.
Herald added a subscriber: cfe-commits.

Fining the bug number Bug 52565: https://bugs.llvm.org/show_bug.cgi?id=52565


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114564

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fast-math.c
  clang/test/Preprocessor/aarch64-target-features.c
  clang/test/Preprocessor/arm-target-features.c

Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -267,7 +267,7 @@
 // CHECK-DEFS:#define __ARM_SIZEOF_WCHAR_T 4
 
 // RUN: %clang -target arm-none-linux-gnu -fno-math-errno -fno-signed-zeros\
-// RUN:-fno-trapping-math -fassociative-math -freciprocal-math\
+// RUN:-fno-trapping-math -fassociative-math -freciprocal-math -fapprox-func\
 // RUN:-x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FASTMATH %s
 // RUN: %clang -target arm-none-linux-gnu -ffast-math -x c -E -dM %s -o -\
 // RUN:| FileCheck -match-full-lines --check-prefix=CHECK-FASTMATH %s
Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -115,7 +115,7 @@
 // CHECK-CRC32: __ARM_FEATURE_CRC32 1
 
 // RUN: %clang -target aarch64-none-linux-gnu -fno-math-errno -fno-signed-zeros\
-// RUN:-fno-trapping-math -fassociative-math -freciprocal-math\
+// RUN:-fno-trapping-math -fassociative-math -freciprocal-math -fapprox-func\
 // RUN:-x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FASTMATH %s
 // RUN: %clang -target aarch64-none-linux-gnu -ffast-math -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FASTMATH %s
 // RUN: %clang -target arm64-none-linux-gnu -ffast-math -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FASTMATH %s
Index: clang/test/Driver/fast-math.c
===
--- clang/test/Driver/fast-math.c
+++ clang/test/Driver/fast-math.c
@@ -130,14 +130,14 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 //
 // RUN: %clang -### -fno-math-errno -fassociative-math -freciprocal-math \
-// RUN: -fno-signed-zeros -fno-trapping-math -c %s 2>&1 \
+// RUN: -fno-signed-zeros -fno-trapping-math -fapprox-func -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s
 // CHECK-UNSAFE-MATH: "-cc1"
 // CHECK-UNSAFE-MATH: "-menable-unsafe-fp-math"
 // CHECK-UNSAFE-MATH: "-mreassociate"
 //
 // RUN: %clang -### -fno-fast-math -fno-math-errno -fassociative-math -freciprocal-math \
-// RUN: -fno-signed-zeros -fno-trapping-math -c %s 2>&1 \
+// RUN: -fno-signed-zeros -fno-trapping-math -fapprox-func -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-FAST-MATH-UNSAFE-MATH %s
 // CHECK-NO-FAST-MATH-UNSAFE-MATH: "-cc1"
 // CHECK-NO-FAST-MATH-UNSAFE-MATH: "-menable-unsafe-fp-math"
@@ -178,7 +178,7 @@
 // RUN: -fno-math-errno -ffp-contract=fast -fno-rounding-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-FAST-MATH %s
 // RUN: %clang -### -fno-honor-infinities -fno-honor-nans -fno-math-errno \
-// RUN: -fassociative-math -freciprocal-math -fno-signed-zeros \
+// RUN: -fassociative-math -freciprocal-math -fno-signed-zeros -fapprox-func \
 // RUN: -fno-trapping-math -ffp-contract=fast -fno-rounding-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-FAST-MATH %s
 // CHECK-FAST-MATH: "-cc1"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2873,6 +2873,7 @@
   AssociativeMath = true;
   ReciprocalMath = true;
   SignedZeros = false;
+  ApproxFunc = true;
   TrappingMath = false;
   FPExceptionBehavior = "";
   break;
@@ -2899,6 +2900,7 @@
   MathErrno = false;
   AssociativeMath = true;
   ReciprocalMath = true;
+  ApproxFunc = true;
   SignedZeros = false;
   TrappingMath = false;
   RoundingFPMath = false;
@@ -2914,6 +2916,7 @@
   MathErrno = TC.IsMathErrnoDefault();
   AssociativeMath = false;
   ReciprocalMath = false;
+  ApproxFunc = false;
   SignedZeros = true;
   // -fno_fast_math restores default denormal and fpcontract handling
   DenormalFPMath = DefaultDenormalFPMath;
@@ -2965,7 +2968,7 @@
 CmdArgs.push_back("-fmath-errno");
 
   if (!MathErrno && AssociativeMath && ReciprocalMath && !SignedZeros &&
-  !TrappingMath)
+  ApproxFunc && !TrappingMath)
 

[PATCH] D114326: Update the list of CUDA versions up to 11.5

2021-11-24 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:131
+  std::initializer_list Versions = {
+  "11.5", "11.4", "11.3", "11.2", "11.1", "11.0", "10.2", "10.1",
+  "10.0", "9.2",  "9.1",  "9.0",  "8.0",  "7.5",  "7.0"};

mojca wrote:
> tra wrote:
> > tra wrote:
> > > mojca wrote:
> > > > carlosgalvezp wrote:
> > > > > mojca wrote:
> > > > > > tra wrote:
> > > > > > > tra wrote:
> > > > > > > > mojca wrote:
> > > > > > > > > kadircet wrote:
> > > > > > > > > > looks like the list is getting big and hard to maintain. 
> > > > > > > > > > considering that this is done only once per compiler 
> > > > > > > > > > invocation (and we check for existence of directories down 
> > > > > > > > > > in the loop anyway). what about throwing in an extra 
> > > > > > > > > > directory listing to base-directories mentioned down below 
> > > > > > > > > > and populate `Candidates` while preserving the 
> > > > > > > > > > newest-version-first order?
> > > > > > > > > I totally agree with the sentiment, and that was my initial 
> > > > > > > > > thought as well, but with zero experience I was too scared to 
> > > > > > > > > make any more significant changes.
> > > > > > > > > 
> > > > > > > > > I can try to come up with a new patch (that doesn't need 
> > > > > > > > > further maintenance whenever a new CUDA version gets 
> > > > > > > > > released) if that's what you are suggesting. I would 
> > > > > > > > > nevertheless merge this one, and prepare a new more advanced 
> > > > > > > > > patch separately, but that's finally your call.
> > > > > > > > > 
> > > > > > > > > What's your suggestion about D.SysRoot + "Program Files/..."? 
> > > > > > > > > At the time when this function gets called it looks like 
> > > > > > > > > D.SysRoot is empty (or at least my debugger says so) and in 
> > > > > > > > > my case it resolves to D: while the CUDA support is installed 
> > > > > > > > > under C:.
> > > > > > > > > 
> > > > > > > > > Is there any special LLVM-specific/preferrable way to iterate 
> > > > > > > > > through directories?
> > > > > > > > > 
> > > > > > > > > (What I also miss a bit in the whole process in an option to 
> > > > > > > > > simply say "I want CUDA 11.1" without the need to explicitly 
> > > > > > > > > spell out the full path.)
> > > > > > > > > 
> > > > > > > > > If you provide me give some general guidelines, I'll prepare 
> > > > > > > > > another, hopefully more future-proof patch.
> > > > > > > > > 
> > > > > > > > > (Side note: I'm not sure if I'm calling clang-format 
> > > > > > > > > correctly, but if I call it, it keeps reformatting the rest 
> > > > > > > > > of this file.)
> > > > > > > > This whole list may no longer be particularly useful. The most 
> > > > > > > > common use case on Linux, AFAICT, is to install only one CUDA 
> > > > > > > > version using system-provided package manager.
> > > > > > > > E.g. 
> > > > > > > > https://packages.ubuntu.com/focal/amd64/nvidia-cuda-toolkit/filelist
> > > > > > > > 
> > > > > > > > TBH, I'm tempted to limit autodetection to only that one 
> > > > > > > > system-default version and require user to use --cuda-path if 
> > > > > > > > they need something else.
> > > > > > > I think on windows (I mean the windows environment itself, not 
> > > > > > > WSL), CUDA installer sets an environment variable which could be 
> > > > > > > used to detect the default CUDA version, so it may warrant a 
> > > > > > > windows-specific way to find it. 
> > > > > > On Windows this is certainly not the case. Unless the installation 
> > > > > > is changed manually, one always gets the new version installed into 
> > > > > > a new directory.
> > > > > > 
> > > > > > I really do need multiple versions on Windows (and the ability to 
> > > > > > pick an older one) if I want to compile a binary that works on 
> > > > > > someone else's computer (if I compile against the latest CUDA, 
> > > > > > users need "the latest" drivers that may sometimes not even be 
> > > > > > available for their machine).
> > > > > > 
> > > > > > (That said, at least when using CMake, the selection needs to be 
> > > > > > done by CMake anyway, and maybe CMake could be forced to specify 
> > > > > > the correct flag automatically.)
> > > > > > 
> > > > > > So even if the functionality gets removed from non-Windows 
> > > > > > platforms, it would be really nice to keep it for Windows.
> > > > > > 
> > > > > > Now, there are three "conflicting" feedbacks/suggestions above. I 
> > > > > > can try to improve support, but it would be really helpful to reach 
> > > > > > the consensus of what needs to be done before coding it.
> > > > > > one always gets the new version installed into a new directory.
> > > > > A similar thing happens on Linux.
> > > > > 
> > > > > > users need "the latest" drivers
> > > > > Since CUDA 10.2, there's some "[[ 
> > > > > https://docs.nvidia.com/deploy/cuda-compatibility/ | compatibility 
> 

[PATCH] D113925: [HIP] Add HIP scope atomic operations

2021-11-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:5587
 // the GNU atomics specification, but we enforce it, because if we didn't 
it
 // would be very confusing. FIXME:  For whom? How so?
 Diag(ExprRange.getBegin(), diag::err_atomic_op_needs_trivial_copy)

I'm confused about what's happening here.  You're editing comments to make more 
tendentious claims, and then adding FIXMEs to make charged questions about your 
own claims?  Did you consider just not editing the comments?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113925

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


[PATCH] D114562: [clang][docs] Inclusive language: remove use of sanity check in option description

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



Comment at: clang/docs/ThreadSafetyAnalysis.rst:471
 
-  + ``-Wthread-safety-attributes``: Sanity checks on attribute syntax.
+  + ``-Wthread-safety-attributes``: Validation checks on attribute syntax.
   + ``-Wthread-safety-analysis``: The core analysis.

I'd just say "Rejects invalid attribute syntax." But also
- surely this is totally obvious, that invalid syntax causes an error? why do 
we even need to write this?
- line 469 says "three" but then there are four bullet points


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114562

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


[PATCH] D114562: [clang][docs] Inclusive language: remove use of sanity check in option description

2021-11-24 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA created this revision.
ZarkoCA added reviewers: aaron.ballman, delesley, quinnp.
ZarkoCA added a project: clang.
ZarkoCA requested review of this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114562

Files:
  clang/docs/ThreadSafetyAnalysis.rst


Index: clang/docs/ThreadSafetyAnalysis.rst
===
--- clang/docs/ThreadSafetyAnalysis.rst
+++ clang/docs/ThreadSafetyAnalysis.rst
@@ -468,7 +468,7 @@
 
 * ``-Wthread-safety``:  Umbrella flag which turns on the following three:
 
-  + ``-Wthread-safety-attributes``: Sanity checks on attribute syntax.
+  + ``-Wthread-safety-attributes``: Validation checks on attribute syntax.
   + ``-Wthread-safety-analysis``: The core analysis.
   + ``-Wthread-safety-precise``: Requires that mutex expressions match 
precisely.
This warning can be disabled for code which has a lot of aliases.


Index: clang/docs/ThreadSafetyAnalysis.rst
===
--- clang/docs/ThreadSafetyAnalysis.rst
+++ clang/docs/ThreadSafetyAnalysis.rst
@@ -468,7 +468,7 @@
 
 * ``-Wthread-safety``:  Umbrella flag which turns on the following three:
 
-  + ``-Wthread-safety-attributes``: Sanity checks on attribute syntax.
+  + ``-Wthread-safety-attributes``: Validation checks on attribute syntax.
   + ``-Wthread-safety-analysis``: The core analysis.
   + ``-Wthread-safety-precise``: Requires that mutex expressions match precisely.
This warning can be disabled for code which has a lot of aliases.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1ad7de9 - Headers: exclude `#include_next ` on MSVC

2021-11-24 Thread Saleem Abdulrasool via cfe-commits

Author: Saleem Abdulrasool
Date: 2021-11-24T12:52:16-08:00
New Revision: 1ad7de9e92bc2977698e5f6d6493202b50c912d5

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

LOG: Headers: exclude `#include_next ` on MSVC

The 14.31.30818 toolset has the following in the `stdatomic.h`:
~~~
 #ifndef __cplusplus
 #error  is not yet supported when compiling as C, but this is 
planned for a future release.
 #endif
~~~

This results in clang failing to build existing code which relied on
`stdatomic.h` in C mode on Windows.  Simply fallback to the clang header
until that header is available as a complete implementation.

Added: 


Modified: 
clang/lib/Headers/stdatomic.h

Removed: 




diff  --git a/clang/lib/Headers/stdatomic.h b/clang/lib/Headers/stdatomic.h
index 665551ea69a4..1e47bcb2bacf 100644
--- a/clang/lib/Headers/stdatomic.h
+++ b/clang/lib/Headers/stdatomic.h
@@ -12,8 +12,12 @@
 
 /* If we're hosted, fall back to the system's stdatomic.h. FreeBSD, for
  * example, already has a Clang-compatible stdatomic.h header.
+ *
+ * Exclude the MSVC path as well as the MSVC header as of the 14.31.30818
+ * explicitly disallows `stdatomic.h` in the C mode via an `#error`.  Fallback
+ * to the clang resource header until that is fully supported.
  */
-#if __STDC_HOSTED__ && __has_include_next()
+#if __STDC_HOSTED__ && __has_include_next() && !defined(_MSC_VER)
 # include_next 
 #else
 



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


[PATCH] D114553: [HIP] Add atomic load, atomic store and atomic cmpxchng_weak builtin support in HIP-clang

2021-11-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

we also need a sema test like clang/test/SemaOpenCL/atomic-ops.cl




Comment at: clang/test/CodeGenCUDA/atomic-ops.cu:30-32
+  val = __hip_atomic_load(ptr, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  __hip_atomic_store(ptr, ptr2, 5);
+  flag = __hip_atomic_compare_exchange_weak(ptr, ptr2, , desired, 
__HIP_MEMORY_SCOPE_WORKGROUP);

all three builtins need to accept memory order parameter. check 
clang/test/CodeGenOpenCL/atomic-ops.cl for reference


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114553

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


[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2021-11-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoD.td:489
 
+let Predicates = [HasStdExtZdinx] in {
+def : InstAlias<"fabs.d $rd, $rs", (FSGNJX_D_INX GPRF64Op:$rd, GPRF64Op:$rs, 
GPRF64Op:$rs)>;

Aren't these aliases only valid for RV64. You need IN32X aliases for RV32 right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

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


[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2021-11-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:69
 {"zfh", RISCVExtensionVersion{0, 1}},
+{"zfinx", RISCVExtensionVersion{1, 0}},
+{"zdinx", RISCVExtensionVersion{1, 0}},

Do we need to enforce that these can't be mixed with F, D, and Zfh?



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:1718
+!getSTI().hasFeature(RISCV::FeatureStdExtF) &&
+!getSTI().hasFeature(RISCV::FeatureStdExtD) &&
+!getSTI().hasFeature(RISCV::FeatureStdExtZfh)));

D and Zfh imply F. Is it enough to just check F?



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoF.td:77
 let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
-class FPFMAS_rrr_frm
-: RVInstR4Frm<0b00, opcode, (outs FPR32:$rd),
-  (ins FPR32:$rs1, FPR32:$rs2, FPR32:$rs3, frmarg:$funct3),
+class FPFMAS_rrr_frm_single

Can we merge this with FPFMAD_rrr_frm_single and FPFMAH_rrr_frm_single by 
passing the 0b00/0b01/0b10 value from 
FPFMAS_rrr_frm/FPFMAD_rrr_frm/FPFMAH_rrr_frm?

This applies to most of the `_single` classes. We should share them if possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

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


[PATCH] D114560: [OPENMP]Fix PR51327: Range based for loop not working if range's type is a template.

2021-11-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: jdoerfert, mikerice.
Herald added subscribers: guansong, yaxunl.
ABataev requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

Need to postpone anlysis of the ranged for loops till the actual
instantiation to avoid erroneous emission of error messages.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114560

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/for_loop_auto.cpp


Index: clang/test/OpenMP/for_loop_auto.cpp
===
--- /dev/null
+++ clang/test/OpenMP/for_loop_auto.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -verify -fopenmp -ast-print -std=c++20 %s -Wsign-conversion 
| FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++20 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -std=c++20 -include-pch %t -fsyntax-only -verify 
%s -ast-print | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print -std=c++20 %s 
-Wsign-conversion | FileCheck %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++20 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -std=c++20 -include-pch %t -fsyntax-only 
-verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+// CHECK:  template <> void do_loop(const auto ) {
+// CHECK-NEXT: #pragma omp parallel for
+// CHECK-NEXT:for (const auto  : v)
+// CHECK-NEXT:  ;
+// CHECK-NEXT: }
+
+void do_loop(const auto ) {
+#pragma omp parallel for
+  for (const auto  : v)
+;
+}
+#endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -8804,6 +8804,9 @@
   }
   assert(((For && For->getBody()) || (CXXFor && CXXFor->getBody())) &&
  "No loop body.");
+  // Postpone analysis in dependent contexts for ranged for loops.
+  if (CXXFor && SemaRef.CurContext->isDependentContext())
+return false;
 
   OpenMPIterationSpaceChecker ISC(SemaRef, SupportsNonRectangular, DSA,
   For ? For->getForLoc() : 
CXXFor->getForLoc());


Index: clang/test/OpenMP/for_loop_auto.cpp
===
--- /dev/null
+++ clang/test/OpenMP/for_loop_auto.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -verify -fopenmp -ast-print -std=c++20 %s -Wsign-conversion | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++20 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -std=c++20 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print -std=c++20 %s -Wsign-conversion | FileCheck %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++20 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -std=c++20 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+// CHECK:  template <> void do_loop(const auto ) {
+// CHECK-NEXT: #pragma omp parallel for
+// CHECK-NEXT:for (const auto  : v)
+// CHECK-NEXT:  ;
+// CHECK-NEXT: }
+
+void do_loop(const auto ) {
+#pragma omp parallel for
+  for (const auto  : v)
+;
+}
+#endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -8804,6 +8804,9 @@
   }
   assert(((For && For->getBody()) || (CXXFor && CXXFor->getBody())) &&
  "No loop body.");
+  // Postpone analysis in dependent contexts for ranged for loops.
+  if (CXXFor && SemaRef.CurContext->isDependentContext())
+return false;
 
   OpenMPIterationSpaceChecker ISC(SemaRef, SupportsNonRectangular, DSA,
   For ? For->getForLoc() : CXXFor->getForLoc());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2021-11-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Parse/ParsePragma.cpp:511
+RISCVPragmaHandler = std::make_unique(Actions);
+PP.AddPragmaHandler(RISCVPragmaHandler.get());
+  }

Since this is a clang specific pragma should it be `#pragma clang riscv 
intrinsic`? gcc's pragma for SVE is `#pragma GCC aarch64 "arm_sve.h"`



Comment at: clang/lib/Parse/ParsePragma.cpp:3842
+  }
+
+  PP.setPredefines("#define __riscv_pragma_vector_intrinsics");

Do we need to check that there are no tokens left to parse? Quick look at other 
handles I see a check for tok::eod



Comment at: clang/lib/Sema/SemaLookup.cpp:904
+  QualType ,
+  SmallVector ) {
+  // Get the QualType instance of the return type.

Can this be SmallVectorImpl?



Comment at: clang/lib/Sema/SemaLookup.cpp:921
+  QualType , QualType ,
+  SmallVector ) {
+  FunctionProtoType::ExtProtoInfo PI(

SmallVectorImpl



Comment at: clang/lib/Sema/SemaLookup.cpp:929
+
+static unsigned GetTargetFeatures(const TargetInfo ) {
+  bool HasF = TI.hasFeature("f");

Use a fixed size type like uint32_t since it is a bit vector.



Comment at: clang/lib/Sema/SemaLookup.cpp:949
+Sema , LookupResult , IdentifierInfo *II, Preprocessor ,
+const unsigned FctIndex, const unsigned Len, const unsigned BuiltinIndex) {
+

const on integer arguments doesn't make a much sense. It just prevents you from 
assigning over the variable in the function body.



Comment at: clang/lib/Sema/SemaLookup.cpp:966
+  ASTContext  = S.Context;
+  unsigned RVVTargetFeatures = GetTargetFeatures(Context.getTargetInfo());
+

Use a fixed size type like uint32_t here or uint8_t to match RequiredExts,



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1513
+  OS << "enum RVVTypeID {\n";
+  StringMap Seen;
+  for (const auto  : TypeMap) {

Use StringSet?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1516
+auto *RVVTy = T.first;
+if (Seen.find(RVVTy->getShortStr()) == Seen.end()) {
+  OS << "  RVVT_" + RVVTy->getShortStr() << ",\n";

With StringSet you can use
```
if (Seen.insert(RVVTy->getShortStr()).second)
```

The .second field from the pair will tell if you the insert happened or not.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1551
+StringRef IName = Def->getName();
+if (FctOverloadMap.find(IName) == FctOverloadMap.end()) {
+  FctOverloadMap.insert(std::make_pair(

I don't think you need to insert anything here. The 
`FctOverloadMap[IName].push_back(` line below will construct an empty entry 
before the push_back if it doesn't already exist.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1575
+  StringRef GName = Def->getMangledName();
+  if (FctOverloadMap.find(GName) == FctOverloadMap.end()) {
+FctOverloadMap.insert(std::make_pair(

I don't think you need to insert anything. The push_back line will take care of 
it.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1616
+  // List of signatures known to be emitted.
+  std::vector KnownSignatures;
+

Can this be a vector of unique_ptrs?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1622
+// Gather all signatures for the current function.
+auto *CurSignatureList = new BuiltinIndexListTy();
+for (const auto  : Fct.second)

Can this be a unique_ptr?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1639
+  *Candidate == *CurSignatureList) {
+if (CanReuseSignature(Candidate, Fct.second)) {
+  SignatureListMap.find(Candidate)->second.Names.push_back(Fct.first);

I think this condition can be an additional && on the previous if?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1640
+if (CanReuseSignature(Candidate, Fct.second)) {
+  SignatureListMap.find(Candidate)->second.Names.push_back(Fct.first);
+  SignatureListMap.find(Candidate)->second.BuiltinIndex.push_back(

Don't call SignatureListMap.find(Candidate) twice.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1677
+// Report an error when seeing an entry that is too large for the
+// current index type (unsigned short).  When hitting this, the type
+// of SignatureTable will need to be changed.

I'd use uint16_t rather than unsigned short.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1721
+void RVVEmitter::EmitBuiltinMapTable(raw_ostream 

[PATCH] D114559: [clang] ASTMatchers: Fix out-of-bounds access in foreachArgumentWithParamType.

2021-11-24 Thread Felix Berger via Phabricator via cfe-commits
flx created this revision.
flx requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The matcher crashes when a variadic function pointer is invoked because the
FunctionProtoType has fewer parameters than arguments.

Matching of non-variadic arguments now works.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114559

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp


Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1094,6 +1094,31 @@
   S, CallExpr, std::make_unique>("arg")));
 }
 
+TEST(ForEachArgumentWithParamType, MatchesVariadicFunctionPtrCalls) {
+  StatementMatcher ArgumentY =
+  declRefExpr(to(varDecl(hasName("y".bind("arg");
+  TypeMatcher IntType = qualType(builtinType()).bind("type");
+  StatementMatcher CallExpr =
+  callExpr(forEachArgumentWithParamType(ArgumentY, IntType));
+
+  StringRef S = R"cpp(
+void fcntl(int fd, int cmd, ...) {}
+
+template 
+void f(Func F) {
+  int y = 42;
+  F(y, 1, 3);
+}
+
+void g() { f(fcntl); }
+  )cpp";
+
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  S, CallExpr, std::make_unique>("type")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  S, CallExpr, std::make_unique>("arg")));
+}
+
 TEST(QualType, hasCanonicalType) {
   EXPECT_TRUE(notMatches("typedef int _ref;"
"int a;"
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4885,7 +4885,7 @@
 
   // This test is cheaper compared to the big matcher in the next if.
   // Therefore, please keep this order.
-  if (FProto) {
+  if (FProto && FProto->getNumParams() > ParamIndex) {
 QualType ParamType = FProto->getParamType(ParamIndex);
 if (ParamMatcher.matches(ParamType, Finder, )) {
   Result.addMatch(ParamMatches);


Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1094,6 +1094,31 @@
   S, CallExpr, std::make_unique>("arg")));
 }
 
+TEST(ForEachArgumentWithParamType, MatchesVariadicFunctionPtrCalls) {
+  StatementMatcher ArgumentY =
+  declRefExpr(to(varDecl(hasName("y".bind("arg");
+  TypeMatcher IntType = qualType(builtinType()).bind("type");
+  StatementMatcher CallExpr =
+  callExpr(forEachArgumentWithParamType(ArgumentY, IntType));
+
+  StringRef S = R"cpp(
+void fcntl(int fd, int cmd, ...) {}
+
+template 
+void f(Func F) {
+  int y = 42;
+  F(y, 1, 3);
+}
+
+void g() { f(fcntl); }
+  )cpp";
+
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  S, CallExpr, std::make_unique>("type")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  S, CallExpr, std::make_unique>("arg")));
+}
+
 TEST(QualType, hasCanonicalType) {
   EXPECT_TRUE(notMatches("typedef int _ref;"
"int a;"
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4885,7 +4885,7 @@
 
   // This test is cheaper compared to the big matcher in the next if.
   // Therefore, please keep this order.
-  if (FProto) {
+  if (FProto && FProto->getNumParams() > ParamIndex) {
 QualType ParamType = FProto->getParamType(ParamIndex);
 if (ParamMatcher.matches(ParamType, Finder, )) {
   Result.addMatch(ParamMatches);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114326: Update the list of CUDA versions up to 11.5

2021-11-24 Thread Mojca Miklavec via Phabricator via cfe-commits
mojca added inline comments.



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:131
+  std::initializer_list Versions = {
+  "11.5", "11.4", "11.3", "11.2", "11.1", "11.0", "10.2", "10.1",
+  "10.0", "9.2",  "9.1",  "9.0",  "8.0",  "7.5",  "7.0"};

tra wrote:
> tra wrote:
> > mojca wrote:
> > > carlosgalvezp wrote:
> > > > mojca wrote:
> > > > > tra wrote:
> > > > > > tra wrote:
> > > > > > > mojca wrote:
> > > > > > > > kadircet wrote:
> > > > > > > > > looks like the list is getting big and hard to maintain. 
> > > > > > > > > considering that this is done only once per compiler 
> > > > > > > > > invocation (and we check for existence of directories down in 
> > > > > > > > > the loop anyway). what about throwing in an extra directory 
> > > > > > > > > listing to base-directories mentioned down below and populate 
> > > > > > > > > `Candidates` while preserving the newest-version-first order?
> > > > > > > > I totally agree with the sentiment, and that was my initial 
> > > > > > > > thought as well, but with zero experience I was too scared to 
> > > > > > > > make any more significant changes.
> > > > > > > > 
> > > > > > > > I can try to come up with a new patch (that doesn't need 
> > > > > > > > further maintenance whenever a new CUDA version gets released) 
> > > > > > > > if that's what you are suggesting. I would nevertheless merge 
> > > > > > > > this one, and prepare a new more advanced patch separately, but 
> > > > > > > > that's finally your call.
> > > > > > > > 
> > > > > > > > What's your suggestion about D.SysRoot + "Program Files/..."? 
> > > > > > > > At the time when this function gets called it looks like 
> > > > > > > > D.SysRoot is empty (or at least my debugger says so) and in my 
> > > > > > > > case it resolves to D: while the CUDA support is installed 
> > > > > > > > under C:.
> > > > > > > > 
> > > > > > > > Is there any special LLVM-specific/preferrable way to iterate 
> > > > > > > > through directories?
> > > > > > > > 
> > > > > > > > (What I also miss a bit in the whole process in an option to 
> > > > > > > > simply say "I want CUDA 11.1" without the need to explicitly 
> > > > > > > > spell out the full path.)
> > > > > > > > 
> > > > > > > > If you provide me give some general guidelines, I'll prepare 
> > > > > > > > another, hopefully more future-proof patch.
> > > > > > > > 
> > > > > > > > (Side note: I'm not sure if I'm calling clang-format correctly, 
> > > > > > > > but if I call it, it keeps reformatting the rest of this file.)
> > > > > > > This whole list may no longer be particularly useful. The most 
> > > > > > > common use case on Linux, AFAICT, is to install only one CUDA 
> > > > > > > version using system-provided package manager.
> > > > > > > E.g. 
> > > > > > > https://packages.ubuntu.com/focal/amd64/nvidia-cuda-toolkit/filelist
> > > > > > > 
> > > > > > > TBH, I'm tempted to limit autodetection to only that one 
> > > > > > > system-default version and require user to use --cuda-path if 
> > > > > > > they need something else.
> > > > > > I think on windows (I mean the windows environment itself, not 
> > > > > > WSL), CUDA installer sets an environment variable which could be 
> > > > > > used to detect the default CUDA version, so it may warrant a 
> > > > > > windows-specific way to find it. 
> > > > > On Windows this is certainly not the case. Unless the installation is 
> > > > > changed manually, one always gets the new version installed into a 
> > > > > new directory.
> > > > > 
> > > > > I really do need multiple versions on Windows (and the ability to 
> > > > > pick an older one) if I want to compile a binary that works on 
> > > > > someone else's computer (if I compile against the latest CUDA, users 
> > > > > need "the latest" drivers that may sometimes not even be available 
> > > > > for their machine).
> > > > > 
> > > > > (That said, at least when using CMake, the selection needs to be done 
> > > > > by CMake anyway, and maybe CMake could be forced to specify the 
> > > > > correct flag automatically.)
> > > > > 
> > > > > So even if the functionality gets removed from non-Windows platforms, 
> > > > > it would be really nice to keep it for Windows.
> > > > > 
> > > > > Now, there are three "conflicting" feedbacks/suggestions above. I can 
> > > > > try to improve support, but it would be really helpful to reach the 
> > > > > consensus of what needs to be done before coding it.
> > > > > one always gets the new version installed into a new directory.
> > > > A similar thing happens on Linux.
> > > > 
> > > > > users need "the latest" drivers
> > > > Since CUDA 10.2, there's some "[[ 
> > > > https://docs.nvidia.com/deploy/cuda-compatibility/ | compatibility mode 
> > > > ]]" that allows to run newer CUDA on older drivers. As long as you are 
> > > > not using the latest features, of course.
> > > > 
> > > > I'm personally all up for removing redundancy and duplication. 
> > > I'm 

[PATCH] D113118: [clang][AST] Check context of record in structural equivalence.

2021-11-24 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests on windows: http://45.33.8.238/win/49558/step_7.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113118

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


[PATCH] D114320: [clang-format] Extend AllowShortBlocksOnASingleLine for else blocks

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

In D114320#3151741 , @jessesna wrote:

> In D114320#3148046 , 
> @MyDeveloperDay wrote:
>
>> Ok now I'm a little puzzled, shouldn't this be covered by 
>> `AllowShortIfStatementsOnASingleLine`?
>
> That's exactly what i thought when i first stumbled over the behavior :D But 
> I think the majority of users might not even consider adding empty else 
> blocks. Only a few either just do it or have to comply with some standards, 
> f.e. MISRA  .

I tend to agree with you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114320

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


[PATCH] D114553: [HIP] Add atomic load, atomic store and atomic cmpxchng_weak builtin support in HIP-clang

2021-11-24 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 389577.
gandhi21299 added a comment.

removed changes in atomic-ops.cl, CUDA test may be sufficient.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114553

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/Builtins.def
  clang/lib/AST/Expr.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGenCUDA/atomic-ops.cu

Index: clang/test/CodeGenCUDA/atomic-ops.cu
===
--- clang/test/CodeGenCUDA/atomic-ops.cu
+++ clang/test/CodeGenCUDA/atomic-ops.cu
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -x hip -std=c++11 -triple amdgcn -fcuda-is-device -emit-llvm %s -o - | FileCheck %s
 #include "Inputs/cuda.h"
 
-// CHECK-LABEL: @_Z24atomic32_op_singlethreadPiii
+// CHECK-LABEL: @_Z24atomic32_op_singlethreadPiS_ii
 // CHECK: cmpxchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw xchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw add i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
@@ -10,7 +10,15 @@
 // CHECK: atomicrmw xor i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw min i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw max i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
-__device__ int atomic32_op_singlethread(int *ptr, int val, int desired) {
+// CHECK: load atomic i32, i32* {{%[0-9]+}} syncscope("singlethread-one-as") acquire, align 4
+// CHECK: store atomic i32 {{%[0-9]+}}, i32* {{%[0-9]+}} seq_cst, align 4
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 {{%[0-9]+}}, i8* align 8 {{%[0-9]+}}, i64 4, i1 false)
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as") monotonic monotonic, align 4
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as") acquire monotonic, align 4
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as") release monotonic, align 4
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as") acq_rel monotonic, align 4
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup") seq_cst monotonic, align 4
+__device__ int atomic32_op_singlethread(int *ptr, int *ptr2, int val, int desired) {
   bool flag = __hip_atomic_compare_exchange_strong(ptr, , desired, __ATOMIC_RELAXED, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_exchange(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_fetch_add(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
@@ -19,6 +27,9 @@
   val = __hip_atomic_fetch_xor(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_fetch_min(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_fetch_max(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  val = __hip_atomic_load(ptr, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  __hip_atomic_store(ptr, ptr2, 5);
+  flag = __hip_atomic_compare_exchange_weak(ptr, ptr2, , desired, __HIP_MEMORY_SCOPE_WORKGROUP);
   return flag ? val : desired;
 }
 
@@ -31,7 +42,7 @@
   return val;
 }
 
-// CHECK-LABEL: @_Z21atomic32_op_wavefrontPiii
+// CHECK-LABEL: @_Z21atomic32_op_wavefrontPiS_ii
 // CHECK: cmpxchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
 // CHECK: atomicrmw xchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
 // CHECK: atomicrmw add i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
@@ -40,7 +51,9 @@
 // CHECK: atomicrmw xor i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
 // CHECK: atomicrmw min i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
 // CHECK: atomicrmw max i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
-__device__ int atomic32_op_wavefront(int *ptr, int val, int desired) {
+// CHECK: load atomic i32, i32* {{%[0-9]+}} syncscope("wavefront-one-as") acquire, align 4
+// CHECK: store atomic i32 {{%[0-9]+}}, i32* {{%[0-9]+}} seq_cst, align 4
+__device__ int atomic32_op_wavefront(int *ptr, int *ptr2, int val, int desired) {
   bool flag = __hip_atomic_compare_exchange_strong(ptr, , desired, __ATOMIC_RELAXED, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
   val = __hip_atomic_exchange(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
   val = __hip_atomic_fetch_add(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
@@ -49,6 +62,8 @@
   val = __hip_atomic_fetch_xor(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
   val = 

[clang] d42a643 - [NFC][clang]Inclusive language: remove remaining uses of sanity

2021-11-24 Thread Zarko Todorovski via cfe-commits

Author: Zarko Todorovski
Date: 2021-11-24T14:20:13-05:00
New Revision: d42a6432aa37a6b9aa7e4f5209e9679c8a4c2fbb

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

LOG: [NFC][clang]Inclusive language: remove remaining uses of sanity

Missed some uses of sanity check in previous commits.

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
clang/utils/TableGen/ASTTableGen.cpp
clang/utils/check_cfc/check_cfc.py

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index fe96db9ca918e..99babd58b0276 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -7483,7 +7483,7 @@ class ExprEvaluatorBase
 const Expr *Source = E->getSourceExpr();
 if (!Source)
   return Error(E);
-if (Source == E) { // sanity checking.
+if (Source == E) {
   assert(0 && "OpaqueValueExpr recursively refers to itself");
   return Error(E);
 }

diff  --git a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp 
b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
index bc939d2528002..d57bab154b617 100644
--- a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -686,8 +686,8 @@ SwitchNodeBuilder::generateDefaultCaseNode(ProgramStateRef 
St,
   assert(Src->succ_rbegin() != Src->succ_rend());
   CFGBlock *DefaultBlock = *Src->succ_rbegin();
 
-  // Sanity check for default blocks that are unreachable and not caught
-  // by earlier stages.
+  // Basic correctness check for default blocks that are unreachable and not
+  // caught by earlier stages.
   if (!DefaultBlock)
 return nullptr;
 

diff  --git a/clang/utils/TableGen/ASTTableGen.cpp 
b/clang/utils/TableGen/ASTTableGen.cpp
index 3f6da40964e0b..6aa8b28a942f3 100644
--- a/clang/utils/TableGen/ASTTableGen.cpp
+++ b/clang/utils/TableGen/ASTTableGen.cpp
@@ -107,7 +107,7 @@ static void visitASTNodeRecursive(ASTNode node, ASTNode 
base,
 static void visitHierarchy(RecordKeeper ,
StringRef nodeClassName,
ASTNodeHierarchyVisitor visit) {
-  // Check for the node class, just as a sanity check.
+  // Check for the node class, just as a basic correctness check.
   if (!records.getClass(nodeClassName)) {
 PrintFatalError(Twine("cannot find definition for node class ")
   + nodeClassName);

diff  --git a/clang/utils/check_cfc/check_cfc.py 
b/clang/utils/check_cfc/check_cfc.py
index 311f502f800b3..cab33b41c1ca0 100755
--- a/clang/utils/check_cfc/check_cfc.py
+++ b/clang/utils/check_cfc/check_cfc.py
@@ -339,7 +339,7 @@ def perform_check(self, arguments, my_env):
 # Prevent infinite loop if called with absolute path.
 arguments_a[0] = os.path.basename(arguments_a[0])
 
-# Sanity check
+# Basic correctness check
 enabled_checks = [check_name
   for check_name in checks
   if config.getboolean('Checks', check_name)]



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


[PATCH] D114553: [HIP] Add atomic load, atomic store and atomic cmpxchng_weak builtin support in HIP-clang

2021-11-24 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 created this revision.
gandhi21299 added reviewers: yaxunl, b-sumner, t-tye, tra, rjmccall.
gandhi21299 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Introduce __hip_atomic_load, __hip_atomic_store and 
__hip_atomic_compare_exchange_weak
builtins in HIP.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114553

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/Builtins.def
  clang/lib/AST/Expr.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGenCUDA/atomic-ops.cu
  clang/test/CodeGenOpenCL/atomic-ops.cl

Index: clang/test/CodeGenOpenCL/atomic-ops.cl
===
--- clang/test/CodeGenOpenCL/atomic-ops.cl
+++ clang/test/CodeGenOpenCL/atomic-ops.cl
@@ -35,7 +35,7 @@
 
 atomic_int j;
 
-void fi1(atomic_int *i) {
+void fi1(atomic_int *i, int* z) {
   // CHECK-LABEL: @fi1
   // CHECK: load atomic i32, i32* %{{[.0-9A-Z_a-z]+}} syncscope("workgroup") seq_cst, align 4
   int x = __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_group);
@@ -48,6 +48,9 @@
 
   // CHECK: load atomic i32, i32* %{{[.0-9A-Z_a-z]+}} syncscope("wavefront") seq_cst, align 4
   x = __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_sub_group);
+
+  // CHECK: load i32, i32 addrspace(5)* %atomic-temp3, align 4
+  x = __hip_atomic_load(z, memory_scope_device);
 }
 
 void fi2(atomic_int *i) {
Index: clang/test/CodeGenCUDA/atomic-ops.cu
===
--- clang/test/CodeGenCUDA/atomic-ops.cu
+++ clang/test/CodeGenCUDA/atomic-ops.cu
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -x hip -std=c++11 -triple amdgcn -fcuda-is-device -emit-llvm %s -o - | FileCheck %s
 #include "Inputs/cuda.h"
 
-// CHECK-LABEL: @_Z24atomic32_op_singlethreadPiii
+// CHECK-LABEL: @_Z24atomic32_op_singlethreadPiS_ii
 // CHECK: cmpxchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw xchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw add i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
@@ -10,7 +10,15 @@
 // CHECK: atomicrmw xor i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw min i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw max i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
-__device__ int atomic32_op_singlethread(int *ptr, int val, int desired) {
+// CHECK: load atomic i32, i32* {{%[0-9]+}} syncscope("singlethread-one-as") acquire, align 4
+// CHECK: store atomic i32 {{%[0-9]+}}, i32* {{%[0-9]+}} seq_cst, align 4
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 {{%[0-9]+}}, i8* align 8 {{%[0-9]+}}, i64 4, i1 false)
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as") monotonic monotonic, align 4
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as") acquire monotonic, align 4
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as") release monotonic, align 4
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as") acq_rel monotonic, align 4
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup") seq_cst monotonic, align 4
+__device__ int atomic32_op_singlethread(int *ptr, int *ptr2, int val, int desired) {
   bool flag = __hip_atomic_compare_exchange_strong(ptr, , desired, __ATOMIC_RELAXED, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_exchange(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_fetch_add(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
@@ -19,6 +27,9 @@
   val = __hip_atomic_fetch_xor(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_fetch_min(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_fetch_max(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  val = __hip_atomic_load(ptr, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  __hip_atomic_store(ptr, ptr2, 5);
+  flag = __hip_atomic_compare_exchange_weak(ptr, ptr2, , desired, __HIP_MEMORY_SCOPE_WORKGROUP);
   return flag ? val : desired;
 }
 
@@ -31,7 +42,7 @@
   return val;
 }
 
-// CHECK-LABEL: @_Z21atomic32_op_wavefrontPiii
+// CHECK-LABEL: @_Z21atomic32_op_wavefrontPiS_ii
 // CHECK: cmpxchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
 // CHECK: atomicrmw xchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
 // CHECK: atomicrmw add i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
@@ -40,7 +51,9 @@
 // CHECK: atomicrmw xor i32* 

[clang] c79345f - [NFC][Clang][test] Inclusive language: Remove and rephrase uses of sanity test/check in clang/test

2021-11-24 Thread Zarko Todorovski via cfe-commits

Author: Zarko Todorovski
Date: 2021-11-24T14:03:49-05:00
New Revision: c79345fb7b149d9c952f8506c9e6c6317a5b4cd8

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

LOG: [NFC][Clang][test] Inclusive language: Remove and rephrase uses of sanity 
test/check in clang/test

Part of work to use more inclusive terms in clang/llvm.

Added: 


Modified: 
clang/test/Analysis/additive-folding.cpp
clang/test/Analysis/bitwise-ops.c
clang/test/Analysis/comparison-implicit-casts.cpp
clang/test/Analysis/ctor.mm
clang/test/Analysis/derived-to-base.cpp
clang/test/Analysis/dtor.cpp
clang/test/Analysis/expr-inspection.cpp
clang/test/Analysis/malloc-sizeof.cpp
clang/test/Analysis/plist-html-macros.c
clang/test/Analysis/reference.cpp
clang/test/Analysis/retain-release.m
clang/test/CodeGen/attr-nodebug.c
clang/test/CodeGenObjCXX/arc-attrs.mm
clang/test/CodeGenObjCXX/arc.mm
clang/test/Driver/arm-target-as-march-mcpu.s
clang/test/Driver/clang-g-opts.c
clang/test/Modules/framework-name.m
clang/test/Modules/target-features.m
clang/test/Modules/va_list.m
clang/test/PCH/cxx11-statement-attributes.cpp
clang/test/Rewriter/instancetype-test.mm
clang/test/Rewriter/rewrite-foreach-in-block.mm
clang/test/Sema/dllexport.c
clang/test/Sema/dllimport.c
clang/test/Sema/predef.c
clang/test/SemaCXX/coroutines-exp-namespace.cpp
clang/test/SemaCXX/coroutines.cpp
clang/test/SemaCXX/dllexport.cpp
clang/test/SemaCXX/dllimport.cpp
clang/test/SemaCXX/warn-thread-safety-analysis.cpp
clang/test/SemaObjC/arc-repeated-weak.mm
clang/test/SemaObjC/conversion.m
clang/test/SemaObjC/instancetype.m
clang/test/SemaObjC/warn-retain-cycle.m
clang/test/SemaObjCXX/instancetype.mm
clang/unittests/AST/ASTImporterFixtures.h
clang/unittests/Analysis/CFGDominatorTree.cpp
clang/unittests/Sema/ExternalSemaSourceTest.cpp
clang/unittests/Tooling/Syntax/TokensTest.cpp

Removed: 




diff  --git a/clang/test/Analysis/additive-folding.cpp 
b/clang/test/Analysis/additive-folding.cpp
index 6c84bf345e5ee..ddb32bdfa966a 100644
--- a/clang/test/Analysis/additive-folding.cpp
+++ b/clang/test/Analysis/additive-folding.cpp
@@ -141,7 +141,7 @@ void tautologiesOutside(unsigned char a) {
 
 // Wraparound with mixed types. Note that the analyzer assumes
 // -fwrapv semantics.
-void mixedWraparoundSanityCheck(int a) {
+void mixedWraparoundBasicCheck(int a) {
   int max = INT_MAX;
   int min = INT_MIN;
 
@@ -197,7 +197,7 @@ void mixedSignedness3(unsigned a) {
 }
 
 
-void multiplicativeSanityTest(int x) {
+void multiplicativeBasicTest(int x) {
   // At one point we were ignoring the *4 completely -- the constraint manager
   // would see x < 8 and then declare the assertion to be known false.
   if (x*4 < 8)

diff  --git a/clang/test/Analysis/bitwise-ops.c 
b/clang/test/Analysis/bitwise-ops.c
index fcd3d7dbc7cff..d8d2c920517d4 100644
--- a/clang/test/Analysis/bitwise-ops.c
+++ b/clang/test/Analysis/bitwise-ops.c
@@ -4,7 +4,7 @@ void clang_analyzer_eval(int);
 #define CHECK(expr) if (!(expr)) return; clang_analyzer_eval(expr)
 
 void testPersistentConstraints(int x, int y) {
-  // Sanity check
+  // Basic check
   CHECK(x); // expected-warning{{TRUE}}
   CHECK(x & 1); // expected-warning{{TRUE}}
   

diff  --git a/clang/test/Analysis/comparison-implicit-casts.cpp 
b/clang/test/Analysis/comparison-implicit-casts.cpp
index fe5254c0a53bd..dac2860110366 100644
--- a/clang/test/Analysis/comparison-implicit-casts.cpp
+++ b/clang/test/Analysis/comparison-implicit-casts.cpp
@@ -18,7 +18,7 @@ typedef typeof(sizeof(int)) size_t;
 void PR12206(int x) {
   size_t comparisonSize = sizeof(1 == 1);
 
-  // Sanity check. This test is useless if size_t isn't bigger than bool.
+  // This test is useless if size_t isn't bigger than bool.
   clang_analyzer_eval(sizeof(size_t) > comparisonSize); // 
expected-warning{{TRUE}}
 
   // Build a SymIntExpr, dependent on x.
@@ -75,7 +75,7 @@ size_t strlen(const char *s);
 void PR12206_strlen(const char *x) {
   size_t comparisonSize = sizeof(1 == 1);
 
-  // Sanity check. This test is useless if size_t isn't bigger than bool.
+  // This test is useless if size_t isn't bigger than bool.
   clang_analyzer_eval(sizeof(size_t) > comparisonSize); // 
expected-warning{{TRUE}}
 
   // Create a value that requires more bits to store than a comparison result.

diff  --git a/clang/test/Analysis/ctor.mm b/clang/test/Analysis/ctor.mm
index 08f06e75aebfe..1eafabb443de6 100644
--- a/clang/test/Analysis/ctor.mm
+++ b/clang/test/Analysis/ctor.mm
@@ -93,7 +93,7 @@ void test() {
 
 clang_analyzer_eval(obj.get() == 3); // expected-warning{{TRUE}}
 
-// Sanity check for devirtualization.
+// Correctness 

[clang] dc1aa8e - [PowerPC] Add missed clang portion of c933c2eb3346

2021-11-24 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-11-24T12:42:58-06:00
New Revision: dc1aa8eacd1e0e554f206cc15d730f37ea90c4ea

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

LOG: [PowerPC] Add missed clang portion of c933c2eb3346

The clang portion of c933c2eb3346 was missed as I made
some kind of mistake squashing the commits with git.
This patch just adds those.

The original review: https://reviews.llvm.org/D114088

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-p8vector.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index cd6b2df10e52..4ba23f8f3139 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -424,6 +424,12 @@ BUILTIN(__builtin_altivec_vctzh, "V8UsV8Us", "")
 BUILTIN(__builtin_altivec_vctzw, "V4UiV4Ui", "")
 BUILTIN(__builtin_altivec_vctzd, "V2ULLiV2ULLi", "")
 
+// P8 BCD builtins.
+BUILTIN(__builtin_ppc_bcdadd, "V16UcV16UcV16UcIi", "")
+BUILTIN(__builtin_ppc_bcdsub, "V16UcV16UcV16UcIi", "")
+BUILTIN(__builtin_ppc_bcdadd_p, "iiV16UcV16Uc", "")
+BUILTIN(__builtin_ppc_bcdsub_p, "iiV16UcV16Uc", "")
+
 BUILTIN(__builtin_altivec_vclzlsbb, "SiV16Uc", "")
 BUILTIN(__builtin_altivec_vctzlsbb, "SiV16Uc", "")
 BUILTIN(__builtin_altivec_vprtybw, "V4UiV4Ui", "")

diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 3366e1fc94b1..55195b0781fb 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -19,6 +19,10 @@
 #define __CR6_EQ_REV 1
 #define __CR6_LT 2
 #define __CR6_LT_REV 3
+#define __CR6_GT 4
+#define __CR6_GT_REV 5
+#define __CR6_SO 6
+#define __CR6_SO_REV 7
 
 /* Constants for vec_test_data_class */
 #define __VEC_CLASS_FP_SUBNORMAL_N (1 << 0)
@@ -19037,6 +19041,51 @@ vec_sra(vector signed __int128 __a, vector unsigned 
__int128 __b) {
 #endif /* __SIZEOF_INT128__ */
 #endif /* __POWER10_VECTOR__ */
 
+#ifdef __POWER8_VECTOR__
+#define __bcdadd(__a, __b, __ps) __builtin_ppc_bcdadd((__a), (__b), (__ps))
+#define __bcdsub(__a, __b, __ps) __builtin_ppc_bcdsub((__a), (__b), (__ps))
+
+static __inline__ long __bcdadd_ofl(vector unsigned char __a,
+vector unsigned char __b) {
+  return __builtin_ppc_bcdadd_p(__CR6_SO, __a, __b);
+}
+
+static __inline__ long __bcdsub_ofl(vector unsigned char __a,
+vector unsigned char __b) {
+  return __builtin_ppc_bcdsub_p(__CR6_SO, __a, __b);
+}
+
+static __inline__ long __bcd_invalid(vector unsigned char __a) {
+  return __builtin_ppc_bcdsub_p(__CR6_SO, __a, __a);
+}
+
+static __inline__ long __bcdcmpeq(vector unsigned char __a,
+  vector unsigned char __b) {
+  return __builtin_ppc_bcdsub_p(__CR6_EQ, __a, __b);
+}
+
+static __inline__ long __bcdcmplt(vector unsigned char __a,
+  vector unsigned char __b) {
+  return __builtin_ppc_bcdsub_p(__CR6_LT, __a, __b);
+}
+
+static __inline__ long __bcdcmpgt(vector unsigned char __a,
+  vector unsigned char __b) {
+  return __builtin_ppc_bcdsub_p(__CR6_GT, __a, __b);
+}
+
+static __inline__ long __bcdcmple(vector unsigned char __a,
+  vector unsigned char __b) {
+  return __builtin_ppc_bcdsub_p(__CR6_GT_REV, __a, __b);
+}
+
+static __inline__ long __bcdcmpge(vector unsigned char __a,
+  vector unsigned char __b) {
+  return __builtin_ppc_bcdsub_p(__CR6_LT_REV, __a, __b);
+}
+
+#endif // __POWER8_VECTOR__
+
 #undef __ATTRS_o_ai
 
 #endif /* __ALTIVEC_H */

diff  --git a/clang/test/CodeGen/builtins-ppc-p8vector.c 
b/clang/test/CodeGen/builtins-ppc-p8vector.c
index 90e6de283cb1..7825d69c97ec 100644
--- a/clang/test/CodeGen/builtins-ppc-p8vector.c
+++ b/clang/test/CodeGen/builtins-ppc-p8vector.c
@@ -1272,3 +1272,85 @@ vector unsigned int test_vec_subec_unsigned (vector 
unsigned int a, vector unsig
 // CHECK: xor <4 x i32> {{%[0-9]+}}, 
 // CHECK: ret <4 x i32>
 }
+
+int test_bcd_invalid(vector unsigned char a) {
+  // CHECK-LABEL: test_bcd_invalid
+  // CHECK: call i32 @llvm.ppc.bcdsub.p(i32 6, <16 x i8>
+  // CHECK-LE-LABEL: test_bcd_invalid
+  // CHECK-LE: call i32 @llvm.ppc.bcdsub.p(i32 6, <16 x i8>
+  return __bcd_invalid(a);
+}
+
+vector unsigned char test_bcd_add(vector unsigned char a, vector unsigned char 
b,
+  int ps) {
+  // CHECK-LABEL: test_bcd_add
+  // CHECK: call <16 x i8> @llvm.ppc.bcdadd(<16 x i8>
+  // CHECK-LE-LABEL: test_bcd_add
+  // CHECK-LE: call <16 x i8> @llvm.ppc.bcdadd(<16 x i8>
+  return __bcdadd(a, b, 1);
+}
+
+int test_bcd_add_ofl(vector unsigned char a, vector unsigned char 

[PATCH] D114326: Update the list of CUDA versions up to 11.5

2021-11-24 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:131
+  std::initializer_list Versions = {
+  "11.5", "11.4", "11.3", "11.2", "11.1", "11.0", "10.2", "10.1",
+  "10.0", "9.2",  "9.1",  "9.0",  "8.0",  "7.5",  "7.0"};

tra wrote:
> mojca wrote:
> > kadircet wrote:
> > > looks like the list is getting big and hard to maintain. considering that 
> > > this is done only once per compiler invocation (and we check for 
> > > existence of directories down in the loop anyway). what about throwing in 
> > > an extra directory listing to base-directories mentioned down below and 
> > > populate `Candidates` while preserving the newest-version-first order?
> > I totally agree with the sentiment, and that was my initial thought as 
> > well, but with zero experience I was too scared to make any more 
> > significant changes.
> > 
> > I can try to come up with a new patch (that doesn't need further 
> > maintenance whenever a new CUDA version gets released) if that's what you 
> > are suggesting. I would nevertheless merge this one, and prepare a new more 
> > advanced patch separately, but that's finally your call.
> > 
> > What's your suggestion about D.SysRoot + "Program Files/..."? At the time 
> > when this function gets called it looks like D.SysRoot is empty (or at 
> > least my debugger says so) and in my case it resolves to D: while the CUDA 
> > support is installed under C:.
> > 
> > Is there any special LLVM-specific/preferrable way to iterate through 
> > directories?
> > 
> > (What I also miss a bit in the whole process in an option to simply say "I 
> > want CUDA 11.1" without the need to explicitly spell out the full path.)
> > 
> > If you provide me give some general guidelines, I'll prepare another, 
> > hopefully more future-proof patch.
> > 
> > (Side note: I'm not sure if I'm calling clang-format correctly, but if I 
> > call it, it keeps reformatting the rest of this file.)
> This whole list may no longer be particularly useful. The most common use 
> case on Linux, AFAICT, is to install only one CUDA version using 
> system-provided package manager.
> E.g. https://packages.ubuntu.com/focal/amd64/nvidia-cuda-toolkit/filelist
> 
> TBH, I'm tempted to limit autodetection to only that one system-default 
> version and require user to use --cuda-path if they need something else.
I think on windows (I mean the windows environment itself, not WSL), CUDA 
installer sets an environment variable which could be used to detect the 
default CUDA version, so it may warrant a windows-specific way to find it. 



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:131
+  std::initializer_list Versions = {
+  "11.5", "11.4", "11.3", "11.2", "11.1", "11.0", "10.2", "10.1",
+  "10.0", "9.2",  "9.1",  "9.0",  "8.0",  "7.5",  "7.0"};

mojca wrote:
> carlosgalvezp wrote:
> > mojca wrote:
> > > tra wrote:
> > > > tra wrote:
> > > > > mojca wrote:
> > > > > > kadircet wrote:
> > > > > > > looks like the list is getting big and hard to maintain. 
> > > > > > > considering that this is done only once per compiler invocation 
> > > > > > > (and we check for existence of directories down in the loop 
> > > > > > > anyway). what about throwing in an extra directory listing to 
> > > > > > > base-directories mentioned down below and populate `Candidates` 
> > > > > > > while preserving the newest-version-first order?
> > > > > > I totally agree with the sentiment, and that was my initial thought 
> > > > > > as well, but with zero experience I was too scared to make any more 
> > > > > > significant changes.
> > > > > > 
> > > > > > I can try to come up with a new patch (that doesn't need further 
> > > > > > maintenance whenever a new CUDA version gets released) if that's 
> > > > > > what you are suggesting. I would nevertheless merge this one, and 
> > > > > > prepare a new more advanced patch separately, but that's finally 
> > > > > > your call.
> > > > > > 
> > > > > > What's your suggestion about D.SysRoot + "Program Files/..."? At 
> > > > > > the time when this function gets called it looks like D.SysRoot is 
> > > > > > empty (or at least my debugger says so) and in my case it resolves 
> > > > > > to D: while the CUDA support is installed under C:.
> > > > > > 
> > > > > > Is there any special LLVM-specific/preferrable way to iterate 
> > > > > > through directories?
> > > > > > 
> > > > > > (What I also miss a bit in the whole process in an option to simply 
> > > > > > say "I want CUDA 11.1" without the need to explicitly spell out the 
> > > > > > full path.)
> > > > > > 
> > > > > > If you provide me give some general guidelines, I'll prepare 
> > > > > > another, hopefully more future-proof patch.
> > > > > > 
> > > > > > (Side note: I'm not sure if I'm calling clang-format correctly, but 
> > > > > > if I call it, it keeps reformatting the rest of this file.)
> > > > > This whole list may no longer be 

[PATCH] D114546: [OPENMP]Fix PR52117: Crash caused by target region inside of task construct.

2021-11-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: jdoerfert, mikerice.
Herald added subscribers: guansong, yaxunl.
ABataev requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

Need to do the analysis of the captured expressions in the clauses.
Previously the compiler ignored them and it may lead to a compiler crash
trying to get the address of the mapped variables.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114546

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/Analysis/cfg-openmp.cpp
  clang/test/OpenMP/task_target_device_codegen.c
  clang/test/OpenMP/taskloop_codegen.cpp

Index: clang/test/OpenMP/taskloop_codegen.cpp
===
--- clang/test/OpenMP/taskloop_codegen.cpp
+++ clang/test/OpenMP/taskloop_codegen.cpp
@@ -238,8 +238,8 @@
 // CHECK-LABEL: taskloop_with_class
 void taskloop_with_class() {
   St s1;
-  // CHECK: [[TD:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @{{.+}}, i32 [[GTID:%.+]], i32 1, i64 88, i64 8, i32 (i32, i8*)* bitcast (i32 (i32, [[TD_TYPE:%.+]]*)* @{{.+}} to i32 (i32, i8*)*))
-  // CHECK: call void @__kmpc_taskloop(%struct.ident_t* @{{.+}}, i32 [[GTID]], i8* [[TD]], i32 1, i64* %{{.+}}, i64* %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 0, i8* bitcast (void ([[TD_TYPE]]*, [[TD_TYPE]]*, i32)* @{{.+}} to i8*))
+  // CHECK: [[TD:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @{{.+}}, i32 [[GTID:%.+]], i32 1, i64 80, i64 8, i32 (i32, i8*)* bitcast (i32 (i32, [[TD_TYPE:%.+]]*)* @{{.+}} to i32 (i32, i8*)*))
+  // CHECK: call void @__kmpc_taskloop(%struct.ident_t* @{{.+}}, i32 [[GTID]], i8* [[TD]], i32 1, i64* %{{.+}}, i64* %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 0, i8* null)
 #pragma omp taskloop
   for (St s = St(); s < s1; s += 1) {
   }
Index: clang/test/OpenMP/task_target_device_codegen.c
===
--- /dev/null
+++ clang/test/OpenMP/task_target_device_codegen.c
@@ -0,0 +1,105 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[   .].+[.|,]" --prefix-filecheck-ir-name _
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fopenmp-version=50 -x c -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -fopenmp-version=50 -x c -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+void test_task_affinity() {
+  int t;
+#pragma omp task
+  {
+#pragma omp target device(t)
+;
+  }
+}
+#endif
+// CHECK-LABEL: define {{[^@]+}}@test_task_affinity
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[T:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON:%.*]], align 1
+// CHECK-NEXT:[[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB1:[0-9]+]])
+// CHECK-NEXT:[[TMP1:%.*]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @[[GLOB1]], i32 [[TMP0]], i32 1, i64 48, i64 0, i32 (i32, i8*)* bitcast (i32 (i32, %struct.kmp_task_t_with_privates*)* @.omp_task_entry. to i32 (i32, i8*)*))
+// CHECK-NEXT:[[TMP2:%.*]] = bitcast i8* [[TMP1]] to %struct.kmp_task_t_with_privates*
+// CHECK-NEXT:[[TMP3:%.*]] = getelementptr inbounds [[STRUCT_KMP_TASK_T_WITH_PRIVATES:%.*]], %struct.kmp_task_t_with_privates* [[TMP2]], i32 0, i32 0
+// CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds [[STRUCT_KMP_TASK_T_WITH_PRIVATES]], %struct.kmp_task_t_with_privates* [[TMP2]], i32 0, i32 1
+// CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds [[STRUCT__KMP_PRIVATES_T:%.*]], %struct..kmp_privates.t* [[TMP4]], i32 0, i32 0
+// CHECK-NEXT:[[TMP6:%.*]] = load i32, i32* [[T]], align 4
+// CHECK-NEXT:store i32 [[TMP6]], i32* [[TMP5]], align 8
+// CHECK-NEXT:[[TMP7:%.*]] = call i32 @__kmpc_omp_task(%struct.ident_t* @[[GLOB1]], i32 [[TMP0]], i8* [[TMP1]])
+// CHECK-NEXT:ret void
+//
+//
+// CHECK-LABEL: define {{[^@]+}}@{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_test_task_affinity_l18
+// CHECK-SAME: () #[[ATTR1:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret void
+//
+//
+// CHECK-LABEL: define 

[PATCH] D114100: [NFC][clang-tools-extra] Inclusive language: replace master with main

2021-11-24 Thread Quinn Pham via Phabricator via cfe-commits
quinnp added a comment.

@sammccall could you take a look at the other changes when you have time? 
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114100

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


[PATCH] D114481: [NFC][AIX]Disable precompiled module file tests on AIX

2021-11-24 Thread Steven Wan 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 rG06d4a76309cd: [NFC][AIX]Disable precompiled module file 
tests on AIX (authored by stevewan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114481

Files:
  clang/test/ClangScanDeps/modules-pch-common-submodule.c
  clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
  clang/test/ClangScanDeps/modules-pch.c
  clang/test/PCH/debug-info-pch-path.c


Index: clang/test/PCH/debug-info-pch-path.c
===
--- clang/test/PCH/debug-info-pch-path.c
+++ clang/test/PCH/debug-info-pch-path.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: cd %t
Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/modules-pch/* %t
 
Index: clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that we discover dependency on a precompiled module (and generate the
 // appropriate `-fmodule-file=` argument) when it's imported by a **submodule**
 // instead of a top-level module.
Index: clang/test/ClangScanDeps/modules-pch-common-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that when depending on a precompiled module, we depend on the
 // **top-level** module. Submodules don't have some information present (for
 // example the path to the modulemap file) and depending on them might cause


Index: clang/test/PCH/debug-info-pch-path.c
===
--- clang/test/PCH/debug-info-pch-path.c
+++ clang/test/PCH/debug-info-pch-path.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: cd %t
Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/modules-pch/* %t
 
Index: clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that we discover dependency on a precompiled module (and generate the
 // appropriate `-fmodule-file=` argument) when it's imported by a **submodule**
 // instead of a top-level module.
Index: clang/test/ClangScanDeps/modules-pch-common-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that when depending on a precompiled module, we depend on the
 // **top-level** module. Submodules don't have some information present (for
 // example the path to the modulemap file) and depending on them might cause
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 06d4a76 - [NFC][AIX]Disable precompiled module file tests on AIX

2021-11-24 Thread Steven Wan via cfe-commits

Author: Steven Wan
Date: 2021-11-24T13:22:09-05:00
New Revision: 06d4a76309cd97e25859770b3da29006ccac421a

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

LOG: [NFC][AIX]Disable precompiled module file tests on AIX

The PCH reader looks for `__clangast` section in the precompiled module file, 
which is not present in the file on AIX, and we don't support writing this 
custom section in XCOFF yet.

Reviewed By: daltenty

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

Added: 


Modified: 
clang/test/ClangScanDeps/modules-pch-common-submodule.c
clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
clang/test/ClangScanDeps/modules-pch.c
clang/test/PCH/debug-info-pch-path.c

Removed: 




diff  --git a/clang/test/ClangScanDeps/modules-pch-common-submodule.c 
b/clang/test/ClangScanDeps/modules-pch-common-submodule.c
index 0189ab346ac01..c7f3e76cf0a15 100644
--- a/clang/test/ClangScanDeps/modules-pch-common-submodule.c
+++ b/clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that when depending on a precompiled module, we depend on the
 // **top-level** module. Submodules don't have some information present (for
 // example the path to the modulemap file) and depending on them might cause

diff  --git a/clang/test/ClangScanDeps/modules-pch-common-via-submodule.c 
b/clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
index 3d35ede3b67c9..e63e310b22d09 100644
--- a/clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
+++ b/clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that we discover dependency on a precompiled module (and generate the
 // appropriate `-fmodule-file=` argument) when it's imported by a **submodule**
 // instead of a top-level module.

diff  --git a/clang/test/ClangScanDeps/modules-pch.c 
b/clang/test/ClangScanDeps/modules-pch.c
index 755ddeea67c56..2be17743a64b9 100644
--- a/clang/test/ClangScanDeps/modules-pch.c
+++ b/clang/test/ClangScanDeps/modules-pch.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/modules-pch/* %t
 

diff  --git a/clang/test/PCH/debug-info-pch-path.c 
b/clang/test/PCH/debug-info-pch-path.c
index 272d9ac1ab7cf..192d5c79d4819 100644
--- a/clang/test/PCH/debug-info-pch-path.c
+++ b/clang/test/PCH/debug-info-pch-path.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: cd %t



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


[PATCH] D114481: [NFC][AIX]Disable precompiled module file tests on AIX

2021-11-24 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 389535.
stevewan added a comment.

Explain the rationale


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114481

Files:
  clang/test/ClangScanDeps/modules-pch-common-submodule.c
  clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
  clang/test/ClangScanDeps/modules-pch.c
  clang/test/PCH/debug-info-pch-path.c


Index: clang/test/PCH/debug-info-pch-path.c
===
--- clang/test/PCH/debug-info-pch-path.c
+++ clang/test/PCH/debug-info-pch-path.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: cd %t
Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/modules-pch/* %t
 
Index: clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that we discover dependency on a precompiled module (and generate the
 // appropriate `-fmodule-file=` argument) when it's imported by a **submodule**
 // instead of a top-level module.
Index: clang/test/ClangScanDeps/modules-pch-common-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that when depending on a precompiled module, we depend on the
 // **top-level** module. Submodules don't have some information present (for
 // example the path to the modulemap file) and depending on them might cause


Index: clang/test/PCH/debug-info-pch-path.c
===
--- clang/test/PCH/debug-info-pch-path.c
+++ clang/test/PCH/debug-info-pch-path.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: cd %t
Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/modules-pch/* %t
 
Index: clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that we discover dependency on a precompiled module (and generate the
 // appropriate `-fmodule-file=` argument) when it's imported by a **submodule**
 // instead of a top-level module.
Index: clang/test/ClangScanDeps/modules-pch-common-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that when depending on a precompiled module, we depend on the
 // **top-level** module. Submodules don't have some information present (for
 // example the path to the modulemap file) and depending on them might cause
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108479: [Clang] Add __builtin_addressof_nocfi

2021-11-24 Thread Sami Tolvanen via Phabricator via cfe-commits
samitolvanen planned changes to this revision.
samitolvanen added a comment.

In D108479#3150298 , @rjmccall wrote:

> Your builtin is using custom type-checking (`t`), which suppresses all the 
> normal conversions that happen on expressions.  Specifically, it skips 
> lvalue-to-rvalue conversion, so in this example the argument ends up being an 
> l-value reference to a variable rather than an r-value loaded from that 
> variable.

OK, that explains it. Thanks for the explanation!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108479

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


[PATCH] D114454: [NFC][AIX]Disable unstable CSA tests failing on AIX

2021-11-24 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

> Let me summon them.

*I have no memory of this place.*

Sorry to disappoint.  That blame was four years ago, not counting covid-related 
time dilation.

I do agree that disabling a test just to please a static analyzer is probably 
not the best way to go.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114454

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


[PATCH] D114234: [clang][dataflow] Add base types for building dataflow analyses

2021-11-24 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev updated this revision to Diff 389522.
sgatev marked an inline comment as done.
sgatev added a comment.

Document the role of the "Dynamic" suffix in the name of 
DataflowAnalysisDynamic and its members.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114234

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/Environment.h
  clang/lib/Analysis/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/DataflowAnalysis.cpp

Index: clang/lib/Analysis/FlowSensitive/DataflowAnalysis.cpp
===
--- /dev/null
+++ clang/lib/Analysis/FlowSensitive/DataflowAnalysis.cpp
@@ -0,0 +1,34 @@
+//===- DataflowAnalysis.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file defines base types for building dataflow analyses that run over
+//  Control-Flow Graphs (CFGs).
+//
+//===--===//
+
+#include 
+
+#include "clang/Analysis/CFG.h"
+#include "clang/Analysis/FlowSensitive/DataflowAnalysis.h"
+#include "clang/Analysis/FlowSensitive/Environment.h"
+#include "llvm/ADT/Optional.h"
+
+using namespace clang;
+using namespace dataflow;
+
+std::vector>
+runDataflowAnalysis(const CFG , DataflowAnalysisDynamic ,
+const Environment ) {
+  // FIXME: Consider enforcing that `Cfg` meets the requirements that
+  // are specified in the header. This could be done by remembering
+  // what options were used to build `Cfg` and asserting on them here.
+
+  // FIXME: Implement work list-based algorithm to compute the fixed
+  // point of `Analysis::transform` for every basic block in `Cfg`.
+  return {};
+}
Index: clang/lib/Analysis/FlowSensitive/CMakeLists.txt
===
--- /dev/null
+++ clang/lib/Analysis/FlowSensitive/CMakeLists.txt
@@ -0,0 +1,7 @@
+add_clang_library(clangAnalysisFlowSensitive
+  DataflowAnalysis.cpp
+
+  LINK_LIBS
+  clangAnalysis
+  clangAST
+  )
Index: clang/lib/Analysis/CMakeLists.txt
===
--- clang/lib/Analysis/CMakeLists.txt
+++ clang/lib/Analysis/CMakeLists.txt
@@ -44,3 +44,4 @@
   )
 
 add_subdirectory(plugins)
+add_subdirectory(FlowSensitive)
Index: clang/include/clang/Analysis/FlowSensitive/Environment.h
===
--- /dev/null
+++ clang/include/clang/Analysis/FlowSensitive/Environment.h
@@ -0,0 +1,27 @@
+//===-- Environment.h ---*- C++ -*-===//
+//
+// 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 defines an Environment class that is used by dataflow analyses
+//  that run over Control-Flow Graphs (CFGs) to keep track of the state of the
+//  program at given program points.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_ENVIRONMENT_H
+#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_ENVIRONMENT_H
+
+namespace clang {
+namespace dataflow {
+
+/// Holds the state of the program (store and heap) at a given program point.
+class Environment {};
+
+} // namespace dataflow
+} // namespace clang
+
+#endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_ENVIRONMENT_H
Index: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
===
--- /dev/null
+++ clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
@@ -0,0 +1,167 @@
+//===- DataflowAnalysis.h ---*- C++ -*-===//
+//
+// 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 defines base types for building dataflow analyses that run over
+//  Control-Flow Graphs (CFGs).
+//
+//===--===//
+
+#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_DATAFLOWANALYSIS_H
+#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_DATAFLOWANALYSIS_H
+
+#include 
+#include 
+
+#include 

[PATCH] D109372: [RISCV][RFC] Add Clang support for RISC-V overlay system

2021-11-24 Thread Edward Jones via Phabricator via cfe-commits
edward-jones updated this revision to Diff 389520.

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

https://reviews.llvm.org/D109372

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/riscv-overlay.c
  clang/test/Driver/riscv-overlay.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/riscv-overlay-attr.c
  clang/test/Sema/riscv-overlay-namespace.cpp

Index: clang/test/Sema/riscv-overlay-namespace.cpp
===
--- /dev/null
+++ clang/test/Sema/riscv-overlay-namespace.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -triple riscv32-unknown-elf -verify -fsyntax-only -moverlay
+// RUN: %clang_cc1 %s -triple riscv64-unknown-elf -verify -fsyntax-only -moverlay
+
+namespace {
+class foo {
+public:
+  static int X() __attribute__((overlay_call)) { return 0; } // expected-error {{functions marked with 'overlay_call' attribute must have external linkage}}
+};
+} // end of anonymous namespace
+
+namespace X {
+class bar {
+public:
+  static int X() __attribute__((overlay_call)) { return 1; }
+};
+} // end of namespace X
+
+extern "C" {
+int main(void) { return foo::X() + X::bar::X(); }
+}
Index: clang/test/Sema/riscv-overlay-attr.c
===
--- /dev/null
+++ clang/test/Sema/riscv-overlay-attr.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple riscv32 -moverlay -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple riscv64 -moverlay -fsyntax-only -verify %s
+
+int notAFunction __attribute__((overlay_call));
+// expected-warning@-1 {{'overlay_call' attribute only applies to functions}}
+
+void incompatForwardDecl(int x);
+void __attribute__((overlay_call)) incompatForwardDecl(int x) {}
+// expected-error@-1 {{redeclaration of 'incompatForwardDecl' must not have the 'overlay_call' attribute}}
+// expected-note@-3 {{previous definition is here}}
+
+static void staticcall() __attribute__((overlay_call)) {}
+// expected-error@-1 {{functions marked with 'overlay_call' attribute must have external linkage}}
+
+static void __attribute__((overlay_call)) staticcall2() {}
+// expected-error@-1 {{functions marked with 'overlay_call' attribute must have external linkage}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -147,6 +147,7 @@
 // CHECK-NEXT: PassObjectSize (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: PatchableFunctionEntry (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: Pointer (SubjectMatchRule_record_not_is_union)
+// CHECK-NEXT: RISCVOverlayCall (SubjectMatchRule_function)
 // CHECK-NEXT: ReleaseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: RenderScriptKernel (SubjectMatchRule_function)
 // CHECK-NEXT: ReqdWorkGroupSize (SubjectMatchRule_function)
Index: clang/test/Driver/riscv-overlay.c
===
--- /dev/null
+++ clang/test/Driver/riscv-overlay.c
@@ -0,0 +1,5 @@
+// Check that ComRV Driver Arguments
+
+// RUN: not %clang -target riscv32 -moverlay %s -o %t.o -mabi=ilp32f 2>&1 \
+// RUN:   | FileCheck -check-prefix=INVALID-ABI %s
+// INVALID-ABI: invalid ABI 'ilp32f' when using '-moverlay'
Index: clang/test/CodeGen/riscv-overlay.c
===
--- /dev/null
+++ clang/test/CodeGen/riscv-overlay.c
@@ -0,0 +1,11 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-attributes
+// RUN: %clang_cc1 -triple riscv32 -moverlay -emit-llvm %s -o - \
+// RUN:| FileCheck %s
+
+// CHECK-LABEL: @test_overlay_func(
+// CHECK-SAME: #0
+// CHECK: attributes #0 = {
+// CHECK-SAME: "overlay"
+int __attribute__((overlay_call)) test_overlay_func(void) {
+  return 5;
+}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -2039,6 +2039,33 @@
   D->addAttr(::new (S.Context) CmseNSEntryAttr(S.Context, AL));
 }
 
+static void handleRISCVOverlayAttr(Sema , Decl *D, const ParsedAttr ) {
+  if (!S.getLangOpts().Overlay) {
+S.Diag(AL.getRange().getBegin(), diag::warn_attribute_ignored_overlay)
+<< AL;
+return;
+  }
+
+  if (isFunctionOrMethod(D)) {
+

[PATCH] D114320: [clang-format] Extend AllowShortBlocksOnASingleLine for else blocks

2021-11-24 Thread Jesses Gott via Phabricator via cfe-commits
jessesna added a comment.

In D114320#3148046 , @MyDeveloperDay 
wrote:

> Ok now I'm a little puzzled, shouldn't this be covered by 
> `AllowShortIfStatementsOnASingleLine`?

That's exactly what i thought when i first stumbled over the behavior :D But I 
think the majority of users might not even consider adding empty else blocks. 
Only a few either just do it or have to comply with some standards, f.e. MISRA 
 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114320

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


[PATCH] D114521: [clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I think the problem here is encapsulated by adding the following tests

   Style.BraceWrapping.AfterFunction = true;
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
   Style.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_AllIfsAndElse;
   Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Always;
   Style.AllowShortLoopsOnASingleLine = true;
   Style.ColumnLimit = 80;
  
   Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Never;
   verifyFormat("void shortfunction() { bar(); }", Style);
   verifyFormat("if (x) { bar(); }", Style);
   verifyFormat("for (;;) { bar(); }", Style);
   verifyFormat("while (true) { bar(); }", Style);
   Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_MultiLine;
   verifyFormat("void shortfunction() { bar(); }", Style);
   verifyFormat("if (x) { bar(); }", Style);
  >>> FAILS  ^^^
  
   verifyFormat("for (;;) { bar(); }", Style);
  >>> FAILS  ^^^
  
   verifyFormat("while (true) { bar(); }", Style);
  >>> FAILS  ^^^
  
   Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Never;
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
   Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
   Style.AllowShortLoopsOnASingleLine = false;
   verifyFormat("void shortfunction()\n"
"{\n"
"  foo();\n"
"}",
Style);
   verifyFormat("if (x) {\n"
"  foo();\n"
"}",
Style);
   verifyFormat("for (;;) {\n"
"  foo();\n"
"}",
Style);
   verifyFormat("while (true) {\n"
"  foo();\n"
"}",
Style);
  
   Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_MultiLine;
   verifyFormat("void shortfunction()\n"
"{\n"
"  foo();\n"
"}",
Style);
   verifyFormat("if (x) {\n"
"  foo();\n"
"}",
Style);
   verifyFormat("for (;;) {\n"
"  foo();\n"
"}",
Style);
   verifyFormat("while (true) {\n"
"  foo();\n"
"}",
Style);


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114521

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


[PATCH] D114540: Big-endian version of vpermxor

2021-11-24 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

Please also add a test for this builtin to the front end test 
`clang/test/CodeGen/builtins-ppc-crypto.c`




Comment at: llvm/lib/Target/PowerPC/PPCInstrVSX.td:2499
  (COPY_TO_REGCLASS $c, VSRC>;
+  def : Pat<(v16i8 (int_ppc_altivec_crypto_vpermxor_be v16i8:$a,
+v16i8:$b, v16i8:$c)),

Although it would be redundant, it is not invalid to use this builtin/intrinsic 
in BE compilations. As such, please move this to a block that has only the
`[HasVSX, HasP8Altivec]` predicates as the desired code is the same for LE/BE.



Comment at: llvm/test/CodeGen/PowerPC/crypto_bifs_be.ll:9
+entry:
+  %a = alloca <16 x i8>, align 16
+  %b = alloca <16 x i8>, align 16

Please clean up this test case a bit:
- Run `opt --passes="default"` on it to clean up the unnecessary code
- Remove the attributes
- The 755 permissions on the test case are unusual
- Produce the CHECK's automatically using 
`$LLVM_SRC/utils/update_llc_test_checks.py`
- Add a BE invocation (either the P8 or the P9 can just use the 
`powerpc64-unknown-linux-gnu` triple)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114540

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


[PATCH] D114521: [clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.



> @curdeius 
> Alright, I'll create a report https://bugs.llvm.org/show_bug.cgi?id=52598

That is related. But I'd rather handle it separately because the fix for the 
function and the fix for a while or if will need to be different.

It really comes down to this line..

  if (Line.First == Line.Last && Line.First->isNot(TT_FunctionLBrace)

in the if case and in the while case the `{` isn't labeled like it is for the 
function

  M=0 C=0 T=Unknown S=1 F=0 B=0 BK=1 P=0 Name=l_brace L=1 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text='{'

To be honest this is something we should think about, if every `{` and `}` 
every `(`,`)` and `[`,`]` got given a Type labels this would be super good at 
disambiguating them

This is not something new, we've been doing it with the ')' of a cstyle cast 
for years `CastRParen`

  M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=int L=3 PPK=2 FakeLParens=2/ 
FakeRParens=0 II=0x25a969b1660 Text='int'
  M=0 C=1 T=StartOfName S=1 F=0 B=0 BK=0 P=220 Name=identifier L=5 PPK=2 
FakeLParens= FakeRParens=0 II=0x25a969b8768 Text='a'
  M=0 C=0 T=BinaryOperator S=1 F=0 B=0 BK=0 P=22 Name=equal L=7 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text='='
  M=0 C=1 T=Unknown S=1 F=0 B=0 BK=0 P=22 Name=l_paren L=9 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text='('
  M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=59 Name=int L=12 PPK=2 FakeLParens= 
FakeRParens=0 II=0x25a969b1660 Text='int'
  M=0 C=0 T=CastRParen S=0 F=0 B=0 BK=0 P=43 Name=r_paren L=13 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text=')'

but in this case, the real problem here is that `Multiline`  just too lax, 
basically Multiline doesn't in my view seem to be doing what it expects

F20680737: image.png 

From this is seems it should ONLY be returning 0 (meaning don't join the line), 
if the "clause" in the (if,for,while) contains multiple conditions that have 
been broken over several lines.

I just don't think this is sufficiently constrained.

  // Don't merge a trailing multi-line control statement block like:
  // } else if (foo &&
  //bar)
  // { <-- current Line
  //   baz();
  // }
  if (Line.First == Line.Last  &&
  Style.BraceWrapping.AfterControlStatement ==
  FormatStyle::BWACS_MultiLine)
return 0;




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114521

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


[PATCH] D113118: [clang][AST] Check context of record in structural equivalence.

2021-11-24 Thread Balázs Kéri 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 rG6b96b2a0bf65: [clang][AST] Check context of record in 
structural equivalence. (authored by balazske).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113118

Files:
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/unittests/AST/StructuralEquivalenceTest.cpp

Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -929,6 +929,136 @@
   EXPECT_TRUE(testStructuralMatch(First, Second));
 }
 
+struct StructuralEquivalenceRecordContextTest : StructuralEquivalenceTest {};
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceNoVsNamed) {
+  auto Decls = makeDecls("class X;", "namespace N { class X; }",
+Lang_CXX03, cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceNamedVsNamed) {
+  auto Decls = makeDecls("namespace A { class X; }",
+"namespace B { class X; }", Lang_CXX03,
+cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceAnonVsNamed) {
+  auto Decls = makeDecls("namespace { class X; }",
+"namespace N { class X; }", Lang_CXX03,
+cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceNoVsAnon) {
+  auto Decls = makeDecls("class X;", "namespace { class X; }",
+Lang_CXX03, cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceAnonVsAnon) {
+  auto Decls = makeDecls("namespace { class X; }",
+"namespace { class X; }", Lang_CXX03,
+cxxRecordDecl());
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceAnonVsAnonAnon) {
+  auto Decls = makeDecls("namespace { class X; }",
+"namespace { namespace { class X; } }",
+Lang_CXX03, cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest,
+   NamespaceNamedNamedVsNamedNamed) {
+  auto Decls = makeDecls(
+  "namespace A { namespace N { class X; } }",
+  "namespace B { namespace N { class X; } }", Lang_CXX03, cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceNamedVsInline) {
+  auto Decls = makeDecls(
+  "namespace A { namespace A { class X; } }",
+  "namespace A { inline namespace A { class X; } }", Lang_CXX17,
+  cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceInlineVsInline) {
+  auto Decls = makeDecls(
+  "namespace A { inline namespace A { class X; } }",
+  "namespace A { inline namespace B { class X; } }", Lang_CXX17,
+  cxxRecordDecl());
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceInlineTopLevel) {
+  auto Decls = makeDecls("inline namespace A { class X; } }",
+"inline namespace B { class X; } }",
+Lang_CXX17, cxxRecordDecl());
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, TransparentContext) {
+  auto Decls = makeDecls("extern \"C\" { class X; }", "class X;",
+Lang_CXX03, cxxRecordDecl());
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, TransparentContextNE) {
+  auto Decls = makeDecls("extern \"C\" { class X; }",
+"namespace { class X; }", Lang_CXX03,
+cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, TransparentContextInNamespace) {
+  auto Decls = makeDecls(
+  "extern \"C\" { namespace N { class X; } }",
+  "namespace N { extern \"C\" { class X; } }", Lang_CXX03, cxxRecordDecl());
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceTest, NamespaceOfRecordMember) {
+  auto Decls = makeDecls(
+  R"(
+  class X;
+  class Y { X* x; };
+  )",
+  R"(
+  namespace N { class X; }
+  class Y { N::X* x; };
+ 

[clang] 6b96b2a - [clang][AST] Check context of record in structural equivalence.

2021-11-24 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2021-11-24T17:36:15+01:00
New Revision: 6b96b2a0bf65ff838d4dbf909a5120d4d1083e29

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

LOG: [clang][AST] Check context of record in structural equivalence.

The AST structural equivalence check did not differentiate between
a struct and a struct with same name in different namespace. When
type of a member is checked it is possible to encounter such a case
and wrongly decide that the types are similar. This problem is fixed
by check for the namespaces of a record declaration.

Reviewed By: martong

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

Added: 


Modified: 
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/unittests/AST/StructuralEquivalenceTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTStructuralEquivalence.cpp 
b/clang/lib/AST/ASTStructuralEquivalence.cpp
index e85feb779190f..7fd24e2aa9ad2 100644
--- a/clang/lib/AST/ASTStructuralEquivalence.cpp
+++ b/clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -1347,6 +1347,42 @@ 
IsStructurallyEquivalentLambdas(StructuralEquivalenceContext ,
   return true;
 }
 
+/// Determine if context of a class is equivalent.
+static bool IsRecordContextStructurallyEquivalent(RecordDecl *D1,
+  RecordDecl *D2) {
+  // The context should be completely equal, including anonymous and inline
+  // namespaces.
+  // We compare objects as part of full translation units, not subtrees of
+  // translation units.
+  DeclContext *DC1 = D1->getDeclContext()->getNonTransparentContext();
+  DeclContext *DC2 = D2->getDeclContext()->getNonTransparentContext();
+  while (true) {
+// Special case: We allow a struct defined in a function to be equivalent
+// with a similar struct defined outside of a function.
+if ((DC1->isFunctionOrMethod() && DC2->isTranslationUnit()) ||
+(DC2->isFunctionOrMethod() && DC1->isTranslationUnit()))
+  return true;
+
+if (DC1->getDeclKind() != DC2->getDeclKind())
+  return false;
+if (DC1->isTranslationUnit())
+  break;
+if (DC1->isInlineNamespace() != DC2->isInlineNamespace())
+  return false;
+if (const auto *ND1 = dyn_cast(DC1)) {
+  const auto *ND2 = cast(DC2);
+  if (!DC1->isInlineNamespace() &&
+  !IsStructurallyEquivalent(ND1->getIdentifier(), 
ND2->getIdentifier()))
+return false;
+}
+
+DC1 = DC1->getParent()->getNonTransparentContext();
+DC2 = DC2->getParent()->getNonTransparentContext();
+  }
+
+  return true;
+}
+
 /// Determine structural equivalence of two records.
 static bool IsStructurallyEquivalent(StructuralEquivalenceContext ,
  RecordDecl *D1, RecordDecl *D2) {
@@ -1386,6 +1422,12 @@ static bool 
IsStructurallyEquivalent(StructuralEquivalenceContext ,
 }
   }
 
+  // If the records occur in 
diff erent context (namespace), these should be
+  // 
diff erent. This is specially important if the definition of one or both
+  // records is missing.
+  if (!IsRecordContextStructurallyEquivalent(D1, D2))
+return false;
+
   // If both declarations are class template specializations, we know
   // the ODR applies, so check the template and template arguments.
   const auto *Spec1 = dyn_cast(D1);

diff  --git a/clang/unittests/AST/StructuralEquivalenceTest.cpp 
b/clang/unittests/AST/StructuralEquivalenceTest.cpp
index 9ae0da8b9dd2c..2f5b5c1460950 100644
--- a/clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ b/clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -929,6 +929,136 @@ TEST_F(StructuralEquivalenceTest, ExplicitBoolSame) {
   EXPECT_TRUE(testStructuralMatch(First, Second));
 }
 
+struct StructuralEquivalenceRecordContextTest : StructuralEquivalenceTest {};
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceNoVsNamed) {
+  auto Decls = makeDecls("class X;", "namespace N { class X; }",
+Lang_CXX03, cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceNamedVsNamed) {
+  auto Decls = makeDecls("namespace A { class X; }",
+"namespace B { class X; }", Lang_CXX03,
+cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceAnonVsNamed) {
+  auto Decls = makeDecls("namespace { class X; }",
+"namespace N { class X; }", Lang_CXX03,
+cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceNoVsAnon) {
+  auto Decls = makeDecls("class X;", 

[PATCH] D114539: [clang-tidy] performance-unnecessary-copy-initialization: handle pointer containers.

2021-11-24 Thread Felix Berger via Phabricator via cfe-commits
flx added a comment.

This looks great, but goes past my knowledge of the AST API :) While the 
existing and new test coverage provides good confidence, one other reviewer 
taking look would be good.




Comment at: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp:112
+  switch (
+  E->ClassifyModifiable(Finder->getASTContext(), Loc).getModifiable()) 
{
+  case Expr::Classification::CM_Untested:

Reuse Ctx here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114539

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


[PATCH] D114539: [clang-tidy] performance-unnecessary-copy-initialization: handle pointer containers.

2021-11-24 Thread Clement Courbet via Phabricator via cfe-commits
courbet updated this revision to Diff 389504.
courbet added a comment.

Rebase on submitted unit tests so that we can see the changes better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114539

Files:
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
  clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
@@ -101,23 +101,23 @@
 void f(const S target) {
   useVal(/*const*/target);
   useConstRef(/*const*/target);
-  useConstPtr();
-  useConstPtrConstRef();
+  useConstPtr(&/*const*/target);
+  useConstPtrConstRef(&/*const*/target);
   /*const*/target.constMethod();
   /*const*/target(ConstTag{});
   /*const*/target[42];
   useConstRef((/*const*/target));
   (/*const*/target).constMethod();
   (void)(/*const*/target == /*const*/target);
-  (void)target;
-  (void)
-  (void)*
+  (void)/*const*/target;
+  (void)&/*const*/target;
+  (void)*&/*const*/target;
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
-  useIntConstPtr(_member);
+  useIntConstPtr(&/*const*/target.int_member);
 }
 )");
 }
@@ -127,23 +127,23 @@
 void f(const S& target) {
   useVal(/*const*/target);
   useConstRef(/*const*/target);
-  useConstPtr();
-  useConstPtrConstRef();
+  useConstPtr(&/*const*/target);
+  useConstPtrConstRef(&/*const*/target);
   /*const*/target.constMethod();
   /*const*/target(ConstTag{});
   /*const*/target[42];
   useConstRef((/*const*/target));
   (/*const*/target).constMethod();
   (void)(/*const*/target == /*const*/target);
-  (void)target;
-  (void)
-  (void)*
+  (void)/*const*/target;
+  (void)&/*const*/target;
+  (void)*&/*const*/target;
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
-  useIntConstPtr(_member);
+  useIntConstPtr(&/*const*/target.int_member);
 }
 )");
 }
@@ -153,8 +153,8 @@
 void f(S target, const S& other) {
   useConstRef(/*const*/target);
   useVal(/*const*/target);
-  useConstPtr();
-  useConstPtrConstRef();
+  useConstPtr(&/*const*/target);
+  useConstPtrConstRef(&/*const*/target);
   /*const*/target.constMethod();
   target.nonConstMethod();
   /*const*/target(ConstTag{});
@@ -167,15 +167,15 @@
   (/*const*/target).constMethod();
   (void)(/*const*/target == /*const*/target);
   (void)(/*const*/target == other);
-  (void)target;
-  (void)
-  (void)*
+  (void)/*const*/target;
+  (void)&/*const*/target;
+  (void)*&/*const*/target;
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
-  useIntConstPtr(_member);
+  useIntConstPtr(&/*const*/target.int_member);
 }
 )");
 }
@@ -185,8 +185,8 @@
 void f(S& target) {
   useVal(/*const*/target);
   useConstRef(/*const*/target);
-  useConstPtr();
-  useConstPtrConstRef();
+  useConstPtr(&/*const*/target);
+  useConstPtrConstRef(&/*const*/target);
   /*const*/target.constMethod();
   target.nonConstMethod();
   /*const*/target(ConstTag{});
@@ -194,15 +194,15 @@
   useConstRef((/*const*/target));
   (/*const*/target).constMethod();
   (void)(/*const*/target == /*const*/target);
-  (void)target;
-  (void)
-  (void)*
+  (void)/*const*/target;
+  (void)&/*const*/target;
+  (void)*&/*const*/target;
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
-  useIntConstPtr(_member);
+  useIntConstPtr(&/*const*/target.int_member);
 }
 )");
 }
@@ -210,26 +210,26 @@
 

[PATCH] D114481: [NFC][AIX]Disable precompiled module file tests on AIX

2021-11-24 Thread David Tenty via Phabricator via cfe-commits
daltenty accepted this revision.
daltenty added a comment.
This revision is now accepted and ready to land.

LGTM, with minor nit.




Comment at: clang/test/ClangScanDeps/modules-pch-common-submodule.c:1
+// UNSUPPORTED: aix
+

Let's add a comment, to let folks know what's going on with these. Something 
like:

// Unsupported on AIX because we don't support the requisite __clangast section 
in XCOFF yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114481

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


[PATCH] D114540: Big-endian version of vpermxor

2021-11-24 Thread Tarique Islam via Phabricator via cfe-commits
tislam created this revision.
tislam added a reviewer: nemanjai.
Herald added subscribers: kbarton, hiraditya.
tislam requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

A big-endian version of `vpermxor`, named `vpermxor_be`, is added to LLVM and 
Clang. `vpermxor_be` can be called directly on a little-endian platform.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114540

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrVSX.td
  llvm/test/CodeGen/PowerPC/crypto_bifs_be.ll

Index: llvm/test/CodeGen/PowerPC/crypto_bifs_be.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/crypto_bifs_be.ll
@@ -0,0 +1,94 @@
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s
+
+; Function Attrs: nounwind
+define <16 x i8> @test_vpermxorb() #0 {
+entry:
+  %a = alloca <16 x i8>, align 16
+  %b = alloca <16 x i8>, align 16
+  %c = alloca <16 x i8>, align 16
+  store <16 x i8> , <16 x i8>* %a, align 16
+  store <16 x i8> , <16 x i8>* %b, align 16
+  store <16 x i8> , <16 x i8>* %c, align 16
+  %0 = load <16 x i8>,  <16 x i8>* %a, align 16
+  %1 = load <16 x i8>,  <16 x i8>* %b, align 16
+  %2 = load <16 x i8>,  <16 x i8>* %c, align 16
+  %3 = call <16 x i8> @llvm.ppc.altivec.crypto.vpermxor.be(<16 x i8> %0, <16 x i8> %1, <16 x i8> %2)
+  ret <16 x i8> %3
+; CHECK-NOT: xxlnor
+; CHECK: vpermxor 2,
+}
+
+; Function Attrs: nounwind readnone
+declare <16 x i8> @llvm.ppc.altivec.crypto.vpermxor.be(<16 x i8>, <16 x i8>, <16 x i8>) #1
+
+; Function Attrs: nounwind
+define <8 x i16> @test_vpermxorh() #0 {
+entry:
+  %a = alloca <8 x i16>, align 16
+  %b = alloca <8 x i16>, align 16
+  %c = alloca <8 x i16>, align 16
+  store <8 x i16> , <8 x i16>* %a, align 16
+  store <8 x i16> , <8 x i16>* %b, align 16
+  store <8 x i16> , <8 x i16>* %c, align 16
+  %0 = load <8 x i16>,  <8 x i16>* %a, align 16
+  %1 = bitcast <8 x i16> %0 to <16 x i8>
+  %2 = load <8 x i16>,  <8 x i16>* %b, align 16
+  %3 = bitcast <8 x i16> %2 to <16 x i8>
+  %4 = load <8 x i16>,  <8 x i16>* %c, align 16
+  %5 = bitcast <8 x i16> %4 to <16 x i8>
+  %6 = call <16 x i8> @llvm.ppc.altivec.crypto.vpermxor.be(<16 x i8> %1, <16 x i8> %3, <16 x i8> %5)
+  %7 = bitcast <16 x i8> %6 to <8 x i16>
+  ret <8 x i16> %7
+; CHECK-NOT: xxlnor
+; CHECK: vpermxor 2,
+}
+
+; Function Attrs: nounwind
+define <4 x i32> @test_vpermxorw() #0 {
+entry:
+  %a = alloca <4 x i32>, align 16
+  %b = alloca <4 x i32>, align 16
+  %c = alloca <4 x i32>, align 16
+  store <4 x i32> , <4 x i32>* %a, align 16
+  store <4 x i32> , <4 x i32>* %b, align 16
+  store <4 x i32> , <4 x i32>* %c, align 16
+  %0 = load <4 x i32>,  <4 x i32>* %a, align 16
+  %1 = bitcast <4 x i32> %0 to <16 x i8>
+  %2 = load <4 x i32>,  <4 x i32>* %b, align 16
+  %3 = bitcast <4 x i32> %2 to <16 x i8>
+  %4 = load <4 x i32>,  <4 x i32>* %c, align 16
+  %5 = bitcast <4 x i32> %4 to <16 x i8>
+  %6 = call <16 x i8> @llvm.ppc.altivec.crypto.vpermxor.be(<16 x i8> %1, <16 x i8> %3, <16 x i8> %5)
+  %7 = bitcast <16 x i8> %6 to <4 x i32>
+  ret <4 x i32> %7
+; CHECK-NOT: xxlnor
+; CHECK: vpermxor 2,
+}
+
+; Function Attrs: nounwind
+define <2 x i64> @test_vpermxord() #0 {
+entry:
+  %a = alloca <2 x i64>, align 16
+  %b = alloca <2 x i64>, align 16
+  %c = alloca <2 x i64>, align 16
+  store <2 x i64> , <2 x i64>* %a, align 16
+  store <2 x i64> , <2 x i64>* %b, align 16
+  store <2 x i64> , <2 x i64>* %c, align 16
+  %0 = load <2 x i64>,  <2 x i64>* %a, align 16
+  %1 = bitcast <2 x i64> %0 to <16 x i8>
+  %2 = load <2 x i64>,  <2 x i64>* %b, align 16
+  %3 = bitcast <2 x i64> %2 to <16 x i8>
+  %4 = load <2 x i64>,  <2 x i64>* %c, align 16
+  %5 = bitcast <2 x i64> %4 to <16 x i8>
+  %6 = call <16 x i8> @llvm.ppc.altivec.crypto.vpermxor.be(<16 x i8> %1, <16 x i8> %3, <16 x i8> %5)
+  %7 = bitcast <16 x i8> %6 to <2 x i64>
+  ret <2 x i64> %7
+; CHECK-NOT: xxlnor
+; CHECK: vpermxor 2,
+}
+
+attributes #0 = { nounwind "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { nounwind readnone }
Index: llvm/lib/Target/PowerPC/PPCInstrVSX.td
===
--- llvm/lib/Target/PowerPC/PPCInstrVSX.td
+++ llvm/lib/Target/PowerPC/PPCInstrVSX.td
@@ -2491,11 +2491,16 @@
 
 // These Altivec patterns are here because we need a VSX instruction to match
 // the intrinsic (but only for little endian system).
-let Predicates = [HasVSX, IsLittleEndian, HasP8Altivec] in
+let Predicates = [HasVSX, IsLittleEndian, 

[clang-tools-extra] 3b72448 - [clang-tidy] Add unit tests for `DeclRefExprUtils`.

2021-11-24 Thread Clement Courbet via cfe-commits

Author: Clement Courbet
Date: 2021-11-24T16:47:55+01:00
New Revision: 3b72448084052785b79566fa5bd374feb8ae3907

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

LOG: [clang-tidy] Add unit tests for `DeclRefExprUtils`.

In preparation for D114539.

Added: 
clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp

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

Removed: 




diff  --git a/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt 
b/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
index 4a8d50f01473..6c9fa61cf92e 100644
--- a/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ b/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -20,6 +20,7 @@ add_extra_unittest(ClangTidyTests
   AddConstTest.cpp
   ClangTidyDiagnosticConsumerTest.cpp
   ClangTidyOptionsTest.cpp
+  DeclRefExprUtilsTest.cpp
   IncludeInserterTest.cpp
   GlobListTest.cpp
   GoogleModuleTest.cpp

diff  --git a/clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp 
b/clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
new file mode 100644
index ..d47add410b2c
--- /dev/null
+++ b/clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
@@ -0,0 +1,315 @@
+#include "../clang-tidy/utils/DeclRefExprUtils.h"
+#include "ClangTidyDiagnosticConsumer.h"
+#include "ClangTidyTest.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tidy {
+
+namespace {
+using namespace clang::ast_matchers;
+
+class ConstReferenceDeclRefExprsTransform : public ClangTidyCheck {
+public:
+  ConstReferenceDeclRefExprsTransform(StringRef CheckName,
+  ClangTidyContext *Context)
+  : ClangTidyCheck(CheckName, Context) {}
+
+  void registerMatchers(MatchFinder *Finder) override {
+Finder->addMatcher(varDecl(hasName("target")).bind("var"), this);
+  }
+
+  void check(const MatchFinder::MatchResult ) override {
+const auto *D = Result.Nodes.getNodeAs("var");
+using utils::decl_ref_expr::constReferenceDeclRefExprs;
+const auto const_decrefexprs = constReferenceDeclRefExprs(
+*D, *cast(D->getDeclContext())->getBody(),
+*Result.Context);
+
+for (const DeclRefExpr *const Expr : const_decrefexprs) {
+  assert(Expr);
+  diag(Expr->getBeginLoc(), "const usage")
+  << FixItHint::CreateInsertion(Expr->getBeginLoc(), "/*const*/");
+}
+  }
+};
+} // namespace
+
+namespace test {
+
+void RunTest(StringRef Snippet) {
+
+  StringRef CommonCode = R"(
+struct ConstTag{};
+struct NonConstTag{};
+
+struct S {
+  void constMethod() const;
+  void nonConstMethod();
+
+  void operator()(ConstTag) const;
+  void operator()(NonConstTag);
+
+  void operator[](int);
+  void operator[](int) const;
+
+  bool operator==(const S&) const;
+
+  int int_member;
+  int* ptr_member;
+
+};
+
+struct Derived : public S {
+
+};
+
+void useVal(S);
+void useRef(S&);
+void usePtr(S*);
+void usePtrPtr(S**);
+void usePtrConstPtr(S* const*);
+void useConstRef(const S&);
+void useConstPtr(const S*);
+void useConstPtrRef(const S*&);
+void useConstPtrPtr(const S**);
+void useConstPtrConstRef(const S* const&);
+void useConstPtrConstPtr(const S* const*);
+
+void useInt(int);
+void useIntRef(int&);
+void useIntConstRef(const int&);
+void useIntPtr(int*);
+void useIntConstPtr(const int*);
+
+)";
+
+  std::string Code = (CommonCode + Snippet).str();
+
+  llvm::SmallVector Parts;
+  StringRef(Code).split(Parts, "/*const*/");
+
+  EXPECT_EQ(Code, runCheckOnCode(
+  join(Parts, "")));
+}
+
+TEST(ConstReferenceDeclRefExprsTest, ConstValueVar) {
+  RunTest(R"(
+void f(const S target) {
+  useVal(/*const*/target);
+  useConstRef(/*const*/target);
+  useConstPtr();
+  useConstPtrConstRef();
+  /*const*/target.constMethod();
+  /*const*/target(ConstTag{});
+  /*const*/target[42];
+  useConstRef((/*const*/target));
+  (/*const*/target).constMethod();
+  (void)(/*const*/target == /*const*/target);
+  (void)target;
+  (void)
+  (void)*
+  S copy1 = /*const*/target;
+  S copy2(/*const*/target);
+  useInt(target.int_member);
+  useIntConstRef(target.int_member);
+  useIntPtr(target.ptr_member);
+  useIntConstPtr(_member);
+}
+)");
+}
+
+TEST(ConstReferenceDeclRefExprsTest, ConstRefVar) {
+  RunTest(R"(
+void f(const S& target) {
+  useVal(/*const*/target);
+  useConstRef(/*const*/target);
+  useConstPtr();
+  useConstPtrConstRef();
+  

[PATCH] D114521: [clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

2021-11-24 Thread Kyrylo Bohdanenko via Phabricator via cfe-commits
KyrBoh added a comment.

@MyDeveloperDay

> What it seems is "AllowShortIfStatementsOnASingleLine" ONLY seems to work 
> when there are no {}

AFAIR, there are 2 settings (in case of control statements):

- AllowShortBlocksOnASingleLine --> whether to treat (curly-)braced blocks as a 
single statement (i.e. allow them be one-liners)
- AllowShortIfStatementsOnASingleLine --> this actually tells whether control 
statements *can* be one-liners

So these two should be considered in pair. BTW, the documentation for 
AllowShortIfStatementsOnASingleLine seems to be a bit misleading

@curdeius 
Alright, I'll create a report


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114521

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


[PATCH] D114521: [clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

However if we add

  AllowShortBlocksOnASingleLine : Always

then it will be

  class Foo {
foo() {
  if (x) bar();
  if (x) { bar(); }
}
  };

but if we set

  BasedOnStyle: LLVM
  AllowShortIfStatementsOnASingleLine: Never
  ColumnLimit: 80
  AllowShortBlocksOnASingleLine : Always

we get

  class Foo {
foo() {
  if (x)
bar();
  if (x) {
bar();
  }
}
  };

which feels like `if(x){ bar(); }` is primarily controlled by  
`AllowShortBlocksOnASingleLine`  i.e. setting it to `Never` will override the 
`AllowShortIfStatementsOnASingleLine` setting for if statements with braces.

However if `AllowShortBlocksOnASingleLine` is `Always` then if 
`AllowShortIfStatementsOnASingleLine` is set to `Never` then it wins.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114521

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


[PATCH] D114105: [clang-tidy] Ignore narrowing conversions in case of bitfields

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

I think it's in pretty good shape, please have a look to help me move this 
forward.


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

https://reviews.llvm.org/D114105

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


[PATCH] D114105: [clang-tidy] Ignore narrowing conversions in case of bitfields

2021-11-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 389496.
steakhal edited the summary of this revision.
steakhal added a comment.

Bitshifts have nothing to do with this issue, thus I'm simply matching for 
bitfield -> `int` implicit casts due to promotions.


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

https://reviews.llvm.org/D114105

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-bitfields.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-bitfields.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-bitfields.cpp
@@ -0,0 +1,154 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-narrowing-conversions %t \
+// RUN:   -std=c++17 -- -target x86_64-unknown-linux
+
+#define CHAR_BITS 8
+static_assert(sizeof(unsigned int) == 32 / CHAR_BITS);
+
+template 
+struct is_same {
+  static constexpr bool value = false;
+};
+template 
+struct is_same {
+  static constexpr bool value = true;
+};
+
+template 
+static constexpr bool is_same_v = is_same::value;
+
+struct NoBitfield {
+  unsigned int id;
+};
+struct SmallBitfield {
+  unsigned int id : 4;
+};
+
+struct BigBitfield {
+  unsigned int id : 31;
+};
+struct CompleteBitfield {
+  unsigned int id : 32;
+};
+
+int example_warning(unsigned x) {
+  // CHECK-MESSAGES: :[[@LINE+1]]:10: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
+  return x;
+}
+
+void test_binary_and(SmallBitfield x) {
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+
+  x.id & 1;
+  x.id & 1u;
+
+  1 & x.id;
+  1u & x.id;
+}
+
+void test_binary_or(SmallBitfield x) {
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+
+  x.id | 1;
+  x.id | 1u;
+
+  1 | x.id;
+  1u | x.id;
+}
+
+void test(NoBitfield x) {
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+
+  x.id << 1;
+  x.id << 1u;
+  x.id >> 1;
+  x.id >> 1u;
+  x.id + 1;
+  x.id + 1u;
+
+  1 << x.id;
+  1u << x.id;
+  1 >> x.id;
+  1u >> x.id;
+  1 + x.id;
+  1u + x.id;
+}
+
+void test(SmallBitfield x) {
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+
+  x.id << 1;
+  x.id << 1u;
+  x.id >> 1;
+  x.id >> 1u;
+
+  x.id + 1;
+  x.id + 1u;
+
+  1 << x.id;
+  1u << x.id;
+  1 >> x.id;
+  1u >> x.id;
+
+  1 + x.id;
+  1u + x.id;
+}
+
+void test(BigBitfield x) {
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+
+  x.id << 1;
+  x.id << 1u;
+  x.id >> 1;
+  x.id >> 1u;
+
+  x.id + 1;
+  x.id + 1u;
+
+  1 << x.id;
+  1u << x.id;
+  1 >> x.id;
+  1u >> x.id;
+
+  1 + x.id;
+  1u + x.id;
+}
+
+void test(CompleteBitfield x) {
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+
+  x.id << 1;
+  x.id << 1u;
+  x.id >> 1;
+  x.id >> 1u;
+
+  x.id + 1;
+  x.id + 1u;
+
+  1 << x.id;
+  1u << x.id;
+  1 >> x.id;
+  1u >> x.id;
+
+  1 + x.id;
+  1u + x.id;
+}
+
+void test_parens(SmallBitfield x) {
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+  x.id << (2);
+  ((x.id)) << (2);
+
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+  (2) << x.id;
+  (2) << ((x.id));
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
@@ -83,6 +83,46 @@
 binaryOperator(hasOperands(IsConversionFromIgnoredType,
hasType(isInteger();
 
+  // Bitfields are special. Due to integral promotion [conv.prom/5] bitfield
+  // member access expressions are frequently wrapped by an implicit cast to
+  // `int` if that type can represent all the values of the bitfield.
+  //
+  // Consider these examples:
+  //   struct SmallBitfield { unsigned int id : 4; };
+  //   x.id & 1; (case-1)
+  //   x.id & 1u;(case-2)
+  //   x.id << 1u;   (case-3)
+  //   (unsigned)x.id << 1;  (case-4)
+  //
+  // Due to the promotion rules, we would get a warning for case-1. It's
+  // debatable how useful this is, but the user at least has a convenient way of
+  // //fixing// it by adding the `u` unsigned-suffix to the literal as
+  // demonstrated by case-2. However, this won't work for shift operators like
+  // the one in case-3. In case of a normal binary operator, both operands
+  // contribute to the result type. However, the type of the shift expression is
+  // the promoted type of the left operand. One could still suppress this
+  // superfluous warning by explicitly casting the bitfield member access as
+  // case-4 demonstrates, but why? 

[PATCH] D114521: [clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

2021-11-24 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

LGTM.
@KyrBoh, could you create a bug report for the problem you described, please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114521

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


[PATCH] D114521: [clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D114521#3151431 , @curdeius wrote:

> LGTM, but I have one question. You mentioned in the bug ticket comment that 
> "this exposes a greater issue in AllowShortXXX". Have you found other cases 
> that misbehave? If so, then it would probably be good to add them.

So when I took a look I think I stumbled on what @KyrBoh said below, but I'm 
not convinced its related. (so really want to deal with this separately)

What it seems is "AllowShortIfStatementsOnASingleLine" ONLY seems to work when 
there are no `{}`  (this seems to be by design 
https://clang.llvm.org/docs/ClangFormatStyleOptions.html)

i.e. for

  BasedOnStyle: LLVM
  AllowShortIfStatementsOnASingleLine: AllIfsAndElse
  ColumnLimit: 80

I get

  class Foo {
foo() {
  if (x) bar();
  if (x) {
bar();
  }
}
  };

So I think that was just me not understanding that limitation, (although I 
agree it doesn't seem to follow other options of a similar name)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114521

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


[PATCH] D114539: [clang-tidy] performance-unnecessary-copy-initialization: handle pointer containers.

2021-11-24 Thread Clement Courbet via Phabricator via cfe-commits
courbet created this revision.
courbet added reviewers: flx, aaron.ballman.
Herald added subscribers: carlosgalvezp, xazax.hun, mgorny.
courbet requested review of this revision.
Herald added a project: clang-tools-extra.

This includes modifying `DeclRefExprUtils` to handle more cases.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114539

Files:
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
  clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
@@ -0,0 +1,315 @@
+#include "../clang-tidy/utils/DeclRefExprUtils.h"
+#include "ClangTidyDiagnosticConsumer.h"
+#include "ClangTidyTest.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tidy {
+
+namespace {
+using namespace clang::ast_matchers;
+
+class ConstReferenceDeclRefExprsTransform : public ClangTidyCheck {
+public:
+  ConstReferenceDeclRefExprsTransform(StringRef CheckName,
+  ClangTidyContext *Context)
+  : ClangTidyCheck(CheckName, Context) {}
+
+  void registerMatchers(MatchFinder *Finder) override {
+Finder->addMatcher(varDecl(hasName("target")).bind("var"), this);
+  }
+
+  void check(const MatchFinder::MatchResult ) override {
+const auto *D = Result.Nodes.getNodeAs("var");
+using utils::decl_ref_expr::constReferenceDeclRefExprs;
+const auto const_decrefexprs = constReferenceDeclRefExprs(
+*D, *cast(D->getDeclContext())->getBody(),
+*Result.Context);
+
+for (const DeclRefExpr *const Expr : const_decrefexprs) {
+  assert(Expr);
+  diag(Expr->getBeginLoc(), "const usage")
+  << FixItHint::CreateInsertion(Expr->getBeginLoc(), "/*const*/");
+}
+  }
+};
+} // namespace
+
+namespace test {
+
+void RunTest(StringRef Snippet) {
+
+  StringRef CommonCode = R"(
+struct ConstTag{};
+struct NonConstTag{};
+
+struct S {
+  void constMethod() const;
+  void nonConstMethod();
+
+  void operator()(ConstTag) const;
+  void operator()(NonConstTag);
+
+  void operator[](int);
+  void operator[](int) const;
+
+  bool operator==(const S&) const;
+
+  int int_member;
+  int* ptr_member;
+
+};
+
+struct Derived : public S {
+
+};
+
+void useVal(S);
+void useRef(S&);
+void usePtr(S*);
+void usePtrPtr(S**);
+void usePtrConstPtr(S* const*);
+void useConstRef(const S&);
+void useConstPtr(const S*);
+void useConstPtrRef(const S*&);
+void useConstPtrPtr(const S**);
+void useConstPtrConstRef(const S* const&);
+void useConstPtrConstPtr(const S* const*);
+
+void useInt(int);
+void useIntRef(int&);
+void useIntConstRef(const int&);
+void useIntPtr(int*);
+void useIntConstPtr(const int*);
+
+)";
+
+  std::string Code = (CommonCode + Snippet).str();
+
+  llvm::SmallVector Parts;
+  StringRef(Code).split(Parts, "/*const*/");
+
+  EXPECT_EQ(Code, runCheckOnCode(
+  join(Parts, "")));
+}
+
+TEST(ConstReferenceDeclRefExprsTest, ConstValueVar) {
+  RunTest(R"(
+void f(const S target) {
+  useVal(/*const*/target);
+  useConstRef(/*const*/target);
+  useConstPtr(&/*const*/target);
+  useConstPtrConstRef(&/*const*/target);
+  /*const*/target.constMethod();
+  /*const*/target(ConstTag{});
+  /*const*/target[42];
+  useConstRef((/*const*/target));
+  (/*const*/target).constMethod();
+  (void)(/*const*/target == /*const*/target);
+  (void)/*const*/target;
+  (void)&/*const*/target;
+  (void)*&/*const*/target;
+  S copy1 = /*const*/target;
+  S copy2(/*const*/target);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
+  useIntPtr(target.ptr_member);
+  useIntConstPtr(&/*const*/target.int_member);
+}
+)");
+}
+
+TEST(ConstReferenceDeclRefExprsTest, ConstRefVar) {
+  RunTest(R"(
+void f(const S& target) {
+  useVal(/*const*/target);
+  useConstRef(/*const*/target);
+  useConstPtr(&/*const*/target);
+  useConstPtrConstRef(&/*const*/target);
+  /*const*/target.constMethod();
+  /*const*/target(ConstTag{});
+  /*const*/target[42];
+  useConstRef((/*const*/target));
+  (/*const*/target).constMethod();
+  (void)(/*const*/target == /*const*/target);
+  (void)/*const*/target;
+  (void)&/*const*/target;
+  (void)*&/*const*/target;
+  S copy1 = /*const*/target;
+  S 

[PATCH] D112230: [OpenCL] Add support of __opencl_c_device_enqueue feature macro.

2021-11-24 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:9554
+
+const auto  =
+Info.Ctx.getTargetInfo().getSupportedOpenCLOpts();

azabaznov wrote:
> azabaznov wrote:
> > Anastasia wrote:
> > > What test case covers this change? It feels like something we should try 
> > > to diagnose earlier...
> > The test case which exactly was added. Since blocks in constant address 
> > space are disallowed at this point, we can treat all other blocks with no 
> > captures not as constant expressions - it will make CodeGen generate block  
> > literal in local scope for blocks with no captures. See `buildGlobalBlock 
> > `and `CodeGenModule::GetAddrOfGlobalBlock` for details.
> I mean - //blocks_no_global_literal.cl// - that's exactly the case which 
> covers it.
Ok I see, it doesn't seem to have any constant but my guess is that it becomes 
constant implicitly?

Does the case with program scope variable supported need testing too or is it 
covered elsewhere?



Comment at: clang/lib/Sema/Sema.cpp:328
+auto OCLCompatibleVersion = getLangOpts().getOpenCLCompatibleVersion();
+if (OCLCompatibleVersion >= 200) {
+  if ((OCLCompatibleVersion == 200) ||

I wonder if we should simplify this condition by only checking 
`getLangOpts().Blocks` but then we make sure to set it correctly based on the 
language version and the target just like we do now for generic address space 
or pipes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112230

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


[PATCH] D114533: LLVM IR should allow bitcast between address spaces with the same size.

2021-11-24 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D114533#3151482 , @lebedev.ri 
wrote:

> In D114533#3151423 , @arsenm wrote:
>
>> Patch description should include this avoids a need to introduce 
>> ptrtoint/inttoptr pairs
>
> That is a good point, but all the motivational cases seem to be about 
> chaining the address space of the pointee pointer.
> Does this come up for changing the address space of the pointer itself? I'm 
> just wondering if this is still relevant with opaque pointers.

Nothing about address spaces changes with opaque pointers. The address space is 
a property of the pointer itself, not the memory it points to. This is for 
dealing with cases where we end up with a bit reinterpret of a pointer in 
another address space, and need to do a true no-op cast to convert them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114533

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


[PATCH] D114521: [clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

2021-11-24 Thread Kyrylo Bohdanenko via Phabricator via cfe-commits
KyrBoh added a comment.

In D114521#3151431 , @curdeius wrote:

> LGTM, but I have one question. You mentioned in the bug ticket comment that 
> "this exposes a greater issue in AllowShortXXX". Have you found other cases 
> that misbehave? If so, then it would probably be good to add them.

There also seems to be a behavior caused by AfterControlStatement = Multiline. 
This code:

if (condition) { contrinue; }

Is broken up into lines:

if (condition)
{

  continue;

}

I am not sure if this is intended behavior or not.

Because when having this configuration:

BreakBeforeBraces: Custom
BraceWrapping:

  AfterControlStatement: Never

AllowShortBlocksOnASingleLine: Always
AllowShortIfStatementsOnASingleLine: WithoutElse # any value except Never

clang-format would leave that code unchanged.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114521

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


[PATCH] D114533: LLVM IR should allow bitcast between address spaces with the same size.

2021-11-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D114533#3151423 , @arsenm wrote:

> Patch description should include this avoids a need to introduce 
> ptrtoint/inttoptr pairs

That is a good point, but all the motivational cases seem to be about chaining 
the address space of the pointee pointer.
Does this come up for changing the address space of the pointer itself? I'm 
just wondering if this is still relevant with opaque pointers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114533

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


[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 389488.
MyDeveloperDay added a comment.

Rebasing previously landed but reverted commit


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

https://reviews.llvm.org/D72326

Files:
  clang/docs/ClangFormat.rst
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -21343,6 +21343,64 @@
   }());
 }
 
+TEST(FormatStyle, GetStyleFromExteranlFile) {
+  llvm::vfs::InMemoryFileSystem FS;
+  // Explicit format file in parent directory.
+  ASSERT_TRUE(
+  FS.addFile("/e/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM")));
+  ASSERT_TRUE(
+  FS.addFile("/e/explicit.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  ASSERT_TRUE(FS.addFile("/e/sub/sub/sub/test.cpp", 0,
+ llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style = getStyle("file:/e/explicit.clang-format",
+"/e/sub/sub/sub/test.cpp", "LLVM", "", );
+  ASSERT_TRUE((bool)Style);
+  ASSERT_EQ(*Style, getGoogleStyle());
+
+  // Relative pah to a format file
+  ASSERT_TRUE(
+  FS.addFile("../../e/explicit.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  Style = getStyle("file:../../e/explicit.clang-format",
+   "/e/sub/sub/sub/test.cpp", "LLVM", "", );
+  ASSERT_TRUE((bool)Style);
+  ASSERT_EQ(*Style, getGoogleStyle());
+
+  // Missing explicit format file
+  Style = getStyle("file:/e/missing.clang-format", "/e/sub/sub/sub/test.cpp",
+   "LLVM", "", );
+  ASSERT_FALSE((bool)Style);
+  llvm::consumeError(Style.takeError());
+
+  // Format file from the filesystem
+  SmallString<128> FormatFilePath;
+  std::error_code ECF = llvm::sys::fs::createTemporaryFile(
+  "FormatFileTest", "tpl", FormatFilePath);
+  EXPECT_FALSE((bool)ECF);
+  llvm::raw_fd_ostream FormatFileTest(FormatFilePath, ECF);
+  EXPECT_FALSE((bool)ECF);
+  FormatFileTest << "BasedOnStyle: Google\n";
+  FormatFileTest.close();
+
+  SmallString<128> TestFilePath;
+  std::error_code ECT =
+  llvm::sys::fs::createTemporaryFile("CodeFileTest", "cc", TestFilePath);
+  EXPECT_FALSE((bool)ECT);
+  llvm::raw_fd_ostream CodeFileTest(TestFilePath, ECT);
+  CodeFileTest << "int i;\n";
+  CodeFileTest.close();
+
+  std::string format_file_arg = std::string("file:") + FormatFilePath.c_str();
+  Style = getStyle(format_file_arg, TestFilePath, "LLVM", "", nullptr);
+
+  llvm::sys::fs::remove(FormatFilePath.c_str());
+  llvm::sys::fs::remove(TestFilePath.c_str());
+  ASSERT_TRUE((bool)Style);
+  ASSERT_EQ(*Style, getGoogleStyle());
+}
+
 TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
   // Column limit is 20.
   std::string Code = "Type *a =\n"
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3163,6 +3163,8 @@
 ".clang-format file located in one of the parent\n"
 "directories of the source file (or current\n"
 "directory for stdin).\n"
+"Use -style=file: to explicitly specify"
+"the configuration file.\n"
 "Use -style=\"{key: value, ...}\" to set specific\n"
 "parameters, e.g.:\n"
 "  -style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"";
@@ -3211,6 +3213,29 @@
   return GuessedLanguage;
 }
 
+/// Attempts to load a format file
+llvm::Expected LoadConfigFile(StringRef ConfigFile,
+   llvm::vfs::FileSystem *FS,
+   bool *IsSuitable) {
+  FormatStyle Style = getLLVMStyle();
+  *IsSuitable = false;
+
+  llvm::ErrorOr> Text =
+  FS->getBufferForFile(ConfigFile.str());
+  if (std::error_code EC = Text.getError())
+return make_string_error(EC.message());
+  std::error_code ParserErrorCode =
+  parseConfiguration(Text.get()->getBuffer(), );
+  if (ParserErrorCode == ParseError::Unsuitable) {
+return Style;
+  } else if (ParserErrorCode != ParseError::Success) {
+return make_string_error("Error reading " + ConfigFile + ": " +
+ ParserErrorCode.message());
+  }
+  *IsSuitable = true;
+  return Style;
+}
+
 const char *DefaultFormatStyle = "file";
 
 const char *DefaultFallbackStyle = "LLVM";
@@ -3245,6 +3270,23 @@
   return Style;
   }
 
+  llvm::SmallVector FilesToLookFor;
+  // User provided clang-format file using -style=file:/path/to/format/file
+  // Check for explicit config filename
+  if (StyleName.startswith_insensitive("file:")) {
+auto StyleNameFile = StyleName.substr(5);
+bool IsSuitable = true;
+

[PATCH] D114504: [clang][DebugInfo] Debug support for private variables inside an OpenMP task construct

2021-11-24 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok added a comment.

In D114504#3151332 , @djtodoro wrote:

> Thanks for doing this! Can you please update the summary, since it hard to 
> read with the format like this (at least, just try to reformat the debugger 
> output properly with the Phabricator formatters)?

Sorry for the bad formatting. I have corrected it now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114504

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


[PATCH] D114521: [clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

2021-11-24 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

LGTM, but I have one question. You mentioned in the bug ticket comment that 
"this exposes a greater issue in AllowShortXXX". Have you found other cases 
that misbehave? If so, then it would probably be good to add them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114521

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


[PATCH] D114088: [PowerPC] Add BCD add/sub/cmp builtins

2021-11-24 Thread Bardia Mahjour via Phabricator via cfe-commits
bmahjour added a comment.

@nemanjai how come the changes in `altivec.h` and 
`clang/test/CodeGen/builtins-ppc-p8vector.c` have been removed in the latest 
diff and the commit above?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114088

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


[PATCH] D114533: LLVM IR should allow bitcast between address spaces with the same size.

2021-11-24 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

Patch description should include this avoids a need to introduce 
ptrtoint/inttoptr pairs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114533

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


[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

After rebasing these tests seem to work (on Windows)

  -- Testing: 24 tests, 16 workers --
  PASS: Clang :: Format/dry-run-alias.cpp (1 of 24)
  PASS: Clang :: Format/remove-duplicate-includes.cpp (2 of 24)
  PASS: Clang :: Format/disable-format.cpp (3 of 24)
  PASS: Clang :: Format/cursor.cpp (4 of 24)
  PASS: Clang :: Format/multiple-inputs.cpp (5 of 24)
  PASS: Clang :: Format/basic.cpp (6 of 24)
  PASS: Clang :: Format/incomplete.cpp (7 of 24)
  PASS: Clang :: Format/line-ranges.cpp (8 of 24)
  PASS: Clang :: Format/adjust-indent.cpp (9 of 24)
  UNSUPPORTED: Clang :: Format/style-on-command-line.cpp (10 of 24)
  PASS: Clang :: Format/ranges.cpp (11 of 24)
  PASS: Clang :: Format/access-modifiers.cpp (12 of 24)
  PASS: Clang :: Format/multiple-inputs-error.cpp (13 of 24)
  PASS: Clang :: Format/dump-config-objc.h (14 of 24)
  PASS: Clang :: Format/xmloutput.cpp (15 of 24)
  PASS: Clang :: Format/dump-config-cxx.h (16 of 24)
  PASS: Clang :: Format/multiple-inputs-inplace.cpp (17 of 24)
  PASS: Clang :: Format/error-config.cpp (18 of 24)
  PASS: Clang :: Format/dry-run.cpp (19 of 24)
  PASS: Clang :: Format/inplace.cpp (20 of 24)
  PASS: Clang :: Format/dump-config-list-override.cpp (21 of 24)
  PASS: Clang :: Format/disable-include-sorting.cpp (22 of 24)
  PASS: Clang :: Format/language-detection.cpp (23 of 24)
  PASS: Clang :: Format/verbose.cpp (24 of 24)

I'm going to Commandeer this revision and see if we can't get this relanded.


Repository:
  rC Clang

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

https://reviews.llvm.org/D72326

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


[PATCH] D112430: [ARM][libunwind] add PACBTI-M support for libunwind

2021-11-24 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 389481.
stuij added a comment.

address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112430

Files:
  clang/lib/Headers/unwind.h
  libunwind/include/libunwind.h
  libunwind/include/unwind_arm_ehabi.h
  libunwind/src/DwarfInstructions.hpp
  libunwind/src/Registers.hpp
  libunwind/src/Unwind-EHABI.cpp
  libunwind/src/UnwindCursor.hpp
  libunwind/src/UnwindRegistersRestore.S
  libunwind/src/assembly.h

Index: libunwind/src/assembly.h
===
--- libunwind/src/assembly.h
+++ libunwind/src/assembly.h
@@ -81,7 +81,7 @@
 #define PPC64_OPD2
 #endif
 
-#if defined(__ARM_FEATURE_BTI_DEFAULT)
+#if defined(__aarch64__) && defined(__ARM_FEATURE_BTI_DEFAULT)
   .pushsection ".note.gnu.property", "a" SEPARATOR \
   .balign 8 SEPARATOR  \
   .long 4 SEPARATOR\
@@ -99,6 +99,17 @@
 #define AARCH64_BTI
 #endif
 
+#if !defined(__aarch64__)
+#ifdef __ARM_FEATURE_PAC_DEFAULT
+  .eabi_attribute Tag_PAC_extension, 2
+  .eabi_attribute Tag_PACRET_use, 1
+#endif
+#ifdef __ARM_FEATURE_BTI_DEFAULT
+  .eabi_attribute Tag_BTI_extension, 1
+  .eabi_attribute Tag_BTI_use, 1
+#endif
+#endif
+
 #define GLUE2(a, b) a ## b
 #define GLUE(a, b) GLUE2(a, b)
 #define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name)
Index: libunwind/src/UnwindRegistersRestore.S
===
--- libunwind/src/UnwindRegistersRestore.S
+++ libunwind/src/UnwindRegistersRestore.S
@@ -660,7 +660,13 @@
   ldr sp, [lr, #52]
   ldr lr, [lr, #60]  @ restore pc into lr
 #endif
+#if defined(__ARM_FEATURE_BTI_DEFAULT) && !defined(__ARM_ARCH_ISA_ARM)
+  // 'bx' is not BTI setting when used with lr, therefore r12 is used instead
+  mov r12, lr
+  JMP(r12)
+#else
   JMP(lr)
+#endif
 
 @
 @ static void libunwind::Registers_arm::restoreVFPWithFLDMD(unw_fpreg_t* values)
Index: libunwind/src/UnwindCursor.hpp
===
--- libunwind/src/UnwindCursor.hpp
+++ libunwind/src/UnwindCursor.hpp
@@ -655,7 +655,9 @@
 #if defined(_LIBUNWIND_TARGET_X86_64)
   if (regNum >= UNW_X86_64_RAX && regNum <= UNW_X86_64_R15) return true;
 #elif defined(_LIBUNWIND_TARGET_ARM)
-  if (regNum >= UNW_ARM_R0 && regNum <= UNW_ARM_R15) return true;
+  if ((regNum >= UNW_ARM_R0 && regNum <= UNW_ARM_R15) ||
+  regNum == UNW_ARM_RA_AUTH_CODE)
+return true;
 #elif defined(_LIBUNWIND_TARGET_AARCH64)
   if (regNum >= UNW_AARCH64_X0 && regNum <= UNW_ARM64_X30) return true;
 #endif
Index: libunwind/src/Unwind-EHABI.cpp
===
--- libunwind/src/Unwind-EHABI.cpp
+++ libunwind/src/Unwind-EHABI.cpp
@@ -256,6 +256,7 @@
   size_t offset, size_t len) {
   bool wrotePC = false;
   bool finish = false;
+  bool hasReturnAddrAuthCode = false;
   while (offset < len && !finish) {
 uint8_t byte = getByte(data, offset++);
 if ((byte & 0x80) == 0) {
@@ -342,6 +343,10 @@
   break;
 }
 case 0xb4:
+  hasReturnAddrAuthCode = true;
+  _Unwind_VRS_Pop(context, _UVRSC_PSEUDO,
+  0 /* Return Address Auth Code */, _UVRSD_UINT32);
+  break;
 case 0xb5:
 case 0xb6:
 case 0xb7:
@@ -417,6 +422,16 @@
   if (!wrotePC) {
 uint32_t lr;
 _Unwind_VRS_Get(context, _UVRSC_CORE, UNW_ARM_LR, _UVRSD_UINT32, );
+#ifdef __ARM_FEATURE_PAUTH
+if (hasReturnAddrAuthCode) {
+  uint32_t sp;
+  uint32_t pac;
+  _Unwind_VRS_Get(context, _UVRSC_CORE, UNW_ARM_SP, _UVRSD_UINT32, );
+  _Unwind_VRS_Get(context, _UVRSC_PSEUDO, UNW_ARM_RA_AUTH_CODE, _UVRSD_UINT32,
+  );
+  __asm__ __volatile__("autg %0, %1, %2" : : "r"(pac), "r"(lr), "r"(sp) :);
+}
+#endif
 _Unwind_VRS_Set(context, _UVRSC_CORE, UNW_ARM_IP, _UVRSD_UINT32, );
   }
   return _URC_CONTINUE_UNWIND;
@@ -927,6 +942,15 @@
 case _UVRSC_WMMXD:
   break;
 #endif
+case _UVRSC_PSEUDO:
+  // There's only one pseudo-register, PAC, with regno == 0.
+  if (representation != _UVRSD_UINT32 || regno != 0)
+return _UVRSR_FAILED;
+  return __unw_set_reg(cursor, (unw_regnum_t)(UNW_ARM_RA_AUTH_CODE),
+   *(unw_word_t *)valuep) == UNW_ESUCCESS
+ ? _UVRSR_OK
+ : _UVRSR_FAILED;
+  break;
   }
   _LIBUNWIND_ABORT("unsupported register class");
 }
@@ -981,6 +1005,15 @@
 case _UVRSC_WMMXD:
   break;
 #endif
+case _UVRSC_PSEUDO:
+  // There's only one pseudo-register, PAC, with regno == 0.
+  if (representation != _UVRSD_UINT32 || regno != 0)
+return _UVRSR_FAILED;
+  return 

[PATCH] D114502: File Reorganization changes

2021-11-24 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: mlir/lib/ExecutionEngine/CMakeLists.txt:153
+  set(CMAKE_MODULE_PATH "${HIP_PATH}/lib/cmake/hip" ${CMAKE_MODULE_PATH})
   find_package(HIP)
   if (NOT HIP_FOUND)

mehdi_amini wrote:
> Is MLIR really coupled to Clang here? That seems suspicious to me.
In particular, this makes MLIR sensitive to the version actually installed on 
the machine, which is independent from whatever clang is in the repo. This 
seems undesirable, what am I missing here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114502

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


[PATCH] D114502: File Reorganization changes

2021-11-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

could you please include a complete diff context in the patch? You can do that 
by using git diff -U




Comment at: mlir/lib/ExecutionEngine/CMakeLists.txt:153
+  set(CMAKE_MODULE_PATH "${HIP_PATH}/lib/cmake/hip" ${CMAKE_MODULE_PATH})
   find_package(HIP)
   if (NOT HIP_FOUND)

mehdi_amini wrote:
> mehdi_amini wrote:
> > Is MLIR really coupled to Clang here? That seems suspicious to me.
> In particular, this makes MLIR sensitive to the version actually installed on 
> the machine, which is independent from whatever clang is in the repo. This 
> seems undesirable, what am I missing here?
Probably it is not depending on clang, but depending on HIP cmake file to get 
HIP package to be able to use HIP header and library files for kernel launching 
API.

To be compatible with all ROCm releases, probably CMAKE_MODULE_PATH should also 
include the HIP cmake path for both old and new ROCm releases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114502

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


[PATCH] D114502: File Reorganization changes

2021-11-24 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: mlir/lib/ExecutionEngine/CMakeLists.txt:153
+  set(CMAKE_MODULE_PATH "${HIP_PATH}/lib/cmake/hip" ${CMAKE_MODULE_PATH})
   find_package(HIP)
   if (NOT HIP_FOUND)

Is MLIR really coupled to Clang here? That seems suspicious to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114502

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


[PATCH] D114502: File Reorganization changes

2021-11-24 Thread Ranjith Ramakrishnan via Phabricator via cfe-commits
raramakr created this revision.
raramakr added reviewers: yaxunl, msearles.
Herald added subscribers: sdasgup3, wenzhicui, wrengr, Chia-hungDuan, dcaballe, 
cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, 
Joonsoo, kerbowa, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, csigg, 
antiagainst, shauheen, rriddle, mehdi_amini, mgorny, nhaehnle, jvesely.
raramakr requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: openmp-commits, cfe-commits, sstefan1, 
stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, OpenMP, MLIR.

ROCM file reorganization feature(SWDEV-29145 )

- Device library path moved to /opt/rocm/share
- External module header file access using 
- Hip is installed in /opt/rocm
- Hsa header files moved to /opt/rocm/include/hsa/
- Hip cmake file moved to /opt/rocm/lib/cmake/hip




Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114502

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/hip.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/ockl.bc
  
clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc
  
clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_daz_opt_off.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_daz_opt_on.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_finite_only_off.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_finite_only_on.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_isa_version_1010.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_isa_version_1011.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_isa_version_1012.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_isa_version_803.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_isa_version_900.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_isa_version_908.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_unsafe_math_off.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_unsafe_math_on.bc
  
clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_wavefrontsize64_off.bc
  
clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_wavefrontsize64_on.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/ocml.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/opencl.bc
  clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/hip.bc
  clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/ockl.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc
  clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_daz_opt_off.bc
  clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_daz_opt_on.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_finite_only_off.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_finite_only_on.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_isa_version_1010.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_isa_version_1011.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_isa_version_1012.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_isa_version_803.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_isa_version_900.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_isa_version_908.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_unsafe_math_off.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_unsafe_math_on.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_wavefrontsize64_off.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_wavefrontsize64_on.bc
  clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/ocml.bc
  clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/opencl.bc
  
clang/test/Driver/Inputs/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/asanrtl.bc
  
clang/test/Driver/Inputs/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/hip.bc
  
clang/test/Driver/Inputs/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/ockl.bc
  
clang/test/Driver/Inputs/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc
  
clang/test/Driver/Inputs/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc
  
clang/test/Driver/Inputs/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/oclc_daz_opt_off.bc
  

[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2021-11-24 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 389352.
mizvekov added a comment.

- fix IntrospectionTests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

Files:
  clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
  clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
  clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
  clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
  clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
  clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/DumpASTTests.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-copy-constructor-init.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison-32bits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance-nesting-threshold.cpp
  clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp
  clang/bindings/python/tests/cindex/test_type.py
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/lib/ARCMigrate/ObjCMT.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTDiagnostic.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/FormatString.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/ScanfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Sema/TypeLocBuilder.cpp
  clang/lib/Sema/TypeLocBuilder.h
  clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/test/AST/ast-dump-APValue-anon-union.cpp
  clang/test/AST/ast-dump-APValue-struct.cpp
  clang/test/AST/ast-dump-APValue-union.cpp
  clang/test/AST/ast-dump-decl.cpp
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/AST/ast-dump-funcs.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
  clang/test/AST/ast-dump-overloaded-operators.cpp
  clang/test/AST/ast-dump-records-json.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/AST/ast-dump-stmt.cpp
  clang/test/AST/ast-dump-template-decls-json.cpp
  clang/test/AST/ast-dump-temporaries-json.cpp
  clang/test/AST/coroutine-locals-cleanup-exp-namespace.cpp
  clang/test/AST/coroutine-locals-cleanup.cpp
  clang/test/AST/float16.cpp
  clang/test/AST/sourceranges.cpp
  clang/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/method-call-path-notes.cpp.plist
  clang/test/Analysis/analyzer-display-progress.cpp
  clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
  clang/test/Analysis/blocks.mm
  clang/test/Analysis/bug_hash_test.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/cfg-rich-constructors.cpp
  clang/test/Analysis/cfg-rich-constructors.mm
  clang/test/Analysis/cfg.cpp
  clang/test/Analysis/copy-elision.cpp
  clang/test/Analysis/cxx-uninitialized-object-inheritance.cpp
  clang/test/Analysis/dump_egraph.cpp
  clang/test/Analysis/exploded-graph-rewriter/dynamic_types.cpp
  clang/test/Analysis/initializers-cfg-output.cpp
  clang/test/Analysis/inlining/Inputs/expected-plists/path-notes.cpp.plist
  clang/test/Analysis/lambdas.cpp
  

[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2021-11-24 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 389298.
mizvekov edited the summary of this revision.
mizvekov added a comment.
Herald added subscribers: llvm-commits, dexonsmith.
Herald added a project: LLVM.

- Avoid using any storage for an empty ElaboratedTYpeLoc.
  - But we still require pointer alignment for it, due to pre-existing bugs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

Files:
  clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
  clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
  clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
  clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
  clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
  clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/DumpASTTests.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-copy-constructor-init.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison-32bits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance-nesting-threshold.cpp
  clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp
  clang/bindings/python/tests/cindex/test_type.py
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/lib/ARCMigrate/ObjCMT.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTDiagnostic.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/FormatString.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/ScanfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Sema/TypeLocBuilder.cpp
  clang/lib/Sema/TypeLocBuilder.h
  clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/test/AST/ast-dump-APValue-anon-union.cpp
  clang/test/AST/ast-dump-APValue-struct.cpp
  clang/test/AST/ast-dump-APValue-union.cpp
  clang/test/AST/ast-dump-decl.cpp
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/AST/ast-dump-funcs.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
  clang/test/AST/ast-dump-overloaded-operators.cpp
  clang/test/AST/ast-dump-records-json.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/AST/ast-dump-stmt.cpp
  clang/test/AST/ast-dump-template-decls-json.cpp
  clang/test/AST/ast-dump-temporaries-json.cpp
  clang/test/AST/coroutine-locals-cleanup-exp-namespace.cpp
  clang/test/AST/coroutine-locals-cleanup.cpp
  clang/test/AST/float16.cpp
  clang/test/AST/sourceranges.cpp
  clang/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/method-call-path-notes.cpp.plist
  clang/test/Analysis/analyzer-display-progress.cpp
  clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
  clang/test/Analysis/blocks.mm
  clang/test/Analysis/bug_hash_test.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/cfg-rich-constructors.cpp
  clang/test/Analysis/cfg-rich-constructors.mm
  clang/test/Analysis/cfg.cpp
  clang/test/Analysis/copy-elision.cpp
  clang/test/Analysis/cxx-uninitialized-object-inheritance.cpp
  

[PATCH] D114533: LLVM IR should allow bitcast between address spaces with the same size.

2021-11-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Is there an RFC? This quite seems like asking for problems.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114533

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


[PATCH] D114533: LLVM IR should allow bitcast between address spaces with the same size.

2021-11-24 Thread krishna chaitanya sankisa via Phabricator via cfe-commits
skc7 created this revision.
skc7 added reviewers: sameerds, arsenm.
Herald added subscribers: dexonsmith, lxfind, jdoerfert, zzheng, hiraditya.
skc7 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, wdng.
Herald added projects: clang, LLVM.

When the addrspacecast instruction was added, the ability to bitcast between 
pointers from different address spaces was removed.
There are cases, where after analysis, cast between pointers from different 
address spaces can be concluded to be a no-op cast.
If bitcast can be allowed in these scenarios, it would help further optimise 
the IR in Transform passes since its a no-op cast.
This enhancement to bitcast will require that pointers to the two address 
spaces have the same bit widths(can be queried from DataLayout).
Frontend should never misuse the bitcast wherever addrspace cast would have 
been more appropriate.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114533

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/TargetFolder.h
  llvm/include/llvm/IR/ConstantFolder.h
  llvm/include/llvm/IR/Constants.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/IRBuilderFolder.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/include/llvm/IR/Instructions.h
  llvm/include/llvm/IR/NoFolder.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/Analysis/LoopUnrollAnalyzer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Coroutines/Coroutines.cpp
  llvm/lib/Transforms/Utils/VNCoercion.cpp
  llvm/test/Transforms/GVN/gvn-eliminate-inttoptr-ptrtoint-for-load.ll
  llvm/test/Transforms/GVN/gvn-eliminate-inttoptr-ptrtoint-for-vector-load.ll
  
llvm/test/Transforms/GVN/gvn-eliminate-inttoptr-ptrtoint-for-vector-ptr-load.ll
  llvm/test/Verifier/bitcast-vector-pointer-as-neg.ll
  llvm/test/Verifier/bitcast-vector-pointer-different-addrspace-illegal.ll
  llvm/test/Verifier/bitcast-vector-pointer-neg.ll
  llvm/test/Verifier/bitcast-vector-pointer-pos.ll
  llvm/test/Verifier/bitcast-vector-pointer-same-addrspace.ll
  llvm/unittests/IR/InstructionsTest.cpp

Index: llvm/unittests/IR/InstructionsTest.cpp
===
--- llvm/unittests/IR/InstructionsTest.cpp
+++ llvm/unittests/IR/InstructionsTest.cpp
@@ -189,6 +189,10 @@
 TEST(InstructionsTest, CastInst) {
   LLVMContext C;
 
+  DataLayout DL("e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-"
+"p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
+"v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7");
+
   Type *Int8Ty = Type::getInt8Ty(C);
   Type *Int16Ty = Type::getInt16Ty(C);
   Type *Int32Ty = Type::getInt32Ty(C);
@@ -217,7 +221,11 @@
   Type *Int32PtrAS1Ty = PointerType::get(Int32Ty, 1);
   Type *Int64PtrAS1Ty = PointerType::get(Int64Ty, 1);
 
+  Type *Int32PtrAS2Ty = PointerType::get(Int32Ty, 2);
+  Type *Int32PtrAS3Ty = PointerType::get(Int32Ty, 3);
+
   Type *V2Int32PtrAS1Ty = FixedVectorType::get(Int32PtrAS1Ty, 2);
+  Type *V2Int32PtrAS2Ty = FixedVectorType::get(Int32PtrAS2Ty, 2);
   Type *V2Int64PtrAS1Ty = FixedVectorType::get(Int64PtrAS1Ty, 2);
   Type *V4Int32PtrAS1Ty = FixedVectorType::get(Int32PtrAS1Ty, 4);
   Type *VScaleV4Int32PtrAS1Ty = ScalableVectorType::get(Int32PtrAS1Ty, 4);
@@ -238,50 +246,52 @@
   EXPECT_EQ(CastInst::Trunc, CastInst::getCastOpcode(c64, true, V8x8Ty, true));
   EXPECT_EQ(CastInst::SExt, CastInst::getCastOpcode(c8, true, V8x64Ty, true));
 
-  EXPECT_FALSE(CastInst::isBitCastable(V8x8Ty, X86MMXTy));
-  EXPECT_FALSE(CastInst::isBitCastable(X86MMXTy, V8x8Ty));
-  EXPECT_FALSE(CastInst::isBitCastable(Int64Ty, X86MMXTy));
-  EXPECT_FALSE(CastInst::isBitCastable(V8x64Ty, V8x8Ty));
-  EXPECT_FALSE(CastInst::isBitCastable(V8x8Ty, V8x64Ty));
-
-  // Check address space casts are rejected since we don't know the sizes here
-  EXPECT_FALSE(CastInst::isBitCastable(Int32PtrTy, Int32PtrAS1Ty));
-  EXPECT_FALSE(CastInst::isBitCastable(Int32PtrAS1Ty, Int32PtrTy));
-  EXPECT_FALSE(CastInst::isBitCastable(V2Int32PtrTy, V2Int32PtrAS1Ty));
-  EXPECT_FALSE(CastInst::isBitCastable(V2Int32PtrAS1Ty, V2Int32PtrTy));
-  EXPECT_TRUE(CastInst::isBitCastable(V2Int32PtrAS1Ty, V2Int64PtrAS1Ty));
+  EXPECT_FALSE(CastInst::isBitCastable(V8x8Ty, X86MMXTy, DL));
+  EXPECT_FALSE(CastInst::isBitCastable(X86MMXTy, V8x8Ty, DL));
+  EXPECT_FALSE(CastInst::isBitCastable(Int64Ty, X86MMXTy, DL));
+  EXPECT_FALSE(CastInst::isBitCastable(V8x64Ty, V8x8Ty, DL));
+  EXPECT_FALSE(CastInst::isBitCastable(V8x8Ty, V8x64Ty, DL));
+
+  // Check validity of casts here
+  EXPECT_TRUE(CastInst::isBitCastable(Int32PtrAS2Ty, Int32PtrAS3Ty, DL));
+  EXPECT_FALSE(CastInst::isBitCastable(Int32PtrAS1Ty, Int32PtrAS2Ty, DL));
+  EXPECT_TRUE(CastInst::isBitCastable(Int32PtrTy, Int32PtrAS1Ty, DL));
+  

[PATCH] D114527: [VE] Support multiple architectures installation

2021-11-24 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 updated this revision to Diff 389479.
kaz7 added a comment.

Update ve-toolchain.c and ve-toolchain.cpp using -ccc-install-dir
option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114527

Files:
  clang/lib/Driver/ToolChains/VEToolchain.cpp
  clang/test/Driver/Inputs/basic_ve_tree/bin/.keep
  clang/test/Driver/Inputs/basic_ve_tree/include/c++/v1/.keep
  
clang/test/Driver/Inputs/basic_ve_tree/include/ve-unknown-linux-gnu/c++/v1/.keep
  clang/test/Driver/ve-toolchain.c
  clang/test/Driver/ve-toolchain.cpp

Index: clang/test/Driver/ve-toolchain.cpp
===
--- clang/test/Driver/ve-toolchain.cpp
+++ clang/test/Driver/ve-toolchain.cpp
@@ -4,72 +4,89 @@
 ///-
 /// Checking dwarf-version
 
-// RUN: %clangxx -### -g -target ve %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
+// RUN: %clangxx -### -g -target ve-unknown-linux-gnu \
+// RUN: %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
 // DWARF_VER: "-dwarf-version=4"
 
 ///-
 /// Checking include-path
 
-// RUN: %clangxx -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
-// RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
+// RUN: %clangxx -### -target ve-unknown-linux-gnu \
+// RUN: --sysroot %S/Inputs/basic_ve_tree %s \
+// RUN: -ccc-install-dir %S/Inputs/basic_ve_tree/bin \
+// RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: 2>&1 | FileCheck -check-prefix=DEFINC %s
 // DEFINC: clang{{.*}} "-cc1"
 // DEFINC-SAME: "-nostdsysteminc"
 // DEFINC-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // DEFINC-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// DEFINC-SAME: "-internal-isystem" "[[RESOURCE_DIR]]/include/c++/v1"
+// DEFINC-SAME: "-internal-isystem" "{{.*}}/bin/../include/ve-unknown-linux-gnu/c++/v1"
+// DEFINC-SAME: "-internal-isystem" "{{.*}}/bin/../include/c++/v1"
 // DEFINC-SAME: "-internal-isystem" "[[RESOURCE_DIR]]/include"
 // DEFINC-SAME: "-internal-isystem" "[[SYSROOT]]/opt/nec/ve/include"
 
-// RUN: %clangxx -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
-// RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
+// RUN: %clangxx -### -target ve-unknown-linux-gnu \
+// RUN: --sysroot %S/Inputs/basic_ve_tree %s \
+// RUN: -ccc-install-dir %S/Inputs/basic_ve_tree/bin \
+// RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: -nostdlibinc 2>&1 | FileCheck -check-prefix=NOSTDLIBINC %s
 // NOSTDLIBINC: clang{{.*}} "-cc1"
 // NOSTDLIBINC-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // NOSTDLIBINC-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// NOSTDLIBINC-NOT: "-internal-isystem" "[[RESOURCE_DIR]]/include/c++/v1"
+// NOSTDLIBINC-NOT: "-internal-isystem" "{{.*}}/bin/../include/ve-unknown-linux-gnu/c++/v1"
+// NOSTDLIBINC-NOT: "-internal-isystem" "{{.*}}/bin/../include/c++/v1"
 // NOSTDLIBINC-SAME: "-internal-isystem" "[[RESOURCE_DIR]]/include"
 // NOSTDLIBINC-NOT: "-internal-isystem" "[[SYSROOT]]/opt/nec/ve/include"
 
-// RUN: %clangxx -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
-// RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
+// RUN: %clangxx -### -target ve-unknown-linux-gnu \
+// RUN: --sysroot %S/Inputs/basic_ve_tree %s \
+// RUN: -ccc-install-dir %S/Inputs/basic_ve_tree/bin \
+// RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: -nobuiltininc 2>&1 | FileCheck -check-prefix=NOBUILTININC %s
 // NOBUILTININC: clang{{.*}} "-cc1"
 // NOBUILTININC-SAME: "-nobuiltininc"
 // NOBUILTININC-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // NOBUILTININC-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// NOBUILTININC-SAME: "-internal-isystem" "[[RESOURCE_DIR]]/include/c++/v1"
+// NOBUILTININC-SAME: "-internal-isystem" "{{.*}}/bin/../include/ve-unknown-linux-gnu/c++/v1"
+// NOBUILTININC-SAME: "-internal-isystem" "{{.*}}/bin/../include/c++/v1"
 // NOBUILTININC-NOT: "-internal-isystem" "[[RESOURCE_DIR]]/include"
 // NOBUILTININC-SAME: "-internal-isystem" "[[SYSROOT]]/opt/nec/ve/include"
 
-// RUN: %clangxx -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
-// RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
+// RUN: %clangxx -### -target ve-unknown-linux-gnu \
+// RUN: --sysroot %S/Inputs/basic_ve_tree %s \
+// RUN: -ccc-install-dir %S/Inputs/basic_ve_tree/bin \
+// RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: -nostdinc 2>&1 | FileCheck -check-prefix=NOSTDINC %s
 // NOSTDINC: clang{{.*}} "-cc1"
 // NOSTDINC-SAME: "-nobuiltininc"
 // NOSTDINC-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // NOSTDINC-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// NOSTDINC-NOT: "-internal-isystem" "[[RESOURCE_DIR]]/include/c++/v1"
+// NOSTDINC-NOT: "-internal-isystem" 

[PATCH] D114504: [clang][DebugInfo] Debug support for private variables inside an OpenMP task construct

2021-11-24 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

Thanks for doing this! Can you please update the summary, since it hard to read 
with the format like this (at least, just try to reformat the debugger output 
properly with the Phabricator formatters)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114504

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


[PATCH] D114530: [clang][scan-build] Use cc/c++ instead of gcc/g++ on FreeBSD.

2021-11-24 Thread Frederic Cambus via Phabricator via cfe-commits
fcambus created this revision.
fcambus added reviewers: emaste, mgorny.
Herald added subscribers: krytarowski, arichardson.
fcambus requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

All supported FreeBSD platforms do not have GCC in base anymore.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114530

Files:
  clang/tools/scan-build/libexec/ccc-analyzer


Index: clang/tools/scan-build/libexec/ccc-analyzer
===
--- clang/tools/scan-build/libexec/ccc-analyzer
+++ clang/tools/scan-build/libexec/ccc-analyzer
@@ -80,7 +80,7 @@
   if (-x "/usr/bin/xcrun") {
 $UseXCRUN = 1;
   }
-} elsif (`uname -s` =~ m/OpenBSD/) {
+} elsif (`uname -s` =~ m/(FreeBSD|OpenBSD)/) {
   $DefaultCCompiler = 'cc';
   $DefaultCXXCompiler = 'c++';
 } else {


Index: clang/tools/scan-build/libexec/ccc-analyzer
===
--- clang/tools/scan-build/libexec/ccc-analyzer
+++ clang/tools/scan-build/libexec/ccc-analyzer
@@ -80,7 +80,7 @@
   if (-x "/usr/bin/xcrun") {
 $UseXCRUN = 1;
   }
-} elsif (`uname -s` =~ m/OpenBSD/) {
+} elsif (`uname -s` =~ m/(FreeBSD|OpenBSD)/) {
   $DefaultCCompiler = 'cc';
   $DefaultCXXCompiler = 'c++';
 } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >