[clang] 17139b2 - [clang-format] Reformat. NFC.

2021-04-27 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2021-04-27T09:10:58+02:00
New Revision: 17139b2b21a080c8584fbfe059e8adf85fd26c07

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

LOG: [clang-format] Reformat. NFC.

Added: 


Modified: 
clang/lib/Format/Format.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 00849107c894..b6aa445bb9f4 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -3054,7 +3054,7 @@ llvm::Expected getStyle(StringRef StyleName, 
StringRef FileName,
 
   LLVM_DEBUG(llvm::dbgs() << "Applying child configurations\n");
 
-  for (const auto& MemBuf : llvm::reverse(ChildFormatTextToApply)){
+  for (const auto &MemBuf : llvm::reverse(ChildFormatTextToApply)) {
 auto Ec = parseConfiguration(*MemBuf, &Style, AllowUnknownOptions,
  dropDiagnosticHandler);
 // It was already correctly parsed.



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


[PATCH] D85802: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2021-04-27 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D85802#2717684 , @leonardchan wrote:

>> That's odd. Does your `CMakeCache.txt` file have 
>> `CLANG_ROUND_TRIP_CC1_ARGS:BOOL=OFF` by any chance? It's possible it didn't 
>> get switched to `ON` when D97462  landed.
>>
>> With the way the tests are written now, I'd expect them to fail in assert 
>> build without the code generating `-fcxx-abi=`.
>
> Ah, I did not have that flag ON by default (incrementally working off an old 
> invocation), and turning this on without the `GenerateArg` bit causes 
> `cxx-abi-switch.cpp` to fail. Thanks for catching this!

Great, thanks for confirming.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85802

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


[PATCH] D77598: Integral template argument suffix and cast printing

2021-04-27 Thread Pratyush Das via Phabricator via cfe-commits
reikdas added a comment.

ping...


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

https://reviews.llvm.org/D77598

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


[PATCH] D101259: [clang-tidy] Fix cppcoreguidelines-pro-type-vararg false positives with __builtin_ms_va_list

2021-04-27 Thread Georgy Komarov via Phabricator via cfe-commits
jubnzv updated this revision to Diff 340738.

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

https://reviews.llvm.org/D101259

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
@@ -58,3 +58,11 @@
   (void)__builtin_isinf_sign(0.f);
   (void)__builtin_prefetch(nullptr);
 }
+
+// Some implementations of __builtin_va_list and __builtin_ms_va_list desugared
+// as 'char *' or 'void *'. This test checks whether we are handling this case
+// correctly and not generating false positives.
+void no_false_positive_desugar_va_list(char *in) {
+char *tmp1 = in;
+void *tmp2 = in;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
@@ -0,0 +1,26 @@
+// Purpose:
+// Ensure that the 'cppcoreguidelines-pro-type-vararg' check works with the
+// built-in va_list on Windows systems.
+
+// REQUIRES: system-windows
+
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-vararg %t
+
+void test_ms_va_list(int a, ...) {
+  __builtin_ms_va_list ap;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type va_list; use variadic templates instead
+  __builtin_ms_va_start(ap, a);
+  int b = __builtin_va_arg(ap, int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not use va_arg to define c-style vararg functions; use variadic templates instead
+  __builtin_ms_va_end(ap);
+}
+
+void test_typedefs(int a, ...) {
+  typedef __builtin_ms_va_list my_va_list1;
+  my_va_list1 ap1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type va_list; use variadic templates instead
+
+  using my_va_list2 = __builtin_ms_va_list;
+  my_va_list2 ap2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type va_list; use variadic templates instead
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
@@ -10,6 +10,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/TargetInfo.h"
 
 using namespace clang::ast_matchers;
 
@@ -60,8 +61,43 @@
 AST_MATCHER(QualType, isVAList) {
   ASTContext &Context = Finder->getASTContext();
   QualType Desugar = Node.getDesugaredType(Context);
-  return Context.getBuiltinVaListType().getDesugaredType(Context) == Desugar ||
- Context.getBuiltinMSVaListType().getDesugaredType(Context) == Desugar;
+  QualType NodeTy = Node.getUnqualifiedType();
+
+  auto CheckVaList = [](const QualType &NodeTy, const QualType &Expected,
+const ASTContext &Context) {
+QualType Desugar = NodeTy;
+QualType Ty;
+do {
+  Ty = Desugar;
+  Desugar = Ty.getSingleStepDesugaredType(Context);
+  if (Desugar == Expected)
+return true;
+} while (Desugar != Ty);
+return false;
+  };
+
+  // The internal implementation of __builtin_va_list depends on the target
+  // type. Some targets implements va_list as 'char *' or 'void *'.
+  // In these cases we need to remove all typedefs one by one to check this.
+  const auto VaListKind = Context.getTargetInfo().getBuiltinVaListKind();
+  using BuiltinVaListKind = TargetInfo::BuiltinVaListKind;
+  if (VaListKind == BuiltinVaListKind::CharPtrBuiltinVaList ||
+  VaListKind == BuiltinVaListKind::VoidPtrBuiltinVaList) {
+if (CheckVaList(NodeTy, Context.getBuiltinVaListType(), Context))
+  return true;
+  } else if (Desugar ==
+ Context.getBuiltinVaListType().getDesugaredType(Context)) {
+return true;
+  }
+
+  // We also need to check the implementation of __builtin_ms_va_list in the
+  // same way, because it may differ from the va_list implementation.
+  if (Desugar == Context.getBuiltinMSVaListType().getDesugaredType(Context)) {
+if (CheckVaList(NodeTy, Context.getBuiltinMSVaListType(), Context))
+  return true;
+  }
+
+  return false;
 }
 
 AST_MATCHER_P(AdjustedType, hasOriginalType,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3feb84a - [clang-format] Merge SpacesInAngles tests. NFC.

2021-04-27 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2021-04-27T09:32:09+02:00
New Revision: 3feb84a36f5128dd0f6e9c65314609a9ce4372bc

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

LOG: [clang-format] Merge SpacesInAngles tests. NFC.

Added: 


Modified: 
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 734ffed088a1..8b626f43e0e8 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -10314,20 +10314,6 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
   verifyFormat("vector< int > x{ };", SpaceBetweenBraces);
 }
 
-TEST_F(FormatTest, FormatSpacesInAngles) {
-  FormatStyle SpaceInAngles = getLLVMStyle();
-  SpaceInAngles.SpacesInAngles = true;
-  verifyFormat("vector< ::std::string > x1;", SpaceInAngles);
-  verifyFormat("Foo< int, Bar > x2;", SpaceInAngles);
-  verifyFormat("Foo< ::int, ::Bar > x3;", SpaceInAngles);
-
-  SpaceInAngles.SpacesInAngles = false;
-  verifyFormat("vector<::std::string> x4;", SpaceInAngles);
-  verifyFormat("vector x5;", SpaceInAngles);
-  verifyFormat("Foo x6;", SpaceInAngles);
-  verifyFormat("Foo<::int, ::Bar> x7;", SpaceInAngles);
-}
-
 TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {
   verifyFormat("vector x = {1, 22, 333, , 5, 66, 777,\n"
" 1, 22, 333, , 5, 66, 777,\n"
@@ -18458,6 +18444,10 @@ TEST_F(FormatTest, SpacesInAngles) {
   FormatStyle Spaces = getLLVMStyle();
   Spaces.SpacesInAngles = true;
 
+  verifyFormat("vector< ::std::string > x1;", Spaces);
+  verifyFormat("Foo< int, Bar > x2;", Spaces);
+  verifyFormat("Foo< ::int, ::Bar > x3;", Spaces);
+
   verifyFormat("static_cast< int >(arg);", Spaces);
   verifyFormat("template < typename T0, typename T1 > void f() {}", Spaces);
   verifyFormat("f< int, float >();", Spaces);
@@ -18479,6 +18469,11 @@ TEST_F(FormatTest, SpacesInAngles) {
   verifyFormat("A< A< int > >();", Spaces);
 
   Spaces.SpacesInAngles = false;
+  verifyFormat("vector<::std::string> x4;", Spaces);
+  verifyFormat("vector x5;", Spaces);
+  verifyFormat("Foo x6;", Spaces);
+  verifyFormat("Foo<::int, ::Bar> x7;", Spaces);
+
   verifyFormat("A>();", Spaces);
 }
 



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


[PATCH] D101328: [clangd] run clang-format on FindTargetTests.cpp

2021-04-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101328

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


[PATCH] D101059: [X86][AMX] Add description for AMX new interface.

2021-04-27 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101059

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-27 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

I noticed that with this patch
 libcxx/test/std/strings/basic.string/string.cons/iter_alloc_deduction.fail.cpp
fails:

  error: 'warning' diagnostics seen but not expected: 
File 
/repo/uabelho/master-github/libcxx/test/std/strings/basic.string/string.cons/iter_alloc_deduction.fail.cpp
 Line 51: variable 's' set but not used
  1 error generated.

(I don't know anything about the testcase I just noticed it failed when trying 
to uplift my downstream repo.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D100841: [clangd][Index][NFC] Make local class collection optional

2021-04-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet abandoned this revision.
kadircet added a comment.

> This seems reasonable, but having found the problem, do we still want to land 
> it?

I suppose not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100841

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


[PATCH] D100667: [clang] Fix assert() crash when checking undeduced arg alignment

2021-04-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

thanks, I think we can simplify a bit more.




Comment at: clang/lib/Sema/SemaChecking.cpp:4543
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  auto CheckTypeOK = [](QualType Ty) {
+if (Ty->isIncompleteType() || Ty->isUndeducedType())

adamcz wrote:
> hokein wrote:
> > The current fix is on top of kadir's fix, now the code becomes more 
> > add-hoc, it looks like a smell to me.
> > 
> > 
> > It looks like `CheckArgAlignment` has an implicit invariant (the arg type 
> > should never be undeduced), and this invariant was enforced by dropping the 
> > invalid AST. Now with `RecoveryExpr`, we might break the invariant -- when 
> > the RecoveryExpr preserves an `undeduced` type, like the test case in this 
> > patch (which is done via the 
> > [code](https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaExprCXX.cpp#L1420)).
> > 
> > 
> > I think a right fix is to fix in the `RecoveryExpr` side, `RecoveryExpr` 
> > should not preserve an undeduced type, we did it for function return type 
> > already (https://reviews.llvm.org/D87350), but it didn't cover all places. 
> > I think a general fixing place is `Sema::CreateRecoveryExpr`, if the 
> > passing `T` is undeduced, fallback to dependent type.
> > 
> Ooh, interesting. Thanks for the info.
> 
> I updated the change to catch this in CreateRecoveryExpr as well. I kept my 
> original changes too, they shouldn't harm anything and it's better than 
> crashing.
> 
> Let me know what you think about this now.
> I kept my original changes too, they shouldn't harm anything and it's better 
> than crashing.

I'm a bit nervous about keeping the change/extending the undeduced-type here, 
this looks like a defensive programming, it might hide some bugs in the future. 
 As we have figured out the root cause, I'd also remove the bailout 
`isUndeducedType` case here.



Comment at: clang/lib/Sema/SemaExpr.cpp:19668
 T = Context.DependentTy;
+  else if (const auto *U = T->getUnqualifiedDesugaredType())
+if (U->isUndeducedType())

I'm not sure we need this well. I think the above `T->isUndeducedType()` should 
be enough to fix all known crashes. I'd just remove this one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100667

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


[PATCH] D89013: [libcxx] Support per-target __config_site in per-target runtime build

2021-04-27 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 340743.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89013

Files:
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  
clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/c++/v1/.keep
  
clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/c++/v1/.keep
  
clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/c++/v1/.keep
  
clang/test/Driver/Inputs/basic_linux_libcxx_tree/usr/include/x86_64-linux-gnu/c++/v1/.keep
  
clang/test/Driver/Inputs/basic_linux_libcxxv2_tree/usr/include/x86_64-linux-gnu/c++/v2/.keep
  
clang/test/Driver/Inputs/basic_linux_libstdcxx_libcxxv2_tree/usr/include/x86_64-linux-gnu/c++/v2/.keep
  clang/test/Driver/fuchsia.cpp
  clang/test/Driver/linux-header-search.cpp
  libcxx/CMakeLists.txt
  libcxx/benchmarks/CMakeLists.txt
  libcxx/include/CMakeLists.txt

Index: libcxx/include/CMakeLists.txt
===
--- libcxx/include/CMakeLists.txt
+++ libcxx/include/CMakeLists.txt
@@ -209,9 +209,9 @@
   wctype.h
   )
 
-configure_file("__config_site.in" "${LIBCXX_GENERATED_INCLUDE_DIR}/__config_site" @ONLY)
+configure_file("__config_site.in" "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}/__config_site" @ONLY)
 
-set(_all_includes "${LIBCXX_GENERATED_INCLUDE_DIR}/__config_site")
+set(_all_includes "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}/__config_site")
 foreach(f ${files})
   set(src "${CMAKE_CURRENT_SOURCE_DIR}/${f}")
   set(dst "${LIBCXX_GENERATED_INCLUDE_DIR}/${f}")
@@ -228,24 +228,26 @@
 add_dependencies(cxx-headers generate-cxx-headers ${LIBCXX_CXX_ABI_HEADER_TARGET})
 # TODO: Use target_include_directories once we figure out why that breaks the runtimes build
 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
-  target_compile_options(cxx-headers INTERFACE /I "${LIBCXX_GENERATED_INCLUDE_DIR}")
+  target_compile_options(cxx-headers INTERFACE /I "${LIBCXX_GENERATED_INCLUDE_DIR}"
+ INTERFACE /I "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}")
 else()
-  target_compile_options(cxx-headers INTERFACE -I "${LIBCXX_GENERATED_INCLUDE_DIR}")
+  target_compile_options(cxx-headers INTERFACE -I${LIBCXX_GENERATED_INCLUDE_DIR}
+ INTERFACE -I${LIBCXX_GENERATED_INCLUDE_TARGET_DIR})
 endif()
 
 if (LIBCXX_INSTALL_HEADERS)
   foreach(file ${files})
 get_filename_component(dir ${file} DIRECTORY)
 install(FILES ${file}
-  DESTINATION include/c++/v1/${dir}
+  DESTINATION ${LIBCXX_INSTALL_INCLUDE_DIR}/${dir}
   COMPONENT cxx-headers
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
 )
   endforeach()
 
   # Install the generated __config_site.
-  install(FILES ${LIBCXX_GENERATED_INCLUDE_DIR}/__config_site
-DESTINATION include/c++/v1
+  install(FILES ${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}/__config_site
+DESTINATION ${LIBCXX_INSTALL_INCLUDE_TARGET_DIR}
 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
 COMPONENT cxx-headers)
 
Index: libcxx/benchmarks/CMakeLists.txt
===
--- libcxx/benchmarks/CMakeLists.txt
+++ libcxx/benchmarks/CMakeLists.txt
@@ -15,6 +15,10 @@
 -Wl,-rpath,${LIBCXX_LIBRARY_DIR}
 ${SANITIZER_FLAGS}
 )
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
+  list(APPEND BENCHMARK_LIBCXX_COMPILE_FLAGS
+-isystem "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}")
+endif()
 if (DEFINED LIBCXX_CXX_ABI_LIBRARY_PATH)
   list(APPEND BENCHMARK_LIBCXX_COMPILE_FLAGS
   -L${LIBCXX_CXX_ABI_LIBRARY_PATH}
Index: libcxx/CMakeLists.txt
===
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -408,7 +408,10 @@
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
   set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
   set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
+  set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
   set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE})
+  set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1")
+  set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
   if(LIBCXX_LIBDIR_SUBDIR)
 string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR})
 string(APPEND LIBCXX_INSTALL_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR})
@@ -416,11 +419,17 @@
 elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
   set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
   set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
+  set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}")
   set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX})
+  set

[clang] d6c6db2 - [X86][AMX] Add description for AMX new interface.

2021-04-27 Thread via cfe-commits

Author: Luo, Yuanke
Date: 2021-04-27T16:05:11+08:00
New Revision: d6c6db2feaab42c8132d584b547c18e443ba7f96

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

LOG: [X86][AMX] Add description for AMX new interface.

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

Added: 


Modified: 
clang/lib/Headers/amxintrin.h

Removed: 




diff  --git a/clang/lib/Headers/amxintrin.h b/clang/lib/Headers/amxintrin.h
index 12d21d40bcff..6dc0c1f031c4 100644
--- a/clang/lib/Headers/amxintrin.h
+++ b/clang/lib/Headers/amxintrin.h
@@ -30,7 +30,7 @@
 /// config and the tile data, and the tiles are zeroed. Any invalid
 /// configurations will result in #GP fault.
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  LDTILECFG  instruction.
 ///
@@ -46,7 +46,7 @@ _tile_loadconfig(const void *__config) {
 /// palette, the number of bytes per row, and the number of rows. If tiles
 /// are not configured, all zeroes will be stored to memory.
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  STTILECFG  instruction.
 ///
@@ -60,7 +60,7 @@ _tile_storeconfig(void *__config) {
 /// Release the tile configuration to return to the init state, which
 /// releases all storage it currently holds.
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILERELEASE  instruction.
 static __inline__ void __DEFAULT_FN_ATTRS_TILE _tile_release(void) {
@@ -71,7 +71,7 @@ static __inline__ void __DEFAULT_FN_ATTRS_TILE 
_tile_release(void) {
 /// destination tile "dst" using the tile configuration previously configured
 /// via "_tile_loadconfig".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILELOADD  instruction.
 ///
@@ -91,7 +91,7 @@ static __inline__ void __DEFAULT_FN_ATTRS_TILE 
_tile_release(void) {
 /// that the data will likely not be reused in the near future and the data
 /// caching can be optimized accordingly.
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILELOADDT1  instruction.
 ///
@@ -109,7 +109,7 @@ static __inline__ void __DEFAULT_FN_ATTRS_TILE 
_tile_release(void) {
 /// "stride" using the tile configuration previously configured via
 /// "_tile_loadconfig".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILESTORED  instruction.
 ///
@@ -124,7 +124,7 @@ static __inline__ void __DEFAULT_FN_ATTRS_TILE 
_tile_release(void) {
 
 /// Zero the tile specified by "tdest".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILEZERO  instruction.
 ///
@@ -138,7 +138,7 @@ static __inline__ void __DEFAULT_FN_ATTRS_TILE 
_tile_release(void) {
 /// results. Sum these 4 results with the corresponding 32-bit integer in 
"dst",
 /// and store the 32-bit result back to tile "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBSSD  instruction.
 ///
@@ -157,7 +157,7 @@ static __inline__ void __DEFAULT_FN_ATTRS_TILE 
_tile_release(void) {
 /// 32-bit results. Sum these 4 results with the corresponding 32-bit integer
 /// in "dst", and store the 32-bit result back to tile "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBSUD  instruction.
 ///
@@ -176,7 +176,7 @@ static __inline__ void __DEFAULT_FN_ATTRS_TILE 
_tile_release(void) {
 /// results. Sum these 4 results with the corresponding 32-bit integer in 
"dst",
 /// and store the 32-bit result back to tile "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBUSD  instruction.
 ///
@@ -195,7 +195,7 @@ static __inline__ void __DEFAULT_FN_ATTRS_TILE 
_tile_release(void) {
 /// 32-bit results. Sum these 4 results with the corresponding 32-bit integer 
in
 /// "dst", and store the 32-bit result back to tile "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBUUD  instruction.
 ///
@@ -213,7 +213,7 @@ static __inline__ void __DEFAULT_FN_ATTRS_TILE 
_tile_release(void) {
 /// elements with elements in "dst", and store the 32-bit result back to tile
 /// "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBF16PS  instruction.
 ///
@@ -226,8 +226,12 @@ static __inline__ void __DEFAULT_FN_ATTRS_TILE 
_tile_release(void) {
 #define _tile_dpbf16ps(dst, src0, src1)
\
   __builtin_ia32_tdpbf16ps((dst), (src0), (src1))
 
+/// AMX tile register size can be configured, the maximum size is 16x64=1024
+/// bytes. Since there is no 2D type in llvm IR, we use vector type to
+/// represent 2D tile and the fixed size is maximum amx tile register size.
 typedef int _tile1024i __a

[PATCH] D101059: [X86][AMX] Add description for AMX new interface.

2021-04-27 Thread LuoYuanke 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 rGd6c6db2feaab: [X86][AMX] Add description for AMX new 
interface. (authored by LuoYuanke).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101059

Files:
  clang/lib/Headers/amxintrin.h

Index: clang/lib/Headers/amxintrin.h
===
--- clang/lib/Headers/amxintrin.h
+++ clang/lib/Headers/amxintrin.h
@@ -30,7 +30,7 @@
 /// config and the tile data, and the tiles are zeroed. Any invalid
 /// configurations will result in #GP fault.
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  LDTILECFG  instruction.
 ///
@@ -46,7 +46,7 @@
 /// palette, the number of bytes per row, and the number of rows. If tiles
 /// are not configured, all zeroes will be stored to memory.
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  STTILECFG  instruction.
 ///
@@ -60,7 +60,7 @@
 /// Release the tile configuration to return to the init state, which
 /// releases all storage it currently holds.
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILERELEASE  instruction.
 static __inline__ void __DEFAULT_FN_ATTRS_TILE _tile_release(void) {
@@ -71,7 +71,7 @@
 /// destination tile "dst" using the tile configuration previously configured
 /// via "_tile_loadconfig".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILELOADD  instruction.
 ///
@@ -91,7 +91,7 @@
 /// that the data will likely not be reused in the near future and the data
 /// caching can be optimized accordingly.
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILELOADDT1  instruction.
 ///
@@ -109,7 +109,7 @@
 /// "stride" using the tile configuration previously configured via
 /// "_tile_loadconfig".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILESTORED  instruction.
 ///
@@ -124,7 +124,7 @@
 
 /// Zero the tile specified by "tdest".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILEZERO  instruction.
 ///
@@ -138,7 +138,7 @@
 /// results. Sum these 4 results with the corresponding 32-bit integer in "dst",
 /// and store the 32-bit result back to tile "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBSSD  instruction.
 ///
@@ -157,7 +157,7 @@
 /// 32-bit results. Sum these 4 results with the corresponding 32-bit integer
 /// in "dst", and store the 32-bit result back to tile "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBSUD  instruction.
 ///
@@ -176,7 +176,7 @@
 /// results. Sum these 4 results with the corresponding 32-bit integer in "dst",
 /// and store the 32-bit result back to tile "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBUSD  instruction.
 ///
@@ -195,7 +195,7 @@
 /// 32-bit results. Sum these 4 results with the corresponding 32-bit integer in
 /// "dst", and store the 32-bit result back to tile "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBUUD  instruction.
 ///
@@ -213,7 +213,7 @@
 /// elements with elements in "dst", and store the 32-bit result back to tile
 /// "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBF16PS  instruction.
 ///
@@ -226,8 +226,12 @@
 #define _tile_dpbf16ps(dst, src0, src1)\
   __builtin_ia32_tdpbf16ps((dst), (src0), (src1))
 
+/// AMX tile register size can be configured, the maximum size is 16x64=1024
+/// bytes. Since there is no 2D type in llvm IR, we use vector type to
+/// represent 2D tile and the fixed size is maximum amx tile register size.
 typedef int _tile1024i __attribute__((__vector_size__(1024), __aligned__(64)));
 
+/// This is internal intrinsic. C/C++ user should avoid calling it directly.
 static __inline__ _tile1024i __DEFAULT_FN_ATTRS_INT8
 _tile_loadd_internal(unsigned short m, unsigned short n, const void *base,
  __SIZE_TYPE__ stride) {
@@ -235,30 +239,35 @@
  (__SIZE_TYPE__)(stride));
 }
 
+/// This is internal intrinsic. C/C++ user should avoid calling it directly.
 static __inline__ _tile1024i __DEFAULT_FN_ATTRS_INT8
 _tile_dpbssd_internal(unsigned short m, unsigned short n, unsigned short k,
   _tile1024i dst, _tile1024i src1, _tile1024i src2) {
   return __builtin_ia32_tdpbssd_internal(m, n, k, dst, src1, src2);
 }
 
+/// This is internal intrinsic. C/C++ user should avoid calling it directly.
 static __inline__ _tile1024i __DEFAULT_FN_ATTRS_INT8
 _tile_dpbsud_internal(unsigned short m, unsig

[PATCH] D101324: Hurd: Clean up Debian multiarch /usr/include/

2021-04-27 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul added a comment.

FI, I don't have commit access.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101324

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


[PATCH] D101122: introduce flag -fsanitize-address-detect-stack-use-after-return-mode. No functional change.

2021-04-27 Thread Kevin Athey via Phabricator via cfe-commits
kda updated this revision to Diff 340746.
kda added a comment.

Revisions as requested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101122

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h


Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
@@ -20,5 +20,16 @@
   Invalid, ///< Not a valid destructor Kind.
   // TODO(dliew): Add more more kinds.
 };
+
+/// Kinds of ASan detect stack use after return
+enum class AsanDetectStackUseAfterReturnKind {
+  Never,   ///< Never detect stack use after return.
+  Runtime, ///< Detect stack use after return if runtime flag is enabled
+   ///< (ASAN_OPTIONS=detect_stack_use_after_return=1)
+  Always,  ///< Always detect stack use after return.
+  Invalid, ///< Not a valid detect mode.
+};
+
 } // namespace llvm
+
 #endif
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1544,6 +1544,16 @@
   NormalizedValuesScope<"llvm::AsanDtorKind">,
   NormalizedValues<["None", "Global"]>,
   MarshallingInfoEnum, "Global">;
+def sanitize_address_detect_stack_use_after_return_mode_EQ
+: Joined<["-"], "fsanitize-address-detect-stack-use-after-return-mode=">,
+  MetaVarName<"">,
+  Flags<[CC1Option]>,
+  HelpText<"Select the enabling method of detect-stack-use-after-return in 
AddressSanitizer">,
+  Group,
+  Values<"always,runtime,never">,
+  NormalizedValuesScope<"llvm::AsanDetectStackUseAfterReturnKind">,
+  NormalizedValues<["Never", "Runtime", "Always"]>,
+  
MarshallingInfoEnum, 
"Runtime">;
 // Note: This flag was introduced when it was necessary to distinguish between
 //   ABI for correct codegen.  This is no longer needed, but the flag is
 //   not removed since targeting either ABI will behave the same.
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -222,6 +222,10 @@
 ENUM_CODEGENOPT(SanitizeAddressDtorKind, llvm::AsanDtorKind, 2,
 llvm::AsanDtorKind::Global)  ///< Set how ASan global
  ///< destructors are emitted.
+ENUM_CODEGENOPT(SanitizeAddressDetectStackUseAfterReturn,
+llvm::AsanDetectStackUseAfterReturnKind, 2,
+llvm::AsanDetectStackUseAfterReturnKind::Runtime
+) ///< Set detection mode for stack-use-after-return.
 CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete 
detection
  ///< in MemorySanitizer
 CODEGENOPT(SanitizeCfiCrossDso, 1, 0) ///< Enable cross-dso support in CFI.


Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
@@ -20,5 +20,16 @@
   Invalid, ///< Not a valid destructor Kind.
   // TODO(dliew): Add more more kinds.
 };
+
+/// Kinds of ASan detect stack use after return
+enum class AsanDetectStackUseAfterReturnKind {
+  Never,   ///< Never detect stack use after return.
+  Runtime, ///< Detect stack use after return if runtime flag is enabled
+   ///< (ASAN_OPTIONS=detect_stack_use_after_return=1)
+  Always,  ///< Always detect stack use after return.
+  Invalid, ///< Not a valid detect mode.
+};
+
 } // namespace llvm
+
 #endif
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1544,6 +1544,16 @@
   NormalizedValuesScope<"llvm::AsanDtorKind">,
   NormalizedValues<["None", "Global"]>,
   MarshallingInfoEnum, "Global">;
+def sanitize_address_detect_stack_use_after_return_mode_EQ
+: Joined<["-"], "fsanitize-address-detect-stack-use-after-return-mode=">,
+  MetaVarName<"">,
+  Flags<[CC1Option]>,
+  HelpText<"Select the enabling method of detect-stack-use-after-return in AddressSanitizer">,
+  Group,
+  Values<"always,runtime,never">,
+  NormalizedValuesScope<"llvm::AsanDetectStackUseAfterReturnKind">,
+  NormalizedValues<["Never", "Runtime", "Always"]>,
+  MarshallingInfoEnum, "Runtime">;
 // Note: This flag was int

[PATCH] D101059: [X86][AMX] Add description for AMX new interface.

2021-04-27 Thread Xiang Zhang via Phabricator via cfe-commits
xiangzhangllvm added a comment.

+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101059

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


[PATCH] D101344: [clang-format] Add `SpacesInAngles: Leave` option to keep spacing inside angle brackets as is.

2021-04-27 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: MyDeveloperDay, HazardyKnusperkeks.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

A need for such an option came up in a few libc++ reviews. That's because 
libc++ has both code in C++03 and newer standards.
Currently, it uses `Standard: C++03` setting for clang-format, but this breaks 
e.g. u8"string" literals.
Also, angle brackets are the only place where C++03-specific formatting needs 
to be applied.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101344

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10286,7 +10286,7 @@
   verifyFormat("f({}, {{}, {}}, MyMap[{k, v}]);", SpaceBeforeBrace);
 
   FormatStyle SpaceBetweenBraces = getLLVMStyle();
-  SpaceBetweenBraces.SpacesInAngles = true;
+  SpaceBetweenBraces.SpacesInAngles = FormatStyle::SIAS_Always;
   SpaceBetweenBraces.SpacesInParentheses = true;
   SpaceBetweenBraces.SpacesInSquareBrackets = true;
   verifyFormat("vector< int > x{ 1, 2, 3, 4 };", SpaceBetweenBraces);
@@ -16308,7 +16308,6 @@
   CHECK_PARSE_BOOL(SortUsingDeclarations);
   CHECK_PARSE_BOOL(SpacesInParentheses);
   CHECK_PARSE_BOOL(SpacesInSquareBrackets);
-  CHECK_PARSE_BOOL(SpacesInAngles);
   CHECK_PARSE_BOOL(SpacesInConditionalStatement);
   CHECK_PARSE_BOOL(SpaceInEmptyBlock);
   CHECK_PARSE_BOOL(SpaceInEmptyParentheses);
@@ -16865,6 +16864,15 @@
   "  Maximum: 1",
   SpacesInLineCommentPrefix.Maximum, 1u);
   EXPECT_EQ(Style.SpacesInLineCommentPrefix.Minimum, 1u);
+
+  Style.SpacesInAngles = FormatStyle::SIAS_Always;
+  CHECK_PARSE("SpacesInAngles: Never", SpacesInAngles, FormatStyle::SIAS_Never);
+  CHECK_PARSE("SpacesInAngles: Always", SpacesInAngles,
+  FormatStyle::SIAS_Always);
+  CHECK_PARSE("SpacesInAngles: Leave", SpacesInAngles, FormatStyle::SIAS_Leave);
+  // For backward compatibility:
+  CHECK_PARSE("SpacesInAngles: false", SpacesInAngles, FormatStyle::SIAS_Never);
+  CHECK_PARSE("SpacesInAngles: true", SpacesInAngles, FormatStyle::SIAS_Always);
 }
 
 TEST_F(FormatTest, ParsesConfigurationWithLanguages) {
@@ -18442,7 +18450,7 @@
 
 TEST_F(FormatTest, SpacesInAngles) {
   FormatStyle Spaces = getLLVMStyle();
-  Spaces.SpacesInAngles = true;
+  Spaces.SpacesInAngles = FormatStyle::SIAS_Always;
 
   verifyFormat("vector< ::std::string > x1;", Spaces);
   verifyFormat("Foo< int, Bar > x2;", Spaces);
@@ -18458,23 +18466,48 @@
Spaces);
 
   Spaces.Standard = FormatStyle::LS_Cpp03;
-  Spaces.SpacesInAngles = true;
+  Spaces.SpacesInAngles = FormatStyle::SIAS_Always;
   verifyFormat("A< A< int > >();", Spaces);
 
-  Spaces.SpacesInAngles = false;
+  Spaces.SpacesInAngles = FormatStyle::SIAS_Never;
+  verifyFormat("A >();", Spaces);
+
+  Spaces.SpacesInAngles = FormatStyle::SIAS_Leave;
+  verifyFormat("vector< ::std::string> x4;", "vector<::std::string> x4;",
+   Spaces);
+  verifyFormat("vector< ::std::string > x4;", "vector<::std::string > x4;",
+   Spaces);
+
   verifyFormat("A >();", Spaces);
+  verifyFormat("A >();", "A>();", Spaces);
+  verifyFormat("A< A< int > >();", Spaces);
 
   Spaces.Standard = FormatStyle::LS_Cpp11;
-  Spaces.SpacesInAngles = true;
+  Spaces.SpacesInAngles = FormatStyle::SIAS_Always;
   verifyFormat("A< A< int > >();", Spaces);
 
-  Spaces.SpacesInAngles = false;
+  Spaces.SpacesInAngles = FormatStyle::SIAS_Never;
   verifyFormat("vector<::std::string> x4;", Spaces);
   verifyFormat("vector x5;", Spaces);
   verifyFormat("Foo x6;", Spaces);
   verifyFormat("Foo<::int, ::Bar> x7;", Spaces);
 
   verifyFormat("A>();", Spaces);
+
+  Spaces.SpacesInAngles = FormatStyle::SIAS_Leave;
+  verifyFormat("vector<::std::string> x4;", Spaces);
+  verifyFormat("vector< ::std::string > x4;", Spaces);
+  verifyFormat("vector x5;", Spaces);
+  verifyFormat("vector< int > x5;", Spaces);
+  verifyFormat("Foo x6;", Spaces);
+  verifyFormat("Foo< int, Bar > x6;", Spaces);
+  verifyFormat("Foo<::int, ::Bar> x7;", Spaces);
+  verifyFormat("Foo< ::int, ::Bar > x7;", Spaces);
+
+  verifyFormat("A>();", Spaces);
+  verifyFormat("A< A< int > >();", Spaces);
+  verifyFormat("A >();", Spaces);
+  verifyFormat("A< A< int>>();", Spaces);
 }
 
 TEST_F(FormatTest, SpaceAfterTemplateKeyword) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3094,6 +3094,9 @@
 bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
  const FormatToken &

[PATCH] D101317: hurd: Fix i386 research path

2021-04-27 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul updated this revision to Diff 340749.
sthibaul added a comment.

Retrigger buildable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101317

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Hurd.h
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/c++/4.6.0/.keep
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/i386-gnu/c++/4.6.0/.keep
  clang/test/Driver/hurd.c
  clang/test/Driver/hurd.cpp

Index: clang/test/Driver/hurd.cpp
===
--- /dev/null
+++ clang/test/Driver/hurd.cpp
@@ -0,0 +1,98 @@
+// UNSUPPORTED: system-windows
+
+// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN: --target=i386-pc-hurd-gnu \
+// RUN: --sysroot=%S/Inputs/basic_hurd_tree \
+// RUN:   | FileCheck --check-prefix=CHECK %s
+// CHECK: "-cc1"
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0"
+/// Debian specific - the path component after 'include' is i386-gnu even
+/// though the installation is i686-gnu.
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/i386-gnu/c++/4.6.0"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0/backward"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK: "-internal-externc-isystem"
+// CHECK-SAME: {{^}} "[[SYSROOT]]/usr/include/i386-gnu"
+// CHECK-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK: "-dynamic-linker" "/lib/ld.so"
+// CHECK: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbegin.o"
+// CHECK: "-L
+// CHECK-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../lib32"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib/i386-gnu"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib/../lib32"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/i386-gnu"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/../lib32"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
+
+// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN: --target=i386-pc-hurd-gnu -static \
+// RUN: --sysroot=%S/Inputs/basic_hurd_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-STATIC %s
+// CHECK-STATIC: "-cc1"
+// CHECK-STATIC: "-static-define"
+// CHECK-STATIC: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0"
+/// Debian specific - the path component after 'include' is i386-gnu even
+/// though the installation is i686-gnu.
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/i386-gnu/c++/4.6.0"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0/backward"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-STATIC: "-internal-externc-isystem"
+// CHECK-STATIC-SAME: {{^}} "[[SYSROOT]]/usr/include/i386-gnu"
+// CHECK-STATIC-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-STATIC-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// CHECK-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-STATIC: "-static"
+// CHECK-STATIC: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbeginT.o"
+// CHECK-STATIC: "-L
+// CHECK-STATIC-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../lib32"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/lib/i386-gnu"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/lib/../lib32"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/i386-gnu"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/../lib32"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/lib"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
+
+// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN: --target=i386-pc-hurd-gnu -shared \
+// RUN: --sysroot=%S/Inputs/basic_hurd_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-SHARED %s
+// CHECK-SHARED: "-cc1"
+// CHECK-SHARED: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-SHARED-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0"
+/// Debian specific - the path component after 'include' is i386-gnu even
+/// though the installation is i686-gnu.
+// CHECK-SHARED-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../

[PATCH] D101317: hurd: Fix i386 research path

2021-04-27 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul updated this revision to Diff 340751.
sthibaul added a comment.

Retrigger buildable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101317

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/as
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/ld
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/lib/.keep
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i686-gnu/bin/as
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i686-gnu/bin/ld
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i686-gnu/lib/.keep
  
clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbegin.o
  
clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbegin.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbegin.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbeginS.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbeginT.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbegin.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbeginS.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbeginT.o
  clang/test/Driver/hurd.c


Index: clang/test/Driver/hurd.c
===
--- clang/test/Driver/hurd.c
+++ clang/test/Driver/hurd.c
@@ -11,7 +11,7 @@
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 // CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK: "-dynamic-linker" "/lib/ld.so"
-// CHECK: "{{.*}}/usr/lib/gcc/i386-gnu/4.6.0{{/|}}crtbegin.o"
+// CHECK: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbegin.o"
 // CHECK: "-L[[SYSROOT]]/lib/i386-gnu"
 // CHECK: "-L[[SYSROOT]]/lib/../lib32"
 // CHECK: "-L[[SYSROOT]]/usr/lib/i386-gnu"
@@ -33,7 +33,7 @@
 // CHECK-STATIC: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 // CHECK-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-STATIC: "-static"
-// CHECK-STATIC: "{{.*}}/usr/lib/gcc/i386-gnu/4.6.0{{/|}}crtbeginT.o"
+// CHECK-STATIC: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbeginT.o"
 // CHECK-STATIC: "-L[[SYSROOT]]/lib/i386-gnu"
 // CHECK-STATIC: "-L[[SYSROOT]]/lib/../lib32"
 // CHECK-STATIC: "-L[[SYSROOT]]/usr/lib/i386-gnu"
@@ -53,7 +53,7 @@
 // CHECK-SHARED: "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-SHARED: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 // CHECK-SHARED: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK-SHARED: "{{.*}}/usr/lib/gcc/i386-gnu/4.6.0{{/|}}crtbeginS.o"
+// CHECK-SHARED: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbeginS.o"
 // CHECK-SHARED: "-L[[SYSROOT]]/lib/i386-gnu"
 // CHECK-SHARED: "-L[[SYSROOT]]/lib/../lib32"
 // CHECK-SHARED: "-L[[SYSROOT]]/usr/lib/i386-gnu"
@@ -67,7 +67,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-CROSS %s
 // CHECK-CROSS-NOT: warning:
 // CHECK-CROSS: "-cc1" "-triple" "i386-pc-hurd-gnu"
-// CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/../../../../i386-gnu/bin{{/|}}as"
 "--32"
-// CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/../../../../i386-gnu/bin{{/|}}ld"
 {{.*}} "-m" "elf_i386"
-// CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0{{/|}}crtbegin.o"
-// CHECK-CROSS: 
"-L{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/../../../../i386-gnu/lib"
+// CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/../../../../i686-gnu/bin{{/|}}as"
 "--32"
+// CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/../../../../i686-gnu/bin{{/|}}ld"
 {{.*}} "-m" "elf_i386"
+// CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbegin.o"
+// CHECK-CROSS: 
"-L{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/../../../../i686-gnu/lib"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2115,7 +2115,7 @@
   "i686-pc-linux-gnu",  "i386-redhat-linux6E",
   "i686-redhat-linux",  "i386-redhat-linux",
   "i586-suse-linux","i686-montavista-linux",
-  "i686-linux-android", "i386-gnu",
+  "i686-linux-android", "i686-gnu",
   };
 
   static const char *const M68kLibDirs[] = {"/lib"};


Index: clang/test/Driver/hurd.c
===
--- clang/test/Driver/hurd.c
+++ clang/test/Driver/hurd.c
@@ -11,7 +11,7 @@
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 // CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK: "-dynamic-linker" "/lib/ld.so"
-// 

[PATCH] D101122: introduce flag -fsanitize-address-detect-stack-use-after-return-mode. No functional change.

2021-04-27 Thread Kevin Athey via Phabricator via cfe-commits
kda marked 4 inline comments as done.
kda added a comment.

Thank you for delineating the steps.

Unfortunately, I don't know where to even start looking for the tests you 
mention in step 1.  Are you looking for something like this: 
https://reviews.llvm.org/differential/changeset/?ref=2496958

For the 3 files I have here, which step are they in?  (Step 1?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101122

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


[PATCH] D101122: introduce flag -fsanitize-address-detect-stack-use-after-return-mode. No functional change.

2021-04-27 Thread Kevin Athey via Phabricator via cfe-commits
kda updated this revision to Diff 340754.
kda added a comment.

fixed up some more naming issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101122

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h


Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
@@ -20,5 +20,16 @@
   Invalid, ///< Not a valid destructor Kind.
   // TODO(dliew): Add more more kinds.
 };
+
+/// Kinds of ASan detect stack use after return
+enum class AsanDetectStackUseAfterReturnKind {
+  Never,   ///< Never detect stack use after return.
+  Runtime, ///< Detect stack use after return if runtime flag is enabled
+   ///< (ASAN_OPTIONS=detect_stack_use_after_return=1)
+  Always,  ///< Always detect stack use after return.
+  Invalid, ///< Not a valid detect mode.
+};
+
 } // namespace llvm
+
 #endif
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1544,6 +1544,16 @@
   NormalizedValuesScope<"llvm::AsanDtorKind">,
   NormalizedValues<["None", "Global"]>,
   MarshallingInfoEnum, "Global">;
+def sanitize_address_detect_stack_use_after_return_EQ
+: Joined<["-"], "fsanitize-address-detect-stack-use-after-return=">,
+  MetaVarName<"">,
+  Flags<[CC1Option]>,
+  HelpText<"Select the enabling method of detect-stack-use-after-return in 
AddressSanitizer">,
+  Group,
+  Values<"never,runtime,always">,
+  NormalizedValuesScope<"llvm::AsanDetectStackUseAfterReturnKind">,
+  NormalizedValues<["Never", "Runtime", "Always"]>,
+  
MarshallingInfoEnum, 
"Runtime">;
 // Note: This flag was introduced when it was necessary to distinguish between
 //   ABI for correct codegen.  This is no longer needed, but the flag is
 //   not removed since targeting either ABI will behave the same.
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -222,6 +222,10 @@
 ENUM_CODEGENOPT(SanitizeAddressDtorKind, llvm::AsanDtorKind, 2,
 llvm::AsanDtorKind::Global)  ///< Set how ASan global
  ///< destructors are emitted.
+ENUM_CODEGENOPT(SanitizeAddressDetectStackUseAfterReturn,
+llvm::AsanDetectStackUseAfterReturnKind, 2,
+llvm::AsanDetectStackUseAfterReturnKind::Runtime
+) ///< Set detection mode for stack-use-after-return.
 CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete 
detection
  ///< in MemorySanitizer
 CODEGENOPT(SanitizeCfiCrossDso, 1, 0) ///< Enable cross-dso support in CFI.


Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
@@ -20,5 +20,16 @@
   Invalid, ///< Not a valid destructor Kind.
   // TODO(dliew): Add more more kinds.
 };
+
+/// Kinds of ASan detect stack use after return
+enum class AsanDetectStackUseAfterReturnKind {
+  Never,   ///< Never detect stack use after return.
+  Runtime, ///< Detect stack use after return if runtime flag is enabled
+   ///< (ASAN_OPTIONS=detect_stack_use_after_return=1)
+  Always,  ///< Always detect stack use after return.
+  Invalid, ///< Not a valid detect mode.
+};
+
 } // namespace llvm
+
 #endif
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1544,6 +1544,16 @@
   NormalizedValuesScope<"llvm::AsanDtorKind">,
   NormalizedValues<["None", "Global"]>,
   MarshallingInfoEnum, "Global">;
+def sanitize_address_detect_stack_use_after_return_EQ
+: Joined<["-"], "fsanitize-address-detect-stack-use-after-return=">,
+  MetaVarName<"">,
+  Flags<[CC1Option]>,
+  HelpText<"Select the enabling method of detect-stack-use-after-return in AddressSanitizer">,
+  Group,
+  Values<"never,runtime,always">,
+  NormalizedValuesScope<"llvm::AsanDetectStackUseAfterReturnKind">,
+  NormalizedValues<["Never", "Runtime", "Always"]>,
+  MarshallingInfoEnum, "Runtime">;
 // Note: This flag was introduced wh

[PATCH] D100772: [ARM] Neon Polynomial vadd Intrinsic fix

2021-04-27 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D100772

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


[PATCH] D101346: [AST] Fix getExprLoc reported for cxxDependentScopeMemberExpr

2021-04-27 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: rsmith.
steveire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

All other CallExpr use the location of the member name as the
getExprLoc:

  https://godbolt.org/z/jx16G9Gdr


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101346

Files:
  clang/include/clang/AST/ExprCXX.h
  clang/unittests/AST/SourceLocationTest.cpp


Index: clang/unittests/AST/SourceLocationTest.cpp
===
--- clang/unittests/AST/SourceLocationTest.cpp
+++ clang/unittests/AST/SourceLocationTest.cpp
@@ -634,6 +634,39 @@
  friendDecl()));
 }
 
+TEST(CXXDependentScopeMemberExpr, ExprLocation) {
+
+  llvm::Annotations Example(R"cpp(
+template
+struct MyContainer
+{
+template 
+void pushBack();
+
+void foo();
+};
+
+template
+struct Derived : MyContainer
+{
+void bar()
+{
+MyContainer::template $member_name^pushBack();
+}
+};
+  )cpp");
+
+  auto AST = tooling::buildASTFromCode(Example.code());
+  SourceManager &SM = AST->getSourceManager();
+  auto &Ctx = AST->getASTContext();
+
+  auto *M = selectFirst(
+  "mem", match(cxxDependentScopeMemberExpr().bind("mem"), Ctx));
+  ASSERT_TRUE(M != nullptr);
+
+  ASSERT_EQ(SM.getFileOffset(M->getExprLoc()), Example.point("member_name"));
+}
+
 TEST(FriendDecl, FriendTemplateClassRange) {
   RangeVerifier Verifier;
   Verifier.expectRange(2, 1, 3, 14);
Index: clang/include/clang/AST/ExprCXX.h
===
--- clang/include/clang/AST/ExprCXX.h
+++ clang/include/clang/AST/ExprCXX.h
@@ -3774,6 +3774,8 @@
 return MemberNameInfo.getEndLoc();
   }
 
+  SourceLocation getExprLoc() const LLVM_READONLY { return getMemberLoc(); }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXDependentScopeMemberExprClass;
   }


Index: clang/unittests/AST/SourceLocationTest.cpp
===
--- clang/unittests/AST/SourceLocationTest.cpp
+++ clang/unittests/AST/SourceLocationTest.cpp
@@ -634,6 +634,39 @@
  friendDecl()));
 }
 
+TEST(CXXDependentScopeMemberExpr, ExprLocation) {
+
+  llvm::Annotations Example(R"cpp(
+template
+struct MyContainer
+{
+template 
+void pushBack();
+
+void foo();
+};
+
+template
+struct Derived : MyContainer
+{
+void bar()
+{
+MyContainer::template $member_name^pushBack();
+}
+};
+  )cpp");
+
+  auto AST = tooling::buildASTFromCode(Example.code());
+  SourceManager &SM = AST->getSourceManager();
+  auto &Ctx = AST->getASTContext();
+
+  auto *M = selectFirst(
+  "mem", match(cxxDependentScopeMemberExpr().bind("mem"), Ctx));
+  ASSERT_TRUE(M != nullptr);
+
+  ASSERT_EQ(SM.getFileOffset(M->getExprLoc()), Example.point("member_name"));
+}
+
 TEST(FriendDecl, FriendTemplateClassRange) {
   RangeVerifier Verifier;
   Verifier.expectRange(2, 1, 3, 14);
Index: clang/include/clang/AST/ExprCXX.h
===
--- clang/include/clang/AST/ExprCXX.h
+++ clang/include/clang/AST/ExprCXX.h
@@ -3774,6 +3774,8 @@
 return MemberNameInfo.getEndLoc();
   }
 
+  SourceLocation getExprLoc() const LLVM_READONLY { return getMemberLoc(); }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXDependentScopeMemberExprClass;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-27 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.

I think this added a regression, where you have this context:

  uint32_t LocalAccessible::SelectedItemCount() {
uint32_t count = 0;
AccIterator iter(this, filters::GetSelected);
LocalAccessible* selected = nullptr;
while ((selected = iter.Next())) ++count;
  
return count;
  }



  [task 2021-04-27T02:39:42.523Z] 02:39:42ERROR -  
/builds/worker/checkouts/gecko/accessible/generic/LocalAccessible.cpp:2455:20: 
error: variable 'selected' set but not used [-Werror,-Wunused-but-set-variable]
  [task 2021-04-27T02:39:42.523Z] 02:39:42 INFO -LocalAccessible* 
selected = nullptr;
  [task 2021-04-27T02:39:42.523Z] 02:39:42 INFO - ^
  [task 2021-04-27T02:39:42.523Z] 02:39:42 INFO -  1 error generated.

The file in cause is this 

 one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D99840: [clang-format] Correctly attach enum braces with ShortEnums disabled

2021-04-27 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. I also consider it a bug. LLVM should not be affected as it uses 
`AllowShortEnumsOnASingleLine: true` whereas this problem arises only with 
`AllowShortEnumsOnASingleLine: false`.
Anyway, those that find the new behaviour problematic, can always set 
`BreakBeforeBraces: Custom` and `BraceWrapping.AfterEnum: true` to get the old 
behaviour.
@lunasorcery, please update release notes before landing.
If you don't have commit rights, please provide "Your Name " for 
commit attribution, otherwise we'll use the name/email associated with you 
Phabricator account.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99840

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


[PATCH] D101259: [clang-tidy] Fix cppcoreguidelines-pro-type-vararg false positives with __builtin_ms_va_list

2021-04-27 Thread Georgy Komarov via Phabricator via cfe-commits
jubnzv updated this revision to Diff 340757.

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

https://reviews.llvm.org/D101259

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
@@ -58,3 +58,11 @@
   (void)__builtin_isinf_sign(0.f);
   (void)__builtin_prefetch(nullptr);
 }
+
+// Some implementations of __builtin_va_list and __builtin_ms_va_list desugared
+// as 'char *' or 'void *'. This test checks whether we are handling this case
+// correctly and not generating false positives.
+void no_false_positive_desugar_va_list(char *in) {
+  char *tmp1 = in;
+  void *tmp2 = in;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
@@ -0,0 +1,26 @@
+// Purpose:
+// Ensure that the 'cppcoreguidelines-pro-type-vararg' check works with the
+// built-in va_list on Windows systems.
+
+// REQUIRES: system-windows
+
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-vararg %t
+
+void test_ms_va_list(int a, ...) {
+  __builtin_ms_va_list ap;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type va_list; use variadic templates instead
+  __builtin_ms_va_start(ap, a);
+  int b = __builtin_va_arg(ap, int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not use va_arg to define c-style vararg functions; use variadic templates instead
+  __builtin_ms_va_end(ap);
+}
+
+void test_typedefs(int a, ...) {
+  typedef __builtin_ms_va_list my_va_list1;
+  my_va_list1 ap1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type va_list; use variadic templates instead
+
+  using my_va_list2 = __builtin_ms_va_list;
+  my_va_list2 ap2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type va_list; use variadic templates instead
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
@@ -10,6 +10,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/TargetInfo.h"
 
 using namespace clang::ast_matchers;
 
@@ -60,8 +61,45 @@
 AST_MATCHER(QualType, isVAList) {
   ASTContext &Context = Finder->getASTContext();
   QualType Desugar = Node.getDesugaredType(Context);
-  return Context.getBuiltinVaListType().getDesugaredType(Context) == Desugar ||
- Context.getBuiltinMSVaListType().getDesugaredType(Context) == Desugar;
+  QualType NodeTy = Node.getUnqualifiedType();
+
+  auto CheckVaList = [](const QualType &NodeTy, const QualType &Expected,
+const ASTContext &Context) {
+if (NodeTy == Expected)
+  return true;
+QualType Desugar = NodeTy;
+QualType Ty;
+do {
+  Ty = Desugar;
+  Desugar = Ty.getSingleStepDesugaredType(Context);
+  if (Desugar == Expected)
+return true;
+} while (Desugar != Ty);
+return false;
+  };
+
+  // The internal implementation of __builtin_va_list depends on the target
+  // type. Some targets implements va_list as 'char *' or 'void *'.
+  // In these cases we need to remove all typedefs one by one to check this.
+  const auto VaListKind = Context.getTargetInfo().getBuiltinVaListKind();
+  using BuiltinVaListKind = TargetInfo::BuiltinVaListKind;
+  if (VaListKind == BuiltinVaListKind::CharPtrBuiltinVaList ||
+  VaListKind == BuiltinVaListKind::VoidPtrBuiltinVaList) {
+if (CheckVaList(NodeTy, Context.getBuiltinVaListType(), Context))
+  return true;
+  } else if (Desugar ==
+ Context.getBuiltinVaListType().getDesugaredType(Context)) {
+return true;
+  }
+
+  // We also need to check the implementation of __builtin_ms_va_list in the
+  // same way, because it may differ from the va_list implementation.
+  if (Desugar == Context.getBuiltinMSVaListType().getDesugaredType(Context)) {
+if (CheckVaList(NodeTy, Context.getBuiltinMSVaListType(), Context))
+  return true;
+  }
+
+  return false;
 }
 
 AST_MATCHER_P(AdjustedType, hasOriginalType,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm

[PATCH] D100919: [AArch64] Support customizing stack protector guard

2021-04-27 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3110
+}
+if (EffectiveTriple.isAArch64() && Value != "sysreg" && Value != "global") 
{
+  D.Diag(diag::err_drv_invalid_value_with_suggestion)

Shouldn't this also allow "tls"? At least that's what the previous code works 
out to, I don't know if that actually works on AArch64 or if it just didn't 
error.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3138
 }
+if (EffectiveTriple.isAArch64() && Value != "sp_el0") {
+  D.Diag(diag::err_drv_invalid_value_with_suggestion)

nickdesaulniers wrote:
> nickdesaulniers wrote:
> > nickdesaulniers wrote:
> > > nickdesaulniers wrote:
> > > > nickdesaulniers wrote:
> > > > > TODO: can we re-use `AArch64SysReg::lookupSysRegByName` in the 
> > > > > frontend?
> > > > I don't think so because 
> > > > `llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h` is under lib/ not 
> > > > include/. Not sure if I should just remove reg validation?
> > > Guidance provided by @echristo and @jyknight was that we should avoid 
> > > such linkage requirements on Target/, so instead I'll work on adding a 
> > > helper to clang/lib/Driver/ToolChains/Arch/AArch64.cpp that duplicates 
> > > logic from `AArch64SysReg::lookupSysRegByName`.
> > It looks like there's ~1000 possible sysregs for aarch64 ATM; do we really 
> > want to add all of those to clang?
> I'm going to post that as a separate commit/review on top of this series, 
> that way it doesn't pollute this code review. This is ready to be reviewed.
If the number of different registers people actually use with this option is 
somewhere < 10 I'd just hardcode the names here as needed. (a large amount of 
those sysregs won't be suitable for this purpose anyway)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100919

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


[PATCH] D101327: [Clang][Driver] validate sysregs for -mstack-protector-guard-reg=

2021-04-27 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

A lot of these system registers are going to be unsuitable for the stack 
canary. They're either read only, they have fixed bits, or they'll get 
overwritten by various system events.

I'm not suggesting we audit this list for those things, what seems reasonable 
to me is just to support the ones that the Linux kernel uses. (what GCC allows 
I'm not sure)

https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/AArch64-Options.html

  -mstack-protector-guard=guard
  -mstack-protector-guard-reg=reg
  -mstack-protector-guard-offset=offset
  Generate stack protection code using canary at guard. Supported locations are 
‘global’ for a global canary or ‘sysreg’ for a canary in an appropriate system 
register.
  
  With the latter choice the options -mstack-protector-guard-reg=reg and 
-mstack-protector-guard-offset=offset furthermore specify which system register 
to use as base register for reading the canary, and from what offset from that 
base register. There is no default register or offset as this is entirely for 
use within the Linux kernel.

So if kernel builds are using a small subset of registers, just check for 
those. Otherwise we've got another duplicated list that we (Arm) will probably 
forget to update anyway when new registers are added.

Either way it's one more stick on the "why doesn't clang just use the backend 
info" fire, but it's smaller at least if we limit the registers. E.g.

  error: invalid value 'foo' in 'mstack-protector-guard-reg=','for AArch64' 
valid values are sp_el1 sp_el2


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101327

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


[PATCH] D101347: hurd: Clean up test

2021-04-27 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul created this revision.
sthibaul requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- We dropped windows support
- Upgrade to current gcc 10 version


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101347

Files:
  
clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/10/crtbegin.o
  
clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbegin.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/c++/10/.keep
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/c++/4.6.0/.keep
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/i386-gnu/c++/10/.keep
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/i386-gnu/c++/4.6.0/.keep
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/10/crtbegin.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/10/crtbeginS.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/10/crtbeginT.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbegin.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbeginS.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbeginT.o
  clang/test/Driver/hurd.cpp

Index: clang/test/Driver/hurd.cpp
===
--- clang/test/Driver/hurd.cpp
+++ clang/test/Driver/hurd.cpp
@@ -6,22 +6,22 @@
 // RUN:   | FileCheck --check-prefix=CHECK %s
 // CHECK: "-cc1"
 // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
-// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/c++/10"
 /// Debian specific - the path component after 'include' is i386-gnu even
 /// though the installation is i686-gnu.
-// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/i386-gnu/c++/4.6.0"
-// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0/backward"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/i386-gnu/c++/10"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/c++/10/backward"
 // CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include"
 // CHECK: "-internal-externc-isystem"
 // CHECK-SAME: {{^}} "[[SYSROOT]]/usr/include/i386-gnu"
 // CHECK-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
-// CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK: "{{.*}}ld" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK: "-dynamic-linker" "/lib/ld.so"
-// CHECK: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbegin.o"
+// CHECK: "{{.*}}/usr/lib/gcc/i686-gnu/10/crtbegin.o"
 // CHECK: "-L
-// CHECK-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0"
-// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../lib32"
+// CHECK-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/i686-gnu/10"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../lib32"
 // CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib/i386-gnu"
 // CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib/../lib32"
 // CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/i386-gnu"
@@ -36,22 +36,22 @@
 // CHECK-STATIC: "-cc1"
 // CHECK-STATIC: "-static-define"
 // CHECK-STATIC: "-isysroot" "[[SYSROOT:[^"]+]]"
-// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/c++/10"
 /// Debian specific - the path component after 'include' is i386-gnu even
 /// though the installation is i686-gnu.
-// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/i386-gnu/c++/4.6.0"
-// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0/backward"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/i386-gnu/c++/10"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/c++/10/backward"
 // CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include"
 // CHECK-STATIC: "-internal-externc-isystem"
 // CHECK-STATIC-SAME: {{^}} "[[SYSROOT]]/usr/include/i386-gnu"
 // CHECK-STATIC-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-STATIC-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
-// CHECK-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-STATIC: "{{.*}}ld" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-STATIC: "-static"
-// CHECK-STATIC: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbeginT.o

[PATCH] D101348: [Driver] Fix tests failing in per-target multiarch layout

2021-04-27 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: haowei, leonardchan.
phosek requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

These failures were revealed by b4537c3f51bc6c011ddd9c10b80043ac4ce16a01 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101348

Files:
  clang/test/Driver/compiler-rt-unwind.c
  clang/test/Driver/cross-linux.c
  clang/test/Driver/env.c
  clang/test/Driver/sanitizer-ld.c

Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -115,6 +115,7 @@
 
 // RUN: %clang -no-canonical-prefixes %s -### -o /dev/null -fsanitize=address \
 // RUN: -target i386-unknown-linux -fuse-ld=ld -stdlib=platform \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree -lstdc++ -static 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-LINUX-CXX-STATIC %s
 //
@@ -284,16 +285,19 @@
 
 // RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-LINUX %s
 
 // RUN: %clang -fsanitize=float-divide-by-zero %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-LINUX %s
 
 // RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN: -static-libsan \
 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-LINUX %s
@@ -317,18 +321,21 @@
 
 // RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN: -shared-libsan \
 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-LINUX-SHAREDLIBASAN %s
 
 // RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN: -static-libsan -shared-libsan \
 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-LINUX-SHAREDLIBASAN %s
 
 // RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN: -shared -shared-libsan \
 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-LINUX-SHAREDLIBASAN %s
@@ -338,6 +345,7 @@
 
 // RUN: %clang -fsanitize=undefined -fsanitize-link-c++-runtime %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-LINUX-LINK-CXX %s
 // CHECK-UBSAN-LINUX-LINK-CXX-NOT: "-lstdc++"
@@ -361,6 +369,7 @@
 
 // RUN: %clang -fsanitize=undefined -fsanitize-minimal-runtime %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-MINIMAL-LINUX %s
 // CHECK-UBSAN-MINIMAL-LINUX: "{{.*}}ld{{(.exe)?}}"
@@ -383,6 +392,7 @@
 
 // RUN: %clang -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-UBSAN-LINUX %s
 // CHECK-ASAN-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}"
@@ -393,6 +403,7 @@
 
 // RUN: %clangxx -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld -stdlib=platform \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-UBSAN-LINUX-CXX %s
 // CHECK-ASAN-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
@@ -404,6 +415,7 @@
 
 // RUN: %clangxx -fsanitize=memory,undefined %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux -fuse-ld=ld \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-MSAN-UBSAN-LINUX-CXX %s
 // CHECK-MSAN-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
@@ -412,6 +424,7 @@
 
 // RUN: %clangxx -fsanitize=thread,undefined %s -### -o %t.o 2>&1 \
 // 

[PATCH] D100919: [AArch64] Support customizing stack protector guard

2021-04-27 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added inline comments.



Comment at: clang/test/Driver/stack-protector-guard.c:59
+// INVALID-VALUE-AARCH64: error: invalid value 'tls' in 
'mstack-protector-guard=','valid arguments to '-mstack-protector-guard=' 
are:sysreg global'
+// INVALID-REG-AARCH64: error: invalid value 'foo' in 
'mstack-protector-guard-reg=','for AArch64'

I'm not sure if this is due to your code or the error machinery itself but 
these errors are strangely written.

I'd expect:
```
error: invalid value 'tls' in 'mstack-protector-guard='tls', valid arguments to 
'-mstack-protector-guard=' are:sysreg global'
```

Maybe it's assuming that there could be multiple values and `','` means that 
list option treats the value as a list? Or it's not using the right value and 
the comma is meant to be after the `=''` as in my example.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100919

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


[PATCH] D101346: [AST] Fix getExprLoc reported for cxxDependentScopeMemberExpr

2021-04-27 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 340762.
steveire added a comment.

Update test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101346

Files:
  clang/include/clang/AST/ExprCXX.h
  clang/unittests/AST/SourceLocationTest.cpp


Index: clang/unittests/AST/SourceLocationTest.cpp
===
--- clang/unittests/AST/SourceLocationTest.cpp
+++ clang/unittests/AST/SourceLocationTest.cpp
@@ -634,6 +634,35 @@
  friendDecl()));
 }
 
+TEST(CXXDependentScopeMemberExpr, ExprLocation) {
+
+  llvm::Annotations Example(R"cpp(
+template
+struct MyContainer
+{
+template 
+void pushBack();
+};
+
+template
+void testCall()
+{
+  MyContainer mc;
+  mc.template $member_name^pushBack();
+}
+  )cpp");
+
+  auto AST = tooling::buildASTFromCode(Example.code());
+  SourceManager &SM = AST->getSourceManager();
+  auto &Ctx = AST->getASTContext();
+
+  auto *M = selectFirst(
+  "mem", match(cxxDependentScopeMemberExpr().bind("mem"), Ctx));
+  ASSERT_TRUE(M != nullptr);
+
+  ASSERT_EQ(SM.getFileOffset(M->getExprLoc()), Example.point("member_name"));
+}
+
 TEST(FriendDecl, FriendTemplateClassRange) {
   RangeVerifier Verifier;
   Verifier.expectRange(2, 1, 3, 14);
Index: clang/include/clang/AST/ExprCXX.h
===
--- clang/include/clang/AST/ExprCXX.h
+++ clang/include/clang/AST/ExprCXX.h
@@ -3774,6 +3774,8 @@
 return MemberNameInfo.getEndLoc();
   }
 
+  SourceLocation getExprLoc() const LLVM_READONLY { return getMemberLoc(); }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXDependentScopeMemberExprClass;
   }


Index: clang/unittests/AST/SourceLocationTest.cpp
===
--- clang/unittests/AST/SourceLocationTest.cpp
+++ clang/unittests/AST/SourceLocationTest.cpp
@@ -634,6 +634,35 @@
  friendDecl()));
 }
 
+TEST(CXXDependentScopeMemberExpr, ExprLocation) {
+
+  llvm::Annotations Example(R"cpp(
+template
+struct MyContainer
+{
+template 
+void pushBack();
+};
+
+template
+void testCall()
+{
+  MyContainer mc;
+  mc.template $member_name^pushBack();
+}
+  )cpp");
+
+  auto AST = tooling::buildASTFromCode(Example.code());
+  SourceManager &SM = AST->getSourceManager();
+  auto &Ctx = AST->getASTContext();
+
+  auto *M = selectFirst(
+  "mem", match(cxxDependentScopeMemberExpr().bind("mem"), Ctx));
+  ASSERT_TRUE(M != nullptr);
+
+  ASSERT_EQ(SM.getFileOffset(M->getExprLoc()), Example.point("member_name"));
+}
+
 TEST(FriendDecl, FriendTemplateClassRange) {
   RangeVerifier Verifier;
   Verifier.expectRange(2, 1, 3, 14);
Index: clang/include/clang/AST/ExprCXX.h
===
--- clang/include/clang/AST/ExprCXX.h
+++ clang/include/clang/AST/ExprCXX.h
@@ -3774,6 +3774,8 @@
 return MemberNameInfo.getEndLoc();
   }
 
+  SourceLocation getExprLoc() const LLVM_READONLY { return getMemberLoc(); }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXDependentScopeMemberExprClass;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101331: hurd: Detect libstdc++ include paths on Debian Hurd i386

2021-04-27 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul updated this revision to Diff 340765.
sthibaul added a comment.

Fix clang-tidy warning


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101331

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Hurd.h
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/c++/4.6.0/.keep
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/i386-gnu/c++/4.6.0/.keep
  clang/test/Driver/hurd.c
  clang/test/Driver/hurd.cpp

Index: clang/test/Driver/hurd.cpp
===
--- /dev/null
+++ clang/test/Driver/hurd.cpp
@@ -0,0 +1,98 @@
+// UNSUPPORTED: system-windows
+
+// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN: --target=i386-pc-hurd-gnu \
+// RUN: --sysroot=%S/Inputs/basic_hurd_tree \
+// RUN:   | FileCheck --check-prefix=CHECK %s
+// CHECK: "-cc1"
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0"
+/// Debian specific - the path component after 'include' is i386-gnu even
+/// though the installation is i686-gnu.
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/i386-gnu/c++/4.6.0"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0/backward"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK: "-internal-externc-isystem"
+// CHECK-SAME: {{^}} "[[SYSROOT]]/usr/include/i386-gnu"
+// CHECK-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK: "-dynamic-linker" "/lib/ld.so"
+// CHECK: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbegin.o"
+// CHECK: "-L
+// CHECK-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../lib32"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib/i386-gnu"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib/../lib32"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/i386-gnu"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/../lib32"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
+
+// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN: --target=i386-pc-hurd-gnu -static \
+// RUN: --sysroot=%S/Inputs/basic_hurd_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-STATIC %s
+// CHECK-STATIC: "-cc1"
+// CHECK-STATIC: "-static-define"
+// CHECK-STATIC: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0"
+/// Debian specific - the path component after 'include' is i386-gnu even
+/// though the installation is i686-gnu.
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/i386-gnu/c++/4.6.0"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0/backward"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-STATIC: "-internal-externc-isystem"
+// CHECK-STATIC-SAME: {{^}} "[[SYSROOT]]/usr/include/i386-gnu"
+// CHECK-STATIC-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-STATIC-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// CHECK-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-STATIC: "-static"
+// CHECK-STATIC: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbeginT.o"
+// CHECK-STATIC: "-L
+// CHECK-STATIC-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../lib32"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/lib/i386-gnu"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/lib/../lib32"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/i386-gnu"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/../lib32"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/lib"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
+
+// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN: --target=i386-pc-hurd-gnu -shared \
+// RUN: --sysroot=%S/Inputs/basic_hurd_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-SHARED %s
+// CHECK-SHARED: "-cc1"
+// CHECK-SHARED: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-SHARED-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0"
+/// Debian specific - the path component after 'include' is i386-gnu even
+/// though the installation is i686-gnu.
+// CHECK-SHARED-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../

[PATCH] D100980: [OpenCL] Allow use of double type without extension pragma

2021-04-27 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

> Anyway since there is not clear benefit that can be found now for the pragma 
> I think we should minimize its use as much as possible.

Unfortunately it's already there :(

> Anyway since there is not clear benefit that can be found now for the pragma 
> I think we should minimize its use as much as possible.

I personally agree, but I believe in order to go forward this patch should 
introduce diagnostics to commit the introduction of new functionality, I'm not 
sure what exactly it should be. I'm thinking of some pedantic one such as: 
"pragma enable is no longer required for type usage". What do you think?


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

https://reviews.llvm.org/D100980

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


[PATCH] D101347: hurd: Clean up test

2021-04-27 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul updated this revision to Diff 340769.
sthibaul added a comment.

Retrigger buildable with the dep


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101347

Files:
  
clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/10/crtbegin.o
  
clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbegin.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/c++/10/.keep
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/c++/4.6.0/.keep
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/i386-gnu/c++/10/.keep
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/i386-gnu/c++/4.6.0/.keep
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/10/crtbegin.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/10/crtbeginS.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/10/crtbeginT.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbegin.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbeginS.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbeginT.o
  clang/test/Driver/hurd.cpp

Index: clang/test/Driver/hurd.cpp
===
--- clang/test/Driver/hurd.cpp
+++ clang/test/Driver/hurd.cpp
@@ -6,22 +6,22 @@
 // RUN:   | FileCheck --check-prefix=CHECK %s
 // CHECK: "-cc1"
 // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
-// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/c++/10"
 /// Debian specific - the path component after 'include' is i386-gnu even
 /// though the installation is i686-gnu.
-// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/i386-gnu/c++/4.6.0"
-// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0/backward"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/i386-gnu/c++/10"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/c++/10/backward"
 // CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include"
 // CHECK: "-internal-externc-isystem"
 // CHECK-SAME: {{^}} "[[SYSROOT]]/usr/include/i386-gnu"
 // CHECK-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
-// CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK: "{{.*}}ld" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK: "-dynamic-linker" "/lib/ld.so"
-// CHECK: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbegin.o"
+// CHECK: "{{.*}}/usr/lib/gcc/i686-gnu/10/crtbegin.o"
 // CHECK: "-L
-// CHECK-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0"
-// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../lib32"
+// CHECK-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/i686-gnu/10"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../lib32"
 // CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib/i386-gnu"
 // CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib/../lib32"
 // CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/i386-gnu"
@@ -36,22 +36,22 @@
 // CHECK-STATIC: "-cc1"
 // CHECK-STATIC: "-static-define"
 // CHECK-STATIC: "-isysroot" "[[SYSROOT:[^"]+]]"
-// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/c++/10"
 /// Debian specific - the path component after 'include' is i386-gnu even
 /// though the installation is i686-gnu.
-// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/i386-gnu/c++/4.6.0"
-// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0/backward"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/i386-gnu/c++/10"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/c++/10/backward"
 // CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include"
 // CHECK-STATIC: "-internal-externc-isystem"
 // CHECK-STATIC-SAME: {{^}} "[[SYSROOT]]/usr/include/i386-gnu"
 // CHECK-STATIC-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-STATIC-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
-// CHECK-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-STATIC: "{{.*}}ld" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-STATIC: "-static"
-// CHECK-STATIC: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbeginT.o"
+// CHECK-STATIC: "{{.*}}/usr/lib/gcc

[PATCH] D98726: [analyzer] Enabling MallocChecker to take up after SmartPtrModelling

2021-04-27 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

Judging by this line 

 in the `LikelyFalsePositiveSuppressionBRVisitor::finalizeVisitor()` method, it 
seems that the bug report is squelched when the visitor encounters an  
`ExplodedNode` which corresponds to a `LocationContext`, whose associated 
`Decl` lies in **std** namespace. I guess, by default, the option to suppress 
warnings from the std library is enabled. Which makes sense, except in this 
case since `unique_ptr` is in std and it is being used in that function, the 
bug report is suppressed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98726

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


[PATCH] D100980: [OpenCL] Allow use of double type without extension pragma

2021-04-27 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D100980#2719043 , @azabaznov wrote:

>> I am not sure, to be honest I personally think the extension pragma is a 
>> spec failure as it is not specified properly or to allow reasonable 
>> implementation
>
> Unfortunately it's already there :(
>
>> Anyway since there is not clear benefit that can be found now for the pragma 
>> I think we should minimize its use as much as possible.
>
> I personally agree, but I believe in order to go forward this patch should 
> introduce diagnostics to commit the introduction of new functionality, I'm 
> not sure what exactly it should be. I'm thinking of some pedantic one such 
> as: "pragma enable is no longer required for type usage". What do you think?

Well I don't see how we can do this now because we still use the pragma for 
other cases. I only remove one use of it for declaring the types but there are 
others for example for literal conversion:
https://clang.llvm.org/doxygen/SemaExpr_8cpp_source.html#l00816

When the pragma is parsed we can't know why it is in the code to be able to 
issue any warning.

If we remove all uses of pragma for `cl_khr_fp64` we could do something like 
https://reviews.llvm.org/D91534. But we can't do this yet.

My current clean-up only covers one particular case of requiring pragma for 
declaring a type because I don't see why it is useful and it is safe to relax 
as it doesn't cause kernels to compile differently. We can look at other cases 
later but they are relatively infrequent and don't  cause lots of maintenance.


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

https://reviews.llvm.org/D100980

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


[clang] 37bc1dc - [NFC] Workaround MSVC2019 32-bit compiler crash

2021-04-27 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-04-27T11:15:47+01:00
New Revision: 37bc1dc9877fc480493c85c6d02709b3015bb5e8

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

LOG: [NFC] Workaround MSVC2019 32-bit compiler crash

As reported on D100492, this restructuring should stop the internal
compiler error from happening.

Fixes PR50128.

Added: 


Modified: 
clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp 
b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
index 1e274389b119b..91227797a757f 100644
--- a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -525,17 +525,18 @@ void BuiltinNameEmitter::EmitBuiltinTable() {
 
 for (const auto &Overload : SLM.second.Signatures) {
   StringRef ExtName = 
Overload.first->getValueAsDef("Extension")->getName();
+  unsigned int MinVersion =
+  Overload.first->getValueAsDef("MinVersion")->getValueAsInt("ID");
+  unsigned int MaxVersion =
+  Overload.first->getValueAsDef("MaxVersion")->getValueAsInt("ID");
+
   OS << "  { " << Overload.second << ", "
  << Overload.first->getValueAsListOfDefs("Signature").size() << ", "
  << (Overload.first->getValueAsBit("IsPure")) << ", "
  << (Overload.first->getValueAsBit("IsConst")) << ", "
  << (Overload.first->getValueAsBit("IsConv")) << ", "
  << FunctionExtensionIndex[ExtName] << ", "
- << EncodeVersions(Overload.first->getValueAsDef("MinVersion")
-   ->getValueAsInt("ID"),
-   Overload.first->getValueAsDef("MaxVersion")
-   ->getValueAsInt("ID"))
- << " },\n";
+ << EncodeVersions(MinVersion, MaxVersion) << " },\n";
   Index++;
 }
   }



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


[PATCH] D100492: [OpenCL] Change OpenCL builtin version encoding

2021-04-27 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added a comment.

Thanks for experimenting!  I have pushed 37bc1dc9877f 
 ("[NFC] 
Workaround MSVC2019 32-bit compiler crash", 2021-04-27).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100492

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


[PATCH] D101259: [clang-tidy] Fix cppcoreguidelines-pro-type-vararg false positives with __builtin_ms_va_list

2021-04-27 Thread Georgy Komarov via Phabricator via cfe-commits
jubnzv added a comment.

Thanks, I updated my patch and now CI is happy.
I also found a few additional cases that can lead to false positives on the 
platforms which implements `__builtin_va_list` as `void *` or `char *`, and 
added additional checks for this.


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

https://reviews.llvm.org/D101259

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


[PATCH] D101168: [C++4OpenCL] Add clang extension for unsafe kernel parameters

2021-04-27 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:8651
 static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT) {
+  if (PT->isDependentType())
+return InvalidKernelParam;

Anastasia wrote:
> I would rather add an assert for this because we should not ever reach this 
> function for the dependent types?
The function is actually called on dependent types


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101168

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


[clang-tools-extra] 4581bf3 - [clangd] Dont index deeply nested symbols

2021-04-27 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-04-27T12:34:56+02:00
New Revision: 4581bf31bb8333dc1372959f7d650ed940eab710

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

LOG: [clangd] Dont index deeply nested symbols

This is fix for some timeouts and OOM problems faced while indexing an
auto-generated file with thousands of nested lambdas.

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

Added: 


Modified: 
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/AST.h
clang-tools-extra/clangd/index/IndexAction.cpp
clang-tools-extra/clangd/unittests/ASTTests.cpp
clang-tools-extra/clangd/unittests/IndexActionTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index abcfc1af848bc..32bae42a07976 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -524,5 +524,14 @@ bool hasUnstableLinkage(const Decl *D) {
   return VD && !VD->getType().isNull() && VD->getType()->isUndeducedType();
 }
 
+bool isDeeplyNested(const Decl *D, unsigned MaxDepth) {
+  size_t ContextDepth = 0;
+  for (auto *Ctx = D->getDeclContext(); Ctx && !Ctx->isTranslationUnit();
+   Ctx = Ctx->getParent()) {
+if (++ContextDepth == MaxDepth)
+  return true;
+  }
+  return false;
+}
 } // namespace clangd
 } // namespace clang

diff  --git a/clang-tools-extra/clangd/AST.h b/clang-tools-extra/clangd/AST.h
index 94984a915422e..7793b6545c0f6 100644
--- a/clang-tools-extra/clangd/AST.h
+++ b/clang-tools-extra/clangd/AST.h
@@ -171,6 +171,12 @@ std::string getQualification(ASTContext &Context,
 /// the cached value is incorrect. (clang catches this with an assertion).
 bool hasUnstableLinkage(const Decl *D);
 
+/// Checks whether \p D is more than \p MaxDepth away from translation unit
+/// scope.
+/// This is useful for limiting traversals to keep operation latencies
+/// reasonable.
+bool isDeeplyNested(const Decl *D, unsigned MaxDepth = 10);
+
 } // namespace clangd
 } // namespace clang
 

diff  --git a/clang-tools-extra/clangd/index/IndexAction.cpp 
b/clang-tools-extra/clangd/index/IndexAction.cpp
index e5a48df90b4dc..0d8ae93efa4ae 100644
--- a/clang-tools-extra/clangd/index/IndexAction.cpp
+++ b/clang-tools-extra/clangd/index/IndexAction.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "IndexAction.h"
+#include "AST.h"
 #include "Headers.h"
 #include "index/Relation.h"
 #include "index/SymbolOrigin.h"
@@ -21,6 +22,7 @@
 #include "clang/Index/IndexingOptions.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/STLExtras.h"
+#include 
 #include 
 #include 
 #include 
@@ -138,6 +140,12 @@ class IndexAction : public ASTFrontendAction {
 Includes(std::move(Includes)), Opts(Opts),
 PragmaHandler(collectIWYUHeaderMaps(this->Includes.get())) {
 this->Opts.ShouldTraverseDecl = [this](const Decl *D) {
+  // Many operations performed during indexing is linear in terms of depth
+  // of the decl (USR generation, name lookups, figuring out role of a
+  // reference are some examples). Since we index all the decls nested
+  // inside, it becomes quadratic. So we give up on nested symbols.
+  if (isDeeplyNested(D))
+return false;
   auto &SM = D->getASTContext().getSourceManager();
   auto FID = SM.getFileID(SM.getExpansionLoc(D->getLocation()));
   if (!FID.isValid())

diff  --git a/clang-tools-extra/clangd/unittests/ASTTests.cpp 
b/clang-tools-extra/clangd/unittests/ASTTests.cpp
index 4c52c72d703c7..7b662189eaaf3 100644
--- a/clang-tools-extra/clangd/unittests/ASTTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ASTTests.cpp
@@ -351,6 +351,32 @@ TEST(ClangdAST, PrintType) {
 }
   }
 }
+
+TEST(ClangdAST, IsDeeplyNested) {
+  Annotations Test(
+  R"cpp(
+namespace ns {
+class Foo {
+  void bar() {
+class Bar {};
+  }
+};
+})cpp");
+  TestTU TU = TestTU::withCode(Test.code());
+  ParsedAST AST = TU.build();
+
+  EXPECT_TRUE(isDeeplyNested(&findUnqualifiedDecl(AST, "Foo"), 
/*MaxDepth=*/1));
+  EXPECT_FALSE(
+  isDeeplyNested(&findUnqualifiedDecl(AST, "Foo"), /*MaxDepth=*/2));
+
+  EXPECT_TRUE(isDeeplyNested(&findUnqualifiedDecl(AST, "bar"), 
/*MaxDepth=*/2));
+  EXPECT_FALSE(
+  isDeeplyNested(&findUnqualifiedDecl(AST, "bar"), /*MaxDepth=*/3));
+
+  EXPECT_TRUE(isDeeplyNested(&findUnqualifiedDecl(AST, "Bar"), 
/*MaxDepth=*/3));
+  EXPECT_FALSE(
+  isDeeplyNested(&findUnqualifiedDecl(AST, "Bar"), /*MaxDepth=*/4));
+}
 } // namespace
 } // namespace clangd
 } // namespace clang

diff  --git a/clang-tools-extra/clangd/unittests/IndexActionTests.cpp 
b/clang-tools-extra/clangd/unittests/IndexActionTests.cpp
in

[PATCH] D101066: [clangd] Dont index deeply nested symbols

2021-04-27 Thread Kadir Cetinkaya 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 rG4581bf31bb83: [clangd] Dont index deeply nested symbols 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101066

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/index/IndexAction.cpp
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/IndexActionTests.cpp

Index: clang-tools-extra/clangd/unittests/IndexActionTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexActionTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexActionTests.cpp
@@ -281,6 +281,36 @@
   EXPECT_THAT(Ref.Location.FileURI, EndsWith("good.h"));
 }
 
+TEST_F(IndexActionTest, SkipNestedSymbols) {
+  std::string MainFilePath = testPath("main.cpp");
+  addFile(MainFilePath, R"cpp(
+  namespace ns1 {
+  namespace ns2 {
+  namespace ns3 {
+  namespace ns4 {
+  namespace ns5 {
+  namespace ns6 {
+  namespace ns7 {
+  namespace ns8 {
+  namespace ns9 {
+  class Bar {};
+  void foo() {
+class Baz {};
+  }
+  }
+  }
+  }
+  }
+  }
+  }
+  }
+  }
+  })cpp");
+  IndexFileIn IndexFile = runIndexingAction(MainFilePath, {"-std=c++14"});
+  EXPECT_THAT(*IndexFile.Symbols, testing::Contains(HasName("foo")));
+  EXPECT_THAT(*IndexFile.Symbols, testing::Contains(HasName("Bar")));
+  EXPECT_THAT(*IndexFile.Symbols, Not(testing::Contains(HasName("Baz";
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/ASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ASTTests.cpp
@@ -351,6 +351,32 @@
 }
   }
 }
+
+TEST(ClangdAST, IsDeeplyNested) {
+  Annotations Test(
+  R"cpp(
+namespace ns {
+class Foo {
+  void bar() {
+class Bar {};
+  }
+};
+})cpp");
+  TestTU TU = TestTU::withCode(Test.code());
+  ParsedAST AST = TU.build();
+
+  EXPECT_TRUE(isDeeplyNested(&findUnqualifiedDecl(AST, "Foo"), /*MaxDepth=*/1));
+  EXPECT_FALSE(
+  isDeeplyNested(&findUnqualifiedDecl(AST, "Foo"), /*MaxDepth=*/2));
+
+  EXPECT_TRUE(isDeeplyNested(&findUnqualifiedDecl(AST, "bar"), /*MaxDepth=*/2));
+  EXPECT_FALSE(
+  isDeeplyNested(&findUnqualifiedDecl(AST, "bar"), /*MaxDepth=*/3));
+
+  EXPECT_TRUE(isDeeplyNested(&findUnqualifiedDecl(AST, "Bar"), /*MaxDepth=*/3));
+  EXPECT_FALSE(
+  isDeeplyNested(&findUnqualifiedDecl(AST, "Bar"), /*MaxDepth=*/4));
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/IndexAction.cpp
===
--- clang-tools-extra/clangd/index/IndexAction.cpp
+++ clang-tools-extra/clangd/index/IndexAction.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "IndexAction.h"
+#include "AST.h"
 #include "Headers.h"
 #include "index/Relation.h"
 #include "index/SymbolOrigin.h"
@@ -21,6 +22,7 @@
 #include "clang/Index/IndexingOptions.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/STLExtras.h"
+#include 
 #include 
 #include 
 #include 
@@ -138,6 +140,12 @@
 Includes(std::move(Includes)), Opts(Opts),
 PragmaHandler(collectIWYUHeaderMaps(this->Includes.get())) {
 this->Opts.ShouldTraverseDecl = [this](const Decl *D) {
+  // Many operations performed during indexing is linear in terms of depth
+  // of the decl (USR generation, name lookups, figuring out role of a
+  // reference are some examples). Since we index all the decls nested
+  // inside, it becomes quadratic. So we give up on nested symbols.
+  if (isDeeplyNested(D))
+return false;
   auto &SM = D->getASTContext().getSourceManager();
   auto FID = SM.getFileID(SM.getExpansionLoc(D->getLocation()));
   if (!FID.isValid())
Index: clang-tools-extra/clangd/AST.h
===
--- clang-tools-extra/clangd/AST.h
+++ clang-tools-extra/clangd/AST.h
@@ -171,6 +171,12 @@
 /// the cached value is incorrect. (clang catches this with an assertion).
 bool hasUnstableLinkage(const Decl *D);
 
+/// Checks whether \p D is more than \p MaxDepth away from translation unit
+/// scope.
+/// This is useful for limiting traversals to keep operation latencies
+/// reasonable.
+bool isDeeplyNested(const Decl *D, unsigned MaxDepth = 10);
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -524,5 +524,14 @@

[PATCH] D100980: [OpenCL] Allow use of double type without extension pragma

2021-04-27 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

> When the pragma is parsed we can't know why it is in the code to be able to 
> issue any warning.

I mean diagnose once when, for example in your particular case, double type is 
parsed.  Does it require much effort? I think this warning might be useful for 
developers who already rely on pragma usage in their kernels.


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

https://reviews.llvm.org/D100980

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


[PATCH] D100482: [PowerPC] Provide MMA builtins for compatibility

2021-04-27 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai requested changes to this revision.
nemanjai added a comment.
This revision now requires changes to proceed.

There may be something I am overlooking here, but I really don't think we need 
to or want to change the back end. Just add the new builtins to the front end 
as aliases to the existing ones and generate the same code from the front end.

Also, we will want this backported to 12.0.1. Please open a bugzilla bug that 
we can mark as blocking the release and add a link to that PR in this review.




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:15348
+  if (BuiltinID == PPC::BI__builtin_mma_disassemble_pair)
+Intrinsic = Intrinsic::ppc_mma_disassemble_pair;
   if (BuiltinID == PPC::BI__builtin_mma_disassemble_acc) {

The `_mma_` version of the builtin is supposed to just be an alias for the 
`_vsx_` version. There is no need to add a new intrinsic and produce it here. 
Just produce the same intrinsic for both builtins.



Comment at: llvm/include/llvm/IR/IntrinsicsPowerPC.td:1139
   Intrinsic<[llvm_v256i1_ty], [llvm_ptr_ty], [IntrReadMem, 
IntrArgMemOnly]>;
+def int_ppc_mma_lxvp :
+  Intrinsic<[llvm_v256i1_ty], [llvm_ptr_ty], [IntrReadMem, 
IntrArgMemOnly]>;

Please don't define these unless we absolutely need them.

If we don't add these, I think all the code in the back end is no longer needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100482

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


[clang] 59ad4e0 - Reapply "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"

2021-04-27 Thread Pushpinder Singh via cfe-commits

Author: Pushpinder Singh
Date: 2021-04-27T10:47:05Z
New Revision: 59ad4e0f01a8402016a690b3915bdd083285561e

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

LOG: Reapply  "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"

This reverts commit 93604305bb72201641f31cc50a6e7b2fe65d3af3.

Added: 
clang/test/Driver/Inputs/amdgpu-arch/amdgpu_arch_different
clang/test/Driver/Inputs/amdgpu-arch/amdgpu_arch_fail
clang/test/Driver/Inputs/amdgpu-arch/amdgpu_arch_gfx906
clang/test/Driver/Inputs/amdgpu-arch/amdgpu_arch_gfx908_gfx908
clang/test/Driver/amdgpu-openmp-system-arch-fail.c
clang/test/Driver/amdgpu-openmp-system-arch.c
clang/tools/amdgpu-arch/AMDGPUArch.cpp
clang/tools/amdgpu-arch/CMakeLists.txt

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/AMDGPU.h
clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
clang/tools/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 5e580cc4fbb7a..a2ffe1378cb6d 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -67,6 +67,8 @@ def err_drv_no_hip_runtime : Error<
   "cannot find HIP runtime. Provide its path via --rocm-path, or pass "
   "-nogpuinc to build without HIP runtime.">;
 
+def err_drv_undetermined_amdgpu_arch : Error<
+  "Cannot determine AMDGPU architecture: %0. Consider passing it via 
--march.">;
 def err_drv_cuda_version_unsupported : Error<
   "GPU arch %0 is supported by CUDA versions between %1 and %2 (inclusive), "
   "but installation at %3 is %4. Use --cuda-path to specify a 
diff erent CUDA "

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 04a05207cc74b..df3049fe40326 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -924,6 +924,8 @@ def rocm_path_EQ : Joined<["--"], "rocm-path=">, 
Group,
   HelpText<"ROCm installation path, used for finding and automatically linking 
required bitcode libraries.">;
 def hip_path_EQ : Joined<["--"], "hip-path=">, Group,
   HelpText<"HIP runtime installation path, used for finding HIP version and 
adding HIP include path.">;
+def amdgpu_arch_tool_EQ : Joined<["--"], "amdgpu-arch-tool=">, Group,
+  HelpText<"Tool used for detecting AMD GPU arch in the system.">;
 def rocm_device_lib_path_EQ : Joined<["--"], "rocm-device-lib-path=">, 
Group,
   HelpText<"ROCm device library path. Alternative to rocm-path.">;
 def : Joined<["--"], "hip-device-lib-path=">, Alias;

diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index c0b2b78a1b4b2..4da1239dce84e 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -12,9 +12,16 @@
 #include "clang/Basic/TargetID.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/DriverDiagnostic.h"
+#include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/LineIterator.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/VirtualFileSystem.h"
+#include 
+
+#define AMDGPU_ARCH_PROGRAM_NAME "amdgpu-arch"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
@@ -715,6 +722,78 @@ void AMDGPUToolChain::checkTargetID(
   }
 }
 
+llvm::Error
+AMDGPUToolChain::detectSystemGPUs(const ArgList &Args,
+  SmallVector &GPUArchs) const 
{
+  std::string Program;
+  if (Arg *A = Args.getLastArg(options::OPT_amdgpu_arch_tool_EQ))
+Program = A->getValue();
+  else
+Program = GetProgramPath(AMDGPU_ARCH_PROGRAM_NAME);
+  llvm::SmallString<64> OutputFile;
+  llvm::sys::fs::createTemporaryFile("print-system-gpus", "" /* No Suffix */,
+ OutputFile);
+  llvm::FileRemover OutputRemover(OutputFile.c_str());
+  llvm::Optional Redirects[] = {
+  {""},
+  StringRef(OutputFile),
+  {""},
+  };
+
+  std::string ErrorMessage;
+  if (int Result = llvm::sys::ExecuteAndWait(
+  Program.c_str(), {}, {}, Redirects, /* SecondsToWait */ 0,
+  /*MemoryLimit*/ 0, &ErrorMessage)) {
+if (Result > 0) {
+  ErrorMessage = "Exited with error code " + std::to_string(Result);
+} else if (Result == -1) {
+  ErrorMessage = "Execute failed: " + ErrorMessage;
+} else {
+  ErrorMessage = "Crashed: " + ErrorMessage;
+}
+
+return llvm::createStringError(std::error_code(),
+   Program + ": " + Er

[PATCH] D101352: [DOCS] Removed inconsistency in clang vs Clang usage in docs (c vs C)

2021-04-27 Thread Sushma Unnibhavi via Phabricator via cfe-commits
sushmaunnibhavi created this revision.
sushmaunnibhavi added reviewers: xgupta, kbarton, nickdesaulniers, tmfink.
sushmaunnibhavi requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixed bug #37411
Bug Link:https://bugs.llvm.org/show_bug.cgi?id=37411


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101352

Files:
  clang/docs/CommandGuide/clang.rst


Index: clang/docs/CommandGuide/clang.rst
===
--- clang/docs/CommandGuide/clang.rst
+++ clang/docs/CommandGuide/clang.rst
@@ -11,7 +11,7 @@
 
 :program:`clang` is a C, C++, and Objective-C compiler which encompasses
 preprocessing, parsing, optimization, code generation, assembly, and linking.
-Depending on which high-level mode setting is passed, Clang will stop before
+Depending on which high-level mode setting is passed, clang will stop before
 doing a full link.  While Clang is highly integrated, it is important to
 understand the stages of compilation, to understand how to invoke it.  These
 stages are:
@@ -347,7 +347,7 @@
 
 .. option:: -march=
 
-  Specify that Clang should generate code for a specific processor family
+  Specify that clang should generate code for a specific processor family
   member and later.  For example, if you specify -march=i486, the compiler is
   allowed to generate instructions that are valid on i486 and later processors,
   but which may not exist on earlier ones.
@@ -393,7 +393,7 @@
 
 .. option:: -g, -gline-tables-only, -gmodules
 
-  Control debug information output.  Note that Clang debug information works
+  Control debug information output.  Note that clang debug information works
   best at :option:`-O0`.  When more than one option starting with `-g` is
   specified, the last one wins:
 
@@ -422,20 +422,20 @@
   Clang supports a number of optimizations to reduce the size of debug
   information in the binary. They work based on the assumption that the
   debug type information can be spread out over multiple compilation units.
-  For instance, Clang will not emit type definitions for types that are not
+  For instance, clang will not emit type definitions for types that are not
   needed by a module and could be replaced with a forward declaration.
-  Further, Clang will only emit type info for a dynamic C++ class in the
+  Further, clang will only emit type info for a dynamic C++ class in the
   module that contains the vtable for the class.
 
   The :option:`-fstandalone-debug` option turns off these optimizations.
   This is useful when working with 3rd-party libraries that don't come with
-  debug information.  This is the default on Darwin.  Note that Clang will
+  debug information.  This is the default on Darwin.  Note that clang will
   never emit type information for types that are not referenced at all by the
   program.
 
 .. option:: -feliminate-unused-debug-types
 
-  By default, Clang does not emit type information for types that are defined
+  By default, clang does not emit type information for types that are defined
   but not used in a program. To retain the debug info for these unused types,
   the negation **-fno-eliminate-unused-debug-types** can be used.
 
@@ -588,7 +588,7 @@
 
 .. option:: -fshow-column, -fshow-source-location, -fcaret-diagnostics, 
-fdiagnostics-fixit-info, -fdiagnostics-parseable-fixits, 
-fdiagnostics-print-source-range-info, -fprint-source-range-info, 
-fdiagnostics-show-option, -fmessage-length
 
-  These options control how Clang prints out information about diagnostics
+  These options control how clang prints out information about diagnostics
   (errors and warnings). Please see the Clang User's Manual for more 
information.
 
 Preprocessor Options


Index: clang/docs/CommandGuide/clang.rst
===
--- clang/docs/CommandGuide/clang.rst
+++ clang/docs/CommandGuide/clang.rst
@@ -11,7 +11,7 @@
 
 :program:`clang` is a C, C++, and Objective-C compiler which encompasses
 preprocessing, parsing, optimization, code generation, assembly, and linking.
-Depending on which high-level mode setting is passed, Clang will stop before
+Depending on which high-level mode setting is passed, clang will stop before
 doing a full link.  While Clang is highly integrated, it is important to
 understand the stages of compilation, to understand how to invoke it.  These
 stages are:
@@ -347,7 +347,7 @@
 
 .. option:: -march=
 
-  Specify that Clang should generate code for a specific processor family
+  Specify that clang should generate code for a specific processor family
   member and later.  For example, if you specify -march=i486, the compiler is
   allowed to generate instructions that are valid on i486 and later processors,
   but which may not exist on earlier ones.
@@ -393,7 +393,7 @@
 
 .. option:: -g, -gline-tables-only, -gmodules
 
-  Control debug information output.  Note that Clang debug 

[PATCH] D101352: [DOCS] Removed inconsistency in clang vs Clang usage in docs (c vs C)

2021-04-27 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta accepted this revision.
xgupta added a comment.
This revision is now accepted and ready to land.

LGTM, Thanks for the patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101352

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


[PATCH] D100983: [OpenCL] Fix optional image types

2021-04-27 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov accepted this revision.
azabaznov added a comment.
This revision is now accepted and ready to land.

Generally looks good to me, but maybe a test needed, see a comment. Thanks! But 
I'm still not sure about completely removing pragmas for type declarations (see 
https://reviews.llvm.org/D100980#2719196).




Comment at: clang/include/clang/Basic/OpenCLImageTypes.def:68
 IMAGE_WRITE_TYPE(image2d_array_msaa_depth, OCLImage2dArrayMSAADepth, 
"cl_khr_gl_msaa_sharing")
-IMAGE_WRITE_TYPE(image3d, OCLImage3d, "cl_khr_3d_image_writes")
+IMAGE_WRITE_TYPE(image3d, OCLImage3d, "")
 

Maybe we should add a test to check that` image3d_t`  is reserved?


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

https://reviews.llvm.org/D100983

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


[PATCH] D101192: Add support for #elifdef and #elifndef

2021-04-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 340797.
aaron.ballman marked 3 inline comments as done.
aaron.ballman added a comment.

Updating based on review comments.


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

https://reviews.llvm.org/D101192

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Lex/DependencyDirectivesSourceMinimizer.h
  clang/include/clang/Lex/PPCallbacks.h
  clang/include/clang/Lex/PPConditionalDirectiveRecord.h
  clang/include/clang/Lex/PreprocessingRecord.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Basic/IdentifierTable.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Index/IndexingAction.cpp
  clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/PPConditionalDirectiveRecord.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PreprocessingRecord.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/Index/complete-preprocessor.m
  clang/test/Preprocessor/elifdef.c
  clang/test/Preprocessor/if_warning.c
  clang/test/Preprocessor/ifdef-recover.c
  clang/test/Preprocessor/macro_misc.c
  clang/test/Preprocessor/macro_vaopt_check.cpp
  clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp

Index: clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
===
--- clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
+++ clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
@@ -53,6 +53,8 @@
"#if A\n"
"#ifdef A\n"
"#ifndef A\n"
+   "#elifdef A\n"
+   "#elifndef A\n"
"#elif A\n"
"#else\n"
"#include \n"
@@ -70,18 +72,20 @@
   EXPECT_EQ(pp_if, Tokens[3].K);
   EXPECT_EQ(pp_ifdef, Tokens[4].K);
   EXPECT_EQ(pp_ifndef, Tokens[5].K);
-  EXPECT_EQ(pp_elif, Tokens[6].K);
-  EXPECT_EQ(pp_else, Tokens[7].K);
-  EXPECT_EQ(pp_include, Tokens[8].K);
-  EXPECT_EQ(pp_include_next, Tokens[9].K);
-  EXPECT_EQ(pp___include_macros, Tokens[10].K);
-  EXPECT_EQ(pp_import, Tokens[11].K);
-  EXPECT_EQ(decl_at_import, Tokens[12].K);
-  EXPECT_EQ(pp_pragma_import, Tokens[13].K);
-  EXPECT_EQ(cxx_export_decl, Tokens[14].K);
-  EXPECT_EQ(cxx_module_decl, Tokens[15].K);
-  EXPECT_EQ(cxx_import_decl, Tokens[16].K);
-  EXPECT_EQ(pp_eof, Tokens[17].K);
+  EXPECT_EQ(pp_elifdef, Tokens[6].K);
+  EXPECT_EQ(pp_elifndef, Tokens[7].K);
+  EXPECT_EQ(pp_elif, Tokens[8].K);
+  EXPECT_EQ(pp_else, Tokens[9].K);
+  EXPECT_EQ(pp_include, Tokens[10].K);
+  EXPECT_EQ(pp_include_next, Tokens[11].K);
+  EXPECT_EQ(pp___include_macros, Tokens[12].K);
+  EXPECT_EQ(pp_import, Tokens[13].K);
+  EXPECT_EQ(decl_at_import, Tokens[14].K);
+  EXPECT_EQ(pp_pragma_import, Tokens[15].K);
+  EXPECT_EQ(cxx_export_decl, Tokens[16].K);
+  EXPECT_EQ(cxx_module_decl, Tokens[17].K);
+  EXPECT_EQ(cxx_import_decl, Tokens[18].K);
+  EXPECT_EQ(pp_eof, Tokens[19].K);
 }
 
 TEST(MinimizeSourceToDependencyDirectivesTest, Define) {
@@ -324,6 +328,44 @@
Out.data());
 }
 
+TEST(MinimizeSourceToDependencyDirectivesTest, Elifdef) {
+  SmallVector Out;
+
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives("#ifdef A\n"
+"#define B\n"
+"#elifdef C\n"
+"#define D\n"
+"#endif\n",
+Out));
+  EXPECT_STREQ("#ifdef A\n"
+   "#define B\n"
+   "#elifdef C\n"
+   "#define D\n"
+   "#endif\n",
+   Out.data());
+
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives("#ifdef A\n"
+"#define B\n"
+"#elifdef B\n"
+"#define C\n"
+"#elifndef C\n"
+"#define D\n"
+"#else\n"
+"#define E\n"
+"#endif\n",
+Out));
+  EXPECT_STREQ("#ifdef A\n"
+   "#define B\n"
+   "#elifdef B\n"
+   "#define C\n"
+   "#elifndef C\n"
+   "#define D\n"
+   "#else\n"
+   "#define E\n"
+   "#endif\n",
+

[PATCH] D101192: Add support for #elifdef and #elifndef

2021-04-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D101192#2716596 , @mibintc wrote:

> Wow thanks for doing this! I worked on it a couple days a while ago but I 
> abandoned the effort and went back to my day job.

Happy to help!

> It seems like preprocessing ought to be something like a "state machine" but 
> I couldn't figure out the mechanism. Would it make sense to add some kind of 
> high level description of the components, now that you've gone to the 
> [presumably massive] effort of understanding it? Just a couple small comments 
> above.

Adding some developer documentation about the preprocessor may not be a bad 
idea in general, but I think that's orthogonal to this patch. We do have a 
place to add those kind of docs and it looks like the preprocessor is largely 
not mentioned: 
https://clang.llvm.org/docs/InternalsManual.html#the-lexer-and-preprocessor-library.
 However, I'd prefer not to sign up to write those docs at this time.


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

https://reviews.llvm.org/D101192

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


[PATCH] D101168: [C++4OpenCL] Add clang extension for unsafe kernel parameters

2021-04-27 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm updated this revision to Diff 340796.
olestrohm added a comment.

Improved the description and example per the feedback.

The check for dependent type is needed. If it is not included the diagnostic 
will get triggered when the extension is disabled, but not when it's enabled.


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

https://reviews.llvm.org/D101168

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Misc/amdgcn.languageOptsOpenCL.cl
  clang/test/Misc/nvptx.languageOptsOpenCL.cl
  clang/test/Misc/r600.languageOptsOpenCL.cl
  clang/test/SemaOpenCLCXX/invalid-kernel.clcpp

Index: clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
===
--- clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
+++ clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
@@ -1,4 +1,9 @@
-// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only
+// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only -triple spir-unknown-unknown
+// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only -triple spir-unknown-unknown -DUNSAFEKERNELPARAMETER
+
+#ifdef UNSAFEKERNELPARAMETER
+#pragma OPENCL EXTENSION __cl_clang_non_portable_kernel_parameters : enable
+#endif
 
 struct C {
   kernel void m(); //expected-error{{kernel functions cannot be class members}}
@@ -24,8 +29,10 @@
 kernel void int_p_r(__global int *__global &in);
 kernel void int_p_p_r(__global int *__global *__global &in);
 
-// expected-error@+1{{'__private atomic_int' (aka '__private _Atomic(int)') cannot be used as the type of a kernel parameter}}
 kernel void k_atomic_v(atomic_int in);
+#ifndef UNSAFEKERNELPARAMETER
+// expected-error@-2{{'__private atomic_int' (aka '__private _Atomic(int)') cannot be used as the type of a kernel parameter}}
+#endif
 kernel void k_atomic_p(__global atomic_int *in);
 kernel void k_atomic_r(__global atomic_int &in);
 
@@ -56,7 +63,10 @@
   StandardLayout(int a, int b) : a(a), b(b) {}
 };
 
-kernel void standard_v(StandardLayout in) {} //expected-error{{'__private StandardLayout' cannot be used as the type of a kernel parameter}}
+kernel void standard_v(StandardLayout in) {}
+#ifndef UNSAFEKERNELPARAMETER
+//expected-error@-2{{'__private StandardLayout' cannot be used as the type of a kernel parameter}}
+#endif
 kernel void standard_p(__global StandardLayout *in) {}
 kernel void standard_p_p(__global StandardLayout *__global *in) {}
 kernel void standard_r(__global StandardLayout &in) {}
@@ -67,7 +77,19 @@
   int b;
 };
 
-kernel void trivial_v(Trivial in) {} //expected-error{{'__private Trivial' cannot be used as the type of a kernel parameter}}
-kernel void trivial_p(__global Trivial *in) {} //expected-error{{'__global Trivial *__private' cannot be used as the type of a kernel parameter}}
-kernel void trivial_p_p(__global Trivial *__global *in) {} //expected-error{{'__global Trivial *__global *__private' cannot be used as the type of a kernel parameter}}
-kernel void trivial_r(__global Trivial &in) {} //expected-error{{'__global Trivial &__private' cannot be used as the type of a kernel parameter}}
+kernel void trivial_v(Trivial in) {}
+#ifndef UNSAFEKERNELPARAMETER
+//expected-error@-2{{'__private Trivial' cannot be used as the type of a kernel parameter}}
+#endif
+kernel void trivial_p(__global Trivial *in) {}
+#ifndef UNSAFEKERNELPARAMETER
+//expected-error@-2{{'__global Trivial *__private' cannot be used as the type of a kernel parameter}}
+#endif
+kernel void trivial_p_p(__global Trivial *__global *in) {}
+#ifndef UNSAFEKERNELPARAMETER
+//expected-error@-2{{'__global Trivial *__global *__private' cannot be used as the type of a kernel parameter}}
+#endif
+kernel void trivial_r(__global Trivial &in) {}
+#ifndef UNSAFEKERNELPARAMETER
+//expected-error@-2{{'__global Trivial &__private' cannot be used as the type of a kernel parameter}}
+#endif
Index: clang/test/Misc/r600.languageOptsOpenCL.cl
===
--- clang/test/Misc/r600.languageOptsOpenCL.cl
+++ clang/test/Misc/r600.languageOptsOpenCL.cl
@@ -34,6 +34,11 @@
 #endif
 #pragma OPENCL EXTENSION __cl_clang_variadic_functions : enable
 
+#ifndef __cl_clang_non_portable_kernel_parameters
+#error "Missing __cl_clang_non_portable_kernel_parameters define"
+#endif
+#pragma OPENCL EXTENSION __cl_clang_non_portable_kernel_parameters : enable
+
 #ifdef cl_khr_fp16
 #error "Incorrect cl_khr_fp16 define"
 #endif
Index: clang/test/Misc/nvptx.languageOptsOpenCL.cl
===
--- clang/test/Misc/nvptx.languageOptsOpenCL.cl
+++ clang/test/Misc/nvptx.languageOptsOpenCL.cl
@@ -28,6 +28,11 @@
 #endif
 #pragma OPENCL EXTENSION __cl_clang_variadic_functions : enable
 
+#ifndef __cl_clang_non_portable_kernel_parameters
+#error "Missing __cl_clang_non_portable_kernel_parameters 

[PATCH] D100980: [OpenCL] Allow use of double type without extension pragma

2021-04-27 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D100980#2719196 , @azabaznov wrote:

>> When the pragma is parsed we can't know why it is in the code to be able to 
>> issue any warning.
>
> I mean diagnose once when, for example in your particular case, double type 
> is parsed.  Does it require much effort? I think this warning might be useful 
> for developers who already rely on pragma usage in their kernels.

I am not sure I understand your suggestion. Could you show an example perhaps?


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

https://reviews.llvm.org/D100980

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


[PATCH] D96203: [clang][patch] Modify sanitizer options names: renaming blacklist to blocklist

2021-04-27 Thread Melanie Blower via Phabricator via cfe-commits
mibintc abandoned this revision.
mibintc added a comment.

There was no resolution about what option name would be acceptable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96203

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


[clang] 6a92c19 - [C++4OpenCL] Add diagnostics for OpenCL types in templates.

2021-04-27 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2021-04-27T13:04:25+01:00
New Revision: 6a92c19f3bbc47827b8844a2b527f6c6fba63afd

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

LOG: [C++4OpenCL] Add diagnostics for OpenCL types in templates.

Refactored diagnostics for OpenCL types to allow their
reuse for templates.

Patch by olestrohm (Ole Strohm)!

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

Added: 
clang/test/SemaOpenCLCXX/template-opencl-types.clcpp

Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaOpenCL/clk_event_t.cl
clang/test/SemaOpenCL/event_t.cl
clang/test/SemaOpenCL/sampler_t.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index f57e705604c8..9c5bc19f2215 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6726,17 +6726,20 @@ static bool isDeclExternC(const Decl *D) {
 
   llvm_unreachable("Unknown type of decl!");
 }
+
 /// Returns true if there hasn't been any invalid type diagnosed.
-static bool diagnoseOpenCLTypes(Scope *S, Sema &Se, Declarator &D,
-DeclContext *DC, QualType R) {
+static bool diagnoseOpenCLTypes(Sema &Se, VarDecl *NewVD) {
+  DeclContext *DC = NewVD->getDeclContext();
+  QualType R = NewVD->getType();
+
   // OpenCL v2.0 s6.9.b - Image type can only be used as a function argument.
   // OpenCL v2.0 s6.13.16.1 - Pipe type can only be used as a function
   // argument.
   if (R->isImageType() || R->isPipeType()) {
-Se.Diag(D.getIdentifierLoc(),
+Se.Diag(NewVD->getLocation(),
 diag::err_opencl_type_can_only_be_used_as_function_parameter)
 << R;
-D.setInvalidType();
+NewVD->setInvalidDecl();
 return false;
   }
 
@@ -6745,12 +6748,12 @@ static bool diagnoseOpenCLTypes(Scope *S, Sema &Se, 
Declarator &D,
   // OpenCL v2.0 s6.9.q:
   // The clk_event_t and reserve_id_t types cannot be declared in program
   // scope.
-  if (NULL == S->getParent()) {
+  if (NewVD->hasGlobalStorage() && !NewVD->isStaticLocal()) {
 if (R->isReserveIDT() || R->isClkEventT() || R->isEventT()) {
-  Se.Diag(D.getIdentifierLoc(),
+  Se.Diag(NewVD->getLocation(),
   diag::err_invalid_type_for_program_scope_var)
   << R;
-  D.setInvalidType();
+  NewVD->setInvalidDecl();
   return false;
 }
   }
@@ -6763,9 +6766,9 @@ static bool diagnoseOpenCLTypes(Scope *S, Sema &Se, 
Declarator &D,
NR->isReferenceType()) {
   if (NR->isFunctionPointerType() || NR->isMemberFunctionPointerType() ||
   NR->isFunctionReferenceType()) {
-Se.Diag(D.getIdentifierLoc(), diag::err_opencl_function_pointer)
+Se.Diag(NewVD->getLocation(), diag::err_opencl_function_pointer)
 << NR->isReferenceType();
-D.setInvalidType();
+NewVD->setInvalidDecl();
 return false;
   }
   NR = NR->getPointeeType();
@@ -6777,8 +6780,8 @@ static bool diagnoseOpenCLTypes(Scope *S, Sema &Se, 
Declarator &D,
 // OpenCL v1.2 s6.1.1.1: reject declaring variables of the half and
 // half array type (unless the cl_khr_fp16 extension is enabled).
 if (Se.Context.getBaseElementType(R)->isHalfType()) {
-  Se.Diag(D.getIdentifierLoc(), diag::err_opencl_half_declaration) << R;
-  D.setInvalidType();
+  Se.Diag(NewVD->getLocation(), diag::err_opencl_half_declaration) << R;
+  NewVD->setInvalidDecl();
   return false;
 }
   }
@@ -6788,34 +6791,20 @@ static bool diagnoseOpenCLTypes(Scope *S, Sema &Se, 
Declarator &D,
   // address space qualifiers.
   if (R->isEventT()) {
 if (R.getAddressSpace() != LangAS::opencl_private) {
-  Se.Diag(D.getBeginLoc(), diag::err_event_t_addr_space_qual);
-  D.setInvalidType();
+  Se.Diag(NewVD->getBeginLoc(), diag::err_event_t_addr_space_qual);
+  NewVD->setInvalidDecl();
   return false;
 }
   }
 
-  // C++ for OpenCL does not allow the thread_local storage qualifier.
-  // OpenCL C does not support thread_local either, and
-  // also reject all other thread storage class specifiers.
-  DeclSpec::TSCS TSC = D.getDeclSpec().getThreadStorageClassSpec();
-  if (TSC != TSCS_unspecified) {
-bool IsCXX = Se.getLangOpts().OpenCLCPlusPlus;
-Se.Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(),
-diag::err_opencl_unknown_type_specifier)
-<< IsCXX << Se.getLangOpts().getOpenCLVersionTuple().getAsString()
-<< DeclSpec::getSpecifierName(TSC) << 1;
-D.setInvalidType();
-return false;
-  }
-
   if (R->isSamplerT()) {
 // OpenCL v1.2 s6.9.b p4:
 // The sampler type cannot be used with the __local and __global address
 // space qualifiers.
 if (R.getAddressSpace() == LangAS::opencl_local ||
 R.getAddressSpac

[PATCH] D100860: [C++4OpenCL] Add missing OpenCL specific diagnostics in templates

2021-04-27 Thread Anastasia Stulova via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6a92c19f3bbc: [C++4OpenCL] Add diagnostics for OpenCL types 
in templates. (authored by Anastasia).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100860

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaOpenCL/clk_event_t.cl
  clang/test/SemaOpenCL/event_t.cl
  clang/test/SemaOpenCL/sampler_t.cl
  clang/test/SemaOpenCLCXX/template-opencl-types.clcpp

Index: clang/test/SemaOpenCLCXX/template-opencl-types.clcpp
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/template-opencl-types.clcpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only
+
+template
+T global_variable; // expected-error{{the '__global clk_event_t' type cannot be used to declare a program scope variable}}
+
+clk_event_t global_event; // expected-error{{the '__global clk_event_t' type cannot be used to declare a program scope variable}}
+
+template
+void templ() {
+  T loc;
+  // expected-error@-1{{type '__private __read_only image1d_t' can only be used as a function parameter in OpenCL}}
+  // expected-error@-2{{declaring variable of type '__private half' is not allowed}}
+  // expected-error@-3{{the event_t type can only be used with __private address space qualifier}}
+}
+
+void foo() {
+  templ(); // expected-note{{in instantiation of function template specialization 'templ<__read_only image1d_t>' requested here}}
+  templ(); // expected-note{{in instantiation of function template specialization 'templ' requested here}}
+  templ<__local event_t>(); // expected-note{{in instantiation of function template specialization 'templ<__local event_t>' requested here}}
+
+  image1d_t img; // expected-error{{type '__private __read_only image1d_t' can only be used as a function parameter in OpenCL}}
+  half h; // expected-error{{declaring variable of type '__private half' is not allowed}}
+  __local event_t e; // expected-error{{the event_t type can only be used with __private address space qualifier}}
+
+  (void) global_variable; // expected-note{{in instantiation of variable template specialization 'global_variable' requested here}}
+}
Index: clang/test/SemaOpenCL/sampler_t.cl
===
--- clang/test/SemaOpenCL/sampler_t.cl
+++ clang/test/SemaOpenCL/sampler_t.cl
@@ -48,9 +48,6 @@
 sampler_t bad(void); //expected-error{{declaring function return value of type 'sampler_t' is not allowed}}
 
 sampler_t global_nonconst_smp = 0; // expected-error {{global sampler requires a const or constant address space qualifier}}
-#ifdef CHECK_SAMPLER_VALUE
-// expected-warning@-2{{sampler initializer has invalid Filter Mode bits}}
-#endif
 
 const sampler_t glb_smp10 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
 const constant sampler_t glb_smp11 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
Index: clang/test/SemaOpenCL/event_t.cl
===
--- clang/test/SemaOpenCL/event_t.cl
+++ clang/test/SemaOpenCL/event_t.cl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
 
-event_t glb_evt; // expected-error {{the '__private event_t' type cannot be used to declare a program scope variable}} expected-error{{program scope variable must reside in constant address space}}
+event_t glb_evt; // expected-error {{the '__private event_t' type cannot be used to declare a program scope variable}}
 
 constant struct evt_s {
   event_t evt; // expected-error {{the 'event_t' type cannot be used to declare a structure or union field}}
@@ -10,7 +10,7 @@
 
 void kernel ker(event_t argevt) { // expected-error {{'__private event_t' cannot be used as the type of a kernel parameter}}
   event_t e;
-  constant event_t const_evt; // expected-error {{the event_t type can only be used with __private address space qualifier}} expected-error{{variable in constant address space must be initialized}}
+  constant event_t const_evt; // expected-error{{the '__constant event_t' type cannot be used to declare a program scope variable}}
   foo(e);
   foo(0);
   foo(5); // expected-error {{passing 'int' to parameter of incompatible type 'event_t'}}
Index: clang/test/SemaOpenCL/clk_event_t.cl
===
--- clang/test/SemaOpenCL/clk_event_t.cl
+++ clang/test/SemaOpenCL/clk_event_t.cl
@@ -12,6 +12,9 @@
   clk_event_t ce2;
   clk_event_t ce3 = CLK_NULL_EVENT;
 
+  // FIXME: Not obvious if this should give an error as if it was in program scope.
+  static clk_event_t ce4;
+
   if (e == ce1) { // expected-error {{invalid operands to binary expression ('__private event_t' and '__private clk_event_t')}}
 return 9;
   }
Index: clang/lib/Sema/SemaDecl.cpp
===

[PATCH] D100667: [clang] Fix assert() crash when checking undeduced arg alignment

2021-04-27 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz updated this revision to Diff 340802.
adamcz marked 2 inline comments as done.
adamcz added a comment.

review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100667

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/cxx17-undeduced-alignment.cpp


Index: clang/test/SemaCXX/cxx17-undeduced-alignment.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx17-undeduced-alignment.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++17 -verify %s
+//
+// Verifies that clang no longer crashes on undeduced, sugared types.
+
+template  void foo(T &t);
+template 
+void bar(T t) {
+  foo(t);
+}
+
+template 
+struct S { // expected-note {{candidate}}
+  S(T t);  // expected-note {{candidate}}
+  ~S();
+};
+template  S(T t) -> S;
+
+void baz() {
+  // S(123) is undeduced, but when passed to foo() via bar() it is wrapped in
+  // SubstTemplateTypeParm, for which isUndeduced() is false.
+  bar(S(123)); // expected-error {{no matching conversion}}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19661,8 +19661,10 @@
   if (isSFINAEContext())
 return ExprError();
 
-  if (T.isNull() || !Context.getLangOpts().RecoveryASTType)
+  if (T.isNull() || T->isUndeducedType() ||
+  !Context.getLangOpts().RecoveryASTType)
 // We don't know the concrete type, fallback to dependent type.
 T = Context.DependentTy;
+
   return RecoveryExpr::Create(Context, T, Begin, End, SubExprs);
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4540,8 +4540,7 @@
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType())
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);


Index: clang/test/SemaCXX/cxx17-undeduced-alignment.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx17-undeduced-alignment.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++17 -verify %s
+//
+// Verifies that clang no longer crashes on undeduced, sugared types.
+
+template  void foo(T &t);
+template 
+void bar(T t) {
+  foo(t);
+}
+
+template 
+struct S { // expected-note {{candidate}}
+  S(T t);  // expected-note {{candidate}}
+  ~S();
+};
+template  S(T t) -> S;
+
+void baz() {
+  // S(123) is undeduced, but when passed to foo() via bar() it is wrapped in
+  // SubstTemplateTypeParm, for which isUndeduced() is false.
+  bar(S(123)); // expected-error {{no matching conversion}}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19661,8 +19661,10 @@
   if (isSFINAEContext())
 return ExprError();
 
-  if (T.isNull() || !Context.getLangOpts().RecoveryASTType)
+  if (T.isNull() || T->isUndeducedType() ||
+  !Context.getLangOpts().RecoveryASTType)
 // We don't know the concrete type, fallback to dependent type.
 T = Context.DependentTy;
+
   return RecoveryExpr::Create(Context, T, Begin, End, SubExprs);
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4540,8 +4540,7 @@
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType())
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99689: [OPENMP]Add option -fopenmp-cuda-const-firstprivate to control address space of the corresponding global.

2021-04-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 340803.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99689

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/openmp-offload-gpu.c
  clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp

Index: clang/test/OpenMP/target_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/target_firstprivate_codegen.cpp
+++ clang/test/OpenMP/target_firstprivate_codegen.cpp
@@ -52,7 +52,6 @@
 // TCHECK-DAG:  [[TTII:%.+]] = type { i32, i32 }
 // TCHECK-DAG:  [[S1:%.+]] = type { double }
 
-// CHECK-DAG:  [[FP_E:@__omp_offloading_firstprivate_.+_e_l76]] = internal global [[TTII]] zeroinitializer
 // CHECK-DAG:  [[SIZET:@.+]] = private unnamed_addr constant [2 x i{{32|64}}] [i[[SZ:32|64]] 4, i{{64|32}} {{8|4}}]
 // CHECK-DAG:  [[MAPT:@.+]] = private unnamed_addr constant [2 x i64] [i64 288, i64 49]
 // CHECK-DAG:  [[MAPT2:@.+]] = private unnamed_addr constant [9 x i64] [i64 288, i64 161, i64 800, i64 161, i64 161, i64 800, i64 800, i64 161, i64 161]
@@ -336,8 +335,6 @@
   }
   // CHECK:  [[PTR_ADDR_REF:%.+]] = load double*, double** [[PTR_ADDR]],
 
-  // CHECK:  [[E_BC:%.+]] = bitcast [[TTII]]* [[E:%.+]] to i8*
-  // CHECK:  call void @llvm.memcpy.p0i8.p0i8.i{{64|32}}(i8* {{.*}} bitcast ([[TTII]]* [[FP_E]] to i8*), i8* {{.*}} [[E_BC]], i{{64|32}} 8, i1 false)
   // CHECK:  [[BASE_PTR_GEP3_0:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BASE_PTR_ARR3]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
   // CHECK:  [[BCAST_TOPTR:%.+]] = bitcast i8** [[BASE_PTR_GEP3_0]] to double**
   // CHECK:  store double* [[PTR_ADDR_REF]], double** [[BCAST_TOPTR]],
@@ -346,7 +343,7 @@
   // CHECK:  store double* [[PTR_ADDR_REF]], double** [[BCAST_TOPTR]],
   // CHECK:  [[BASE_PTR_GEP3_1:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BASE_PTR_ARR3]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
   // CHECK:  [[BCAST_TOPTR:%.+]] = bitcast i8** [[BASE_PTR_GEP3_1]] to [[TTII]]**
-  // CHECK:  store [[TTII]]* [[FP_E]], [[TTII]]** [[BCAST_TOPTR]],
+  // CHECK:  store [[TTII]]* [[FP_E:%.+]], [[TTII]]** [[BCAST_TOPTR]],
   // CHECK:  [[PTR_GEP3_1:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[PTR_ARR3]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
   // CHECK:  [[BCAST_TOPTR:%.+]] = bitcast i8** [[PTR_GEP3_1]] to [[TTII]]**
   // CHECK:  store [[TTII]]* [[FP_E]], [[TTII]]** [[BCAST_TOPTR]],
@@ -356,9 +353,8 @@
   // CHECK: {{.+}} = call i32 @__tgt_target_mapper(%struct.ident_t* @{{.+}}, i64 -1, {{.+}}, i32 2, i8** [[BASE_PTR_GEP_ARG3]], i8** [[PTR_GEP_ARG3]], i[[SZ]]* getelementptr inbounds ([2 x i[[SZ]]], [2 x i[[SZ]]]* [[SIZET3]], i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[MAPT3]], i32 0, i32 0), i8** null, i8** null)
 
   // TCHECK:  define weak void @__omp_offloading_{{.+}}(double* [[PTR_IN:%.+]], [[TTII]]* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[E:%.+]])
-  // TCHECK-NOT: alloca [[TTII]],
   // TCHECK:  [[PTR_ADDR:%.+]] = alloca double*,
-  // TCHECK-NOT: alloca [[TTII]],
+  // TCHECK:  alloca [[TTII]],
   // TCHECK-NOT: alloca double*,
   // TCHECK:  store double* [[PTR_IN]], double** [[PTR_ADDR]],
   // TCHECK-NOT: store double* %
Index: clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
+++ clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
@@ -1,8 +1,10 @@
 // Test target codegen - host bc file has to be created first.
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -debug-info-kind=limited -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -debug-info-kind=limited -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64 --check-prefix TCHECK-NONCONST
+// RUN: %clang_cc1 -debug-info-kind=limited -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-cuda-const-firstprivate -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64 --check-prefix TCHECK-CONST
 // RUN: %clang_cc1 -v

[PATCH] D100667: [clang] Fix assert() crash when checking undeduced arg alignment

2021-04-27 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:19668
 T = Context.DependentTy;
+  else if (const auto *U = T->getUnqualifiedDesugaredType())
+if (U->isUndeducedType())

hokein wrote:
> I'm not sure we need this well. I think the above `T->isUndeducedType()` 
> should be enough to fix all known crashes. I'd just remove this one.
It's enough to fix all known cases, but I'm a little worried that we'll be 
playing whack-a-mole with bugs like this forever. 

I think the fundamental problem is that a lot of functions have assumptions 
about state of their inputs and the flow is not sufficiently simple to be able 
to catch bugs like this in review. A little bit of defensive programming might 
be the best solution for the problem.
In this case, however, I'm not going to argue with you. Let's try this one more 
time. The updated fix is sufficient for all crashes we've seen so far.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100667

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


[PATCH] D70340: Add a key method to Sema to optimize debug info size

2021-04-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:335
 
+  /// A key method to reduce duplicate type info from Sema.
+  virtual void anchor();

rnk wrote:
> erichkeane wrote:
> > rnk wrote:
> > > hans wrote:
> > > > I worry that this is going to look obscure to most readers passing 
> > > > through. Maybe it could be expanded to more explicitly spell out that 
> > > > it reduces the size of the debug info?
> > > I want to keep it concise, most readers shouldn't need to know what this 
> > > is, and they can look up technical terms like "key method". I'll say 
> > > "debug info" instead of "type info", though, that should be more obvious.
> > FWIW, I just ran into this and did a double/triple take, as it didn't make 
> > sense for me to see a 'virtual' function in a 'final' type that didn't 
> > inherit to anything looked like nonsense.
> > 
> > The only way I found out what this meant (googling "key method" did very 
> > little for me here) was to do a 'git-blame' then found this review.  The 
> > ONLY place that explained what is happening here is the comment you made 
> > here: https://reviews.llvm.org/D70340#1752192
> Sorry, I went ahead and wrote better comments in 
> rG6d78c38986fa0974ea0b37e66f8cb89b256f4e0d.
> 
> Re: key functions, this is where the idea is documented:
> https://itanium-cxx-abi.github.io/cxx-abi/abi.html#vague-vtable
> They control where the vtable is emitted. We have this style rule to take 
> advantage of them:
> https://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers
> However, the existing rule has to do with RTTI and vtables, which doesn't 
> make any sense for Sema.
> 
> The idea that class debug info is tied to the vtable "known", but not well 
> documented. It is mentioned maybe once in the user manual:
> https://clang.llvm.org/docs/UsersManual.html#cmdoption-fstandalone-debug
> I couldn't find any GCC documentation about this behavior, so we're doing 
> better. :)
> 
> @akhuang has been working on the constructor homing feature announced here:
> https://blog.llvm.org/posts/2021-04-05-constructor-homing-for-debug-info/
> So maybe in the near future we won't need this hack.
Thanks!  That is at least more descriptive that a virtual function in a 
non-inheriting final type is intentional and not just silliness.   I appreciate 
the change!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70340

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


[PATCH] D100591: [Clang][AArch64] Disable rounding of return values for AArch64

2021-04-27 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover accepted this revision.
t.p.northover added a comment.
This revision is now accepted and ready to land.

Thanks for updating it. A little disappointing that we can't support BE 
first-class, but much more important that it's not broken and it's not actually 
that common. So I think this is OK now, the backend should cope fine with the 
oddly sized types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100591

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


[PATCH] D101358: [analyzer][StdLibraryFunctionsChecker] Track dependent arguments

2021-04-27 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: vsavchenko, NoQ, steakhal.
Herald added subscribers: ASDenysPetrov, gamesh411, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, 
xazax.hun, whisperity.
Herald added a reviewer: Szelethus.
martong requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When we report an argument constraint violation, we should track those
other arguments that participate in the evaluation of the violation. By
default, we depend only on the argument that is constrained, however,
there are some special cases like the buffer size constraint that might
be encoded in another argument(s).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101358

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints-tracking-notes.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.c


Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -220,8 +220,8 @@
   enum { BUFFER_SIZE = 1024 };
   wchar_t wbuf[BUFFER_SIZE]; // bugpath-note{{'wbuf' initialized here}}
 
-  const size_t size = sizeof(*wbuf);
-  const size_t nitems = sizeof(wbuf);
+  const size_t size = sizeof(*wbuf);   // bugpath-note{{'size' initialized to}}
+  const size_t nitems = sizeof(wbuf);  // bugpath-note{{'nitems' initialized 
to}}
 
   // The 3rd parameter should be the number of elements to read, not
   // the size in bytes.
Index: 
clang/test/Analysis/std-c-library-functions-arg-constraints-tracking-notes.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-arg-constraints-tracking-notes.c
@@ -0,0 +1,33 @@
+// Check the bugpath related to the reports.
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -triple x86_64-unknown-linux-gnu \
+// RUN:   -analyzer-output=text \
+// RUN:   -verify=bugpath
+
+typedef typeof(sizeof(int)) size_t;
+
+int __buf_size_arg_constraint(const void *, size_t);
+void test_buf_size_concrete() {
+  char buf[3];   // bugpath-note{{'buf' initialized here}}
+  int s = 4; // bugpath-note{{'s' initialized to 4}}
+  __buf_size_arg_constraint(buf, s); // \
+  // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{}} \
+  // bugpath-note{{Function argument constraint is not satisfied}}
+}
+
+int __buf_size_arg_constraint_mul(const void *, size_t, size_t);
+void test_buf_size_concrete_with_multiplication() {
+  short buf[3];   // bugpath-note{{'buf' 
initialized here}}
+  int s1 = 4; // bugpath-note{{'s1' 
initialized to 4}}
+  int s2 = sizeof(short); // bugpath-note{{'s2' 
initialized to}}
+  __buf_size_arg_constraint_mul(buf, s1, s2); // \
+  // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{}} \
+  // bugpath-note{{Function argument constraint is not satisfied}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -134,6 +134,12 @@
 }
 ArgNo getArgNo() const { return ArgN; }
 
+// Return those arguments that should be tracked when we report a bug. By
+// default it is the argument that is constrained, however, in some special
+// cases we need to track other arguments as well. E.g. a buffer size might
+// be encoded in another argument.
+virtual std::vector getArgsToTrack() const { return {ArgN}; }
+
 virtual StringRef getName() const = 0;
 
 // Give a description that explains the constraint to the user. Used when
@@ -309,6 +315,15 @@
 : ValueConstraint(Buffer), SizeArgN(BufSize),
   SizeMultiplierArgN(BufSizeMultiplier) {}
 
+std::vector getArgsToTrack() const override {
+  std::vector Result{ArgN};
+  if (SizeArgN)
+Result.push_back(*SizeArgN);
+  if (SizeMultiplierArgN)
+Result.push_back(*SizeMultiplierArgN);
+  return Result;
+}
+
 std::string describe(ProgramStateRef State,
  const Summary &Summary) const override;
 
@@ -576,7 +591,9 @@
   CheckNames[CK_StdCLibraryFunctionArgsChecke

[PATCH] D101358: [analyzer][StdLibraryFunctionsChecker] Track dependent arguments

2021-04-27 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko accepted this revision.
vsavchenko added a comment.
This revision is now accepted and ready to land.

Looking great, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101358

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


[PATCH] D101358: [analyzer][StdLibraryFunctionsChecker] Track dependent arguments

2021-04-27 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Wow, thanks for the real quick review! I appreciate it! :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101358

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


[clang] 4b99f9c - [analyzer][StdLibraryFunctionsChecker] Track dependent arguments

2021-04-27 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2021-04-27T15:35:58+02:00
New Revision: 4b99f9c7db262aa55d56d3af2f228e624ff7b55f

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

LOG: [analyzer][StdLibraryFunctionsChecker] Track dependent arguments

When we report an argument constraint violation, we should track those
other arguments that participate in the evaluation of the violation. By
default, we depend only on the argument that is constrained, however,
there are some special cases like the buffer size constraint that might
be encoded in another argument(s).

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

Added: 
clang/test/Analysis/std-c-library-functions-arg-constraints-tracking-notes.c

Modified: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
clang/test/Analysis/std-c-library-functions-arg-constraints.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index a2409b028fb0..e758b465af1b 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -134,6 +134,12 @@ class StdLibraryFunctionsChecker
 }
 ArgNo getArgNo() const { return ArgN; }
 
+// Return those arguments that should be tracked when we report a bug. By
+// default it is the argument that is constrained, however, in some special
+// cases we need to track other arguments as well. E.g. a buffer size might
+// be encoded in another argument.
+virtual std::vector getArgsToTrack() const { return {ArgN}; }
+
 virtual StringRef getName() const = 0;
 
 // Give a description that explains the constraint to the user. Used when
@@ -309,6 +315,15 @@ class StdLibraryFunctionsChecker
 : ValueConstraint(Buffer), SizeArgN(BufSize),
   SizeMultiplierArgN(BufSizeMultiplier) {}
 
+std::vector getArgsToTrack() const override {
+  std::vector Result{ArgN};
+  if (SizeArgN)
+Result.push_back(*SizeArgN);
+  if (SizeMultiplierArgN)
+Result.push_back(*SizeMultiplierArgN);
+  return Result;
+}
+
 std::string describe(ProgramStateRef State,
  const Summary &Summary) const override;
 
@@ -576,7 +591,9 @@ class StdLibraryFunctionsChecker
   CheckNames[CK_StdCLibraryFunctionArgsChecker],
   "Unsatisfied argument constraints", categories::LogicError);
 auto R = std::make_unique(*BT_InvalidArg, Msg, N);
-bugreporter::trackExpressionValue(N, Call.getArgExpr(VC->getArgNo()), *R);
+
+for (ArgNo ArgN : VC->getArgsToTrack())
+  bugreporter::trackExpressionValue(N, Call.getArgExpr(ArgN), *R);
 
 // Highlight the range of the argument that was violated.
 R->addRange(Call.getArgSourceRange(VC->getArgNo()));

diff  --git 
a/clang/test/Analysis/std-c-library-functions-arg-constraints-tracking-notes.c 
b/clang/test/Analysis/std-c-library-functions-arg-constraints-tracking-notes.c
new file mode 100644
index ..a6d61a5ad242
--- /dev/null
+++ 
b/clang/test/Analysis/std-c-library-functions-arg-constraints-tracking-notes.c
@@ -0,0 +1,33 @@
+// Check the bugpath related to the reports.
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -triple x86_64-unknown-linux-gnu \
+// RUN:   -analyzer-output=text \
+// RUN:   -verify=bugpath
+
+typedef typeof(sizeof(int)) size_t;
+
+int __buf_size_arg_constraint(const void *, size_t);
+void test_buf_size_concrete() {
+  char buf[3];   // bugpath-note{{'buf' initialized here}}
+  int s = 4; // bugpath-note{{'s' initialized to 4}}
+  __buf_size_arg_constraint(buf, s); // \
+  // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{}} \
+  // bugpath-note{{Function argument constraint is not satisfied}}
+}
+
+int __buf_size_arg_constraint_mul(const void *, size_t, size_t);
+void test_buf_size_concrete_with_multiplication() {
+  short buf[3];   // bugpath-note{{'buf' 
initialized here}}
+  int s1 = 4; // bugpath-note{{'s1' 
initialized to 4}}
+  int s2 = sizeof(short); // bugpath-note{{'s2' 
initialized to}}
+  __buf_size_arg_constraint_mul(buf, s1, s2); // \
+  // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{}} \
+  // bugpath-note{{Function argument constraint is not satisfie

[PATCH] D101358: [analyzer][StdLibraryFunctionsChecker] Track dependent arguments

2021-04-27 Thread Gabor Marton 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 rG4b99f9c7db26: [analyzer][StdLibraryFunctionsChecker] Track 
dependent arguments (authored by martong).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101358

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints-tracking-notes.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.c


Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -220,8 +220,8 @@
   enum { BUFFER_SIZE = 1024 };
   wchar_t wbuf[BUFFER_SIZE]; // bugpath-note{{'wbuf' initialized here}}
 
-  const size_t size = sizeof(*wbuf);
-  const size_t nitems = sizeof(wbuf);
+  const size_t size = sizeof(*wbuf);   // bugpath-note{{'size' initialized to}}
+  const size_t nitems = sizeof(wbuf);  // bugpath-note{{'nitems' initialized 
to}}
 
   // The 3rd parameter should be the number of elements to read, not
   // the size in bytes.
Index: 
clang/test/Analysis/std-c-library-functions-arg-constraints-tracking-notes.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-arg-constraints-tracking-notes.c
@@ -0,0 +1,33 @@
+// Check the bugpath related to the reports.
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -triple x86_64-unknown-linux-gnu \
+// RUN:   -analyzer-output=text \
+// RUN:   -verify=bugpath
+
+typedef typeof(sizeof(int)) size_t;
+
+int __buf_size_arg_constraint(const void *, size_t);
+void test_buf_size_concrete() {
+  char buf[3];   // bugpath-note{{'buf' initialized here}}
+  int s = 4; // bugpath-note{{'s' initialized to 4}}
+  __buf_size_arg_constraint(buf, s); // \
+  // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{}} \
+  // bugpath-note{{Function argument constraint is not satisfied}}
+}
+
+int __buf_size_arg_constraint_mul(const void *, size_t, size_t);
+void test_buf_size_concrete_with_multiplication() {
+  short buf[3];   // bugpath-note{{'buf' 
initialized here}}
+  int s1 = 4; // bugpath-note{{'s1' 
initialized to 4}}
+  int s2 = sizeof(short); // bugpath-note{{'s2' 
initialized to}}
+  __buf_size_arg_constraint_mul(buf, s1, s2); // \
+  // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{}} \
+  // bugpath-note{{Function argument constraint is not satisfied}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -134,6 +134,12 @@
 }
 ArgNo getArgNo() const { return ArgN; }
 
+// Return those arguments that should be tracked when we report a bug. By
+// default it is the argument that is constrained, however, in some special
+// cases we need to track other arguments as well. E.g. a buffer size might
+// be encoded in another argument.
+virtual std::vector getArgsToTrack() const { return {ArgN}; }
+
 virtual StringRef getName() const = 0;
 
 // Give a description that explains the constraint to the user. Used when
@@ -309,6 +315,15 @@
 : ValueConstraint(Buffer), SizeArgN(BufSize),
   SizeMultiplierArgN(BufSizeMultiplier) {}
 
+std::vector getArgsToTrack() const override {
+  std::vector Result{ArgN};
+  if (SizeArgN)
+Result.push_back(*SizeArgN);
+  if (SizeMultiplierArgN)
+Result.push_back(*SizeMultiplierArgN);
+  return Result;
+}
+
 std::string describe(ProgramStateRef State,
  const Summary &Summary) const override;
 
@@ -576,7 +591,9 @@
   CheckNames[CK_StdCLibraryFunctionArgsChecker],
   "Unsatisfied argument constraints", categories::LogicError);
 auto R = std::make_unique(*BT_InvalidArg, Msg, N);
-bugreporter::trackExpressionValue(N, Call.getArgExpr(VC->getArgNo()), *R);
+
+for (ArgNo ArgN : VC->getArgsToTrack())
+  bugreporter::trackExpressionValue(N, Call.getArgExpr(ArgN), *R);
 
 // Highlight the range of the argument that was violated.
 R->addRan

[PATCH] D100983: [OpenCL] Fix optional image types

2021-04-27 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/include/clang/Basic/OpenCLImageTypes.def:68
 IMAGE_WRITE_TYPE(image2d_array_msaa_depth, OCLImage2dArrayMSAADepth, 
"cl_khr_gl_msaa_sharing")
-IMAGE_WRITE_TYPE(image3d, OCLImage3d, "cl_khr_3d_image_writes")
+IMAGE_WRITE_TYPE(image3d, OCLImage3d, "")
 

azabaznov wrote:
> Maybe we should add a test to check that` image3d_t`  is reserved?
Do you mean something like:

```typedef int image3d_t;```

And then check that this gives an error?


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

https://reviews.llvm.org/D100983

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


[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-27 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D100807#2718006 , @arphaman wrote:

> It appears that your bot is running on a Mac with M1 
>  is that correct? Which OS do you have 
> installed? Thanks

Correct, it's an M1  Mini. I had to get 
check-clang and check-llvm to pass on M1  
(PR46647, PR46644) so it looks like nobody else is running this config (why 
not?). check-builtins is e.g. still failing (PR49918). Kind of on that note, 
the clang y'all ship with Xcode is > 5% slower than it needs to be due to you 
apparently building it with profiles collected on an intel machine instead of 
with profiles collected on an arm machine (data: 
https://bugs.chromium.org/p/chromium/issues/detail?id=1103322#c34 There's a 
prebuilt binary at 
http://commondatastorage.googleapis.com/chromium-browser-clang/Mac_arm64/clang-llvmorg-13-init-7296-ga749bd76-2.tgz
 with profiles collected on arm that is ~ 12.5% faster than Xcode's clang, see 
comment 29 on that same crbug).

The bot is running macOS 11.3 IIRC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100807

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


[PATCH] D100226: [funcattrs] Add the maximal set of implied attributes to definitions

2021-04-27 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre added inline comments.



Comment at: llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadOnly.ll:14-15
 
-; CHECK: attributes #0 = { readonly }
+; CHECK: attributes #0 = { nofree readonly }
+; CHECK: attributes #1 = { readonly }

I'm getting #0 for both functions. Any idea why that might happen?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100226

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


[PATCH] D100226: [funcattrs] Add the maximal set of implied attributes to definitions

2021-04-27 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadOnly.ll:14-15
 
-; CHECK: attributes #0 = { readonly }
+; CHECK: attributes #0 = { nofree readonly }
+; CHECK: attributes #1 = { readonly }

thopre wrote:
> I'm getting #0 for both functions. Any idea why that might happen?
Random guess: your cmake was not rebuild since we switched to the new-PM and 
`opt` defaults to the old one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100226

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


[PATCH] D100226: [funcattrs] Add the maximal set of implied attributes to definitions

2021-04-27 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre added inline comments.



Comment at: llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadOnly.ll:14-15
 
-; CHECK: attributes #0 = { readonly }
+; CHECK: attributes #0 = { nofree readonly }
+; CHECK: attributes #1 = { readonly }

jdoerfert wrote:
> thopre wrote:
> > I'm getting #0 for both functions. Any idea why that might happen?
> Random guess: your cmake was not rebuild since we switched to the new-PM and 
> `opt` defaults to the old one?
That's a good guess! We are still using the old PM. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100226

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


[clang] 76a412e - [HIP] Fix help text for -fgpu-allow-device-init

2021-04-27 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2021-04-27T10:06:32-04:00
New Revision: 76a412e7a330964fe9914cbaaa0772feef771a28

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

LOG: [HIP] Fix help text for -fgpu-allow-device-init

Add 'experimental' to help text.

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index df3049fe4032..8de28538192c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -942,7 +942,7 @@ defm hip_new_launch_api : BoolFOption<"hip-new-launch-api",
 defm gpu_allow_device_init : BoolFOption<"gpu-allow-device-init",
   LangOpts<"GPUAllowDeviceInit">, DefaultFalse,
   PosFlag, NegFlag,
-  BothFlags<[], " device side init function in HIP">>,
+  BothFlags<[], " device side init function in HIP (experimental)">>,
   ShouldParseIf;
 defm gpu_defer_diag : BoolFOption<"gpu-defer-diag",
   LangOpts<"GPUDeferDiag">, DefaultFalse,



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


[PATCH] D101328: [clangd] run clang-format on FindTargetTests.cpp

2021-04-27 Thread David Goldman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG53e1cb88f280: [clangd] run clang-format on 
FindTargetTests.cpp's FindExplicitReferencesTest (authored by dgoldman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101328

Files:
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1036,37 +1036,36 @@
 
 TEST_F(FindExplicitReferencesTest, All) {
   std::pair Cases[] =
-  {
-  // Simple expressions.
-  {R"cpp(
+  {// Simple expressions.
+   {R"cpp(
 int global;
 int func();
 void foo(int param) {
   $0^global = $1^param + $2^func();
 }
 )cpp",
-   "0: targets = {global}\n"
-   "1: targets = {param}\n"
-   "2: targets = {func}\n"},
-  {R"cpp(
+"0: targets = {global}\n"
+"1: targets = {param}\n"
+"2: targets = {func}\n"},
+   {R"cpp(
 struct X { int a; };
 void foo(X x) {
   $0^x.$1^a = 10;
 }
 )cpp",
-   "0: targets = {x}\n"
-   "1: targets = {X::a}\n"},
-  {R"cpp(
+"0: targets = {x}\n"
+"1: targets = {X::a}\n"},
+   {R"cpp(
 // error-ok: testing with broken code
 int bar();
 int foo() {
   return $0^bar() + $1^bar(42);
 }
 )cpp",
-   "0: targets = {bar}\n"
-   "1: targets = {bar}\n"},
-  // Namespaces and aliases.
-  {R"cpp(
+"0: targets = {bar}\n"
+"1: targets = {bar}\n"},
+   // Namespaces and aliases.
+   {R"cpp(
   namespace ns {}
   namespace alias = ns;
   void foo() {
@@ -1074,19 +1073,19 @@
 using namespace $1^alias;
   }
 )cpp",
-   "0: targets = {ns}\n"
-   "1: targets = {alias}\n"},
-  // Using declarations.
-  {R"cpp(
+"0: targets = {ns}\n"
+"1: targets = {alias}\n"},
+   // Using declarations.
+   {R"cpp(
   namespace ns { int global; }
   void foo() {
 using $0^ns::$1^global;
   }
 )cpp",
-   "0: targets = {ns}\n"
-   "1: targets = {ns::global}, qualifier = 'ns::'\n"},
-  // Simple types.
-  {R"cpp(
+"0: targets = {ns}\n"
+"1: targets = {ns::global}, qualifier = 'ns::'\n"},
+   // Simple types.
+   {R"cpp(
  struct Struct { int a; };
  using Typedef = int;
  void foo() {
@@ -1095,13 +1094,13 @@
static_cast<$4^Struct*>(0);
  }
)cpp",
-   "0: targets = {Struct}\n"
-   "1: targets = {x}, decl\n"
-   "2: targets = {Typedef}\n"
-   "3: targets = {y}, decl\n"
-   "4: targets = {Struct}\n"},
-  // Name qualifiers.
-  {R"cpp(
+"0: targets = {Struct}\n"
+"1: targets = {x}, decl\n"
+"2: targets = {Typedef}\n"
+"3: targets = {y}, decl\n"
+"4: targets = {Struct}\n"},
+   // Name qualifiers.
+   {R"cpp(
  namespace a { namespace b { struct S { typedef int type; }; } }
  void foo() {
$0^a::$1^b::$2^S $3^x;
@@ -1109,16 +1108,16 @@
$6^S::$7^type $8^y;
  }
 )cpp",
-   "0: targets = {a}\n"
-   "1: targets = {a::b}, qualifier = 'a::'\n"
-   "2: targets = {a::b::S}, qualifier = 'a::b::'\n"
-   "3: targets = {x}, decl\n"
-   "4: targets = {a}\n"
-   "5: targets = {a::b}, qualifier = 'a::'\n"
-   "6: targets = {a::b::S}\n"
-   "7: targets = {a::b::S::type}, qualifier = 'struct S::'\n"
-   "8: targets = {y}, decl\n"},
-  {R"cpp(
+"0: targets = {a}\n"
+"1: targets = {a::b}, qualifier = 'a::'\n"
+"2: targets = {a::b::S}, qualifier = 'a::b::'\n"
+"3: targets = {x}, decl\n"
+"4: targets = {a}\n"
+"5: targets = {a::b}, qualifier = 'a::'\n"
+"6: targets = {a::b::S}\n"
+"7: targets = {a::b::S::type}, qualifier = 'struct S::'\n"
+"8: targets = {y}, decl\n"},
+   {R"cpp(
  void foo() {
$0^ten: // PRINT "HELLO WORLD!"
goto $1^ten;
@@ -1135,12 +1134,12 @@
 $2^vector $3^vb;
   }
 )cpp",
-   "0: targets = {vector}\n"
-   "1: targets = {vi}, decl\n"
-   "2: targets = {vector}\n"
-   "3: targets = {vb}, decl\n"},
-  // Template type aliases.
-  {R"cpp(
+"0: targets = {vector}\n"
+"1: targets = {vi}, decl\n"
+"2: targets = {vector}\n"
+  

[clang-tools-extra] 53e1cb8 - [clangd] run clang-format on FindTargetTests.cpp's FindExplicitReferencesTest

2021-04-27 Thread David Goldman via cfe-commits

Author: David Goldman
Date: 2021-04-27T10:07:41-04:00
New Revision: 53e1cb88f28052fa849f28ff164d61e06a3dcfd2

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

LOG: [clangd] run clang-format on FindTargetTests.cpp's 
FindExplicitReferencesTest

Addressing comments in https://reviews.llvm.org/D98984

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 7a25293bf2b9..2263c790d713 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1036,37 +1036,36 @@ class FindExplicitReferencesTest : public 
::testing::Test {
 
 TEST_F(FindExplicitReferencesTest, All) {
   std::pair Cases[] =
-  {
-  // Simple expressions.
-  {R"cpp(
+  {// Simple expressions.
+   {R"cpp(
 int global;
 int func();
 void foo(int param) {
   $0^global = $1^param + $2^func();
 }
 )cpp",
-   "0: targets = {global}\n"
-   "1: targets = {param}\n"
-   "2: targets = {func}\n"},
-  {R"cpp(
+"0: targets = {global}\n"
+"1: targets = {param}\n"
+"2: targets = {func}\n"},
+   {R"cpp(
 struct X { int a; };
 void foo(X x) {
   $0^x.$1^a = 10;
 }
 )cpp",
-   "0: targets = {x}\n"
-   "1: targets = {X::a}\n"},
-  {R"cpp(
+"0: targets = {x}\n"
+"1: targets = {X::a}\n"},
+   {R"cpp(
 // error-ok: testing with broken code
 int bar();
 int foo() {
   return $0^bar() + $1^bar(42);
 }
 )cpp",
-   "0: targets = {bar}\n"
-   "1: targets = {bar}\n"},
-  // Namespaces and aliases.
-  {R"cpp(
+"0: targets = {bar}\n"
+"1: targets = {bar}\n"},
+   // Namespaces and aliases.
+   {R"cpp(
   namespace ns {}
   namespace alias = ns;
   void foo() {
@@ -1074,19 +1073,19 @@ TEST_F(FindExplicitReferencesTest, All) {
 using namespace $1^alias;
   }
 )cpp",
-   "0: targets = {ns}\n"
-   "1: targets = {alias}\n"},
-  // Using declarations.
-  {R"cpp(
+"0: targets = {ns}\n"
+"1: targets = {alias}\n"},
+   // Using declarations.
+   {R"cpp(
   namespace ns { int global; }
   void foo() {
 using $0^ns::$1^global;
   }
 )cpp",
-   "0: targets = {ns}\n"
-   "1: targets = {ns::global}, qualifier = 'ns::'\n"},
-  // Simple types.
-  {R"cpp(
+"0: targets = {ns}\n"
+"1: targets = {ns::global}, qualifier = 'ns::'\n"},
+   // Simple types.
+   {R"cpp(
  struct Struct { int a; };
  using Typedef = int;
  void foo() {
@@ -1095,13 +1094,13 @@ TEST_F(FindExplicitReferencesTest, All) {
static_cast<$4^Struct*>(0);
  }
)cpp",
-   "0: targets = {Struct}\n"
-   "1: targets = {x}, decl\n"
-   "2: targets = {Typedef}\n"
-   "3: targets = {y}, decl\n"
-   "4: targets = {Struct}\n"},
-  // Name qualifiers.
-  {R"cpp(
+"0: targets = {Struct}\n"
+"1: targets = {x}, decl\n"
+"2: targets = {Typedef}\n"
+"3: targets = {y}, decl\n"
+"4: targets = {Struct}\n"},
+   // Name qualifiers.
+   {R"cpp(
  namespace a { namespace b { struct S { typedef int type; }; } }
  void foo() {
$0^a::$1^b::$2^S $3^x;
@@ -1109,16 +1108,16 @@ TEST_F(FindExplicitReferencesTest, All) {
$6^S::$7^type $8^y;
  }
 )cpp",
-   "0: targets = {a}\n"
-   "1: targets = {a::b}, qualifier = 'a::'\n"
-   "2: targets = {a::b::S}, qualifier = 'a::b::'\n"
-   "3: targets = {x}, decl\n"
-   "4: targets = {a}\n"
-   "5: targets = {a::b}, qualifier = 'a::'\n"
-   "6: targets = {a::b::S}\n"
-   "7: targets = {a::b::S::type}, qualifier = 'struct S::'\n"
-   "8: targets = {y}, decl\n"},
-  {R"cpp(
+"0: targets = {a}\n"
+"1: targets = {a::b}, qualifier = 'a::'\n"
+"2: targets = {a::b::S}, qualifier = 'a::b::'\n"
+"3: targets = {x}, decl\n"
+"4: targets = {a}\n"
+"5: targets = {a::b}, qualifier = 'a::'\n"
+"6: targets = {a::b::S}\n"
+"7: targets = {a::b::S::type}, qualifier = 'struct S::'\n"
+"8: targets = {y}, decl\n"},
+   {R"cpp(
  

[PATCH] D101365: [clang-query] Add check to prevent setting srcloc when no introspection is available.

2021-04-27 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: steveire, aaron.ballman.
njames93 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Checks if introspection support is available set output kind parser.
If it isn't present the auto complete will not suggest `srcloc` and an error 
query will be reported if a user tries to access it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101365

Files:
  clang-tools-extra/clang-query/QueryParser.cpp


Index: clang-tools-extra/clang-query/QueryParser.cpp
===
--- clang-tools-extra/clang-query/QueryParser.cpp
+++ clang-tools-extra/clang-query/QueryParser.cpp
@@ -11,6 +11,7 @@
 #include "QuerySession.h"
 #include "clang/ASTMatchers/Dynamic/Parser.h"
 #include "clang/Basic/CharInfo.h"
+#include "clang/Tooling/NodeIntrospection.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include 
@@ -104,17 +105,23 @@
 
 template  QueryRef QueryParser::parseSetOutputKind() {
   StringRef ValStr;
-  unsigned OutKind = LexOrCompleteWord(this, ValStr)
- .Case("diag", OK_Diag)
- .Case("print", OK_Print)
- .Case("detailed-ast", OK_DetailedAST)
- .Case("srcloc", OK_SrcLoc)
- .Case("dump", OK_DetailedAST)
- .Default(~0u);
+  unsigned OutKind =
+  LexOrCompleteWord(this, ValStr)
+  .Case("diag", OK_Diag)
+  .Case("print", OK_Print)
+  .Case("detailed-ast", OK_DetailedAST)
+  .Case("srcloc", OK_SrcLoc,
+/*IsCompletion=*/
+tooling::NodeIntrospection::hasIntrospectionSupport())
+  .Case("dump", OK_DetailedAST)
+  .Default(~0u);
   if (OutKind == ~0u) {
 return new InvalidQuery(
-"expected 'diag', 'print', 'detailed-ast' or 'dump', got '" + ValStr +
-"'");
+"expected 'diag', 'print', 'detailed-ast'" +
+StringRef(tooling::NodeIntrospection::hasIntrospectionSupport()
+  ? ", 'srcloc'"
+  : "") +
+" or 'dump', got '" + ValStr + "'");
   }
 
   switch (OutKind) {
@@ -125,7 +132,9 @@
   case OK_Print:
 return new QueryType(&QuerySession::PrintOutput);
   case OK_SrcLoc:
-return new QueryType(&QuerySession::SrcLocOutput);
+if (tooling::NodeIntrospection::hasIntrospectionSupport())
+  return new QueryType(&QuerySession::SrcLocOutput);
+return new InvalidQuery("'srcloc' output support is not available.");
   }
 
   llvm_unreachable("Invalid output kind");


Index: clang-tools-extra/clang-query/QueryParser.cpp
===
--- clang-tools-extra/clang-query/QueryParser.cpp
+++ clang-tools-extra/clang-query/QueryParser.cpp
@@ -11,6 +11,7 @@
 #include "QuerySession.h"
 #include "clang/ASTMatchers/Dynamic/Parser.h"
 #include "clang/Basic/CharInfo.h"
+#include "clang/Tooling/NodeIntrospection.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include 
@@ -104,17 +105,23 @@
 
 template  QueryRef QueryParser::parseSetOutputKind() {
   StringRef ValStr;
-  unsigned OutKind = LexOrCompleteWord(this, ValStr)
- .Case("diag", OK_Diag)
- .Case("print", OK_Print)
- .Case("detailed-ast", OK_DetailedAST)
- .Case("srcloc", OK_SrcLoc)
- .Case("dump", OK_DetailedAST)
- .Default(~0u);
+  unsigned OutKind =
+  LexOrCompleteWord(this, ValStr)
+  .Case("diag", OK_Diag)
+  .Case("print", OK_Print)
+  .Case("detailed-ast", OK_DetailedAST)
+  .Case("srcloc", OK_SrcLoc,
+/*IsCompletion=*/
+tooling::NodeIntrospection::hasIntrospectionSupport())
+  .Case("dump", OK_DetailedAST)
+  .Default(~0u);
   if (OutKind == ~0u) {
 return new InvalidQuery(
-"expected 'diag', 'print', 'detailed-ast' or 'dump', got '" + ValStr +
-"'");
+"expected 'diag', 'print', 'detailed-ast'" +
+StringRef(tooling::NodeIntrospection::hasIntrospectionSupport()
+  ? ", 'srcloc'"
+  : "") +
+" or 'dump', got '" + ValStr + "'");
   }
 
   switch (OutKind) {
@@ -125,7 +132,9 @@
   case OK_Print:
 return new QueryType(&QuerySession::PrintOutput);
   case OK_SrcLoc:
-return new QueryType(&QuerySession::SrcLocOutput);
+if (tooling::NodeIntrospection::hasIntrospectionSupport())
+  return new QueryType(&QuerySession::SrcLocOutput);
+return new InvalidQuery("'srcloc' output support is not available.");
   }
 
   llvm_unreachable("Invalid output kind");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://li

Re: [PATCH] D96203: [clang][patch] Modify sanitizer options names: renaming blacklist to blocklist

2021-04-27 Thread Eric Christopher via cfe-commits
On Tue, Apr 27, 2021 at 8:01 AM Melanie Blower via Phabricator <
revi...@reviews.llvm.org> wrote:

> mibintc abandoned this revision.
> mibintc added a comment.
>
> There was no resolution about what option name would be acceptable
>

Oh no, I'm sorry that you felt that way.  I saw Vitaly's comment about
exclusion and mine and we were waiting to see if that was ok with you.
You'd said something about allow/disallow, but it had stopped. I'm
happy either way though I do have a preference for exclude to disallow.

Thanks!

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


[PATCH] D98984: [clangd] Improve handling of Objective-C protocols in types

2021-04-27 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 340834.
dgoldman added a comment.

Rebase on top of formatting changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98984

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -676,8 +676,7 @@
 @end
 @interface $Class_decl[[Klass]] <$Interface[[Protocol]]>
 @end
-// FIXME: protocol list in ObjCObjectType should be highlighted.
-id $Variable_decl[[x]];
+id<$Interface[[Protocol]]> $Variable_decl[[x]];
   )cpp",
   R"cpp(
 // ObjC: Categories
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -943,14 +943,32 @@
   )cpp";
   EXPECT_DECLS("ObjCObjectTypeLoc", "@protocol Foo");
 
+  Code = R"cpp(
+@class C;
+@protocol Foo
+@end
+void test([[C]] *p);
+  )cpp";
+  EXPECT_DECLS("ObjCInterfaceTypeLoc", "@class C;");
+
   Code = R"cpp(
 @class C;
 @protocol Foo
 @end
 void test(C<[[Foo]]> *p);
   )cpp";
-  // FIXME: there's no AST node corresponding to 'Foo', so we're stuck.
-  EXPECT_DECLS("ObjCObjectTypeLoc");
+  EXPECT_DECLS("ObjCObjectTypeLoc", "@protocol Foo");
+
+  Code = R"cpp(
+@class C;
+@protocol Foo
+@end
+@protocol Bar
+@end
+void test(C<[[Foo]], Bar> *p);
+  )cpp";
+  // FIXME: We currently can't disambiguate between multiple protocols.
+  EXPECT_DECLS("ObjCObjectTypeLoc", "@protocol Foo", "@protocol Bar");
 }
 
 class FindExplicitReferencesTest : public ::testing::Test {
@@ -1610,12 +1628,12 @@
 @protocol P
 @end
 void foo() {
-  // FIXME: should reference P
-  $0^I *$1^x;
+  $0^I<$1^P> *$2^x;
 }
   )cpp",
 "0: targets = {I}\n"
-"1: targets = {x}, decl\n"},
+"1: targets = {P}\n"
+"2: targets = {x}, decl\n"},
 
// Designated initializers.
{R"cpp(
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -432,10 +432,13 @@
 Outer.add(OIT->getDecl(), Flags);
   }
   void VisitObjCObjectType(const ObjCObjectType *OOT) {
-// FIXME: ObjCObjectTypeLoc has no children for the protocol list, so
-// there is no node in id that refers to ObjCProtocolDecl Foo.
-if (OOT->isObjCQualifiedId() && OOT->getNumProtocols() == 1)
-  Outer.add(OOT->getProtocol(0), Flags);
+// Make all of the protocols targets since there's no child nodes for
+// protocols. This isn't needed for the base type, which *does* have a
+// child `ObjCInterfaceTypeLoc`. This structure is a hack, but it works
+// well for go-to-definition.
+unsigned NumProtocols = OOT->getNumProtocols();
+for (unsigned I = 0; I < NumProtocols; I++)
+  Outer.add(OOT->getProtocol(I), Flags);
   }
 };
 Visitor(*this, Flags).Visit(T.getTypePtr());
@@ -813,30 +816,34 @@
 Visitor(const HeuristicResolver *Resolver) : Resolver(Resolver) {}
 
 const HeuristicResolver *Resolver;
-llvm::Optional Ref;
+llvm::SmallVector Refs;
 
 void VisitElaboratedTypeLoc(ElaboratedTypeLoc L) {
   // We only know about qualifier, rest if filled by inner locations.
+  size_t InitialSize = Refs.size();
   Visit(L.getNamedTypeLoc().getUnqualifiedLoc());
-  // Fill in the qualifier.
-  if (!Ref)
-return;
-  assert(!Ref->Qualifier.hasQualifier() && "qualifier already set");
-  Ref->Qualifier = L.getQualifierLoc();
+  size_t NewSize = Refs.size();
+  // Add qualifier for the newly-added refs.
+  for (unsigned I = InitialSize; I < NewSize; ++I) {
+ReferenceLoc *Ref = &Refs[I];
+// Fill in the qualifier.
+assert(!Ref->Qualifier.hasQualifier() && "qualifier already set");
+Ref->Qualifier = L.getQualifierLoc();
+  }
 }
 
 void VisitTagTypeLoc(TagTypeLoc L) {
-  Ref = ReferenceLoc{NestedNameSpecifierLoc(),
- L.getNameLoc(),
- /*IsDecl=*/false,
- {L.getDecl()}};
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  L.getNameLoc(),
+

[PATCH] D101365: [clang-query] Add check to prevent setting srcloc when no introspection is available.

2021-04-27 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 340835.
njames93 added a comment.

Cleanup.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101365

Files:
  clang-tools-extra/clang-query/QueryParser.cpp


Index: clang-tools-extra/clang-query/QueryParser.cpp
===
--- clang-tools-extra/clang-query/QueryParser.cpp
+++ clang-tools-extra/clang-query/QueryParser.cpp
@@ -11,6 +11,7 @@
 #include "QuerySession.h"
 #include "clang/ASTMatchers/Dynamic/Parser.h"
 #include "clang/Basic/CharInfo.h"
+#include "clang/Tooling/NodeIntrospection.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include 
@@ -104,17 +105,19 @@
 
 template  QueryRef QueryParser::parseSetOutputKind() {
   StringRef ValStr;
-  unsigned OutKind = LexOrCompleteWord(this, ValStr)
- .Case("diag", OK_Diag)
- .Case("print", OK_Print)
- .Case("detailed-ast", OK_DetailedAST)
- .Case("srcloc", OK_SrcLoc)
- .Case("dump", OK_DetailedAST)
- .Default(~0u);
+  bool HasIntrospection = 
tooling::NodeIntrospection::hasIntrospectionSupport();
+  unsigned OutKind =
+  LexOrCompleteWord(this, ValStr)
+  .Case("diag", OK_Diag)
+  .Case("print", OK_Print)
+  .Case("detailed-ast", OK_DetailedAST)
+  .Case("srcloc", OK_SrcLoc, /*IsCompletion=*/HasIntrospection)
+  .Case("dump", OK_DetailedAST)
+  .Default(~0u);
   if (OutKind == ~0u) {
-return new InvalidQuery(
-"expected 'diag', 'print', 'detailed-ast' or 'dump', got '" + ValStr +
-"'");
+return new InvalidQuery("expected 'diag', 'print', 'detailed-ast'" +
+StringRef(HasIntrospection ? ", 'srcloc'" : "") +
+" or 'dump', got '" + ValStr + "'");
   }
 
   switch (OutKind) {
@@ -125,7 +128,9 @@
   case OK_Print:
 return new QueryType(&QuerySession::PrintOutput);
   case OK_SrcLoc:
-return new QueryType(&QuerySession::SrcLocOutput);
+if (HasIntrospection)
+  return new QueryType(&QuerySession::SrcLocOutput);
+return new InvalidQuery("'srcloc' output support is not available.");
   }
 
   llvm_unreachable("Invalid output kind");


Index: clang-tools-extra/clang-query/QueryParser.cpp
===
--- clang-tools-extra/clang-query/QueryParser.cpp
+++ clang-tools-extra/clang-query/QueryParser.cpp
@@ -11,6 +11,7 @@
 #include "QuerySession.h"
 #include "clang/ASTMatchers/Dynamic/Parser.h"
 #include "clang/Basic/CharInfo.h"
+#include "clang/Tooling/NodeIntrospection.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include 
@@ -104,17 +105,19 @@
 
 template  QueryRef QueryParser::parseSetOutputKind() {
   StringRef ValStr;
-  unsigned OutKind = LexOrCompleteWord(this, ValStr)
- .Case("diag", OK_Diag)
- .Case("print", OK_Print)
- .Case("detailed-ast", OK_DetailedAST)
- .Case("srcloc", OK_SrcLoc)
- .Case("dump", OK_DetailedAST)
- .Default(~0u);
+  bool HasIntrospection = tooling::NodeIntrospection::hasIntrospectionSupport();
+  unsigned OutKind =
+  LexOrCompleteWord(this, ValStr)
+  .Case("diag", OK_Diag)
+  .Case("print", OK_Print)
+  .Case("detailed-ast", OK_DetailedAST)
+  .Case("srcloc", OK_SrcLoc, /*IsCompletion=*/HasIntrospection)
+  .Case("dump", OK_DetailedAST)
+  .Default(~0u);
   if (OutKind == ~0u) {
-return new InvalidQuery(
-"expected 'diag', 'print', 'detailed-ast' or 'dump', got '" + ValStr +
-"'");
+return new InvalidQuery("expected 'diag', 'print', 'detailed-ast'" +
+StringRef(HasIntrospection ? ", 'srcloc'" : "") +
+" or 'dump', got '" + ValStr + "'");
   }
 
   switch (OutKind) {
@@ -125,7 +128,9 @@
   case OK_Print:
 return new QueryType(&QuerySession::PrintOutput);
   case OK_SrcLoc:
-return new QueryType(&QuerySession::SrcLocOutput);
+if (HasIntrospection)
+  return new QueryType(&QuerySession::SrcLocOutput);
+return new InvalidQuery("'srcloc' output support is not available.");
   }
 
   llvm_unreachable("Invalid output kind");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] c20e4fb - [clangd] Improve handling of Objective-C protocols in types

2021-04-27 Thread David Goldman via cfe-commits

Author: David Goldman
Date: 2021-04-27T10:20:35-04:00
New Revision: c20e4fbfa6d154616c2dd41e828a02facd000d71

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

LOG: [clangd] Improve handling of Objective-C protocols in types

Improve support for Objective-C protocols for types/type locs

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 16433151d902..6032676b0acd 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -432,10 +432,13 @@ struct TargetFinder {
 Outer.add(OIT->getDecl(), Flags);
   }
   void VisitObjCObjectType(const ObjCObjectType *OOT) {
-// FIXME: ObjCObjectTypeLoc has no children for the protocol list, so
-// there is no node in id that refers to ObjCProtocolDecl Foo.
-if (OOT->isObjCQualifiedId() && OOT->getNumProtocols() == 1)
-  Outer.add(OOT->getProtocol(0), Flags);
+// Make all of the protocols targets since there's no child nodes for
+// protocols. This isn't needed for the base type, which *does* have a
+// child `ObjCInterfaceTypeLoc`. This structure is a hack, but it works
+// well for go-to-definition.
+unsigned NumProtocols = OOT->getNumProtocols();
+for (unsigned I = 0; I < NumProtocols; I++)
+  Outer.add(OOT->getProtocol(I), Flags);
   }
 };
 Visitor(*this, Flags).Visit(T.getTypePtr());
@@ -813,30 +816,34 @@ refInTypeLoc(TypeLoc L, const HeuristicResolver 
*Resolver) {
 Visitor(const HeuristicResolver *Resolver) : Resolver(Resolver) {}
 
 const HeuristicResolver *Resolver;
-llvm::Optional Ref;
+llvm::SmallVector Refs;
 
 void VisitElaboratedTypeLoc(ElaboratedTypeLoc L) {
   // We only know about qualifier, rest if filled by inner locations.
+  size_t InitialSize = Refs.size();
   Visit(L.getNamedTypeLoc().getUnqualifiedLoc());
-  // Fill in the qualifier.
-  if (!Ref)
-return;
-  assert(!Ref->Qualifier.hasQualifier() && "qualifier already set");
-  Ref->Qualifier = L.getQualifierLoc();
+  size_t NewSize = Refs.size();
+  // Add qualifier for the newly-added refs.
+  for (unsigned I = InitialSize; I < NewSize; ++I) {
+ReferenceLoc *Ref = &Refs[I];
+// Fill in the qualifier.
+assert(!Ref->Qualifier.hasQualifier() && "qualifier already set");
+Ref->Qualifier = L.getQualifierLoc();
+  }
 }
 
 void VisitTagTypeLoc(TagTypeLoc L) {
-  Ref = ReferenceLoc{NestedNameSpecifierLoc(),
- L.getNameLoc(),
- /*IsDecl=*/false,
- {L.getDecl()}};
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  L.getNameLoc(),
+  /*IsDecl=*/false,
+  {L.getDecl()}});
 }
 
 void VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc L) {
-  Ref = ReferenceLoc{NestedNameSpecifierLoc(),
- L.getNameLoc(),
- /*IsDecl=*/false,
- {L.getDecl()}};
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  L.getNameLoc(),
+  /*IsDecl=*/false,
+  {L.getDecl()}});
 }
 
 void VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc L) {
@@ -848,63 +855,71 @@ refInTypeLoc(TypeLoc L, const HeuristicResolver 
*Resolver) {
   //1. valias with mask 'Alias'.
   //2. 'vector' with mask 'Underlying'.
   //  we want to return only #1 in this case.
-  Ref = ReferenceLoc{
+  Refs.push_back(ReferenceLoc{
   NestedNameSpecifierLoc(), L.getTemplateNameLoc(), /*IsDecl=*/false,
   explicitReferenceTargets(DynTypedNode::create(L.getType()),
-   DeclRelation::Alias, Resolver)};
+   DeclRelation::Alias, Resolver)});
 }
 void VisitDeducedTemplateSpecializationTypeLoc(
 DeducedTemplateSpecializationTypeLoc L) {
-  Ref = ReferenceLoc{
+  Refs.push_back(ReferenceLoc{
   NestedNameSpecifierLoc(), L.getNameLoc(), /*IsDecl=*/false,
   explicitReferenceTargets(DynTypedNode::create(L.getType()),
-   DeclRelation::Alias, Resolver)};
+   DeclRelation::Alias, Resolv

[PATCH] D98984: [clangd] Improve handling of Objective-C protocols in types

2021-04-27 Thread David Goldman 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 rGc20e4fbfa6d1: [clangd] Improve handling of Objective-C 
protocols in types (authored by dgoldman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98984

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -676,8 +676,7 @@
 @end
 @interface $Class_decl[[Klass]] <$Interface[[Protocol]]>
 @end
-// FIXME: protocol list in ObjCObjectType should be highlighted.
-id $Variable_decl[[x]];
+id<$Interface[[Protocol]]> $Variable_decl[[x]];
   )cpp",
   R"cpp(
 // ObjC: Categories
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -943,14 +943,32 @@
   )cpp";
   EXPECT_DECLS("ObjCObjectTypeLoc", "@protocol Foo");
 
+  Code = R"cpp(
+@class C;
+@protocol Foo
+@end
+void test([[C]] *p);
+  )cpp";
+  EXPECT_DECLS("ObjCInterfaceTypeLoc", "@class C;");
+
   Code = R"cpp(
 @class C;
 @protocol Foo
 @end
 void test(C<[[Foo]]> *p);
   )cpp";
-  // FIXME: there's no AST node corresponding to 'Foo', so we're stuck.
-  EXPECT_DECLS("ObjCObjectTypeLoc");
+  EXPECT_DECLS("ObjCObjectTypeLoc", "@protocol Foo");
+
+  Code = R"cpp(
+@class C;
+@protocol Foo
+@end
+@protocol Bar
+@end
+void test(C<[[Foo]], Bar> *p);
+  )cpp";
+  // FIXME: We currently can't disambiguate between multiple protocols.
+  EXPECT_DECLS("ObjCObjectTypeLoc", "@protocol Foo", "@protocol Bar");
 }
 
 class FindExplicitReferencesTest : public ::testing::Test {
@@ -1610,12 +1628,12 @@
 @protocol P
 @end
 void foo() {
-  // FIXME: should reference P
-  $0^I *$1^x;
+  $0^I<$1^P> *$2^x;
 }
   )cpp",
 "0: targets = {I}\n"
-"1: targets = {x}, decl\n"},
+"1: targets = {P}\n"
+"2: targets = {x}, decl\n"},
 
// Designated initializers.
{R"cpp(
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -432,10 +432,13 @@
 Outer.add(OIT->getDecl(), Flags);
   }
   void VisitObjCObjectType(const ObjCObjectType *OOT) {
-// FIXME: ObjCObjectTypeLoc has no children for the protocol list, so
-// there is no node in id that refers to ObjCProtocolDecl Foo.
-if (OOT->isObjCQualifiedId() && OOT->getNumProtocols() == 1)
-  Outer.add(OOT->getProtocol(0), Flags);
+// Make all of the protocols targets since there's no child nodes for
+// protocols. This isn't needed for the base type, which *does* have a
+// child `ObjCInterfaceTypeLoc`. This structure is a hack, but it works
+// well for go-to-definition.
+unsigned NumProtocols = OOT->getNumProtocols();
+for (unsigned I = 0; I < NumProtocols; I++)
+  Outer.add(OOT->getProtocol(I), Flags);
   }
 };
 Visitor(*this, Flags).Visit(T.getTypePtr());
@@ -813,30 +816,34 @@
 Visitor(const HeuristicResolver *Resolver) : Resolver(Resolver) {}
 
 const HeuristicResolver *Resolver;
-llvm::Optional Ref;
+llvm::SmallVector Refs;
 
 void VisitElaboratedTypeLoc(ElaboratedTypeLoc L) {
   // We only know about qualifier, rest if filled by inner locations.
+  size_t InitialSize = Refs.size();
   Visit(L.getNamedTypeLoc().getUnqualifiedLoc());
-  // Fill in the qualifier.
-  if (!Ref)
-return;
-  assert(!Ref->Qualifier.hasQualifier() && "qualifier already set");
-  Ref->Qualifier = L.getQualifierLoc();
+  size_t NewSize = Refs.size();
+  // Add qualifier for the newly-added refs.
+  for (unsigned I = InitialSize; I < NewSize; ++I) {
+ReferenceLoc *Ref = &Refs[I];
+// Fill in the qualifier.
+assert(!Ref->Qualifier.hasQualifier() && "qualifier already set");
+Ref->Qualifier = L.getQualifierLoc();
+  }
 }
 
 void VisitTagTypeLoc(TagTypeLoc L) {
-  Ref = ReferenceLoc{NestedNameSpecifierLoc(),
- L.getNameLoc(),
- /*IsDecl=*/false,
- {L.getDecl()

[PATCH] D99975: [clangd][ObjC] Improve support for class properties

2021-04-27 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 340840.
dgoldman added a comment.

Rebase on top of main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99975

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -957,6 +957,7 @@
 @end
 void test(C<[[Foo]]> *p);
   )cpp";
+
   EXPECT_DECLS("ObjCObjectTypeLoc", "@protocol Foo");
 
   Code = R"cpp(
@@ -969,6 +970,33 @@
   )cpp";
   // FIXME: We currently can't disambiguate between multiple protocols.
   EXPECT_DECLS("ObjCObjectTypeLoc", "@protocol Foo", "@protocol Bar");
+
+  Code = R"cpp(
+@interface Foo
++ (id)sharedInstance;
+@end
+@implementation Foo
++ (id)sharedInstance { return 0; }
+@end
+void test() {
+  id value = [[Foo]].sharedInstance;
+}
+  )cpp";
+  // FIXME: currently failing.
+  EXPECT_DECLS("ObjCPropertyRefExpr", "@interface Foo");
+
+  Code = R"cpp(
+@interface Foo
++ (id)sharedInstance;
+@end
+@implementation Foo
++ (id)sharedInstance { return 0; }
+@end
+void test() {
+  id value = Foo.[[sharedInstance]];
+}
+  )cpp";
+  EXPECT_DECLS("ObjCPropertyRefExpr", "+ (id)sharedInstance");
 }
 
 class FindExplicitReferencesTest : public ::testing::Test {
@@ -1610,6 +1638,41 @@
"0: targets = {f}\n"
"1: targets = {I::x}\n"
"2: targets = {I::setY:}\n"},
+   // Objective-C: class properties
+   {
+   R"cpp(
+@interface I {}
+@property(class) I *x;
+@end
+id local;
+void foo() {
+  $0^I.$1^x = 0;
+  $2^local = $3^I.$4^x;
+}
+  )cpp",
+   "0: targets = {I}\n"
+   "1: targets = {I::setX:}\n"
+   "2: targets = {local}\n"
+   "3: targets = {I}\n"
+   "4: targets = {I::x}\n"},
+   // Objective-C: implicit class properties
+   {
+   R"cpp(
+@interface I {}
++(I*)x;
++(void)setX:(I*)x;
+@end
+id local;
+void foo() {
+  $0^I.$1^x = 0;
+  $2^local = $3^I.$4^x;
+}
+  )cpp",
+   "0: targets = {I}\n"
+   "1: targets = {I::setX:}\n"
+   "2: targets = {local}\n"
+   "3: targets = {I}\n"
+   "4: targets = {I::x}\n"},
{// Objective-C: methods
 R"cpp(
 @interface I
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -306,6 +306,11 @@
 Outer.add(OME->getMethodDecl(), Flags);
   }
   void VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *OPRE) {
+// FIXME: visiting this here allows us to hover on UIColor in
+// `UIColor.blackColor` but then `blackColor` no longer refers to the
+// method.
+// if (OPRE->isClassReceiver())
+//   Outer.add(OPRE->getClassReceiver(), Flags);
 if (OPRE->isExplicitProperty())
   Outer.add(OPRE->getExplicitProperty(), Flags);
 else {
@@ -763,6 +768,12 @@
 }
 
 void VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *E) {
+  if (E->isClassReceiver()) {
+Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+E->getReceiverLocation(),
+/*IsDecl=*/false,
+{E->getClassReceiver()}});
+  }
   Refs.push_back(ReferenceLoc{
   NestedNameSpecifierLoc(), E->getLocation(),
   /*IsDecl=*/false,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101191: [InstCombine] Fully disable select to and/or i1 folding

2021-04-27 Thread Nikita Popov via Phabricator via cfe-commits
nikic added inline comments.



Comment at: llvm/test/Transforms/InstCombine/logical-select.ll:385
+; CHECK-NEXT:[[OR:%.*]] = select i1 [[AND1]], i1 true, i1 [[AND2]]
+; CHECK-NEXT:ret i1 [[OR]]
 ;

aqjune wrote:
> nikic wrote:
> > It looks like this fold could be salvaged, if we wanted to: 
> > https://alive2.llvm.org/ce/z/TpsYAj
> Thx, I added the transformation.
> If the transformations look good, I'll make it as a separate commit with 
> tests and push it.
Could you please split it off into a separate review? Hard to understand impact 
as part of this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101191

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


[PATCH] D101191: [InstCombine] Fully disable select to and/or i1 folding

2021-04-27 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added inline comments.



Comment at: llvm/test/Transforms/PhaseOrdering/X86/vector-reductions.ll:282
 
+; FIXME: this should be vectorized
 define i1 @cmp_lt_gt(double %a, double %b, double %c) {

I don't think we need to worry about regressing this. It's not ideal before or 
after, but we probably have a better chance of getting to the goal by making 
instcombine/simplifycfg correct and consistent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101191

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-27 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D100581#2718840 , @uabelho wrote:

> I noticed that with this patch
>  
> libcxx/test/std/strings/basic.string/string.cons/iter_alloc_deduction.fail.cpp
> fails:
>
>   error: 'warning' diagnostics seen but not expected: 
> File 
> /repo/uabelho/master-github/libcxx/test/std/strings/basic.string/string.cons/iter_alloc_deduction.fail.cpp
>  Line 51: variable 's' set but not used
>   1 error generated.
>
> (I don't know anything about the testcase I just noticed it failed when 
> trying to uplift my downstream repo.)

looks like this was fixed in 7f98209da6349891b7a74eeadace34d38e7aaadc 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-27 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D100581#2718947 , @Abpostelnicu 
wrote:

> I think this added a regression, where you have this context:
>
>   uint32_t LocalAccessible::SelectedItemCount() {
> uint32_t count = 0;
> AccIterator iter(this, filters::GetSelected);
> LocalAccessible* selected = nullptr;
> while ((selected = iter.Next())) ++count;
>   
> return count;
>   }
>
>
>
>   [task 2021-04-27T02:39:42.523Z] 02:39:42ERROR -  
> /builds/worker/checkouts/gecko/accessible/generic/LocalAccessible.cpp:2455:20:
>  error: variable 'selected' set but not used 
> [-Werror,-Wunused-but-set-variable]
>   [task 2021-04-27T02:39:42.523Z] 02:39:42 INFO -LocalAccessible* 
> selected = nullptr;
>   [task 2021-04-27T02:39:42.523Z] 02:39:42 INFO - ^
>   [task 2021-04-27T02:39:42.523Z] 02:39:42 INFO -  1 error generated.
>
> The file in cause is this 
> 
>  one.
>
> Indeed the value stored in `selected` is not used but this check is a little 
> bit too strict.

That seems like a real finding to me, deleting `selected` should fix it and 
clean up the code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D101347: hurd: Clean up test

2021-04-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101347

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


[PATCH] D101191: [InstCombine] Fully disable select to and/or i1 folding

2021-04-27 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added inline comments.



Comment at: 
llvm/test/Transforms/PhaseOrdering/unsigned-multiply-overflow-check.ll:20
 
+; FIXME: noundef should be attached to args
 define i1 @will_not_overflow(i64 %arg, i64 %arg1) {

Any ideas about what it will take to get those argument attributes for the C++ 
source example shown in the code comment?

SDAG is still going to convert the `select` to `and`, so we can probably avoid 
regressions by replicating InstSimplify's 
omitCheckForZeroBeforeMulWithOverflow() as a DAG combine. Let me know if I 
should do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101191

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


[PATCH] D99530: [OPENMP]Fix PR49098: respect firstprivate of declare target variable.

2021-04-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 340859.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99530

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

Index: clang/test/OpenMP/target_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/target_firstprivate_codegen.cpp
+++ clang/test/OpenMP/target_firstprivate_codegen.cpp
@@ -43,6 +43,9 @@
   tx X;
   ty Y;
 };
+#pragma omp declare target
+int ga = 5;
+#pragma omp end declare target
 
 // CHECK-DAG:  [[TT:%.+]] = type { i64, i8 }
 // CHECK-DAG:  [[TTII:%.+]] = type { i32, i32 }
@@ -52,9 +55,9 @@
 // TCHECK-DAG:  [[TTII:%.+]] = type { i32, i32 }
 // TCHECK-DAG:  [[S1:%.+]] = type { double }
 
-// CHECK-DAG:  [[FP_E:@__omp_offloading_firstprivate_.+_e_l76]] = internal global [[TTII]] zeroinitializer
-// CHECK-DAG:  [[SIZET:@.+]] = private unnamed_addr constant [2 x i{{32|64}}] [i[[SZ:32|64]] 4, i{{64|32}} {{8|4}}]
-// CHECK-DAG:  [[MAPT:@.+]] = private unnamed_addr constant [2 x i64] [i64 288, i64 49]
+// CHECK-DAG:  [[FP_E:@__omp_offloading_firstprivate_.+_e_l79]] = internal global [[TTII]] zeroinitializer
+// CHECK-DAG:  [[SIZET:@.+]] = private unnamed_addr constant [3 x i{{32|64}}] [i[[SZ:32|64]] 4, i{{64|32}} {{8|4}}, i[[SZ:32|64]] 4]
+// CHECK-DAG:  [[MAPT:@.+]] = private unnamed_addr constant [3 x i64] [i64 288, i64 49, i64 288]
 // CHECK-DAG:  [[MAPT2:@.+]] = private unnamed_addr constant [9 x i64] [i64 288, i64 161, i64 800, i64 161, i64 161, i64 800, i64 800, i64 161, i64 161]
 // CHECK-DAG:  [[SIZET3:@.+]] = private unnamed_addr constant [2 x i{{32|64}}] [i{{32|64}} 0, i{{32|64}} 8]
 // CHECK-DAG:  [[MAPT3:@.+]] = private unnamed_addr constant [2 x i64] [i64 32, i64 37]
@@ -76,7 +79,7 @@
   const TT e = {n, n};
   int *p __attribute__ ((aligned (64))) = &a;
 
-#pragma omp target firstprivate(a, p)
+#pragma omp target firstprivate(a, p, ga)
   {
   }
 
@@ -91,8 +94,8 @@
   // CHECK:  [[D:%.+]] = alloca [[TT]],
   // CHECK:  [[P:%.+]] = alloca i32*, align 64
   // CHECK:  [[ACAST:%.+]] = alloca i{{[0-9]+}},
-  // CHECK:  [[BASE_PTR_ARR:%.+]] = alloca [2 x i8*],
-  // CHECK:  [[PTR_ARR:%.+]] = alloca [2 x i8*],
+  // CHECK:  [[BASE_PTR_ARR:%.+]] = alloca [3 x i8*],
+  // CHECK:  [[PTR_ARR:%.+]] = alloca [3 x i8*],
   // CHECK:  [[A2CAST:%.+]] = alloca i{{[0-9]+}},
   // CHECK:  [[BASE_PTR_ARR2:%.+]] = alloca [9 x i8*],
   // CHECK:  [[PTR_ARR2:%.+]] = alloca [9 x i8*],
@@ -116,29 +119,37 @@
   // CHECK-32:  store i{{[0-9]+}} [[AVAL]], i{{[0-9]+}}* [[ACAST]],
   // CHECK:  [[ACAST_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[ACAST]],
   // CHECK:  [[P_PTR:%.+]] = load i32*, i32** [[P]], align 64
-  // CHECK:  [[BASE_PTR_GEP:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BASE_PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
+  // CHECK:  [[BASE_PTR_GEP:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BASE_PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
   // CHECK:  [[ACAST_TOPTR:%.+]] = bitcast i8** [[BASE_PTR_GEP]] to i{{[0-9]+}}*
   // CHECK:  store i{{[0-9]+}} [[ACAST_VAL]], i{{[0-9]+}}* [[ACAST_TOPTR]],
-  // CHECK:  [[PTR_GEP:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
+  // CHECK:  [[PTR_GEP:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
   // CHECK:  [[ACAST_TOPTR2:%.+]] = bitcast i8** [[PTR_GEP]] to i{{[0-9]+}}*
   // CHECK:  store i{{[0-9]+}} [[ACAST_VAL]], i{{[0-9]+}}* [[ACAST_TOPTR2]],
-  // CHECK:  [[BASE_PTR_GEP:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BASE_PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
+  // CHECK:  [[BASE_PTR_GEP:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BASE_PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
   // CHECK:  [[PCAST_TOPTR:%.+]] = bitcast i8** [[BASE_PTR_GEP]] to i32***
   // CHECK:  store i32** [[P]], i32*** [[PCAST_TOPTR]],
-  // CHECK:  [[PTR_GEP:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
+  // CHECK:  [[PTR_GEP:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
   // CHECK:  [[PCAST_TOPTR2:%.+]] = bitcast i8** [[PTR_GEP]] to i32**
   // CHECK:  store i32* [[P_PTR]], i32** [[PCAST_TOPTR2]],
-  // CHECK:  [[BASE_PTR_GEP_ARG:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BASE_PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
-  // CHECK:  [[PTR_GEP_ARG:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
-  // CHECK:  {{.+}} = call i32 @__tgt_target_mapper(%struct.ident_t* @{{.+}}, i64 -1, {{.+}}, i32 2, i8** [[BASE_PTR_GEP_ARG]], i8** [[PTR_GEP_ARG]], i[[SZ]]* getelementptr inbounds ([2 x i[[SZ]]], [2 x i[[SZ]]]* [[SIZET]], i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[MAPT]], i32 0, i32 0), i8** null, i8** null)
-
-  // TCHECK:  d

[PATCH] D101317: hurd: Fix i386 research path

2021-04-27 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul added a comment.

@MaskRay could you review this one as well? Most others are based on it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101317

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


[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-27 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In D100807#2719561 , @thakis wrote:

> In D100807#2718006 , @arphaman 
> wrote:
>
>> It appears that your bot is running on a Mac with M1 
>>  is that correct? Which OS do you have 
>> installed? Thanks
>
> Correct, it's an M1  Mini. I had to get 
> check-clang and check-llvm to pass on M1  
> (PR46647, PR46644) so it looks like nobody else is running this config (why 
> not?). check-builtins is e.g. still failing (PR49918). Kind of on that note, 
> the clang y'all ship with Xcode is > 5% slower than it needs to be due to you 
> apparently building it with profiles collected on an intel machine instead of 
> with profiles collected on an arm machine (data: 
> https://bugs.chromium.org/p/chromium/issues/detail?id=1103322#c34 There's a 
> prebuilt binary at 
> http://commondatastorage.googleapis.com/chromium-browser-clang/Mac_arm64/clang-llvmorg-13-init-7296-ga749bd76-2.tgz
>  with profiles collected on arm that is ~ 12.5% faster than Xcode's clang, 
> see comment 29 on that same crbug).
>
> The bot is running macOS 11.3 IIRC.

We have M1  CI running internally but it's post 
commit only right now (that's something we're hoping to change in the future), 
so this would've been caught in our internal CI. I didn't verify this specific 
patch on an M1  myself though, which is something 
that's probably a good idea to do going forward for driver changes. I didn't 
know there's another M1  bot running in the open 
so I will be mindful of it :)

Thanks for the pointer, I'll take a look the profile data issue, and we will 
work on rectifying it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100807

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


[PATCH] D101317: hurd: Fix i386 research path

2021-04-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

`i386-gnu` no longer exists? That's great.




Comment at: clang/test/Driver/hurd.c:2
 // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
 // RUN: --target=i386-pc-gnu \
 // RUN: --sysroot=%S/Inputs/basic_hurd_tree \

While we currently detects several aliases, it'd be good that clang driver 
doesn't need to do so.

i686-gnu may be preferred (matching the `lib/gcc/$triple` name).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101317

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


[PATCH] D101331: hurd: Detect libstdc++ include paths on Debian Hurd i386

2021-04-27 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul updated this revision to Diff 340871.
sthibaul marked 2 inline comments as done.
sthibaul added a comment.

Rather use i686-gnu triplet


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101331

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Hurd.h
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/c++/4.6.0/.keep
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/i386-gnu/c++/4.6.0/.keep
  clang/test/Driver/hurd.c
  clang/test/Driver/hurd.cpp

Index: clang/test/Driver/hurd.cpp
===
--- /dev/null
+++ clang/test/Driver/hurd.cpp
@@ -0,0 +1,98 @@
+// UNSUPPORTED: system-windows
+
+// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN: --target=i686-pc-hurd-gnu \
+// RUN: --sysroot=%S/Inputs/basic_hurd_tree \
+// RUN:   | FileCheck --check-prefix=CHECK %s
+// CHECK: "-cc1"
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0"
+/// Debian specific - the path component after 'include' is i386-gnu even
+/// though the installation is i686-gnu.
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/i386-gnu/c++/4.6.0"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0/backward"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK: "-internal-externc-isystem"
+// CHECK-SAME: {{^}} "[[SYSROOT]]/usr/include/i386-gnu"
+// CHECK-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK: "-dynamic-linker" "/lib/ld.so"
+// CHECK: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbegin.o"
+// CHECK: "-L
+// CHECK-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../lib32"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib/i386-gnu"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib/../lib32"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/i386-gnu"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/../lib32"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
+
+// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN: --target=i686-pc-hurd-gnu -static \
+// RUN: --sysroot=%S/Inputs/basic_hurd_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-STATIC %s
+// CHECK-STATIC: "-cc1"
+// CHECK-STATIC: "-static-define"
+// CHECK-STATIC: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0"
+/// Debian specific - the path component after 'include' is i386-gnu even
+/// though the installation is i686-gnu.
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/i386-gnu/c++/4.6.0"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0/backward"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-STATIC: "-internal-externc-isystem"
+// CHECK-STATIC-SAME: {{^}} "[[SYSROOT]]/usr/include/i386-gnu"
+// CHECK-STATIC-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-STATIC-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// CHECK-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-STATIC: "-static"
+// CHECK-STATIC: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbeginT.o"
+// CHECK-STATIC: "-L
+// CHECK-STATIC-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../lib32"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/lib/i386-gnu"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/lib/../lib32"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/i386-gnu"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/../lib32"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/lib"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
+
+// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN: --target=i686-pc-hurd-gnu -shared \
+// RUN: --sysroot=%S/Inputs/basic_hurd_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-SHARED %s
+// CHECK-SHARED: "-cc1"
+// CHECK-SHARED: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-SHARED-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0"
+/// Debian specific - the path component after 'include' is i386-gnu even
+/// though the installation is i686-gnu.
+// CHECK-SHARED-SAME: {{^}} "-internal-isystem

[PATCH] D101317: hurd: Fix i386 research path

2021-04-27 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul updated this revision to Diff 340875.
sthibaul marked an inline comment as done.
sthibaul added a comment.

Fix triplet


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101317

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/as
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/ld
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/lib/.keep
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i686-gnu/bin/as
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i686-gnu/bin/ld
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i686-gnu/lib/.keep
  
clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbegin.o
  
clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbegin.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbegin.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbeginS.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbeginT.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbegin.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbeginS.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbeginT.o
  clang/test/Driver/hurd.c


Index: clang/test/Driver/hurd.c
===
--- clang/test/Driver/hurd.c
+++ clang/test/Driver/hurd.c
@@ -1,5 +1,5 @@
 // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
-// RUN: --target=i386-pc-gnu \
+// RUN: --target=i686-pc-hurd-gnu \
 // RUN: --sysroot=%S/Inputs/basic_hurd_tree \
 // RUN:   | FileCheck --check-prefix=CHECK %s
 // CHECK-NOT: warning:
@@ -11,7 +11,7 @@
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 // CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK: "-dynamic-linker" "/lib/ld.so"
-// CHECK: "{{.*}}/usr/lib/gcc/i386-gnu/4.6.0{{/|}}crtbegin.o"
+// CHECK: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbegin.o"
 // CHECK: "-L[[SYSROOT]]/lib/i386-gnu"
 // CHECK: "-L[[SYSROOT]]/lib/../lib32"
 // CHECK: "-L[[SYSROOT]]/usr/lib/i386-gnu"
@@ -20,7 +20,7 @@
 // CHECK: "-L[[SYSROOT]]/usr/lib"
 
 // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
-// RUN: --target=i386-pc-gnu -static \
+// RUN: --target=i686-pc-hurd-gnu -static \
 // RUN: --sysroot=%S/Inputs/basic_hurd_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-STATIC %s
 // CHECK-STATIC-NOT: warning:
@@ -33,7 +33,7 @@
 // CHECK-STATIC: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 // CHECK-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-STATIC: "-static"
-// CHECK-STATIC: "{{.*}}/usr/lib/gcc/i386-gnu/4.6.0{{/|}}crtbeginT.o"
+// CHECK-STATIC: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbeginT.o"
 // CHECK-STATIC: "-L[[SYSROOT]]/lib/i386-gnu"
 // CHECK-STATIC: "-L[[SYSROOT]]/lib/../lib32"
 // CHECK-STATIC: "-L[[SYSROOT]]/usr/lib/i386-gnu"
@@ -42,7 +42,7 @@
 // CHECK-STATIC: "-L[[SYSROOT]]/usr/lib"
 
 // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
-// RUN: --target=i386-pc-gnu -shared \
+// RUN: --target=i686-pc-hurd-gnu -shared \
 // RUN: --sysroot=%S/Inputs/basic_hurd_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-SHARED %s
 // CHECK-SHARED-NOT: warning:
@@ -53,7 +53,7 @@
 // CHECK-SHARED: "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-SHARED: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 // CHECK-SHARED: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK-SHARED: "{{.*}}/usr/lib/gcc/i386-gnu/4.6.0{{/|}}crtbeginS.o"
+// CHECK-SHARED: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbeginS.o"
 // CHECK-SHARED: "-L[[SYSROOT]]/lib/i386-gnu"
 // CHECK-SHARED: "-L[[SYSROOT]]/lib/../lib32"
 // CHECK-SHARED: "-L[[SYSROOT]]/usr/lib/i386-gnu"
@@ -63,11 +63,11 @@
 
 // RUN: %clang -### -o %t %s 2>&1 -no-integrated-as -fuse-ld=ld \
 // RUN: --gcc-toolchain=%S/Inputs/basic_cross_hurd_tree/usr \
-// RUN: --target=i386-pc-gnu \
+// RUN: --target=i686-pc-hurd-gnu \
 // RUN:   | FileCheck --check-prefix=CHECK-CROSS %s
 // CHECK-CROSS-NOT: warning:
-// CHECK-CROSS: "-cc1" "-triple" "i386-pc-hurd-gnu"
-// CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/../../../../i386-gnu/bin{{/|}}as"
 "--32"
-// CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/../../../../i386-gnu/bin{{/|}}ld"
 {{.*}} "-m" "elf_i386"
-// CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0{{/|}}crtbegin.o"
-// CHECK-CROSS: 
"-L{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/../../../../i386-gnu/lib"
+// CHECK-CROSS: "-cc1" "-triple" "i686-pc-hurd-gnu"
+// CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/../../../../i

[PATCH] D101317: hurd: Fix i386 research path

2021-04-27 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul added inline comments.



Comment at: clang/test/Driver/hurd.c:2
 // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
 // RUN: --target=i386-pc-gnu \
 // RUN: --sysroot=%S/Inputs/basic_hurd_tree \

MaskRay wrote:
> While we currently detects several aliases, it'd be good that clang driver 
> doesn't need to do so.
> 
> i686-gnu may be preferred (matching the `lib/gcc/$triple` name).
Ok, updated so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101317

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


[PATCH] D101331: hurd: Detect libstdc++ include paths on Debian Hurd i386

2021-04-27 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul updated this revision to Diff 340878.
sthibaul added a comment.

Rebase on newer D101317 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101331

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Hurd.h
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/c++/4.6.0/.keep
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/i386-gnu/c++/4.6.0/.keep
  clang/test/Driver/hurd.c
  clang/test/Driver/hurd.cpp

Index: clang/test/Driver/hurd.cpp
===
--- /dev/null
+++ clang/test/Driver/hurd.cpp
@@ -0,0 +1,98 @@
+// UNSUPPORTED: system-windows
+
+// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN: --target=i686-pc-hurd-gnu \
+// RUN: --sysroot=%S/Inputs/basic_hurd_tree \
+// RUN:   | FileCheck --check-prefix=CHECK %s
+// CHECK: "-cc1"
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0"
+/// Debian specific - the path component after 'include' is i386-gnu even
+/// though the installation is i686-gnu.
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/i386-gnu/c++/4.6.0"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0/backward"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK: "-internal-externc-isystem"
+// CHECK-SAME: {{^}} "[[SYSROOT]]/usr/include/i386-gnu"
+// CHECK-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK: "-dynamic-linker" "/lib/ld.so"
+// CHECK: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbegin.o"
+// CHECK: "-L
+// CHECK-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../lib32"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib/i386-gnu"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib/../lib32"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/i386-gnu"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/../lib32"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
+
+// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN: --target=i686-pc-hurd-gnu -static \
+// RUN: --sysroot=%S/Inputs/basic_hurd_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-STATIC %s
+// CHECK-STATIC: "-cc1"
+// CHECK-STATIC: "-static-define"
+// CHECK-STATIC: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0"
+/// Debian specific - the path component after 'include' is i386-gnu even
+/// though the installation is i686-gnu.
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/i386-gnu/c++/4.6.0"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0/backward"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-STATIC: "-internal-externc-isystem"
+// CHECK-STATIC-SAME: {{^}} "[[SYSROOT]]/usr/include/i386-gnu"
+// CHECK-STATIC-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-STATIC-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// CHECK-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-STATIC: "-static"
+// CHECK-STATIC: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbeginT.o"
+// CHECK-STATIC: "-L
+// CHECK-STATIC-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../lib32"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/lib/i386-gnu"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/lib/../lib32"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/i386-gnu"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/../lib32"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/lib"
+// CHECK-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
+
+// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN: --target=i686-pc-hurd-gnu -shared \
+// RUN: --sysroot=%S/Inputs/basic_hurd_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-SHARED %s
+// CHECK-SHARED: "-cc1"
+// CHECK-SHARED: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-SHARED-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0"
+/// Debian specific - the path component after 'include' is i386-gnu even
+/// though the installation is i686-gnu.
+// CHECK-SHARED-SAME: {{^}} "-internal-isystem" "[[SYSROOT

[PATCH] D101347: hurd: Clean up test

2021-04-27 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul updated this revision to Diff 340879.
sthibaul added a comment.

Rebase on refreshed D101331 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101347

Files:
  
clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/10/crtbegin.o
  
clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbegin.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/c++/10/.keep
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/c++/4.6.0/.keep
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/i386-gnu/c++/10/.keep
  clang/test/Driver/Inputs/basic_hurd_tree/usr/include/i386-gnu/c++/4.6.0/.keep
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/10/crtbegin.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/10/crtbeginS.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/10/crtbeginT.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbegin.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbeginS.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbeginT.o
  clang/test/Driver/hurd.cpp

Index: clang/test/Driver/hurd.cpp
===
--- clang/test/Driver/hurd.cpp
+++ clang/test/Driver/hurd.cpp
@@ -6,22 +6,22 @@
 // RUN:   | FileCheck --check-prefix=CHECK %s
 // CHECK: "-cc1"
 // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
-// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/c++/10"
 /// Debian specific - the path component after 'include' is i386-gnu even
 /// though the installation is i686-gnu.
-// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/i386-gnu/c++/4.6.0"
-// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0/backward"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/i386-gnu/c++/10"
+// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/c++/10/backward"
 // CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include"
 // CHECK: "-internal-externc-isystem"
 // CHECK-SAME: {{^}} "[[SYSROOT]]/usr/include/i386-gnu"
 // CHECK-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
-// CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK: "{{.*}}ld" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK: "-dynamic-linker" "/lib/ld.so"
-// CHECK: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbegin.o"
+// CHECK: "{{.*}}/usr/lib/gcc/i686-gnu/10/crtbegin.o"
 // CHECK: "-L
-// CHECK-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0"
-// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../lib32"
+// CHECK-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/i686-gnu/10"
+// CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../lib32"
 // CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib/i386-gnu"
 // CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib/../lib32"
 // CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/i386-gnu"
@@ -36,22 +36,22 @@
 // CHECK-STATIC: "-cc1"
 // CHECK-STATIC: "-static-define"
 // CHECK-STATIC: "-isysroot" "[[SYSROOT:[^"]+]]"
-// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/c++/10"
 /// Debian specific - the path component after 'include' is i386-gnu even
 /// though the installation is i686-gnu.
-// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/i386-gnu/c++/4.6.0"
-// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/4.6.0/../../../../include/c++/4.6.0/backward"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/i386-gnu/c++/10"
+// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/c++/10/backward"
 // CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include"
 // CHECK-STATIC: "-internal-externc-isystem"
 // CHECK-STATIC-SAME: {{^}} "[[SYSROOT]]/usr/include/i386-gnu"
 // CHECK-STATIC-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-STATIC-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
-// CHECK-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-STATIC: "{{.*}}ld" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-STATIC: "-static"
-// CHECK-STATIC: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbeginT.o"
+// CHE

[PATCH] D101378: [llvm, clang] Remove stdlib includes from .h files without `std::`

2021-04-27 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: hans.
Herald added a subscriber: arphaman.
thakis requested review of this revision.
Herald added a project: LLVM.

Found files not containing `std::` with:

  
INCL="algorithm|array|list|map|memory|queue|set|string|utility|vector|unordered_map|unordered_set"
  git ls-files llvm/include/llvm | grep '\.h$' | xargs grep -L std:: | \
  xargs grep -El "#include <($INCL)>$" > to_process.txt
  git ls-files clang/include/clang | grep '\.h$' | xargs grep -L std:: | \
  xargs grep -El "#include <($INCL)>$" >> to_process.txt

Then removed these headers from those files with

  INCL_ESCAPED="$(echo $INCL|sed 's/|/\\|/g')"
  cat to_process.txt | xargs sed -i "/^#include <\($INCL_ESCAPED\)>$/d"
  cat to_process.txt | xargs sed -i '/^$/N;/^\n$/D'

No behavior change.


https://reviews.llvm.org/D101378

Files:
  clang/include/clang/AST/DeclContextInternals.h
  clang/include/clang/Driver/Options.h
  clang/include/clang/Index/CommentToXML.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
  clang/include/clang/Tooling/Refactoring/RefactoringActionRule.h
  clang/include/clang/Tooling/Transformer/Parsing.h
  llvm/include/llvm/CodeGen/MachineInstrBuilder.h
  llvm/include/llvm/CodeGen/TileShapeInfo.h
  llvm/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h
  llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
  llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h
  llvm/include/llvm/DebugInfo/GSYM/FileEntry.h
  llvm/include/llvm/DebugInfo/GSYM/StringTable.h
  llvm/include/llvm/ExecutionEngine/Orc/OrcABISupport.h
  llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h
  llvm/include/llvm/Target/CGPassBuilderOption.h
  llvm/include/llvm/Transforms/Scalar/SpeculateAroundPHIs.h

Index: llvm/include/llvm/Transforms/Scalar/SpeculateAroundPHIs.h
===
--- llvm/include/llvm/Transforms/Scalar/SpeculateAroundPHIs.h
+++ llvm/include/llvm/Transforms/Scalar/SpeculateAroundPHIs.h
@@ -15,7 +15,6 @@
 #include "llvm/IR/Function.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Support/Compiler.h"
-#include 
 
 namespace llvm {
 
Index: llvm/include/llvm/Target/CGPassBuilderOption.h
===
--- llvm/include/llvm/Target/CGPassBuilderOption.h
+++ llvm/include/llvm/Target/CGPassBuilderOption.h
@@ -17,7 +17,6 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Target/TargetOptions.h"
-#include 
 
 namespace llvm {
 class TargetMachine;
Index: llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h
===
--- llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h
+++ llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h
@@ -16,7 +16,6 @@
 
 #include "llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h"
 #include "llvm/Support/Error.h"
-#include 
 
 namespace llvm {
 namespace orc {
Index: llvm/include/llvm/ExecutionEngine/Orc/OrcABISupport.h
===
--- llvm/include/llvm/ExecutionEngine/Orc/OrcABISupport.h
+++ llvm/include/llvm/ExecutionEngine/Orc/OrcABISupport.h
@@ -21,7 +21,6 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MathExtras.h"
-#include 
 #include 
 
 namespace llvm {
Index: llvm/include/llvm/DebugInfo/GSYM/StringTable.h
===
--- llvm/include/llvm/DebugInfo/GSYM/StringTable.h
+++ llvm/include/llvm/DebugInfo/GSYM/StringTable.h
@@ -13,8 +13,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/DebugInfo/GSYM/Range.h"
 #include 
-#include 
-
 
 namespace llvm {
 namespace gsym {
Index: llvm/include/llvm/DebugInfo/GSYM/FileEntry.h
===
--- llvm/include/llvm/DebugInfo/GSYM/FileEntry.h
+++ llvm/include/llvm/DebugInfo/GSYM/FileEntry.h
@@ -13,7 +13,6 @@
 #include "llvm/ADT/Hashing.h"
 #include 
 #include 
-#include 
 
 namespace llvm {
 namespace gsym {
Index: llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h
===
--- llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h
+++ llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h
@@ -19,7 +19,6 @@
 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
 #include "llvm/Support/Allocator.h"
 #include 
-#include 
 
 namespace llvm {
 namespace codeview {
Index: llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
===
--- llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
+++ llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
@@ -20,7 +20,6 @@
 #include "llvm/Support/Allocator.h"
 #include 
 

[PATCH] D99975: [clangd][ObjC] Improve support for class properties

2021-04-27 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 340885.
dgoldman marked 2 inline comments as done.
dgoldman added a comment.

Fixes for review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99975

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -969,6 +969,33 @@
   )cpp";
   // FIXME: We currently can't disambiguate between multiple protocols.
   EXPECT_DECLS("ObjCObjectTypeLoc", "@protocol Foo", "@protocol Bar");
+
+  Code = R"cpp(
+@interface Foo
++ (id)sharedInstance;
+@end
+@implementation Foo
++ (id)sharedInstance { return 0; }
+@end
+void test() {
+  id value = [[Foo]].sharedInstance;
+}
+  )cpp";
+  // FIXME: We currently can't identify the interface here.
+  EXPECT_DECLS("ObjCPropertyRefExpr", "+ (id)sharedInstance");
+
+  Code = R"cpp(
+@interface Foo
++ (id)sharedInstance;
+@end
+@implementation Foo
++ (id)sharedInstance { return 0; }
+@end
+void test() {
+  id value = Foo.[[sharedInstance]];
+}
+  )cpp";
+  EXPECT_DECLS("ObjCPropertyRefExpr", "+ (id)sharedInstance");
 }
 
 class FindExplicitReferencesTest : public ::testing::Test {
@@ -1610,6 +1637,41 @@
"0: targets = {f}\n"
"1: targets = {I::x}\n"
"2: targets = {I::setY:}\n"},
+   // Objective-C: class properties
+   {
+   R"cpp(
+@interface I {}
+@property(class) I *x;
+@end
+id local;
+void foo() {
+  $0^I.$1^x = 0;
+  $2^local = $3^I.$4^x;
+}
+  )cpp",
+   "0: targets = {I}\n"
+   "1: targets = {I::setX:}\n"
+   "2: targets = {local}\n"
+   "3: targets = {I}\n"
+   "4: targets = {I::x}\n"},
+   // Objective-C: implicit class properties
+   {
+   R"cpp(
+@interface I {}
++(I*)x;
++(void)setX:(I*)x;
+@end
+id local;
+void foo() {
+  $0^I.$1^x = 0;
+  $2^local = $3^I.$4^x;
+}
+  )cpp",
+   "0: targets = {I}\n"
+   "1: targets = {I::setX:}\n"
+   "2: targets = {local}\n"
+   "3: targets = {I}\n"
+   "4: targets = {I::x}\n"},
{// Objective-C: methods
 R"cpp(
 @interface I
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -306,6 +306,9 @@
 Outer.add(OME->getMethodDecl(), Flags);
   }
   void VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *OPRE) {
+// FIXME: We miss visiting the class receiver if one exists, which
+// means we skip the corresponding ObjCInterfaceDecl ref since it
+// doesn't have a corresponding node.
 if (OPRE->isExplicitProperty())
   Outer.add(OPRE->getExplicitProperty(), Flags);
 else {
@@ -763,6 +766,13 @@
 }
 
 void VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *E) {
+  // There's no contained TypeLoc node for a class receiver type.
+  if (E->isClassReceiver()) {
+Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+E->getReceiverLocation(),
+/*IsDecl=*/false,
+{E->getClassReceiver()}});
+  }
   Refs.push_back(ReferenceLoc{
   NestedNameSpecifierLoc(), E->getLocation(),
   /*IsDecl=*/false,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101191: [InstCombine] Fully disable select to and/or i1 folding

2021-04-27 Thread Juneyoung Lee via Phabricator via cfe-commits
aqjune added inline comments.



Comment at: llvm/test/Transforms/InstCombine/logical-select.ll:385
+; CHECK-NEXT:[[OR:%.*]] = select i1 [[AND1]], i1 true, i1 [[AND2]]
+; CHECK-NEXT:ret i1 [[OR]]
 ;

nikic wrote:
> aqjune wrote:
> > nikic wrote:
> > > It looks like this fold could be salvaged, if we wanted to: 
> > > https://alive2.llvm.org/ce/z/TpsYAj
> > Thx, I added the transformation.
> > If the transformations look good, I'll make it as a separate commit with 
> > tests and push it.
> Could you please split it off into a separate review? Hard to understand 
> impact as part of this change.
It is splitted into D101375



Comment at: 
llvm/test/Transforms/PhaseOrdering/unsigned-multiply-overflow-check.ll:20
 
+; FIXME: noundef should be attached to args
 define i1 @will_not_overflow(i64 %arg, i64 %arg1) {

spatel wrote:
> Any ideas about what it will take to get those argument attributes for the 
> C++ source example shown in the code comment?
> 
> SDAG is still going to convert the `select` to `and`, so we can probably 
> avoid regressions by replicating InstSimplify's 
> omitCheckForZeroBeforeMulWithOverflow() as a DAG combine. Let me know if I 
> should do that.
I promised to do the patch at D82317, but these days I'm occupied with other 
things, so it might not be a recent future (not in a month at least)...

I think it is a good chance to use freeze here: We can add
```
%cond = icmp ne %x, 0
%v = call @llvm.umul.with.overflow(%x, %y)
%ov = extractvalue %v, 1
%res = select i1 %cond, %ov, false
  =>
%y.fr = freeze %y
%v = call @llvm.umul.with.overflow(%x, %y.fr)
%ov = extractvalue %v, 1
%res = %ov
```
into CodeGenPrepare.
What do you think? CodeGenPrepare is already using freeze for a few 
transformations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101191

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


[PATCH] D101378: [llvm, clang] Remove stdlib includes from .h files without `std::`

2021-04-27 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks accepted this revision.
aeubanks added a comment.
This revision is now accepted and ready to land.

lgtm


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

https://reviews.llvm.org/D101378

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


  1   2   3   >