[PATCH] D113676: WIP: [clang][lex] Fix search path usage remark with modules

2021-11-11 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 386749.
jansvoboda11 added a comment.

Add extra test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113676

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/Preprocessor/search-path-usage-modules.m
  clang/test/Preprocessor/search-path-usage.m

Index: clang/test/Preprocessor/search-path-usage.m
===
--- clang/test/Preprocessor/search-path-usage.m
+++ clang/test/Preprocessor/search-path-usage.m
@@ -128,19 +128,3 @@
 // expected-remark-re {{search path used: '{{.*}}/b-missing.hmap'}}
 #endif
 #endif
-
-// Check that search paths with module maps are reported.
-//
-// RUN: mkdir %t/modulemap_abs
-// RUN: sed "s|DIR|%/S/Inputs/search-path-usage|g"\
-// RUN:   %S/Inputs/search-path-usage/modulemap_abs/module.modulemap.template \
-// RUN: > %t/modulemap_abs/module.modulemap
-// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage   \
-// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules \
-// RUN:   -I %t/modulemap_abs  \
-// RUN:   -I %S/Inputs/search-path-usage/a \
-// RUN:   -DMODMAP_ABS -verify
-#ifdef MODMAP_ABS
-@import b; // \
-// expected-remark-re {{search path used: '{{.*}}/modulemap_abs'}}
-#endif
Index: clang/test/Preprocessor/search-path-usage-modules.m
===
--- /dev/null
+++ clang/test/Preprocessor/search-path-usage-modules.m
@@ -0,0 +1,40 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -Eonly %t/test-both.m   -I %t/sp1 -I %t/sp2 -Rsearch-path-usage \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache 2>&1 | FileCheck %t/test-both.m
+// RUN: %clang_cc1 -Eonly %t/test-both.m   -I %t/sp2 -I %t/sp1 -Rsearch-path-usage \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache 2>&1 | FileCheck %t/test-both.m
+
+// RUN: %clang_cc1 -Eonly %t/test-first.m  -I %t/sp2 -I %t/sp1 -Rsearch-path-usage \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache 2>&1 | FileCheck %t/test-first.m
+// RUN: %clang_cc1 -Eonly %t/test-second.m -I %t/sp1 -I %t/sp2 -Rsearch-path-usage \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache 2>&1 | FileCheck %t/test-second.m
+
+//--- sp1/module.modulemap
+module mod1 { header "mod1.h" }
+//--- sp1/mod1.h
+int module1();
+
+//--- sp2/module.modulemap
+module mod2 { header "mod2.h" }
+//--- sp2/mod2.h
+int module2();
+
+//--- test-both.m
+@import mod1;
+@import mod2;
+// CHECK: search path used: '{{.*}}/sp1'
+// CHECK: search path used: '{{.*}}/sp2'
+
+//--- test-first.m
+@import mod1;
+// CHECK-NOT: search path used: '{{.*}}/sp2'
+// CHECK: search path used: '{{.*}}/sp1'
+// CHECK-NOT: search path used: '{{.*}}/sp2'
+
+//--- test-second.m
+@import mod2;
+// CHECK-NOT: search path used: '{{.*}}/sp1'
+// CHECK: search path used: '{{.*}}/sp2'
+// CHECK-NOT: search path used: '{{.*}}/sp1'
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -3908,7 +3908,7 @@
 // An implicitly-loaded module file should have its module listed in some
 // module map file that we've already loaded.
 Module *M =
-PP.getHeaderSearchInfo().lookupModule(F.ModuleName, F.ImportLoc);
+PP.getHeaderSearchInfo().lookupModule(F.ModuleName, SourceLocation());
 auto  = PP.getHeaderSearchInfo().getModuleMap();
 const FileEntry *ModMap = M ? Map.getModuleMapFileForUniquing(M) : nullptr;
 // Don't emit module relocation error if we have -fno-validate-pch
Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -824,6 +824,8 @@
   // Create a new module with this name.
   Module *Result = new Module(Name, SourceLocation(), Parent, IsFramework,
   IsExplicit, NumCreatedModules++);
+  for (const auto  : Callbacks)
+Callback->moduleMapModuleCreated(Result);
   if (!Parent) {
 if (LangOpts.CurrentModule == Name)
   SourceModule = Result;
@@ -1023,6 +1025,8 @@
   Module *Result = new Module(ModuleName, SourceLocation(), Parent,
   /*IsFramework=*/true, /*IsExplicit=*/false,
   NumCreatedModules++);
+  for (const auto  : Callbacks)
+Callback->moduleMapModuleCreated(Result);
   InferredModuleAllowedBy[Result] = ModuleMapFile;
   Result->IsInferred = true;
   if (!Parent) {

[PATCH] D113738: [LTO] Allow passing -Os/-Oz as the optimization level

2021-11-11 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 386748.
aeubanks added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113738

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  lld/COFF/Config.h
  lld/COFF/Driver.cpp
  lld/Common/Args.cpp
  lld/Common/CMakeLists.txt
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/LTO.cpp
  lld/MachO/Config.h
  lld/MachO/Driver.cpp
  lld/include/lld/Common/Args.h
  lld/test/COFF/lto-opt-level.ll
  lld/test/ELF/lto/opt-level.ll
  lld/test/MachO/lto-opt-level.ll
  lld/test/wasm/lto/opt-level.ll
  lld/wasm/Config.h
  lld/wasm/Driver.cpp
  llvm/include/llvm/LTO/Config.h
  llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
  llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
  llvm/include/llvm/Passes/OptimizationLevel.h
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp
  llvm/tools/lto/lto.cpp
  llvm/utils/gn/secondary/lld/Common/BUILD.gn

Index: llvm/utils/gn/secondary/lld/Common/BUILD.gn
===
--- llvm/utils/gn/secondary/lld/Common/BUILD.gn
+++ llvm/utils/gn/secondary/lld/Common/BUILD.gn
@@ -27,6 +27,7 @@
 "//llvm/lib/IR",
 "//llvm/lib/MC",
 "//llvm/lib/Option",
+"//llvm/lib/Passes",
 "//llvm/lib/Support",
 "//llvm/lib/Target",
   ]
Index: llvm/tools/lto/lto.cpp
===
--- llvm/tools/lto/lto.cpp
+++ llvm/tools/lto/lto.cpp
@@ -23,6 +23,7 @@
 #include "llvm/LTO/legacy/LTOCodeGenerator.h"
 #include "llvm/LTO/legacy/LTOModule.h"
 #include "llvm/LTO/legacy/ThinLTOCodeGenerator.h"
+#include "llvm/Passes/OptimizationLevel.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
@@ -34,12 +35,10 @@
 
 // extra command-line flags needed for LTOCodeGenerator
 static cl::opt
-OptLevel("O",
- cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
-  "(default = '-O2')"),
- cl::Prefix,
- cl::ZeroOrMore,
- cl::init('2'));
+OptLevel("O",
+ cl::desc("Optimization level. [-O0, -O1, -O2, -O3, -Os, or -Oz] "
+  "(default = '-O2')"),
+ cl::Prefix, cl::ZeroOrMore, cl::init('2'));
 
 static cl::opt EnableFreestanding(
 "lto-freestanding", cl::init(false),
@@ -152,9 +151,10 @@
   LTOCodeGenerator *CG = unwrap(cg);
   CG->setAttrs(codegen::getMAttrs());
 
-  if (OptLevel < '0' || OptLevel > '3')
-report_fatal_error("Optimization level must be between 0 and 3");
-  CG->setOptLevel(OptLevel - '0');
+  Optional OL = OptimizationLevel::forChar(OptLevel);
+  if (!OL)
+report_fatal_error("invalid optimization level: -O" + Twine(OptLevel));
+  CG->setOptLevel(*OL);
   CG->setFreestanding(EnableFreestanding);
   CG->setDisableVerify(DisableVerify);
 }
@@ -525,20 +525,21 @@
   CodeGen->setFreestanding(EnableFreestanding);
 
   if (OptLevel.getNumOccurrences()) {
-if (OptLevel < '0' || OptLevel > '3')
-  report_fatal_error("Optimization level must be between 0 and 3");
-CodeGen->setOptLevel(OptLevel - '0');
-switch (OptLevel) {
-case '0':
+Optional OL = OptimizationLevel::forChar(OptLevel);
+if (!OL)
+  report_fatal_error("Invalid optimization level: " + Twine(OptLevel));
+CodeGen->setOptLevel(*OL);
+switch (OL->getSpeedupLevel()) {
+case 0:
   CodeGen->setCodeGenOptLevel(CodeGenOpt::None);
   break;
-case '1':
+case 1:
   CodeGen->setCodeGenOptLevel(CodeGenOpt::Less);
   break;
-case '2':
+case 2:
   CodeGen->setCodeGenOptLevel(CodeGenOpt::Default);
   break;
-case '3':
+case 3:
   CodeGen->setCodeGenOptLevel(CodeGenOpt::Aggressive);
   break;
 }
Index: llvm/tools/llvm-lto2/llvm-lto2.cpp
===
--- llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -20,6 +20,7 @@
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/DiagnosticPrinter.h"
 #include "llvm/LTO/LTO.h"
+#include "llvm/Passes/OptimizationLevel.h"
 #include "llvm/Passes/PassPlugin.h"
 #include "llvm/Remarks/HotnessThresholdParser.h"
 #include "llvm/Support/Caching.h"
@@ -36,8 +37,9 @@
 static codegen::RegisterCodeGenFlags CGF;
 
 static cl::opt
-OptLevel("O", cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
-   "(default = '-O2')"),
+OptLevel("O",
+ cl::desc("Optimization level. [-O0, -O1, -O2, -O3, -Os, or -Oz] "
+  "(default = '-O2')"),
  cl::Prefix, cl::ZeroOrMore, cl::init('2'));
 
 static cl::opt CGOptLevel(
@@ -272,7 +274,12 @@
   Conf.OptPipeline = OptPipeline;
   Conf.AAPipeline = AAPipeline;
 
-  Conf.OptLevel = 

[PATCH] D112921: [clang] Enable sized deallocation by default in C++14 onwards

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

Is this going to be reviewed again or committed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112921

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


[PATCH] D8467: C++14: Disable sized deallocation by default due to ABI breakage

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

In D8467#3125313 , @tstellar wrote:

> In D8467#3095610 , @zixuan-wu wrote:
>
>> Hi, I am wondering could -fsized-deallocation this be enabled by default 
>> nowadays in 2021?
>
> Were you planning to work on this?

It's been working on at https://reviews.llvm.org/D112921


Repository:
  rL LLVM

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

https://reviews.llvm.org/D8467

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


[PATCH] D113738: [LTO] Allow passing -Os/-Oz as the optimization level

2021-11-11 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
Herald added subscribers: ormris, steven_wu, hiraditya, arichardson, inglorion, 
sbc100, mgorny, emaste.
Herald added a reviewer: MaskRay.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
aeubanks requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, aheejin.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113738

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  lld/COFF/Config.h
  lld/COFF/Driver.cpp
  lld/Common/Args.cpp
  lld/Common/CMakeLists.txt
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/LTO.cpp
  lld/MachO/Config.h
  lld/MachO/Driver.cpp
  lld/include/lld/Common/Args.h
  lld/test/COFF/lto-opt-level.ll
  lld/test/ELF/lto/opt-level.ll
  lld/test/MachO/lto-opt-level.ll
  lld/test/wasm/lto/opt-level.ll
  lld/wasm/Config.h
  lld/wasm/Driver.cpp
  llvm/include/llvm/LTO/Config.h
  llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
  llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
  llvm/include/llvm/Passes/OptimizationLevel.h
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp
  llvm/tools/lto/lto.cpp
  llvm/utils/gn/secondary/lld/Common/BUILD.gn

Index: llvm/utils/gn/secondary/lld/Common/BUILD.gn
===
--- llvm/utils/gn/secondary/lld/Common/BUILD.gn
+++ llvm/utils/gn/secondary/lld/Common/BUILD.gn
@@ -27,6 +27,7 @@
 "//llvm/lib/IR",
 "//llvm/lib/MC",
 "//llvm/lib/Option",
+"//llvm/lib/Passes",
 "//llvm/lib/Support",
 "//llvm/lib/Target",
   ]
Index: llvm/tools/lto/lto.cpp
===
--- llvm/tools/lto/lto.cpp
+++ llvm/tools/lto/lto.cpp
@@ -23,6 +23,7 @@
 #include "llvm/LTO/legacy/LTOCodeGenerator.h"
 #include "llvm/LTO/legacy/LTOModule.h"
 #include "llvm/LTO/legacy/ThinLTOCodeGenerator.h"
+#include "llvm/Passes/OptimizationLevel.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
@@ -34,12 +35,10 @@
 
 // extra command-line flags needed for LTOCodeGenerator
 static cl::opt
-OptLevel("O",
- cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
-  "(default = '-O2')"),
- cl::Prefix,
- cl::ZeroOrMore,
- cl::init('2'));
+OptLevel("O",
+ cl::desc("Optimization level. [-O0, -O1, -O2, -O3, -Os, or -Oz] "
+  "(default = '-O2')"),
+ cl::Prefix, cl::ZeroOrMore, cl::init('2'));
 
 static cl::opt EnableFreestanding(
 "lto-freestanding", cl::init(false),
@@ -152,9 +151,10 @@
   LTOCodeGenerator *CG = unwrap(cg);
   CG->setAttrs(codegen::getMAttrs());
 
-  if (OptLevel < '0' || OptLevel > '3')
-report_fatal_error("Optimization level must be between 0 and 3");
-  CG->setOptLevel(OptLevel - '0');
+  Optional OL = OptimizationLevel::forChar(OptLevel);
+  if (!OL)
+report_fatal_error("invalid optimization level: -O" + Twine(OptLevel));
+  CG->setOptLevel(*OL);
   CG->setFreestanding(EnableFreestanding);
   CG->setDisableVerify(DisableVerify);
 }
@@ -525,20 +525,21 @@
   CodeGen->setFreestanding(EnableFreestanding);
 
   if (OptLevel.getNumOccurrences()) {
-if (OptLevel < '0' || OptLevel > '3')
-  report_fatal_error("Optimization level must be between 0 and 3");
-CodeGen->setOptLevel(OptLevel - '0');
-switch (OptLevel) {
-case '0':
+Optional OL = OptimizationLevel::forChar(OptLevel);
+if (!OL)
+  report_fatal_error("Invalid optimization level: " + Twine(OptLevel));
+CodeGen->setOptLevel(*OL);
+switch (OL->getSpeedupLevel()) {
+case 0:
   CodeGen->setCodeGenOptLevel(CodeGenOpt::None);
   break;
-case '1':
+case 1:
   CodeGen->setCodeGenOptLevel(CodeGenOpt::Less);
   break;
-case '2':
+case 2:
   CodeGen->setCodeGenOptLevel(CodeGenOpt::Default);
   break;
-case '3':
+case 3:
   CodeGen->setCodeGenOptLevel(CodeGenOpt::Aggressive);
   break;
 }
Index: llvm/tools/llvm-lto2/llvm-lto2.cpp
===
--- llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -20,6 +20,7 @@
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/DiagnosticPrinter.h"
 #include "llvm/LTO/LTO.h"
+#include "llvm/Passes/OptimizationLevel.h"
 #include "llvm/Passes/PassPlugin.h"
 #include "llvm/Remarks/HotnessThresholdParser.h"
 #include "llvm/Support/Caching.h"
@@ -36,8 +37,9 @@
 static codegen::RegisterCodeGenFlags CGF;
 
 static cl::opt
-OptLevel("O", cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
-   "(default = '-O2')"),
+OptLevel("O",
+ cl::desc("Optimization level. [-O0, -O1, -O2, -O3, 

[PATCH] D113455: [clang][objc][codegen] Skip emitting ObjC category metadata when the category is empty

2021-11-11 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: clang/lib/CodeGen/CGObjCMac.cpp:6713
   }
 
+  unsigned Size =

Is it not possible to check whether the category is empty here? If it's empty, 
you can avoid creating the global variable and abandon the builder.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113455

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


[PATCH] D110216: [clang] retain type sugar in auto / template argument deduction

2021-11-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

This change seems to have broken two libc++ tests:

  libc++ :: std/utilities/any/any.nonmembers/any.cast/const_correctness.fail.cpp
  
  Script:
  --
  : 'COMPILED WITH';  /b/s/w/ir/x/w/staging/llvm_build/./bin/clang++ 
/b/s/w/ir/x/w/llvm-project/libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.fail.cpp
 -v --sysroot=/b/s/w/ir/x/w/cipd/linux --target=x86_64-unknown-linux-gnu 
-include /b/s/w/ir/x/w/llvm-project/libcxx/test/support/nasty_macros.h 
-nostdinc++ 
-I/b/s/w/ir/x/w/staging/llvm_build/include/x86_64-unknown-linux-gnu/c++/v1 
-I/b/s/w/ir/x/w/staging/llvm_build/include/c++/v1 
-I/b/s/w/ir/x/w/staging/llvm_build/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/libcxx/include/c++build
 -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS 
-I/b/s/w/ir/x/w/llvm-project/libcxx/test/support -std=c++2b -Werror -Wall 
-Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes 
-Wno-pessimizing-move -Wno-c++11-extensions -Wno-user-defined-literals 
-Wno-noexcept-type -Wno-atomic-alignment -Wsign-compare -Wunused-variable 
-Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef 
-D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety 
-Wuser-defined-warnings -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 
-Wno-macro-redefined -D_LIBCPP_HAS_THREAD_API_PTHREAD -Wno-macro-redefined 
-D_LIBCPP_ABI_VERSION=2  -fsyntax-only -Wno-error -Xclang -verify -Xclang 
-verify-ignore-unexpected=note -ferror-limit=0
  --
  Exit Code: 1
  
  Command Output (stdout):
  --
  $ ":" "COMPILED WITH"
  $ "/b/s/w/ir/x/w/staging/llvm_build/./bin/clang++" 
"/b/s/w/ir/x/w/llvm-project/libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.fail.cpp"
 "-v" "--sysroot=/b/s/w/ir/x/w/cipd/linux" "--target=x86_64-unknown-linux-gnu" 
"-include" "/b/s/w/ir/x/w/llvm-project/libcxx/test/support/nasty_macros.h" 
"-nostdinc++" 
"-I/b/s/w/ir/x/w/staging/llvm_build/include/x86_64-unknown-linux-gnu/c++/v1" 
"-I/b/s/w/ir/x/w/staging/llvm_build/include/c++/v1" 
"-I/b/s/w/ir/x/w/staging/llvm_build/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/libcxx/include/c++build"
 "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-D__STDC_CONSTANT_MACROS" 
"-I/b/s/w/ir/x/w/llvm-project/libcxx/test/support" "-std=c++2b" "-Werror" 
"-Wall" "-Wextra" "-Wshadow" "-Wundef" "-Wno-unused-command-line-argument" 
"-Wno-attributes" "-Wno-pessimizing-move" "-Wno-c++11-extensions" 
"-Wno-user-defined-literals" "-Wno-noexcept-type" "-Wno-atomic-alignment" 
"-Wsign-compare" "-Wunused-variable" "-Wunused-parameter" "-Wunreachable-code" 
"-Wno-unused-local-typedef" "-D_LIBCPP_DISABLE_AVAILABILITY" "-fcoroutines-ts" 
"-Werror=thread-safety" "-Wuser-defined-warnings" 
"-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER" "-Wno-macro-redefined" 
"-D_LIBCPP_HAS_THREAD_API_PTHREAD" "-Wno-macro-redefined" 
"-D_LIBCPP_ABI_VERSION=2" "-fsyntax-only" "-Wno-error" "-Xclang" "-verify" 
"-Xclang" "-verify-ignore-unexpected=note" "-ferror-limit=0"
  # command stderr:
  Fuchsia clang version 14.0.0 (https://llvm.googlesource.com/a/llvm-project 
e1d6f29a1e640e267e1d2b94d0d761e1d15e99bd)
  Target: x86_64-unknown-linux-gnu
  Thread model: posix
  InstalledDir: /b/s/w/ir/x/w/staging/llvm_build/./bin
  Found candidate GCC installation: 
/b/s/w/ir/x/w/cipd/linux/usr/lib/gcc/i586-linux-gnu/4.8
  Found candidate GCC installation: 
/b/s/w/ir/x/w/cipd/linux/usr/lib/gcc/x86_64-linux-gnu/4.8
  Selected GCC installation: 
/b/s/w/ir/x/w/cipd/linux/usr/lib/gcc/x86_64-linux-gnu/4.8
  Candidate multilib: .;@m64
  Selected multilib: .;@m64
   (in-process)
   "/b/s/w/ir/x/w/staging/llvm_build/bin/clang-14" -cc1 -triple 
x86_64-unknown-linux-gnu -fsyntax-only -disable-free -clear-ast-before-backend 
-main-file-name const_correctness.fail.cpp -mrelocation-model static 
-mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math 
-mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic 
-debugger-tuning=gdb -v 
-fcoverage-compilation-dir=/b/s/w/ir/x/w/staging/llvm_build/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/libcxx/test/std/utilities/any/any.nonmembers/any.cast
 -nostdinc++ -resource-dir /b/s/w/ir/x/w/staging/llvm_build/lib/clang/14.0.0 
-include /b/s/w/ir/x/w/llvm-project/libcxx/test/support/nasty_macros.h -I 
/b/s/w/ir/x/w/staging/llvm_build/include/x86_64-unknown-linux-gnu/c++/v1 -I 
/b/s/w/ir/x/w/staging/llvm_build/include/c++/v1 -I 
/b/s/w/ir/x/w/staging/llvm_build/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/libcxx/include/c++build
 -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -D __STDC_CONSTANT_MACROS -I 
/b/s/w/ir/x/w/llvm-project/libcxx/test/support -D _LIBCPP_DISABLE_AVAILABILITY 
-D _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D _LIBCPP_HAS_THREAD_API_PTHREAD -D 
_LIBCPP_ABI_VERSION=2 -isysroot /b/s/w/ir/x/w/cipd/linux -internal-isystem 
/b/s/w/ir/x/w/staging/llvm_build/lib/clang/14.0.0/include -internal-isystem 
/b/s/w/ir/x/w/cipd/linux/usr/local/include -internal-isystem 

[PATCH] D112903: [C++20] [Module] Fix bug47716 and implement [module.interface]/p6

2021-11-11 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 386730.
ChuanqiXu added a comment.

Remove dead codes.


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

https://reviews.llvm.org/D112903

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclBase.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/CXX/module/module.interface/p2-2.cpp
  clang/test/CXX/module/module.interface/p6.cpp

Index: clang/test/CXX/module/module.interface/p6.cpp
===
--- /dev/null
+++ clang/test/CXX/module/module.interface/p6.cpp
@@ -0,0 +1,93 @@
+// The test is check we couldn't export a redeclaration which isn't exported previously and
+// check it is OK to redeclare no matter exported nor not if is the previous declaration is exported.
+// RUN: %clang_cc1 -std=c++20 %s -verify
+
+export module X;
+
+struct S {
+  int n;
+}; // expected-note {{previous declaration is here}}
+typedef S S;
+export typedef S S; // OK, does not redeclare an entity
+export struct S;// expected-error {{cannot export redeclaration 'S' here since the previous declaration is not exported.}}
+
+namespace A {
+struct X; // expected-note {{previous declaration is here}}
+export struct Y;
+} // namespace A
+
+namespace A {
+export struct X; // expected-error {{cannot export redeclaration 'X' here since the previous declaration is not exported.}}
+export struct Y; // OK
+struct Z;// expected-note {{previous declaration is here}}
+export struct Z; // expected-error {{cannot export redeclaration 'Z' here since the previous declaration is not exported.}}
+} // namespace A
+
+namespace A {
+struct B;// expected-note {{previous declaration is here}}
+struct C {}; // expected-note {{previous declaration is here}}
+} // namespace A
+
+namespace A {
+export struct B {}; // expected-error {{cannot export redeclaration 'B' here since the previous declaration is not exported.}}
+export struct C;// expected-error {{cannot export redeclaration 'C' here since the previous declaration is not exported.}}
+} // namespace A
+
+template 
+struct TemplS; // expected-note {{previous declaration is here}}
+
+export template 
+struct TemplS {}; // expected-error {{cannot export redeclaration 'TemplS' here since the previous declaration is not exported.}}
+
+template 
+struct TemplS2; // expected-note {{previous declaration is here}}
+
+export template 
+struct TemplS2 {}; // expected-error {{cannot export redeclaration 'TemplS2' here since the previous declaration is not exported.}}
+
+void baz();// expected-note {{previous declaration is here}}
+export void baz(); // expected-error {{cannot export redeclaration 'baz' here since the previous declaration is not exported.}}
+
+namespace A {
+export void foo();
+void bar();// expected-note {{previous declaration is here}}
+export void bar(); // expected-error {{cannot export redeclaration 'bar' here since the previous declaration is not exported.}}
+void f1(); // expected-note {{previous declaration is here}}
+} // namespace A
+
+// OK
+//
+// [module.interface]/p6
+// A redeclaration of an entity X is implicitly exported if X was introduced by an exported declaration
+void A::foo();
+
+// The compiler couldn't export A::f1() here since A::f1() is declared above without exported.
+// See [module.interface]/p6 for details.
+export void A::f1(); // expected-error {{cannot export redeclaration 'f1' here since the previous declaration is not exported.}}
+
+template 
+void TemplFunc(); // expected-note {{previous declaration is here}}
+
+export template 
+void TemplFunc() { // expected-error {{cannot export redeclaration 'TemplFunc' here since the previous declaration is not exported.}}
+}
+
+namespace A {
+template 
+void TemplFunc2(); // expected-note {{previous declaration is here}}
+export template 
+void TemplFunc2() {} // expected-error {{cannot export redeclaration 'TemplFunc2' here since the previous declaration is not exported.}}
+template 
+void TemplFunc3(); // expected-note {{previous declaration is here}}
+} // namespace A
+
+export template 
+void A::TemplFunc3() {} // expected-error {{cannot export redeclaration 'TemplFunc3' here since the previous declaration is not exported.}}
+
+int var;// expected-note {{previous declaration is here}}
+export int var; // expected-error {{cannot export redeclaration 'var' here since the previous declaration is not exported.}}
+
+template 
+T TemplVar; // expected-note {{previous declaration is here}}
+export template 
+T TemplVar; // expected-error {{cannot export redeclaration 'TemplVar' here since the previous declaration is not exported.}}
Index: clang/test/CXX/module/module.interface/p2-2.cpp
===
--- /dev/null
+++ 

[PATCH] D111477: DO NOT SUBMIT: workaround for context-sensitive use of non-type-template-parameter integer suffixes

2021-11-11 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Renamed in 6512098877c3a230bbd38bc81b14a4e5844739ff 
 to 
`AlwaysIncludeTypeForTemplateArgument`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111477

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


[clang] 6512098 - DebugInfo/Printing: Improve name of policy for including types for template arguments

2021-11-11 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-11-11T21:59:27-08:00
New Revision: 6512098877c3a230bbd38bc81b14a4e5844739ff

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

LOG: DebugInfo/Printing: Improve name of policy for including types for 
template arguments

Feedback from Richard Smith that the policy should be named closer to
the context its used in.

Added: 


Modified: 
clang/include/clang/AST/PrettyPrinter.h
clang/lib/AST/DeclTemplate.cpp
clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 




diff  --git a/clang/include/clang/AST/PrettyPrinter.h 
b/clang/include/clang/AST/PrettyPrinter.h
index 38d122db0749..f6816e938f2a 100644
--- a/clang/include/clang/AST/PrettyPrinter.h
+++ b/clang/include/clang/AST/PrettyPrinter.h
@@ -75,7 +75,7 @@ struct PrintingPolicy {
 MSVCFormatting(false), ConstantsAsWritten(false),
 SuppressImplicitBase(false), FullyQualifiedName(false),
 PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true),
-UsePreferredNames(true), UseIntegerTypeSuffixesAlways(false) {}
+UsePreferredNames(true), AlwaysIncludeTypeForTemplateArgument(false) {}
 
   /// Adjust this printing policy for cases where it's known that we're
   /// printing C++ code (for instance, if AST dumping reaches a C++-only
@@ -280,7 +280,7 @@ struct PrintingPolicy {
 
   /// Whether to use type suffixes (eg: 1U) on integral non-type template
   /// parameters.
-  unsigned UseIntegerTypeSuffixesAlways : 1;
+  unsigned AlwaysIncludeTypeForTemplateArgument : 1;
 
   /// Callbacks to use to allow the behavior of printing to be customized.
   const PrintingCallbacks *Callbacks = nullptr;

diff  --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index 10f7155fcb96..223f06b9db1c 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -204,7 +204,7 @@ bool TemplateParameterList::hasAssociatedConstraints() 
const {
 bool TemplateParameterList::shouldIncludeTypeForArgument(
 const PrintingPolicy , const TemplateParameterList *TPL,
 unsigned Idx) {
-  if (!TPL || Idx >= TPL->size() || Policy.UseIntegerTypeSuffixesAlways)
+  if (!TPL || Idx >= TPL->size() || 
Policy.AlwaysIncludeTypeForTemplateArgument)
 return true;
   const NamedDecl *TemplParam = TPL->getParam(Idx);
   if (const auto *ParamValueDecl =

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 1ce56f98e1f0..af651e6f44b7 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -247,7 +247,7 @@ PrintingPolicy CGDebugInfo::getPrintingPolicy() const {
   PP.SuppressInlineNamespace = false;
   PP.PrintCanonicalTypes = true;
   PP.UsePreferredNames = false;
-  PP.UseIntegerTypeSuffixesAlways = true;
+  PP.AlwaysIncludeTypeForTemplateArgument = true;
 
   // Apply -fdebug-prefix-map.
   PP.Callbacks = 



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


[PATCH] D112903: [C++20] [Module] Fix bug47716 and implement [module.interface]/p6

2021-11-11 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu marked 3 inline comments as done.
ChuanqiXu added inline comments.



Comment at: clang/test/CXX/module/module.interface/p2-2.cpp:1
+// The intention of this file to check we could only export declarations in 
namesapce scope.
+//

I move them here since this is described in p2 instead of p6. I don't merge 
this into p2.cpp since that I feel it is not harmonious to merge this test with 
the test in p2 now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112903

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


[PATCH] D112903: [C++20] [Module] Fix bug47716 and implement [module.interface]/p6

2021-11-11 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 386728.
ChuanqiXu retitled this revision from "[C++20] [Module] Fix front end crashes 
when trying to export a qualified entity which is already declared" to "[C++20] 
[Module] Fix bug47716 and implement [module.interface]/p6".
ChuanqiXu edited the summary of this revision.
ChuanqiXu added a comment.

- Address comments.
- Implement [module.interface]/p6.

In the process of addressing @urnathan 's comment, I found that it is better to 
handle [module.interface]/p6 in Sema::CheckRedeclaration* functions. And I add 
more tests about p6 now. Now it looks much better now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112903

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclBase.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/CXX/module/module.interface/p2-2.cpp
  clang/test/CXX/module/module.interface/p6.cpp

Index: clang/test/CXX/module/module.interface/p6.cpp
===
--- /dev/null
+++ clang/test/CXX/module/module.interface/p6.cpp
@@ -0,0 +1,93 @@
+// The test is check we couldn't export a redeclaration which isn't exported previously and
+// check it is OK to redeclare no matter exported nor not if is the previous declaration is exported.
+// RUN: %clang_cc1 -std=c++20 %s -verify
+
+export module X;
+
+struct S {
+  int n;
+}; // expected-note {{previous declaration is here}}
+typedef S S;
+export typedef S S; // OK, does not redeclare an entity
+export struct S;// expected-error {{cannot export redeclaration 'S' here since the previous declaration is not exported.}}
+
+namespace A {
+struct X; // expected-note {{previous declaration is here}}
+export struct Y;
+} // namespace A
+
+namespace A {
+export struct X; // expected-error {{cannot export redeclaration 'X' here since the previous declaration is not exported.}}
+export struct Y; // OK
+struct Z;// expected-note {{previous declaration is here}}
+export struct Z; // expected-error {{cannot export redeclaration 'Z' here since the previous declaration is not exported.}}
+} // namespace A
+
+namespace A {
+struct B;// expected-note {{previous declaration is here}}
+struct C {}; // expected-note {{previous declaration is here}}
+} // namespace A
+
+namespace A {
+export struct B {}; // expected-error {{cannot export redeclaration 'B' here since the previous declaration is not exported.}}
+export struct C;// expected-error {{cannot export redeclaration 'C' here since the previous declaration is not exported.}}
+} // namespace A
+
+template 
+struct TemplS; // expected-note {{previous declaration is here}}
+
+export template 
+struct TemplS {}; // expected-error {{cannot export redeclaration 'TemplS' here since the previous declaration is not exported.}}
+
+template 
+struct TemplS2; // expected-note {{previous declaration is here}}
+
+export template 
+struct TemplS2 {}; // expected-error {{cannot export redeclaration 'TemplS2' here since the previous declaration is not exported.}}
+
+void baz();// expected-note {{previous declaration is here}}
+export void baz(); // expected-error {{cannot export redeclaration 'baz' here since the previous declaration is not exported.}}
+
+namespace A {
+export void foo();
+void bar();// expected-note {{previous declaration is here}}
+export void bar(); // expected-error {{cannot export redeclaration 'bar' here since the previous declaration is not exported.}}
+void f1(); // expected-note {{previous declaration is here}}
+} // namespace A
+
+// OK
+//
+// [module.interface]/p6
+// A redeclaration of an entity X is implicitly exported if X was introduced by an exported declaration
+void A::foo();
+
+// The compiler couldn't export A::f1() here since A::f1() is declared above without exported.
+// See [module.interface]/p6 for details.
+export void A::f1(); // expected-error {{cannot export redeclaration 'f1' here since the previous declaration is not exported.}}
+
+template 
+void TemplFunc(); // expected-note {{previous declaration is here}}
+
+export template 
+void TemplFunc() { // expected-error {{cannot export redeclaration 'TemplFunc' here since the previous declaration is not exported.}}
+}
+
+namespace A {
+template 
+void TemplFunc2(); // expected-note {{previous declaration is here}}
+export template 
+void TemplFunc2() {} // expected-error {{cannot export redeclaration 'TemplFunc2' here since the previous declaration is not exported.}}
+template 
+void TemplFunc3(); // expected-note {{previous declaration is here}}
+} // namespace A
+
+export template 
+void A::TemplFunc3() {} // expected-error {{cannot export redeclaration 'TemplFunc3' here since the previous declaration is not exported.}}
+
+int var;// 

[PATCH] D112359: [RISCV] Unify depedency check and extension implication parsing logics

2021-11-11 Thread Yueh-Ting Chen via Phabricator via cfe-commits
eopXD added a comment.

ping, thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112359

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


[PATCH] D109557: Adds a BlockIndent option to AlignAfterOpenBracket

2021-11-11 Thread Cameron Mulhern via Phabricator via cfe-commits
csmulhern added a comment.

Any further feedback on the latest iteration?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109557

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


[PATCH] D113729: [Fuchsia][CMake] Don't set libcxxabi and libunwind variables on Windows

2021-11-11 Thread Petr Hosek 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 rG8df26e7b4aea: [Fuchsia][CMake] Dont set libcxxabi and 
libunwind variables on Windows (authored by phosek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113729

Files:
  clang/cmake/caches/Fuchsia.cmake


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -49,26 +49,26 @@
   set(COMPILER_RT_ENABLE_WATCHOS OFF CACHE BOOL "")
 endif()
 
-set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
-set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
-set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
-set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
-set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
-set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
-set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
-set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
-set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
 if(WIN32)
-  set(LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "")
+  set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
   set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
   set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
   set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
-  set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(BUILTINS_CMAKE_ARGS -DCMAKE_SYSTEM_NAME=Windows CACHE STRING "")
   set(RUNTIMES_CMAKE_ARGS -DCMAKE_SYSTEM_NAME=Windows CACHE STRING "")
   set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
 else()
+  set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
+  set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+  set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
+  set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
   set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE 
STRING "")
 endif()


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -49,26 +49,26 @@
   set(COMPILER_RT_ENABLE_WATCHOS OFF CACHE BOOL "")
 endif()
 
-set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
-set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
-set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
-set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
-set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
-set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
-set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
-set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
-set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
 if(WIN32)
-  set(LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "")
+  set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
   set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
   set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
   set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
-  set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(BUILTINS_CMAKE_ARGS -DCMAKE_SYSTEM_NAME=Windows CACHE STRING "")
   set(RUNTIMES_CMAKE_ARGS -DCMAKE_SYSTEM_NAME=Windows CACHE STRING "")
   set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
 else()
+  set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
+  set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+  set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
+  set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
   set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8df26e7 - [Fuchsia][CMake] Don't set libcxxabi and libunwind variables on Windows

2021-11-11 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2021-11-11T19:29:39-08:00
New Revision: 8df26e7b4aeaad0b1777c6909db7b14fec347880

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

LOG: [Fuchsia][CMake] Don't set libcxxabi and libunwind variables on Windows

We don't build libcxxabi and libunwind for Windows so don't set the
corresponding variables to avoid configuration errors.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia.cmake 
b/clang/cmake/caches/Fuchsia.cmake
index a98354b7782fc..a531f9f1c10d8 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -49,26 +49,26 @@ if(APPLE)
   set(COMPILER_RT_ENABLE_WATCHOS OFF CACHE BOOL "")
 endif()
 
-set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
-set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
-set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
-set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
-set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
-set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
-set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
-set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
-set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
 if(WIN32)
-  set(LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "")
+  set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
   set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
   set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
   set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
-  set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(BUILTINS_CMAKE_ARGS -DCMAKE_SYSTEM_NAME=Windows CACHE STRING "")
   set(RUNTIMES_CMAKE_ARGS -DCMAKE_SYSTEM_NAME=Windows CACHE STRING "")
   set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
 else()
+  set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
+  set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+  set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
+  set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
   set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE 
STRING "")
 endif()



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


[PATCH] D113729: [Fuchsia][CMake] Don't set libcxxabi and libunwind variables on Windows

2021-11-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: haowei.
Herald added subscribers: abrachet, mgorny.
phosek requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We don't build libcxxabi and libunwind for Windows so don't set the
corresponding variables to avoid configuration errors.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113729

Files:
  clang/cmake/caches/Fuchsia.cmake


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -49,26 +49,26 @@
   set(COMPILER_RT_ENABLE_WATCHOS OFF CACHE BOOL "")
 endif()
 
-set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
-set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
-set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
-set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
-set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
-set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
-set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
-set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
-set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
 if(WIN32)
-  set(LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "")
+  set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
   set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
   set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
   set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
-  set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(BUILTINS_CMAKE_ARGS -DCMAKE_SYSTEM_NAME=Windows CACHE STRING "")
   set(RUNTIMES_CMAKE_ARGS -DCMAKE_SYSTEM_NAME=Windows CACHE STRING "")
   set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
 else()
+  set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
+  set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+  set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
+  set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
   set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE 
STRING "")
 endif()


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -49,26 +49,26 @@
   set(COMPILER_RT_ENABLE_WATCHOS OFF CACHE BOOL "")
 endif()
 
-set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
-set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
-set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
-set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
-set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
-set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
-set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
-set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
-set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
 if(WIN32)
-  set(LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "")
+  set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
   set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
   set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
   set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
-  set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(BUILTINS_CMAKE_ARGS -DCMAKE_SYSTEM_NAME=Windows CACHE STRING "")
   set(RUNTIMES_CMAKE_ARGS -DCMAKE_SYSTEM_NAME=Windows CACHE STRING "")
   set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
 else()
+  set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
+  set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+  set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
+  set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
   set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51650: Implement target_clones multiversioning

2021-11-11 Thread Jorge Gorbe Moya via Phabricator via cfe-commits
jgorbe added a comment.

This breaks some existing code (we have found this issue building the JPEG XL 
library at github.com/libjxl). This is a very simplified version of the problem:

  #pragma clang attribute push(__attribute__((target("sse2,ssse3"))), apply_to 
= function)
  __attribute__((target("sse2"))) void f() {
  }
  #pragma clang attribute pop

This used to build before this patch, but now fails with

  $ clang -c a.cc
  a.cc:1:45: error: attribute 'target' cannot appear more than once on a 
declaration
  #pragma clang attribute push(__attribute__((target("sse2,ssse3"))), apply_to 
= function)
  ^
  a.cc:2:1: note: when applied to this declaration
  __attribute__((target("sse2"))) void f() {
  ^
  a.cc:2:16: note: conflicting attribute is here
  __attribute__((target("sse2"))) void f() {
 ^
  1 error generated.

Before this patch, the function-level attribute would win. Here's the relevant 
part of the generated IR for that example:

  ; Function Attrs: mustprogress noinline nounwind optnone uwtable
  define dso_local void @_Z1fv() #0 {
ret void
  }
  
  attributes #0 = { mustprogress noinline nounwind optnone uwtable 
"frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-cpu"="x86-64" 
"target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

Note how there's `sse2` (which was in the function-level attribute) but no 
`ssse3` (which wasn't).

Was this semantic change intentional?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D51650

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


[PATCH] D106585: Fix clang debug info irgen of i128 enums

2021-11-11 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment.

In D106585#3125280 , @rnk wrote:

> In D106585#3122726 , @glandium 
> wrote:
>
>> It seems to have been fixed in rG3c47c5ca13b8a502de3272e8105548715947b7a8 
>> .
>
> Are you sure you've arrived at the right code review? This change, D106585 
> , modified type information, which is 
> unrelated to the change you linked to. We have also noticed *other* 
> determinism issues (follow up with @hans to learn more), but they aren't 
> related to this change, which is from July.

Yes, cherry-picking rG3c47c5ca13b8a502de3272e8105548715947b7a8 
, 
rGbadcd585897253e94b7b2d4e6f9f430a2020d642 
 and 
reverting the changes to clang/lib/CodeGen/CGDebugInfo.cpp from 
rG323049329939becf690adbeeff9f5f7e219075ec 
 and 
rGf9f56488e02d1c09a9cd4acde61ce1c712e71405 
 fixes the 
non-determinism in Firefox with clang 13.0.0.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106585

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


[PATCH] D113455: [clang][objc][codegen] Skip emitting ObjC category metadata when the category is empty

2021-11-11 Thread Jan Korous via Phabricator via cfe-commits
jkorous accepted this revision.
jkorous added a comment.

LGTM if we have test coverage for all the cases.




Comment at: clang/test/CodeGenObjC/category-class-empty.m:1
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -O3 -emit-llvm -o - %s | 
FileCheck %s
+// PR7431

zoecarver wrote:
> Is `-O3` needed here?
I would even think `-O0` is better and consider also `-disable-llvm-passes`. 
Ultimately the goal is to make sure frontend codegen doesn't emit the metadata 
so the less processing of the IR in the backend the more sensitive the test 
will be.



Comment at: clang/test/CodeGenObjC/category-class-empty.m:10
+@interface A(foo)
+- (void)foo_myStuff;
+@end

I assume all the cases when we want to emit the metadata (at least one instance 
method, at least one class method, ...) are covered by other tests, right?
If there's a case that's missing we should add a test for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113455

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


[clang] 98f80d2 - [Driver] Fix unused variable warning in release builds. NFC.

2021-11-11 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2021-11-12T00:20:21+01:00
New Revision: 98f80d248d9c888c2219454c1f655bc324b80cdc

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

LOG: [Driver] Fix unused variable warning in release builds. NFC.

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/HIP.cpp 
b/clang/lib/Driver/ToolChains/HIP.cpp
index 1b77e275200d..07af1a0457c7 100644
--- a/clang/lib/Driver/ToolChains/HIP.cpp
+++ b/clang/lib/Driver/ToolChains/HIP.cpp
@@ -64,6 +64,7 @@ static bool shouldSkipSanitizeOption(const ToolChain ,
   auto OptionalGpuArch = parseTargetID(TC.getTriple(), TargetID, );
 
   assert(OptionalGpuArch && "Invalid Target ID");
+  (void)OptionalGpuArch;
   auto Loc = FeatureMap.find("xnack");
   if (Loc == FeatureMap.end() || !Loc->second) {
 Diags.Report(



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


[PATCH] D110216: [clang] retain type sugar in auto / template argument deduction

2021-11-11 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov marked an inline comment as done.
mizvekov added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:559
+  // Get the resolved template arguments from the canonical type.
+  // FIXME: Handle the as-written arguments so the sugar is not lost.
+  ArrayRef PResolved =

rsmith wrote:
> Does this matter on the `P` side? (Can we remove this FIXME?)
Even though P sugar is not relevant to the deduced type, it is relevant to 
diagnostics when there is a deduction failure. This has been relevant in the 
other parts of this patch, so I don't see why we would not at least want to 
preserve it here, though it might be too much trouble to be worth the effort.

I will keep the comment for now, if we have any discussion where it becomes 
clear there would be no difference here, I will make a one line NFC and remove 
it.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:561
+  ArrayRef PResolved =
+  TP->getCanonicalTypeInternal()
+  ->castAs()

rsmith wrote:
> Can we avoid using the `Internal` version here? (The only difference is 
> whether we preserve top-level qualifiers that are outside any type sugar.)
> 
> Might also be worth a comment here explaining that we're going to the 
> canonical type first here to step over any alias templates.
The Internal version is more convenient because TP is a `Type *` not a 
`QualType`, so the suggestion as you have written would not work.

Removing the alias template would be handled by `getUnqualifiedDesugaredType`, 
above, which my understanding is that will remove all top level sugar.

But I see that I went all this way around to preserving the non-canonical TP 
but all I needed really from it was the templateName, which probably is always 
the same as the canonical one, though not sure if that is by design.

I just made a change to get the canonical type on TP above instead, and we can 
circle back to this later.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:571-573
+  // FIXME: Should not lose sugar here.
+  if (const auto *SA = dyn_cast(
+  UA->getCanonicalTypeInternal())) {

rsmith wrote:
> I think we can retain type sugar here without too much effort.
That does not work, blows up some 80 tests.
I will leave the FIXME and circle back to this after I am done with my pile of 
patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110216

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


[PATCH] D113718: Don't append the working directory to absolute paths

2021-11-11 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl created this revision.
aprantl added reviewers: dblaikie, rastogishubham, kastiglione.
aprantl added a project: debug-info.
aprantl requested review of this revision.

This fixes a bug that happens when using -fdebug-prefix-map to remap an 
absolute path to a relative path. Since the path was absolute before remapping, 
it is safe to assume that concatenating the remapped working directory would be 
wrong.


https://reviews.llvm.org/D113718

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-prefix-map.c


Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -5,6 +5,8 @@
 // RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -isysroot %p 
-debugger-tuning=lldb | FileCheck %s -check-prefix CHECK-SYSROOT
 // RUN: %clang -g -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s
 // RUN: %clang -g -ffile-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang -g -fdebug-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
+// RUN: %clang -g -ffile-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
 
 #include "Inputs/stdio.h"
 
@@ -42,3 +44,7 @@
 // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}Inputs/stdio.h", directory: 
"/UNLIKELY_PATH/empty")
 // CHECK-COMPILATION-DIR-NOT: !DIFile(filename:
 // CHECK-SYSROOT: !DICompileUnit({{.*}}sysroot: "/UNLIKELY_PATH/empty"
+
+// CHECK-REL: !DIFile(filename: "./UNLIKELY_PATH/empty{{/|}}{{.*}}",
+// CHECK-REL: !DIFile(filename: 
"./UNLIKELY_PATH/empty{{/|}}{{.*}}Inputs/stdio.h",
+// CHECK-REL-SAME:directory: "")
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -448,7 +448,8 @@
   File = FileBuf;
 }
   } else {
-Dir = CurDir;
+if (!llvm::sys::path::is_absolute(FileName))
+  Dir = CurDir;
 File = RemappedFile;
   }
   llvm::DIFile *F = DBuilder.createFile(File, Dir, CSInfo, Source);


Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -5,6 +5,8 @@
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -isysroot %p -debugger-tuning=lldb | FileCheck %s -check-prefix CHECK-SYSROOT
 // RUN: %clang -g -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s
 // RUN: %clang -g -ffile-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang -g -fdebug-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
+// RUN: %clang -g -ffile-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
 
 #include "Inputs/stdio.h"
 
@@ -42,3 +44,7 @@
 // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}Inputs/stdio.h", directory: "/UNLIKELY_PATH/empty")
 // CHECK-COMPILATION-DIR-NOT: !DIFile(filename:
 // CHECK-SYSROOT: !DICompileUnit({{.*}}sysroot: "/UNLIKELY_PATH/empty"
+
+// CHECK-REL: !DIFile(filename: "./UNLIKELY_PATH/empty{{/|}}{{.*}}",
+// CHECK-REL: !DIFile(filename: "./UNLIKELY_PATH/empty{{/|}}{{.*}}Inputs/stdio.h",
+// CHECK-REL-SAME:directory: "")
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -448,7 +448,8 @@
   File = FileBuf;
 }
   } else {
-Dir = CurDir;
+if (!llvm::sys::path::is_absolute(FileName))
+  Dir = CurDir;
 File = RemappedFile;
   }
   llvm::DIFile *F = DBuilder.createFile(File, Dir, CSInfo, Source);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

2021-11-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D93829: [clangd] Support outgoing calls in call hierarchy

2021-11-11 Thread smekkley via Phabricator via cfe-commits
smekkley added a comment.
Herald added a project: clang-tools-extra.

For what it's worth, outgoing call is useful for looking at grand children and 
jump immediately. Also, clangd doesn't runs on embedded devices, so extra 
memory allocation isn't a concern at all for most users. @sammccall which part 
of the code do you find very complex/concerning?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93829

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


[PATCH] D107994: Making the code compliant to the documentation about Floating Point support default values for C/C++. FPP-MODEL=PRECISE enables FFP-CONTRACT (FMA is enabled).

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

Closed by commit by rGf04e387055e495e3e14570087d68e93593cf2918 



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

https://reviews.llvm.org/D107994

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


[PATCH] D111443: [Driver] Fix ToolChain::getSanitizerArgs

2021-11-11 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Closed by commit rG0309e50f33f6: [Driver] Fix ToolChain::getSanitizerArgs 
(authored by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D111443?vs=386518=386662#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111443

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/BareMetal.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CloudABI.cpp
  clang/lib/Driver/ToolChains/CloudABI.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CrossWindows.cpp
  clang/lib/Driver/ToolChains/CrossWindows.h
  clang/lib/Driver/ToolChains/Cuda.h
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/FreeBSD.h
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Fuchsia.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Driver/ToolChains/Haiku.h
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  clang/lib/Driver/ToolChains/MSP430.h
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MSVC.h
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/lib/Driver/ToolChains/MinGW.h
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/OpenBSD.h
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/lib/Driver/ToolChains/PS4CPU.h
  clang/lib/Driver/ToolChains/TCE.cpp
  clang/lib/Driver/ToolChains/TCE.h
  clang/lib/Driver/ToolChains/VEToolchain.cpp
  clang/lib/Driver/ToolChains/VEToolchain.h
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Driver/ToolChains/WebAssembly.h
  clang/lib/Driver/ToolChains/XCore.cpp
  clang/lib/Driver/ToolChains/XCore.h
  clang/lib/Driver/ToolChains/ZOS.h
  clang/test/Driver/hip-sanitize-options.hip

Index: clang/test/Driver/hip-sanitize-options.hip
===
--- clang/test/Driver/hip-sanitize-options.hip
+++ clang/test/Driver/hip-sanitize-options.hip
@@ -1,47 +1,67 @@
 // REQUIRES: clang-driver, x86-registered-target, amdgpu-registered-target
 
-// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900 \
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900:xnack+ \
 // RUN:   -fsanitize=address \
 // RUN:   -nogpuinc --rocm-path=%S/Inputs/rocm \
-// RUN:   %s 2>&1 | FileCheck %s
+// RUN:   %s 2>&1 | FileCheck -check-prefixes=NORDC %s
 
-// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900 \
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900:xnack+ \
 // RUN:   -fsanitize=address -fno-gpu-sanitize \
 // RUN:   -nogpuinc --rocm-path=%S/Inputs/rocm \
 // RUN:   %s 2>&1 | FileCheck %s
 
-// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900 \
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900:xnack+ \
 // RUN:   -fsanitize=address -fgpu-sanitize \
 // RUN:   -nogpuinc --rocm-path=%S/Inputs/rocm \
 // RUN:   %s 2>&1 | FileCheck -check-prefixes=NORDC %s
 
-// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900 \
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900:xnack+ \
 // RUN:   -fsanitize=address -fgpu-sanitize -fgpu-rdc \
 // RUN:   -nogpuinc --rocm-path=%S/Inputs/rocm \
 // RUN:   %s 2>&1 | FileCheck -check-prefixes=RDC %s
 
-// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900 \
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900:xnack+ \
 // RUN:   -fsanitize=address -fgpu-sanitize \
 // RUN:   -nogpuinc --rocm-path=%S/Inputs/rocm-invalid \
 // RUN:   %s 2>&1 | FileCheck -check-prefixes=FAIL %s
 
 // RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900:xnack- \
-// RUN:   -fsanitize=address -fgpu-sanitize \
-// RUN:   -nogpuinc --rocm-path=%S/Inputs/rocm \
-// RUN:   %s 2>&1 | FileCheck -check-prefix=XNACK %s
+// RUN:   --offload-arch=gfx900:xnack+ --offload-arch=gfx906 -fsanitize=address -fgpu-sanitize \
+// RUN:   -fsanitize=leak -nogpuinc --rocm-path=%S/Inputs/rocm \
+// RUN:   %s 2>&1 | FileCheck -check-prefixes=XNACK %s
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900:xnack- \
+// RUN:   --offload-arch=gfx900:xnack+ --offload-arch=gfx906 -fsanitize=address -fgpu-sanitize \
+// RUN:   

[clang] 0309e50 - [Driver] Fix ToolChain::getSanitizerArgs

2021-11-11 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2021-11-11T17:17:08-05:00
New Revision: 0309e50f33f616baa8fcac8365b728be3ccf06dd

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

LOG: [Driver] Fix ToolChain::getSanitizerArgs

The driver uses class SanitizerArgs to store parsed sanitizer arguments. It 
keeps a cached
SanitizerArgs object in ToolChain and uses it for different jobs. This does not 
work if
the sanitizer options are different for different jobs, which could happen when 
an
offloading toolchain translates the options for different jobs.

To fix this, SanitizerArgs should be created by using the actual arguments 
passed
to jobs instead of the original arguments passed to the driver, since the 
toolchain
may change the original arguments. And the sanitizer arguments should be 
diagnose
once.

This patch also fixes HIP toolchain for handling -fgpu-sanitize: a warning is 
emitted
for GPU's not supporting sanitizer and skipped. This is for backward 
compatibility
with existing -fsanitize options. -fgpu-sanitize is also turned on by default.

Reviewed by: Artem Belevich, Evgenii Stepanov

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/SanitizerArgs.h
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/Driver.cpp
clang/lib/Driver/SanitizerArgs.cpp
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/AIX.h
clang/lib/Driver/ToolChains/AMDGPU.h
clang/lib/Driver/ToolChains/BareMetal.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CloudABI.cpp
clang/lib/Driver/ToolChains/CloudABI.h
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CrossWindows.cpp
clang/lib/Driver/ToolChains/CrossWindows.h
clang/lib/Driver/ToolChains/Cuda.h
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Darwin.h
clang/lib/Driver/ToolChains/FreeBSD.cpp
clang/lib/Driver/ToolChains/FreeBSD.h
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/lib/Driver/ToolChains/Fuchsia.h
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Gnu.h
clang/lib/Driver/ToolChains/HIP.cpp
clang/lib/Driver/ToolChains/Haiku.h
clang/lib/Driver/ToolChains/Linux.cpp
clang/lib/Driver/ToolChains/Linux.h
clang/lib/Driver/ToolChains/MSP430.h
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/Driver/ToolChains/MSVC.h
clang/lib/Driver/ToolChains/MinGW.cpp
clang/lib/Driver/ToolChains/MinGW.h
clang/lib/Driver/ToolChains/NetBSD.cpp
clang/lib/Driver/ToolChains/OpenBSD.h
clang/lib/Driver/ToolChains/PS4CPU.cpp
clang/lib/Driver/ToolChains/PS4CPU.h
clang/lib/Driver/ToolChains/TCE.cpp
clang/lib/Driver/ToolChains/TCE.h
clang/lib/Driver/ToolChains/VEToolchain.cpp
clang/lib/Driver/ToolChains/VEToolchain.h
clang/lib/Driver/ToolChains/WebAssembly.cpp
clang/lib/Driver/ToolChains/WebAssembly.h
clang/lib/Driver/ToolChains/XCore.cpp
clang/lib/Driver/ToolChains/XCore.h
clang/lib/Driver/ToolChains/ZOS.h
clang/test/Driver/hip-sanitize-options.hip

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 8e7c14dc1549b..ff8c36910e13e 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -100,6 +100,14 @@ def err_drv_bad_offload_arch_combo : Error<
   "invalid offload arch combinations: '%0' and '%1' (for a specific processor, 
"
   "a feature should either exist in all offload archs, or not exist in any "
   "offload archs)">;
+def warn_drv_unsupported_option_for_offload_arch_req_feature : Warning<
+  "ignoring '%0' option as it is not currently supported for "
+  "offload arch '%1'. Use it with an offload arch containing '%2' instead">,
+  InGroup;
+def warn_drv_unsupported_option_for_target : Warning<
+  "ignoring '%0' option as it is not currently supported for target '%1'">,
+  InGroup;
+
 def err_drv_invalid_thread_model_for_target : Error<
   "invalid thread model '%0' in '%1' for this target">;
 def err_drv_invalid_linker_name : Error<

diff  --git a/clang/include/clang/Driver/SanitizerArgs.h 
b/clang/include/clang/Driver/SanitizerArgs.h
index e9e329e7cb53f..84bb324775d18 100644
--- a/clang/include/clang/Driver/SanitizerArgs.h
+++ b/clang/include/clang/Driver/SanitizerArgs.h
@@ -65,7 +65,8 @@ class SanitizerArgs {
 
 public:
   /// Parses the sanitizer arguments from an argument list.
-  SanitizerArgs(const ToolChain , const llvm::opt::ArgList );
+  SanitizerArgs(const ToolChain , const llvm::opt::ArgList ,
+bool DiagnoseErrors = true);
 
   bool 

[PATCH] D113455: [clang][objc][codegen] Skip emitting ObjC category metadata when the category is empty

2021-11-11 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver accepted this revision.
zoecarver added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/CodeGen/CGObjCMac.cpp:6683
+  values.add(classMethodList);
+  isEmptyCategory &=
+  instanceMethodList->isNullValue() && classMethodList->isNullValue();

Does this really need to be an `&=`? Is there any case where `isEmptyCategory` 
isn't `true` here?



Comment at: clang/test/CodeGenObjC/category-class-empty.m:1
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -O3 -emit-llvm -o - %s | 
FileCheck %s
+// PR7431

Is `-O3` needed here?



Comment at: clang/test/CodeGenObjC/non-lazy-classes.m:45
 __attribute__((objc_nonlazy_class))
-@implementation E (MyCat) @end
+@implementation E (MyCat)
+-(void) load {

This is to prevent another test from failing? Makes sense. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113455

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


[PATCH] D113694: [Clang] Conform to C++17 definition of literal types

2021-11-11 Thread LĂ©o Lam via Phabricator via cfe-commits
leoetlino updated this revision to Diff 386642.
leoetlino added a comment.

fix formatting issues (sorry for the spam!)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113694

Files:
  clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
  clang/include/clang/AST/DeclCXX.h
  clang/lib/AST/DeclCXX.cpp
  clang/test/CXX/basic/basic.types/p10.cpp

Index: clang/test/CXX/basic/basic.types/p10.cpp
===
--- clang/test/CXX/basic/basic.types/p10.cpp
+++ clang/test/CXX/basic/basic.types/p10.cpp
@@ -1,5 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1y %s -DCXX1Y
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DCXX11 -DCXX11_OR_LATER
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1y %s -DCXX1Y -DCXX11_OR_LATER -DCXX1Y_OR_LATER
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s -DCXX17 -DCXX11_OR_LATER -DCXX1Y_OR_LATER -DCXX17_OR_LATER
 
 struct NonLiteral { NonLiteral(); };
 
@@ -7,7 +8,7 @@
 
 // [C++1y] - void
 constexpr void f() {}
-#ifndef CXX1Y
+#ifdef CXX11
 // expected-error@-2 {{'void' is not a literal type}}
 #endif
 
@@ -20,7 +21,7 @@
 
 struct BeingDefined;
 extern BeingDefined beingdefined;
-struct BeingDefined { 
+struct BeingDefined {
   static constexpr BeingDefined& t = beingdefined;
 };
 
@@ -64,8 +65,14 @@
 };
 constexpr int f(TrivDefaultedDtor) { return 0; }
 
-//  - it is an aggregate type or has at least one constexpr constructor or
+//  - it is [a closure type [C++17]], an aggregate type or has at least one constexpr constructor or
 //constexpr constructor template that is not a copy or move constructor
+#ifndef CXX17_OR_LATER
+// expected-error@+4 {{not a literal type}}
+// expected-note@+2 {{lambda closure types are non-literal types before C++17}}
+#endif
+auto closure = [] {};
+constexpr int f(decltype(closure)) { return 0; }
 struct Agg {
   int a;
   char *b;
@@ -101,7 +108,8 @@
 template constexpr DerivedFromVBase::DerivedFromVBase() : T() {}
 constexpr int nVBase = (DerivedFromVBase(), 0); // expected-error {{constant expression}} expected-note {{cannot construct object of type 'DerivedFromVBase' with virtual base class in a constant expression}}
 
-//  - it has all non-static data members and base classes of literal types
+//  - [C++17] if it is a union, at least one of its non-static data members is of non-volatile literal type, and
+//  - [if it is not a union [C++17]] it has all non-static data members and base classes of literal types
 struct NonLitMember {
   S s; // expected-note {{has data member 's' of non-literal type 'S'}}
 };
@@ -122,6 +130,19 @@
 constexpr int f(MemberType) { return 0; }
 constexpr int f(MemberType) { return 0; } // expected-error {{not a literal type}}
 
+template 
+union UnionType {
+  char c;
+  T t;
+  constexpr UnionType() : c{} {}
+};
+constexpr int f(UnionType) { return 0; }
+#ifndef CXX17_OR_LATER
+// expected-error@+3 {{not a literal type}}
+// expected-note@-6 {{'UnionType' is not literal because it has data member 't' of non-literal type 'NonLiteral'}}
+#endif
+constexpr int f(UnionType) { return 0; }
+
 // - an array of literal type [C++1y] other than an array of runtime bound
 struct ArrGood {
   Agg agg[24];
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -81,8 +81,7 @@
   HasPublicFields(false), HasMutableFields(false), HasVariantMembers(false),
   HasOnlyCMembers(true), HasInClassInitializer(false),
   HasUninitializedReferenceMember(false), HasUninitializedFields(false),
-  HasInheritedConstructor(false),
-  HasInheritedDefaultConstructor(false),
+  HasInheritedConstructor(false), HasInheritedDefaultConstructor(false),
   HasInheritedAssignment(false),
   NeedOverloadResolutionForCopyConstructor(false),
   NeedOverloadResolutionForMoveConstructor(false),
@@ -102,7 +101,8 @@
   DefaultedDefaultConstructorIsConstexpr(true),
   HasConstexprDefaultConstructor(false),
   DefaultedDestructorIsConstexpr(true),
-  HasNonLiteralTypeFieldsOrBases(false), StructuralIfLiteral(true),
+  HasNonLiteralTypeFieldsOrBases(false),
+  HasNonVolatileLiteralTypeFields(false), StructuralIfLiteral(true),
   UserProvidedDefaultConstructor(false), DeclaredSpecialMembers(0),
   ImplicitCopyConstructorCanHaveConstParamForVBase(true),
   ImplicitCopyConstructorCanHaveConstParamForNonVBase(true),
@@ -1103,8 +1103,12 @@
   }
 }
 
+const bool IsNonVolatileLiteralTypeField =
+T->isLiteralType(Context) && !T.isVolatileQualified();
 // Record if this field is the first non-literal or volatile field or base.
-if (!T->isLiteralType(Context) || T.isVolatileQualified())
+if (IsNonVolatileLiteralTypeField)
+  

[PATCH] D87858: [hip] Add HIP scope atomic ops.

2021-11-11 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

In D87858#3125630 , @yaxunl wrote:

> Hi Michael, would you like to continue working on this, or let someone from 
> AMD to take over? Thanks.

please take over it. I will abandon it so that you could start it over.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87858

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


[PATCH] D113707: [clang] Make -masm=intel affect inline asm style

2021-11-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

This seems reasonable, but I worry about headers that contain AT style inline 
asm blobs, such as clang's own intrinsic headers. As you say, the directive is 
local. I would hate to end up in a place where we have to prefix every asm blob 
in clang/lib/Headers/*mmintrin.h with ".att_syntax on;".

Actually, `git grep __asm__ ../clang/lib/Headers` shows that there are not very 
many blobs. Maybe we should just prefix them.


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

https://reviews.llvm.org/D113707

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


[PATCH] D87858: [hip] Add HIP scope atomic ops.

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

Hi Michael, would you like to continue working on this, or let someone from AMD 
to take over? Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87858

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


[PATCH] D113709: Don't consider `LinkageSpec` when calculating DeclContext `Encloses`

2021-11-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: hubert.reinterpretcast, rsmith, aaron.ballman, 
rjmccall.
erichkeane requested review of this revision.

We don't properly handle lookup through using declarations when there is
a linkage spec in the common chain.  This is because `CppLookupName` and
`CppNamespaceLookup` end up skipping `LinkageSpec`'s (correctly, as they
are not lookup scopes), but the `UnqualUsingDirectiveSet` does not.

I discovered that when we are calculating the `CommonAncestor` for a
using-directive, we were coming up with the `LinkageSpec`, instead of
the `LinkageSpec`'s parent.  Then, when we use
`UnqualUsingDirectiveSet::getNamespacesFor` a scope, we don't end up
finding any that were in the `LinkageSpec` (again, since `CppLookupName`
skips linkage specs), so those don't end up participating in the lookup.

The function `UnqualUsingDirectiveSet::addUsingDirective` calculates
this common ancestor via a loop through the the `DeclSpec::Encloses`
function.

Changing this Encloses function to believe that a `LinkageSpec`
`Encloses`nothing ends up fixing the problem without breaking any other tests,
so I opted to do that.  A less aggressive patch could perhaps change only
the `addUsingDirective`, but my examination of all uses of `Encloses`
showedthat it seems to be used exclusively in lookup, which makes me think
this is correct everywhere.


https://reviews.llvm.org/D113709

Files:
  clang/lib/AST/DeclBase.cpp
  clang/test/SemaCXX/lookup-through-linkage.cpp


Index: clang/test/SemaCXX/lookup-through-linkage.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lookup-through-linkage.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -verify
+
+// expected-no-diagnostics
+
+extern "C++" {
+namespace A {
+namespace B {
+int bar;
+}
+} // namespace A
+namespace C {
+void foo() {
+  using namespace A;
+  (void)B::bar;
+}
+} // namespace C
+}
+
+extern "C" {
+extern "C++" {
+namespace D {
+namespace E {
+int bar;
+}
+} // namespace A
+namespace F {
+void foo() {
+  using namespace D;
+  (void)E::bar;
+}
+} // namespace C
+}
+}
Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -1212,7 +1212,8 @@
 return getPrimaryContext()->Encloses(DC);
 
   for (; DC; DC = DC->getParent())
-if (DC->getPrimaryContext() == this)
+if (DC->getDeclKind() != Decl::LinkageSpec &&
+DC->getPrimaryContext() == this)
   return true;
   return false;
 }


Index: clang/test/SemaCXX/lookup-through-linkage.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lookup-through-linkage.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -verify
+
+// expected-no-diagnostics
+
+extern "C++" {
+namespace A {
+namespace B {
+int bar;
+}
+} // namespace A
+namespace C {
+void foo() {
+  using namespace A;
+  (void)B::bar;
+}
+} // namespace C
+}
+
+extern "C" {
+extern "C++" {
+namespace D {
+namespace E {
+int bar;
+}
+} // namespace A
+namespace F {
+void foo() {
+  using namespace D;
+  (void)E::bar;
+}
+} // namespace C
+}
+}
Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -1212,7 +1212,8 @@
 return getPrimaryContext()->Encloses(DC);
 
   for (; DC; DC = DC->getParent())
-if (DC->getPrimaryContext() == this)
+if (DC->getDeclKind() != Decl::LinkageSpec &&
+DC->getPrimaryContext() == this)
   return true;
   return false;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113708: [clang-tidy] Fix `bugprone-use-after-move` check to also consider moves in constructor initializers

2021-11-11 Thread Fabian Wolff via Phabricator via cfe-commits
fwolff created this revision.
fwolff added reviewers: alexfh, carlosgalvezp.
fwolff added a project: clang-tools-extra.
Herald added a subscriber: xazax.hun.
fwolff requested review of this revision.
Herald added a subscriber: cfe-commits.

Fixes PR#38187. Constructors are actually already checked, but only as 
functions, i.e. the check only looks at the constructor body and not at the 
initializers, which misses the (common) case where constructor parameters are 
moved as part of an initializer expression.

One remaining false negative is when both the move //and// the use-after-move 
occur in constructor initializers. This is a lot more difficult to handle, 
though, because the `bugprone-use-after-move` check is currently based on a CFG 
that only takes the body into account, not the initializers, so e.g. 
initialization order would have to manually be considered. I will file a 
follow-up issue for this once PR#38187 is closed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113708

Files:
  clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
@@ -1338,3 +1338,26 @@
   Foo Other{std::move(Bar)};
 }
 } // namespace UnevalContext
+
+class PR38187 {
+public:
+  PR38187(std::string val) : val_(std::move(val)) {
+val.empty();
+// CHECK-NOTES: [[@LINE-1]]:5: warning: 'val' used after it was moved
+// CHECK-NOTES: [[@LINE-3]]:30: note: move occurred here
+  }
+
+private:
+  std::string val_;
+};
+
+class UseAfterMoveInCtorInit {
+public:
+  // TODO: warn here
+  UseAfterMoveInCtorInit(std::string val) : s(std::move(val)), b(val.empty()) {
+  }
+
+private:
+  std::string s;
+  bool b;
+};
Index: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -129,8 +129,12 @@
   Visited.clear();
 
   const CFGBlock *Block = BlockMap->blockContainingStmt(MovingCall);
-  if (!Block)
-return false;
+  if (!Block) {
+// This can happen if MovingCall is in a constructor initializer, which is
+// not included in the CFG because the CFG is built only from the function
+// body.
+Block = >getEntry();
+  }
 
   return findInternal(Block, MovingCall, MovedVariable, TheUseAfterMove);
 }


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
@@ -1338,3 +1338,26 @@
   Foo Other{std::move(Bar)};
 }
 } // namespace UnevalContext
+
+class PR38187 {
+public:
+  PR38187(std::string val) : val_(std::move(val)) {
+val.empty();
+// CHECK-NOTES: [[@LINE-1]]:5: warning: 'val' used after it was moved
+// CHECK-NOTES: [[@LINE-3]]:30: note: move occurred here
+  }
+
+private:
+  std::string val_;
+};
+
+class UseAfterMoveInCtorInit {
+public:
+  // TODO: warn here
+  UseAfterMoveInCtorInit(std::string val) : s(std::move(val)), b(val.empty()) {
+  }
+
+private:
+  std::string s;
+  bool b;
+};
Index: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -129,8 +129,12 @@
   Visited.clear();
 
   const CFGBlock *Block = BlockMap->blockContainingStmt(MovingCall);
-  if (!Block)
-return false;
+  if (!Block) {
+// This can happen if MovingCall is in a constructor initializer, which is
+// not included in the CFG because the CFG is built only from the function
+// body.
+Block = >getEntry();
+  }
 
   return findInternal(Block, MovingCall, MovedVariable, TheUseAfterMove);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111443: [Driver] Fix ToolChain::getSanitizerArgs

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

LGTM


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

https://reviews.llvm.org/D111443

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


[PATCH] D113707: [clang] Make -masm=intel affect inline asm style

2021-11-11 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: hans.
Herald added subscribers: dexonsmith, dang.
thakis requested review of this revision.

With this,

  void f() {  __asm__("mov eax, ebx"); }

now compiles with clang with -masm=intel.

This matches gcc.

The flag is not accepted in clang-cl mode. It has no effect on
MSVC-style `__asm {}` blocks, which are unconditionally in intel
mode both before and after this change.

On difference to gcc is that in clang, inline asm strings are
"local" while they're "global" in gcc. Building the following with
-masm=intel works with clang, but not with gcc where the ".att_syntax"
from the 2nd __asm__() is in effect until file end (or until a
".intel_syntax" somewhere later in the file):

  __asm__("mov eax, ebx");
  __asm__(".att_syntax\nmovl %ebx, %eax");
  __asm__("mov eax, ebx");

Related to PR21401.


https://reviews.llvm.org/D113707

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/inline-asm-intel.c
  clang/test/Driver/masm.c

Index: clang/test/Driver/masm.c
===
--- clang/test/Driver/masm.c
+++ clang/test/Driver/masm.c
@@ -5,10 +5,11 @@
 // RUN: %clang_cl --target=x86_64 /FA -### -- %s 2>&1 | FileCheck --check-prefix=CHECK-CL %s
 
 int f() {
-// CHECK-INTEL: -x86-asm-syntax=intel
-// CHECK-ATT: -x86-asm-syntax=att
+// CHECK-INTEL: -x86-asm-syntax=intel -inline-asm=intel
+// CHECK-ATT: -x86-asm-syntax=att -inline-asm=att
 // CHECK-SOMEREQUIRED: error: unsupported argument 'somerequired' to option 'masm='
 // CHECK-ARM: warning: argument unused during compilation: '-masm=intel'
 // CHECK-CL: -x86-asm-syntax=intel
+// CHECK-CL-NOT: -inline-asm=intel
   return 0;
 }
Index: clang/test/CodeGen/inline-asm-intel.c
===
--- /dev/null
+++ clang/test/CodeGen/inline-asm-intel.c
@@ -0,0 +1,14 @@
+// REQUIRES: x86-registered-target
+
+/// Accept intel inline asm but write it out as att:
+// RUN: %clang_cc1 -triple i386-unknown-unknown -mllvm -x86-asm-syntax=att -inline-asm=intel -O0 -emit-llvm -S %s -o - | FileCheck --check-prefix=ATT %s
+
+/// Accept intel inline asm and write it out as intel:
+// RUN: %clang_cc1 -triple i386-unknown-unknown -mllvm -x86-asm-syntax=intel -inline-asm=intel -O0 -emit-llvm -S %s -o - | FileCheck  --check-prefix=INTEL %s
+
+void f() {
+  __asm__("mov eax, ebx");
+  // ATT: movl %ebx, %eax
+  // INTEL: mov eax, ebx
+}
+
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1614,6 +1614,18 @@
 }
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_inline_asm_EQ)) {
+StringRef Value = A->getValue();
+if (Value == "att") {
+  Opts.InlineAsmDialect = CodeGenOptions::IAD_ATT;
+} else if (Value == "intel") {
+  Opts.InlineAsmDialect = CodeGenOptions::IAD_Intel;
+} else {
+  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
+<< A->getValue();
+}
+  }
+
   // PIC defaults to -fno-direct-access-external-data while non-PIC defaults to
   // -fdirect-access-external-data.
   Opts.DirectAccessExternalData =
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2200,6 +2200,7 @@
 if (Value == "intel" || Value == "att") {
   CmdArgs.push_back("-mllvm");
   CmdArgs.push_back(Args.MakeArgString("-x86-asm-syntax=" + Value));
+  CmdArgs.push_back(Args.MakeArgString("-inline-asm=" + Value));
 } else {
   D.Diag(diag::err_drv_unsupported_option_argument)
   << A->getOption().getName() << Value;
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -2629,8 +2629,14 @@
 llvm::FunctionType::get(ResultType, ArgTypes, false);
 
   bool HasSideEffect = S.isVolatile() || S.getNumOutputs() == 0;
+
+  llvm::InlineAsm::AsmDialect GnuAsmDialect =
+  CGM.getCodeGenOpts().getInlineAsmDialect() == CodeGenOptions::IAD_ATT
+  ? llvm::InlineAsm::AD_ATT
+  : llvm::InlineAsm::AD_Intel;
   llvm::InlineAsm::AsmDialect AsmDialect = isa() ?
-llvm::InlineAsm::AD_Intel : llvm::InlineAsm::AD_ATT;
+llvm::InlineAsm::AD_Intel : GnuAsmDialect;
+
   llvm::InlineAsm *IA = llvm::InlineAsm::get(
   FTy, AsmString, Constraints, HasSideEffect,
   /* IsAlignStack */ false, AsmDialect, HasUnwindClobber);
Index: clang/include/clang/Driver/Options.td

[PATCH] D8467: C++14: Disable sized deallocation by default due to ABI breakage

2021-11-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D8467#3125471 , @rnk wrote:

> In D8467#3125386 , @rjmccall wrote:
>
>> Conceptually, this is (and will always be) a platform decision.  On Apple 
>> platforms, we have a formalized concept of deployment target, where specific 
>> minimum OS versions support sized deallocation and others do not.  On most 
>> other platforms, this is much vaguer — basically down to what C++ libraries 
>> you've got installed — and probably has to be controlled by a flag.  
>> Enabling that flag by default on any particular Linux distribution release 
>> is something I'm not sure we can do unconditionally.
>
> It is already a flag, `-fsized-deallocation`. On some level, whatever default 
> we choose is just a guess about the C++ library support level. Clang tries to 
> encode all kinds of Linux distro-specific knowledge, and it's often wrong 
> anyway. After all that logic, there will be some default. I think at this 
> point the feature should default to being enabled.

Okay.  I think that's fine for most platforms.  Apple would like this to only 
be enabled conditionally based on deployment target.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D8467

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


[PATCH] D112024: [clang] diagnose_as attribute for Fortify diagnosing like builtins.

2021-11-11 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield updated this revision to Diff 386623.
mbenfield added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112024

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/attr-diagnose-as-builtin.c

Index: clang/test/Sema/attr-diagnose-as-builtin.c
===
--- /dev/null
+++ clang/test/Sema/attr-diagnose-as-builtin.c
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 %s -verify
+// RUN: %clang_cc1 -xc++ -triple x86_64-apple-macosx10.14.0 %s -verify
+
+typedef unsigned long size_t;
+
+void *test_memcpy(const void *src, size_t c, void *dst) __attribute__((diagnose_as_builtin(__builtin_memcpy, 3, 1, 2))) {
+  return __builtin_memcpy(dst, src, c);
+}
+
+void call_test_memcpy() {
+  char bufferA[10];
+  char bufferB[11];
+  test_memcpy(bufferB, 10, bufferA);
+  test_memcpy(bufferB, 11, bufferA); // expected-warning {{'memcpy' will always overflow; destination buffer has size 10, but size argument is 11}}
+}
+
+void failure_function_doesnt_exist() __attribute__((diagnose_as_builtin(__function_that_doesnt_exist))) {} // expected-error {{use of undeclared identifier '__function_that_doesnt_exist'}}
+
+void not_a_builtin() {}
+
+void failure_not_a_builtin() __attribute__((diagnose_as_builtin(not_a_builtin))) {} // expected-error {{'diagnose_as_builtin' attribute requires parameter 1 to be a builtin function}}
+
+void failure_too_many_parameters(void *dst, const void *src, size_t count, size_t nothing) __attribute__((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3, 4))) {} // expected-error {{'diagnose_as_builtin' attribute references function __builtin_memcpy, which requires exactly 3 arguments}}
+
+void failure_too_few_parameters(void *dst, const void *src) __attribute__((diagnose_as_builtin(__builtin_memcpy, 1, 2))) {} // expected-error{{'diagnose_as_builtin' attribute references function __builtin_memcpy, which requires exactly 3 arguments}}
+
+void failure_not_an_integer(void *dst, const void *src, size_t count) __attribute__((diagnose_as_builtin(__builtin_memcpy, "abc", 2, 3))) {} // expected-error{{'diagnose_as_builtin' attribute requires parameter 2 to be an integer constant}}
+
+void failure_not_a_builtin2() __attribute__((diagnose_as_builtin("abc"))) {} // expected-error{{'diagnose_as_builtin' attribute requires parameter 1 to be a builtin function}}
+
+void failure_parameter_index_bounds(void *dst, const void *src) __attribute__((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3))) {} // expected-error{{'diagnose_as_builtin' attribute references parameter 3, but the function failure_parameter_index_bounds has only 2 parameters}}
+
+void failure_parameter_types(double dst, const void *src, size_t count) __attribute__((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3))) {} // expected-error{{'diagnose_as_builtin' attribute parameter types do not match: parameter 1 of function 'failure_parameter_types' has type 'double', but parameter 1 of function '__builtin_memcpy' has type 'void *'}}
+
+void to_redeclare(void *dst, const void *src, size_t count);
+
+void use_to_redeclare() {
+  char src[10];
+  char dst[9];
+  // We shouldn't get an error yet.
+  to_redeclare(dst, src, 10);
+}
+
+void to_redeclare(void *dst, const void *src, size_t count) __attribute((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3)));
+
+void error_to_redeclare() {
+  char src[10];
+  char dst[9];
+  // Now we get an error.
+  to_redeclare(dst, src, 10); // expected-warning {{'memcpy' will always overflow; destination buffer has size 9, but size argument is 10}}
+}
+
+// Make sure this works even with extra qualifiers and the pass_object_size attribute.
+void *memcpy2(void *const dst __attribute__((pass_object_size(0))), const void *src, size_t copy_amount) __attribute((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3)));
+
+void call_memcpy2() {
+  char buf1[10];
+  char buf2[11];
+  memcpy2(buf1, buf2, 11); // expected-warning {{'memcpy' will always overflow; destination buffer has size 10, but size argument is 11}}
+}
+
+#ifdef __cplusplus
+template 
+void some_templated_function(int x) {
+  return;
+}
+
+void failure_template(int x) __attribute__((diagnose_as_builtin(some_templated_function, 1))) {} // expected-error{{'diagnose_as_builtin' attribute requires parameter 1 to be a builtin function}}
+
+void failure_template_instantiation(int x) __attribute__((diagnose_as_builtin(some_templated_function, 1))) {} // expected-error{{'diagnose_as_builtin' attribute requires parameter 1 to be a builtin function}}
+#endif
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ 

[PATCH] D112024: [clang] diagnose_as attribute for Fortify diagnosing like builtins.

2021-11-11 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield added a comment.

Would @george.burgess.iv and/or @aaron.ballman mind taking another look at the 
latest revision?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112024

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


[PATCH] D113694: [Clang] Conform to C++17 definition of literal types

2021-11-11 Thread LĂ©o Lam via Phabricator via cfe-commits
leoetlino updated this revision to Diff 386622.
leoetlino added a comment.

Fix Clang.CodeGenCXX::mangle-class-nttp.cpp test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113694

Files:
  clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
  clang/include/clang/AST/DeclCXX.h
  clang/lib/AST/DeclCXX.cpp
  clang/test/CXX/basic/basic.types/p10.cpp

Index: clang/test/CXX/basic/basic.types/p10.cpp
===
--- clang/test/CXX/basic/basic.types/p10.cpp
+++ clang/test/CXX/basic/basic.types/p10.cpp
@@ -1,5 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1y %s -DCXX1Y
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DCXX11 -DCXX11_OR_LATER
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1y %s -DCXX1Y -DCXX11_OR_LATER -DCXX1Y_OR_LATER
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s -DCXX17 -DCXX11_OR_LATER -DCXX1Y_OR_LATER -DCXX17_OR_LATER
 
 struct NonLiteral { NonLiteral(); };
 
@@ -7,7 +8,7 @@
 
 // [C++1y] - void
 constexpr void f() {}
-#ifndef CXX1Y
+#ifdef CXX11
 // expected-error@-2 {{'void' is not a literal type}}
 #endif
 
@@ -20,7 +21,7 @@
 
 struct BeingDefined;
 extern BeingDefined beingdefined;
-struct BeingDefined { 
+struct BeingDefined {
   static constexpr BeingDefined& t = beingdefined;
 };
 
@@ -64,8 +65,14 @@
 };
 constexpr int f(TrivDefaultedDtor) { return 0; }
 
-//  - it is an aggregate type or has at least one constexpr constructor or
+//  - it is [a closure type [C++17]], an aggregate type or has at least one constexpr constructor or
 //constexpr constructor template that is not a copy or move constructor
+#ifndef CXX17_OR_LATER
+// expected-error@+4 {{not a literal type}}
+// expected-note@+2 {{lambda closure types are non-literal types before C++17}}
+#endif
+auto closure = [] {};
+constexpr int f(decltype(closure)) { return 0; }
 struct Agg {
   int a;
   char *b;
@@ -101,7 +108,8 @@
 template constexpr DerivedFromVBase::DerivedFromVBase() : T() {}
 constexpr int nVBase = (DerivedFromVBase(), 0); // expected-error {{constant expression}} expected-note {{cannot construct object of type 'DerivedFromVBase' with virtual base class in a constant expression}}
 
-//  - it has all non-static data members and base classes of literal types
+//  - [C++17] if it is a union, at least one of its non-static data members is of non-volatile literal type, and
+//  - [if it is not a union [C++17]] it has all non-static data members and base classes of literal types
 struct NonLitMember {
   S s; // expected-note {{has data member 's' of non-literal type 'S'}}
 };
@@ -122,6 +130,19 @@
 constexpr int f(MemberType) { return 0; }
 constexpr int f(MemberType) { return 0; } // expected-error {{not a literal type}}
 
+template
+union UnionType {
+  char c;
+  T t;
+  constexpr UnionType() : c{} {}
+};
+constexpr int f(UnionType) { return 0; }
+#ifndef CXX17_OR_LATER
+// expected-error@+3 {{not a literal type}}
+// expected-note@-6 {{'UnionType' is not literal because it has data member 't' of non-literal type 'NonLiteral'}}
+#endif
+constexpr int f(UnionType) { return 0; }
+
 // - an array of literal type [C++1y] other than an array of runtime bound
 struct ArrGood {
   Agg agg[24];
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -102,7 +102,8 @@
   DefaultedDefaultConstructorIsConstexpr(true),
   HasConstexprDefaultConstructor(false),
   DefaultedDestructorIsConstexpr(true),
-  HasNonLiteralTypeFieldsOrBases(false), StructuralIfLiteral(true),
+  HasNonLiteralTypeFieldsOrBases(false),
+  HasNonVolatileLiteralTypeFields(false), StructuralIfLiteral(true),
   UserProvidedDefaultConstructor(false), DeclaredSpecialMembers(0),
   ImplicitCopyConstructorCanHaveConstParamForVBase(true),
   ImplicitCopyConstructorCanHaveConstParamForNonVBase(true),
@@ -1103,8 +1104,12 @@
   }
 }
 
+const bool IsNonVolatileLiteralTypeField =
+T->isLiteralType(Context) && !T.isVolatileQualified();
 // Record if this field is the first non-literal or volatile field or base.
-if (!T->isLiteralType(Context) || T.isVolatileQualified())
+if (IsNonVolatileLiteralTypeField)
+  data().HasNonVolatileLiteralTypeFields = true;
+else
   data().HasNonLiteralTypeFieldsOrBases = true;
 
 if (Field->hasInClassInitializer() ||
Index: clang/include/clang/AST/DeclCXX.h
===
--- clang/include/clang/AST/DeclCXX.h
+++ clang/include/clang/AST/DeclCXX.h
@@ -1354,6 +1354,12 @@
 return data().HasNonLiteralTypeFieldsOrBases;
   }
 
+  /// Determine whether this class has a non-volatile literal type
+  /// non-static data member.
+  bool hasNonVolatileLiteralTypeFields() 

[PATCH] D113518: [clang] Create delegating constructors even in templates

2021-11-11 Thread Fabian Wolff via Phabricator via cfe-commits
fwolff added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp:374
 {
   PositiveSelfInitialization() : PositiveSelfInitialization() {}
 };

carlosgalvezp wrote:
> fwolff wrote:
> > carlosgalvezp wrote:
> > > Not really sure what this test is meant to do. Why would it call the 
> > > destructor of the own class in it's own constructor? Looks very strange 
> > > to me.
> > > 
> > > If anything, the constructor should call the constructor of the base:
> > > 
> > > PositiveSelfInitialization() : NegativeAggregateType()
> > > 
> > > What do you think?
> > The comment above talks about a "pathological template", so my guess is 
> > that this checks that clang-tidy doesn't crash for this input. The only 
> > reason why I had to touch this test at all is that the constructor is now 
> > treated as a delegating constructor, which suppresses the warning.
> Hmm, I see. I would like to make sure we still catch the failure mode "this 
> constructor does not initialize these base classes" for class templates.
> 
> I don't see such test existing (only for non-template classes), maybe you can 
> add that too?
Good point, done now.


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

https://reviews.llvm.org/D113518

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


[PATCH] D113518: [clang] Create delegating constructors even in templates

2021-11-11 Thread Fabian Wolff via Phabricator via cfe-commits
fwolff updated this revision to Diff 386620.

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

https://reviews.llvm.org/D113518

Files:
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
  clang/lib/Sema/SemaDeclCXX.cpp

Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -4496,6 +4496,8 @@
   // (broken) code in a non-template! SetCtorInitializers does not expect this.
   bool Dependent = CurContext->isDependentContext() &&
(BaseType->isDependentType() || Init->isTypeDependent());
+  bool Delegating = Context.hasSameUnqualifiedType(
+  QualType(ClassDecl->getTypeForDecl(), 0), BaseType);
 
   SourceRange InitRange = Init->getSourceRange();
   if (EllipsisLoc.isValid()) {
@@ -4519,8 +4521,7 @@
   const CXXBaseSpecifier *DirectBaseSpec = nullptr;
   const CXXBaseSpecifier *VirtualBaseSpec = nullptr;
   if (!Dependent) {
-if (Context.hasSameUnqualifiedType(QualType(ClassDecl->getTypeForDecl(),0),
-   BaseType))
+if (Delegating)
   return BuildDelegatingInitializer(BaseTInfo, Init, ClassDecl);
 
 FindBaseInitializer(*this, ClassDecl, BaseType, DirectBaseSpec,
@@ -4548,10 +4549,14 @@
   if (Dependent) {
 DiscardCleanupsInEvaluationContext();
 
-return new (Context) CXXCtorInitializer(Context, BaseTInfo,
-/*IsVirtual=*/false,
-InitRange.getBegin(), Init,
-InitRange.getEnd(), EllipsisLoc);
+if (!Delegating)
+  return new (Context)
+  CXXCtorInitializer(Context, BaseTInfo,
+ /*IsVirtual=*/false, InitRange.getBegin(), Init,
+ InitRange.getEnd(), EllipsisLoc);
+else
+  return new (Context) CXXCtorInitializer(
+  Context, BaseTInfo, InitRange.getBegin(), Init, InitRange.getEnd());
   }
 
   // C++ [base.class.init]p2:
@@ -5063,14 +5068,16 @@
   memcpy(initializer, , sizeof (CXXCtorInitializer*));
   Constructor->setCtorInitializers(initializer);
 
-  if (CXXDestructorDecl *Dtor = LookupDestructor(Constructor->getParent())) {
-MarkFunctionReferenced(Initializer->getSourceLocation(), Dtor);
-DiagnoseUseOfDecl(Dtor, Initializer->getSourceLocation());
-  }
+  if (!Constructor->isDependentContext()) {
+if (CXXDestructorDecl *Dtor = LookupDestructor(Constructor->getParent())) {
+  MarkFunctionReferenced(Initializer->getSourceLocation(), Dtor);
+  DiagnoseUseOfDecl(Dtor, Initializer->getSourceLocation());
+}
 
-  DelegatingCtorDecls.push_back(Constructor);
+DelegatingCtorDecls.push_back(Constructor);
 
-  DiagnoseUninitializedFields(*this, Constructor);
+DiagnoseUninitializedFields(*this, Constructor);
+  }
 
   return false;
 }
Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
@@ -372,8 +372,6 @@
 class PositiveSelfInitialization : NegativeAggregateType
 {
   PositiveSelfInitialization() : PositiveSelfInitialization() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these bases: NegativeAggregateType
-  // CHECK-FIXES: PositiveSelfInitialization() : NegativeAggregateType(), PositiveSelfInitialization() {}
 };
 
 class PositiveIndirectMember {
@@ -552,3 +550,27 @@
   int A;
   // CHECK-FIXES-NOT: int A{};
 };
+
+// Check that a delegating constructor in a template does not trigger false positives (PR#37902).
+template 
+struct TemplateWithDelegatingCtor {
+  int X;
+  TemplateWithDelegatingCtor() : X{} {};
+  TemplateWithDelegatingCtor(int) : TemplateWithDelegatingCtor(){};
+};
+
+template 
+struct TemplateWithDelegatingCtorNSDMI {
+  int X{};
+  TemplateWithDelegatingCtorNSDMI() = default;
+  TemplateWithDelegatingCtorNSDMI(int) : TemplateWithDelegatingCtorNSDMI() {}
+};
+
+template 
+class TemplateDoesNotInitializeBase : NegativeAggregateType {
+  int X;
+  TemplateDoesNotInitializeBase() : X(42) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these bases: NegativeAggregateType
+
+  TemplateDoesNotInitializeBase(double) : TemplateDoesNotInitializeBase() {}
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D8467: C++14: Disable sized deallocation by default due to ABI breakage

2021-11-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D8467#3125386 , @rjmccall wrote:

> Conceptually, this is (and will always be) a platform decision.  On Apple 
> platforms, we have a formalized concept of deployment target, where specific 
> minimum OS versions support sized deallocation and others do not.  On most 
> other platforms, this is much vaguer — basically down to what C++ libraries 
> you've got installed — and probably has to be controlled by a flag.  Enabling 
> that flag by default on any particular Linux distribution release is 
> something I'm not sure we can do unconditionally.

It is already a flag, `-fsized-deallocation`. On some level, whatever default 
we choose is just a guess about the C++ library support level. Clang tries to 
encode all kinds of Linux distro-specific knowledge, and it's often wrong 
anyway. After all that logic, there will be some default. I think at this point 
the feature should default to being enabled.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D8467

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


[PATCH] D108567: Implement #pragma clang final extension

2021-11-11 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D108567#3110925 , @sberg wrote:

> does not produce any warnings/errors for me and indicates that NULL silently 
> gets redefined as a null pointer constant in stddef.h.  Is that intended?

Nope, that's a bug. Fixed in 3e7ad1f2b2c0a753749eaba88d369d6032a50764 
. Thank 
you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108567

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


[clang] 3e7ad1f - Emit final macro diagnostics in system headers

2021-11-11 Thread Chris Bieneman via cfe-commits

Author: Chris Bieneman
Date: 2021-11-11T13:51:26-06:00
New Revision: 3e7ad1f2b2c0a753749eaba88d369d6032a50764

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

LOG: Emit final macro diagnostics in system headers

Final macro diagnostics should log from system headers.

As planned, final macros are hard-mode. They always log diagnostics.

Added: 
clang/test/Lexer/Inputs/final-macro-system.h

Modified: 
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/test/Lexer/final-macro.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 92c6b0bbffc30..805dcab2e0084 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -564,7 +564,7 @@ def note_pp_macro_annotation :
 def warn_pragma_final_macro :
   ExtWarn<"macro %0 has been marked as final and should not be "
   "%select{undefined|redefined}1">,
-  InGroup;
+  InGroup,  ShowInSystemHeader;
 
 // - #pragma execution_character_set(...)
 def warn_pragma_exec_charset_expected :

diff  --git a/clang/test/Lexer/Inputs/final-macro-system.h 
b/clang/test/Lexer/Inputs/final-macro-system.h
new file mode 100644
index 0..f30e5d45e4dcd
--- /dev/null
+++ b/clang/test/Lexer/Inputs/final-macro-system.h
@@ -0,0 +1,4 @@
+// expected-warning@+1{{macro 'SYSTEM_MACRO' has been marked as final and 
should not be undefined}}
+#undef SYSTEM_MACRO
+// expected-warning@+1{{macro 'SYSTEM_MACRO' has been marked as final and 
should not be redefined}}
+#define SYSTEM_MACRO WoahMoar

diff  --git a/clang/test/Lexer/final-macro.c b/clang/test/Lexer/final-macro.c
index 498773d9dfdf5..2992714dd8a5a 100644
--- a/clang/test/Lexer/final-macro.c
+++ b/clang/test/Lexer/final-macro.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Wfinal-macro %s -fsyntax-only -verify
+// RUN: %clang_cc1 -Wfinal-macro %s -fsyntax-only -isystem %S/Inputs -verify
 
 // Test warning production
 #define Foo 1
@@ -43,3 +43,8 @@
 // no diagnostics triggered by these pragmas.
 #pragma clang deprecated(Foo)
 #pragma clang restrict_expansion(Foo)
+
+#define SYSTEM_MACRO Woah
+// expected-note@+1 2{{macro marked 'final' here}}
+#pragma clang final(SYSTEM_MACRO)
+#include 



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


[PATCH] D112914: Misleading identifier detection

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



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/misc-misleading-identifier.rst:12
+
+.. code-block:: c
+

aaronpuchert wrote:
> Sphinx can't parse that (perhaps unsurprisingly), could you declare that as 
> having no language?
> 
> ```
> Warning, treated as error:
> /home/buildbot/llvm-build-dir/clang-tools-sphinx-docs/llvm/src/clang-tools-extra/docs/clang-tidy/checks/misc-misleading-identifier.rst:12:Could
>  not lex literal_block as "c". Highlighting skipped.
> ```
> 
> Should be reproducible by building `docs-clang-tools-html` (might need `-j1`).
I fixed this in ac8c813b89f62efcaff4d0c92fdf1a5dd29d795d as the bot was red.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112914

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


[clang-tools-extra] ac8c813 - Fix Sphinx build diagnostics

2021-11-11 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-11-11T14:38:11-05:00
New Revision: ac8c813b89f62efcaff4d0c92fdf1a5dd29d795d

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

LOG: Fix Sphinx build diagnostics

This won't parse as either C or C++ according to Sphinx, so switched to
text to appease Sphinx.

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/misc-misleading-identifier.rst

Removed: 




diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/misc-misleading-identifier.rst 
b/clang-tools-extra/docs/clang-tidy/checks/misc-misleading-identifier.rst
index 8bd8d9b50..1e2b61ac67345 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/misc-misleading-identifier.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/misc-misleading-identifier.rst
@@ -9,7 +9,7 @@ line, as described in `Trojan Source 
`_.
 
 An example of such misleading code follows:
 
-.. code-block:: c
+.. code-block:: text
 
   #include 
 



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


[PATCH] D8467: C++14: Disable sized deallocation by default due to ABI breakage

2021-11-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Conceptually, this is (and will always be) a platform decision.  On Apple 
platforms, we have a formalized concept of deployment target, where specific 
minimum OS versions support sized deallocation and others do not.  On most 
other platforms, this is much vaguer — basically down to what C++ libraries 
you've got installed — and probably has to be controlled by a flag.  Enabling 
that flag by default on any particular Linux distribution release is something 
I'm not sure we can do unconditionally.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D8467

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


[PATCH] D113641: [llvm] Add a SFINAE template parameter to DenseMapInfo

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

Nice :) This looks pretty straightforward, but given how core this is, wait for 
another approver or two.




Comment at: llvm/include/llvm/ADT/DenseMapInfo.h:42
 
-template
-struct DenseMapInfo {
+template  struct DenseMapInfo {
   //static inline T getEmptyKey();

bondhugula wrote:
> A code comment here?
+1. Is there a doc that needs to be updated too? We should update the source of 
truth is for "here's how to use DenseMapInfo", if such documentation even 
exists :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113641

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


[PATCH] D51650: Implement target_clones multiversioning

2021-11-11 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9deab60ae710: Implement target_clones multiversioning 
(authored by erichkeane).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D51650?vs=386573=386597#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D51650

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-target-clones.c
  clang/test/CodeGenCXX/attr-target-clones.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-cpuspecific.c
  clang/test/Sema/attr-target-clones.c
  clang/test/SemaCXX/attr-target-clones.cpp

Index: clang/test/SemaCXX/attr-target-clones.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/attr-target-clones.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu  -fsyntax-only -verify -fexceptions -fcxx-exceptions %s -std=c++14
+
+// expected-error@+2 {{attribute 'target_clones' multiversioned functions do not yet support function templates}}
+template
+int __attribute__((target_clones("sse4.2", "default"))) foo(){ return 1;}
+
+void uses_lambda() {
+  // expected-error@+1 {{attribute 'target_clones' multiversioned functions do not yet support lambdas}}
+  auto x = []()__attribute__((target_clones("sse4.2", "arch=ivybridge", "default"))) {};
+  x();
+}
Index: clang/test/Sema/attr-target-clones.c
===
--- /dev/null
+++ clang/test/Sema/attr-target-clones.c
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu  -fsyntax-only -verify %s
+
+// expected-error@+1 {{'target_clones' multiversioning requires a default target}}
+void __attribute__((target_clones("sse4.2", "arch=sandybridge")))
+no_default(void);
+
+// expected-error@+2 {{'target_clones' and 'target' attributes are not compatible}}
+// expected-note@+1 {{conflicting attribute is here}}
+void __attribute__((target("sse4.2"), target_clones("arch=sandybridge")))
+ignored_attr(void);
+// expected-error@+2 {{'target' and 'target_clones' attributes are not compatible}}
+// expected-note@+1 {{conflicting attribute is here}}
+void __attribute__((target_clones("arch=sandybridge,default"), target("sse4.2")))
+ignored_attr2(void);
+
+int redecl(void);
+int __attribute__((target_clones("sse4.2", "default"))) redecl(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2", "default"))) redecl2(void);
+int __attribute__((target_clones("sse4.2", "default"))) redecl2(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2", "default"))) redecl3(void);
+int redecl3(void);
+
+int __attribute__((target_clones("sse4.2", "arch=atom", "default"))) redecl4(void);
+// expected-error@+3 {{'target_clones' attribute does not match previous declaration}}
+// expected-note@-2 {{previous declaration is here}}
+int __attribute__((target_clones("sse4.2", "arch=sandybridge", "default")))
+redecl4(void) { return 1; }
+
+int __attribute__((target("sse4.2"))) redef2(void) { return 1; }
+// expected-error@+2 {{multiversioning attributes cannot be combined}}
+// expected-note@-2 {{previous declaration is here}}
+int __attribute__((target_clones("sse4.2", "default"))) redef2(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2,default"))) redef3(void) { return 1; }
+// expected-error@+2 {{redefinition of 'redef3'}}
+// expected-note@-2 {{previous definition is here}}
+int __attribute__((target_clones("sse4.2,default"))) redef3(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2,default"))) redef4(void) { return 1; }
+// expected-error@+2 {{redefinition of 'redef4'}}
+// expected-note@-2 {{previous definition is here}}
+int __attribute__((target_clones("sse4.2,default"))) redef4(void) { return 1; }
+
+// Duplicates are allowed, however they alter name mangling.
+// expected-warning@+2 {{mixing 'target_clones' specifier mechanisms is permitted for GCC compatibility}}
+// expected-warning@+1 2 {{version list contains duplicate entries}}
+int __attribute__((target_clones("arch=atom,arch=atom", "arch=atom,default")))
+dupes(void) { return 1; }
+
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("")))
+empty_target_1(void);
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones(",default")))
+empty_target_2(void);
+// expected-warning@+1 {{unsupported '' in 

[clang] 9deab60 - Implement target_clones multiversioning

2021-11-11 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2021-11-11T11:11:16-08:00
New Revision: 9deab60ae710f8c4cc810cd680edfb64c803f42d

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

LOG: Implement target_clones multiversioning

As discussed here: https://lwn.net/Articles/691932/

GCC6.0 adds target_clones multiversioning. This functionality is
an odd cross between the cpu_dispatch and 'target' MV, but is compatible
with neither.

This attribute allows you to list all options, then emits a separately
optimized version of each function per-option (similar to the
cpu_specific attribute). It automatically generates a resolver, just
like the other two.

The mangling however, is... ODD to say the least. The mangling format
is:
...

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

Added: 
clang/test/CodeGen/attr-target-clones.c
clang/test/CodeGenCXX/attr-target-clones.cpp
clang/test/Sema/attr-target-clones.c
clang/test/SemaCXX/attr-target-clones.cpp

Modified: 
clang/include/clang/AST/Decl.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/Decl.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/test/Sema/attr-cpuspecific.c

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 85a3a8ab69708..2eacf1105c18c 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -1840,7 +1840,8 @@ enum class MultiVersionKind {
   None,
   Target,
   CPUSpecific,
-  CPUDispatch
+  CPUDispatch,
+  TargetClones
 };
 
 /// Represents a function declaration or definition.
@@ -2459,6 +2460,10 @@ class FunctionDecl : public DeclaratorDecl,
   /// the target functionality.
   bool isTargetMultiVersion() const;
 
+  /// True if this function is a multiversioned dispatch function as a part of
+  /// the target-clones functionality.
+  bool isTargetClonesMultiVersion() const;
+
   /// \brief Get the associated-constraints of this function declaration.
   /// Currently, this will either be a vector of size 1 containing the
   /// trailing-requires-clause or an empty vector.

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index d8f0fcd56550c..1efde2a0f25f4 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2676,6 +2676,40 @@ def Target : InheritableAttr {
   }];
 }
 
+def TargetClones : InheritableAttr {
+  let Spellings = [GCC<"target_clones">];
+  let Args = [VariadicStringArgument<"featuresStrs">];
+  let Documentation = [TargetClonesDocs];
+  let Subjects = SubjectList<[Function], ErrorDiag>;
+  let AdditionalMembers = [{
+StringRef getFeatureStr(unsigned Index) const {
+  return *(featuresStrs_begin() + Index);
+}
+// 'default' is always moved to the end, so it isn't considered
+// when mangling the index.
+unsigned getMangledIndex(unsigned Index) const {
+  if (getFeatureStr(Index) == "default")
+return std::count_if(featuresStrs_begin(), featuresStrs_end(),
+  [](StringRef S) { return S != "default"; });
+
+  return std::count_if(featuresStrs_begin(), featuresStrs_begin() + Index,
+   [](StringRef S) { return S != "default"; });
+}
+
+// True if this is the first of this version to appear in the config 
string.
+// This is used to make sure we don't try to emit this function multiple
+// times.
+bool isFirstOfVersion(unsigned Index) const {
+  StringRef FeatureStr(getFeatureStr(Index));
+  return 0 == std::count_if(
+  featuresStrs_begin(), featuresStrs_begin() + Index,
+  [FeatureStr](StringRef S) { return S == FeatureStr; });
+}
+  }];
+}
+
+def : MutualExclusions<[TargetClones, Target, CPUDispatch, CPUSpecific]>;
+
 def MinVectorWidth : InheritableAttr {
   let Spellings = [Clang<"min_vector_width">];
   let Args = [UnsignedArgument<"VectorWidth">];

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index e7afb3699eb17..10cce4c2d6898 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -2233,6 +2233,40 @@ Additionally, a function may not become multiversioned 
after its first use.
 }];
 }
 
+def TargetClonesDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Clang supports the 

[PATCH] D113614: [AIX][NFC] Disable clang-repl tests failing due to lack of 64-bit XCOFF support.

2021-11-11 Thread Steven Wan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG42102bce98e5: [AIX][NFC] Disable clang-repl tests failing 
due to lack of 64-bit XCOFF support. (authored by stevewan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113614

Files:
  clang/unittests/Interpreter/InterpreterTest.cpp


Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -145,7 +145,11 @@
   ~LLVMInitRAII() { llvm::llvm_shutdown(); }
 } LLVMInit;
 
+#ifdef _AIX
+TEST(IncrementalProcessing, DISABLED_FindMangledNameSymbol) {
+#else
 TEST(IncrementalProcessing, FindMangledNameSymbol) {
+#endif
 
   std::unique_ptr Interp = createInterpreter();
 
@@ -201,7 +205,11 @@
   return R.getFoundDecl();
 }
 
+#ifdef _AIX
+TEST(IncrementalProcessing, DISABLED_InstantiateTemplate) {
+#else
 TEST(IncrementalProcessing, InstantiateTemplate) {
+#endif
   // FIXME: We cannot yet handle delayed template parsing. If we run with
   // -fdelayed-template-parsing we try adding the newly created decl to the
   // active PTU which causes an assert.


Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -145,7 +145,11 @@
   ~LLVMInitRAII() { llvm::llvm_shutdown(); }
 } LLVMInit;
 
+#ifdef _AIX
+TEST(IncrementalProcessing, DISABLED_FindMangledNameSymbol) {
+#else
 TEST(IncrementalProcessing, FindMangledNameSymbol) {
+#endif
 
   std::unique_ptr Interp = createInterpreter();
 
@@ -201,7 +205,11 @@
   return R.getFoundDecl();
 }
 
+#ifdef _AIX
+TEST(IncrementalProcessing, DISABLED_InstantiateTemplate) {
+#else
 TEST(IncrementalProcessing, InstantiateTemplate) {
+#endif
   // FIXME: We cannot yet handle delayed template parsing. If we run with
   // -fdelayed-template-parsing we try adding the newly created decl to the
   // active PTU which causes an assert.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 42102bc - [AIX][NFC] Disable clang-repl tests failing due to lack of 64-bit XCOFF support.

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

Author: Steven Wan
Date: 2021-11-11T14:10:42-05:00
New Revision: 42102bce98e527f994a7bc68b2255d9e0462f6eb

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

LOG: [AIX][NFC] Disable clang-repl tests failing due to lack of 64-bit XCOFF 
support.

The following interpreter tests failed on AIX because 64-bit XCOFF object files 
are currently not supported on AIX. This patch disables the tests on AIX for 
the time being.

Reviewed By: Jake-Egan

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

Added: 


Modified: 
clang/unittests/Interpreter/InterpreterTest.cpp

Removed: 




diff  --git a/clang/unittests/Interpreter/InterpreterTest.cpp 
b/clang/unittests/Interpreter/InterpreterTest.cpp
index 0f02935b533b4..742aa49763577 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -145,7 +145,11 @@ struct LLVMInitRAII {
   ~LLVMInitRAII() { llvm::llvm_shutdown(); }
 } LLVMInit;
 
+#ifdef _AIX
+TEST(IncrementalProcessing, DISABLED_FindMangledNameSymbol) {
+#else
 TEST(IncrementalProcessing, FindMangledNameSymbol) {
+#endif
 
   std::unique_ptr Interp = createInterpreter();
 
@@ -201,7 +205,11 @@ static NamedDecl *LookupSingleName(Interpreter , 
const char *Name) {
   return R.getFoundDecl();
 }
 
+#ifdef _AIX
+TEST(IncrementalProcessing, DISABLED_InstantiateTemplate) {
+#else
 TEST(IncrementalProcessing, InstantiateTemplate) {
+#endif
   // FIXME: We cannot yet handle delayed template parsing. If we run with
   // -fdelayed-template-parsing we try adding the newly created decl to the
   // active PTU which causes an assert.



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


[PATCH] D8467: C++14: Disable sized deallocation by default due to ABI breakage

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

In D8467#3095610 , @zixuan-wu wrote:

> Hi, I am wondering could -fsized-deallocation this be enabled by default 
> nowadays in 2021?

Were you planning to work on this?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D8467

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


[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2021-11-11 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis updated this revision to Diff 386594.
ggeorgakoudis added a comment.
Herald added subscribers: asavonic, ormris.

Update tests
Fix for attributes to kmpc_alloc_aggregate_arg
Do not emit allocations if there are no arguments in the aggregate


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/AST/ast-dump-openmp-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for.c
  clang/test/CodeGenCXX/observe-noexcept.cpp
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/cancellation_point_codegen.cpp
  clang/test/OpenMP/debug-info-complex-byval.cpp
  clang/test/OpenMP/debug-info-openmp-array.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/declare_variant_construct_codegen_1.c
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/for_lastprivate_codegen.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_private_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen_UDR.cpp
  clang/test/OpenMP/for_reduction_task_codegen.cpp
  clang/test/OpenMP/master_taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_in_reduction_codegen.cpp
  clang/test/OpenMP/metadirective_device_kind_codegen.c
  clang/test/OpenMP/metadirective_device_kind_codegen.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_lambda_pointer_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  clang/test/OpenMP/openmp_win_codegen.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  clang/test/OpenMP/parallel_copyin_codegen.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_for_lastprivate_conditional.cpp
  clang/test/OpenMP/parallel_for_linear_codegen.cpp
  

[PATCH] D106585: Fix clang debug info irgen of i128 enums

2021-11-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a subscriber: hans.
rnk added a comment.

In D106585#3122726 , @glandium wrote:

> It seems to have been fixed in rG3c47c5ca13b8a502de3272e8105548715947b7a8 
> .

Are you sure you've arrived at the right code review? This change, D106585 
, modified type information, which is 
unrelated to the change you linked to. We have also noticed *other* determinism 
issues (follow up with @hans to learn more), but they aren't related to this 
change, which is from July.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106585

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


[PATCH] D51650: Implement target_clones multiversioning

2021-11-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM aside from a nit with naming/wording. Feel free to land without additional 
review (unless you want more review, of course!).




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9868-9869
   InGroup;
+def err_duplicate_attribute : Error<
+  "attribute %0 cannot appear more than once on a declaration">;
 

We typically don't use distinct wording for `err_foo` and `warn_foo` 
diagnostics -- folks tend to assume they've got the same wording and the only 
difference is the severity.

Potential ways forward:

* Rename to `err_duplicate_attribute_exact` and use the same wording as the 
warning version)
* Leave wording alone, rename to something else (perhaps 
`err_repeated_multiversion_attribute`) to make it specific to this usage

I don't insist on a particular path (or a change at all, if you have strong 
attachment), but I think it'd be nice to fix it before landing.


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

https://reviews.llvm.org/D51650

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


[PATCH] D113575: Add `isInitCapture` and `forEachLambdaCapture` matchers.

2021-11-11 Thread Matt Kulukundis via Phabricator via cfe-commits
fowles added a comment.

That is awesome!  Thanks for much for the examples.  Everything here LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113575

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


[PATCH] D112647: [clang-apply-replacements] Correctly handle relative paths

2021-11-11 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8188484daa41: [clang-apply-replacements] Correctly handle 
relative paths (authored by avogelsgesang, committed by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112647

Files:
  clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/basic.h
  
clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file1.yaml
  
clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file2.yaml
  clang-tools-extra/test/clang-apply-replacements/relative-paths.cpp

Index: clang-tools-extra/test/clang-apply-replacements/relative-paths.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/relative-paths.cpp
@@ -0,0 +1,7 @@
+// RUN: mkdir -p %T/Inputs/relative-paths
+// RUN: mkdir -p %T/Inputs/relative-paths/subdir
+// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/relative-paths/basic.h > %T/Inputs/relative-paths/basic.h
+// RUN: sed "s#\$(path)#%/T/Inputs/relative-paths#" %S/Inputs/relative-paths/file1.yaml > %T/Inputs/relative-paths/file1.yaml
+// RUN: sed "s#\$(path)#%/T/Inputs/relative-paths#" %S/Inputs/relative-paths/file2.yaml > %T/Inputs/relative-paths/file2.yaml
+// RUN: clang-apply-replacements %T/Inputs/relative-paths
+// RUN: FileCheck -input-file=%T/Inputs/relative-paths/basic.h %S/Inputs/relative-paths/basic.h
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file2.yaml
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file2.yaml
@@ -0,0 +1,15 @@
+---
+MainSourceFile: source2.cpp
+Diagnostics:
+  - BuildDirectory: $(path)
+DiagnosticName: test-relative-path
+DiagnosticMessage:
+  Message: Fix
+  FilePath: ./basic.h
+  FileOffset: 148
+  Replacements:
+- FilePath:./basic.h
+  Offset:  298
+  Length:  1
+  ReplacementText: elem
+...
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file1.yaml
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file1.yaml
@@ -0,0 +1,27 @@
+---
+MainSourceFile: source1.cpp
+Diagnostics:
+  - BuildDirectory: $(path)/subdir/
+DiagnosticName: test-relative-path
+DiagnosticMessage:
+  Message: Fix
+  FilePath: ../relative-path.h
+  FileOffset: 242
+  Replacements:
+- FilePath:../basic.h
+  Offset:  242
+  Length:  26
+  ReplacementText: 'auto & elem : ints'
+- FilePath:$(path)/basic.h
+  Offset:  276
+  Length:  22
+  ReplacementText: ''
+- FilePath:../basic.h
+  Offset:  298
+  Length:  1
+  ReplacementText: elem
+- FilePath:../../relative-paths/basic.h
+  Offset:  148
+  Length:  0
+  ReplacementText: 'override '
+...
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/basic.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/basic.h
@@ -0,0 +1,32 @@
+#ifndef BASIC_H
+#define BASIC_H
+
+
+class Parent {
+public:
+  virtual void func() {}
+};
+
+class Derived : public Parent {
+public:
+  virtual void func() {}
+  // CHECK: virtual void func() override {}
+};
+
+extern void ext(int (&)[5], const Parent &);
+
+void func(int t) {
+  int ints[5];
+  for (unsigned i = 0; i < 5; ++i) {
+int  = ints[i];
+e = t;
+// CHECK: for (auto & elem : ints) {
+// CHECK-NEXT: elem = t;
+  }
+
+  Derived d;
+
+  ext(ints, d);
+}
+
+#endif // BASIC_H
Index: clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===
--- clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -23,6 +23,7 @@
 #include "clang/Tooling/DiagnosticsYaml.h"
 #include "clang/Tooling/ReplacementsYaml.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
@@ -152,9 +153,13 @@
   DiagReplacements;
 
   auto AddToGroup = [&](const tooling::Replacement ,
-const tooling::TranslationUnitDiagnostics *SourceTU) {
+const tooling::TranslationUnitDiagnostics *SourceTU,
+

[clang-tools-extra] 8188484 - [clang-apply-replacements] Correctly handle relative paths

2021-11-11 Thread Yitzhak Mandelbaum via cfe-commits

Author: Adrian Vogelsgesang
Date: 2021-11-11T18:28:43Z
New Revision: 8188484daa4195a2c8b5253765036fa2c6da7263

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

LOG: [clang-apply-replacements] Correctly handle relative paths

The fixes from the YAML file can refer to relative paths.
Those relative paths are meant to be resolved relative to the
corresponding `build directory`.
However, `clang-apply-replacements` currently interprets all
paths relative to its own working directory. This causes issues,
e.g., when `clang-apply-replacements` is run from outside of
the original build directory.

This commit adjusts `clang-apply-replacements` to take the build
directory into account when resolving relative file paths.

Reviewed By: ymandel

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

Added: 

clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/basic.h

clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file1.yaml

clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file2.yaml
clang-tools-extra/test/clang-apply-replacements/relative-paths.cpp

Modified: 
clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp 
b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
index 1e5012b9891bf..b13b83cf3f000 100644
--- 
a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ 
b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -23,6 +23,7 @@
 #include "clang/Tooling/DiagnosticsYaml.h"
 #include "clang/Tooling/ReplacementsYaml.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
@@ -152,9 +153,13 @@ groupReplacements(const TUReplacements , const 
TUDiagnostics ,
   DiagReplacements;
 
   auto AddToGroup = [&](const tooling::Replacement ,
-const tooling::TranslationUnitDiagnostics *SourceTU) {
+const tooling::TranslationUnitDiagnostics *SourceTU,
+const llvm::Optional BuildDir) {
 // Use the file manager to deduplicate paths. FileEntries are
 // automatically canonicalized.
+auto PrevWorkingDir = SM.getFileManager().getFileSystemOpts().WorkingDir;
+if (BuildDir)
+  SM.getFileManager().getFileSystemOpts().WorkingDir = 
std::move(*BuildDir);
 if (auto Entry = SM.getFileManager().getFile(R.getFilePath())) {
   if (SourceTU) {
 auto  = DiagReplacements[*Entry];
@@ -170,18 +175,19 @@ groupReplacements(const TUReplacements , const 
TUDiagnostics ,
   errs() << "Described file '" << R.getFilePath()
  << "' doesn't exist. Ignoring...\n";
 }
+SM.getFileManager().getFileSystemOpts().WorkingDir = PrevWorkingDir;
   };
 
   for (const auto  : TUs)
 for (const tooling::Replacement  : TU.Replacements)
-  AddToGroup(R, nullptr);
+  AddToGroup(R, nullptr, {});
 
   for (const auto  : TUDs)
 for (const auto  : TU.Diagnostics)
   if (const auto *ChoosenFix = tooling::selectFirstFix(D)) {
 for (const auto  : *ChoosenFix)
   for (const tooling::Replacement  : Fix.second)
-AddToGroup(R, );
+AddToGroup(R, , D.BuildDirectory);
   }
 
   // Sort replacements per file to keep consistent behavior when

diff  --git 
a/clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/basic.h 
b/clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/basic.h
new file mode 100644
index 0..48509684b7725
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/basic.h
@@ -0,0 +1,32 @@
+#ifndef BASIC_H
+#define BASIC_H
+
+
+class Parent {
+public:
+  virtual void func() {}
+};
+
+class Derived : public Parent {
+public:
+  virtual void func() {}
+  // CHECK: virtual void func() override {}
+};
+
+extern void ext(int (&)[5], const Parent &);
+
+void func(int t) {
+  int ints[5];
+  for (unsigned i = 0; i < 5; ++i) {
+int  = ints[i];
+e = t;
+// CHECK: for (auto & elem : ints) {
+// CHECK-NEXT: elem = t;
+  }
+
+  Derived d;
+
+  ext(ints, d);
+}
+
+#endif // BASIC_H

diff  --git 
a/clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file1.yaml
 
b/clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file1.yaml
new file mode 100644
index 0..7219ae8ab00e9
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file1.yaml
@@ -0,0 +1,27 @@
+---
+MainSourceFile: 

[PATCH] D113694: [Clang] Conform to C++17 definition of literal types

2021-11-11 Thread LĂ©o Lam via Phabricator via cfe-commits
leoetlino created this revision.
leoetlino requested review of this revision.
Herald added a project: clang.

C++17 changed the definition of literal types so that unions that
have at least one non-static data member of non-volatile literal type
are also considered literal types.

This patch implements that new rule and also adds a test for closure
types (10.5.2) and for unions (10.5.3) to the existing test file for
literal types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113694

Files:
  clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
  clang/include/clang/AST/DeclCXX.h
  clang/lib/AST/DeclCXX.cpp
  clang/test/CXX/basic/basic.types/p10.cpp

Index: clang/test/CXX/basic/basic.types/p10.cpp
===
--- clang/test/CXX/basic/basic.types/p10.cpp
+++ clang/test/CXX/basic/basic.types/p10.cpp
@@ -1,5 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1y %s -DCXX1Y
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DCXX11 -DCXX11_OR_LATER
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1y %s -DCXX1Y -DCXX11_OR_LATER -DCXX1Y_OR_LATER
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s -DCXX17 -DCXX11_OR_LATER -DCXX1Y_OR_LATER -DCXX17_OR_LATER
 
 struct NonLiteral { NonLiteral(); };
 
@@ -7,7 +8,7 @@
 
 // [C++1y] - void
 constexpr void f() {}
-#ifndef CXX1Y
+#ifdef CXX11
 // expected-error@-2 {{'void' is not a literal type}}
 #endif
 
@@ -20,7 +21,7 @@
 
 struct BeingDefined;
 extern BeingDefined beingdefined;
-struct BeingDefined { 
+struct BeingDefined {
   static constexpr BeingDefined& t = beingdefined;
 };
 
@@ -64,8 +65,14 @@
 };
 constexpr int f(TrivDefaultedDtor) { return 0; }
 
-//  - it is an aggregate type or has at least one constexpr constructor or
+//  - it is [a closure type [C++17]], an aggregate type or has at least one constexpr constructor or
 //constexpr constructor template that is not a copy or move constructor
+#ifndef CXX17_OR_LATER
+// expected-error@+4 {{not a literal type}}
+// expected-note@+2 {{lambda closure types are non-literal types before C++17}}
+#endif
+auto closure = [] {};
+constexpr int f(decltype(closure)) { return 0; }
 struct Agg {
   int a;
   char *b;
@@ -101,7 +108,8 @@
 template constexpr DerivedFromVBase::DerivedFromVBase() : T() {}
 constexpr int nVBase = (DerivedFromVBase(), 0); // expected-error {{constant expression}} expected-note {{cannot construct object of type 'DerivedFromVBase' with virtual base class in a constant expression}}
 
-//  - it has all non-static data members and base classes of literal types
+//  - [C++17] if it is a union, at least one of its non-static data members is of non-volatile literal type, and
+//  - [if it is not a union [C++17]] it has all non-static data members and base classes of literal types
 struct NonLitMember {
   S s; // expected-note {{has data member 's' of non-literal type 'S'}}
 };
@@ -122,6 +130,19 @@
 constexpr int f(MemberType) { return 0; }
 constexpr int f(MemberType) { return 0; } // expected-error {{not a literal type}}
 
+template
+union UnionType {
+  char c;
+  T t;
+  constexpr UnionType() : c{} {}
+};
+constexpr int f(UnionType) { return 0; }
+#ifndef CXX17_OR_LATER
+// expected-error@+3 {{not a literal type}}
+// expected-note@-6 {{'UnionType' is not literal because it has data member 't' of non-literal type 'NonLiteral'}}
+#endif
+constexpr int f(UnionType) { return 0; }
+
 // - an array of literal type [C++1y] other than an array of runtime bound
 struct ArrGood {
   Agg agg[24];
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -102,7 +102,8 @@
   DefaultedDefaultConstructorIsConstexpr(true),
   HasConstexprDefaultConstructor(false),
   DefaultedDestructorIsConstexpr(true),
-  HasNonLiteralTypeFieldsOrBases(false), StructuralIfLiteral(true),
+  HasNonLiteralTypeFieldsOrBases(false),
+  HasNonVolatileLiteralTypeFields(false), StructuralIfLiteral(true),
   UserProvidedDefaultConstructor(false), DeclaredSpecialMembers(0),
   ImplicitCopyConstructorCanHaveConstParamForVBase(true),
   ImplicitCopyConstructorCanHaveConstParamForNonVBase(true),
@@ -1103,8 +1104,12 @@
   }
 }
 
+const bool IsNonVolatileLiteralTypeField =
+T->isLiteralType(Context) && !T.isVolatileQualified();
 // Record if this field is the first non-literal or volatile field or base.
-if (!T->isLiteralType(Context) || T.isVolatileQualified())
+if (IsNonVolatileLiteralTypeField)
+  data().HasNonVolatileLiteralTypeFields = true;
+else
   data().HasNonLiteralTypeFieldsOrBases = true;
 
 if (Field->hasInClassInitializer() ||
Index: clang/include/clang/AST/DeclCXX.h
===
--- clang/include/clang/AST/DeclCXX.h
+++ 

[PATCH] D113575: Add `isInitCapture` and `forEachLambdaCapture` matchers.

2021-11-11 Thread James King via Phabricator via cfe-commits
jcking1034 marked an inline comment as done.
jcking1034 added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4224
+/// float z;
+/// auto f = [=]() { return x + y + z; };
+///   }

fowles wrote:
> it would be nice to be able to do something like
> 
> ```
> int main() {
>   int x, y;
>   float z;
>   auto f = [=, z]() { return x+ y + z; };
> }
> ```
> 
> `lambdaExpr(forEachLambdaCapture(isImplicit())` matches `x` and `y` but not 
> `z`
I believe that this should be possible, I've gone ahead and added some unit 
tests to demonstrate (see the tests named `MatchImplicitCapturesOnly` and 
`MatchExplicitCapturesOnly`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113575

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


[PATCH] D113575: Add `isInitCapture` and `forEachLambdaCapture` matchers.

2021-11-11 Thread James King via Phabricator via cfe-commits
jcking1034 updated this revision to Diff 386577.
jcking1034 added a comment.

Add additional unit tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113575

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -4769,6 +4769,66 @@
 cxxConstructorDecl(forEachConstructorInitializer(cxxCtorInitializer();
 }
 
+TEST(ForEachLambdaCapture, MatchesCaptures) {
+  EXPECT_TRUE(matches(
+  "int main() { int x, y; auto f = [x, y]() { return x + y; }; }",
+  lambdaExpr(forEachLambdaCapture(lambdaCapture())), langCxx11OrLater()));
+  auto matcher = lambdaExpr(forEachLambdaCapture(
+  lambdaCapture(capturesVar(varDecl(hasType(isInteger().bind("LC")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "int main() { int x, y; float z; auto f = [=]() { return x + y + z; }; }",
+  matcher, std::make_unique>("LC", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "int main() { int x, y; float z; auto f = [x, y, z]() { return x + y + "
+  "z; }; }",
+  matcher, std::make_unique>("LC", 2)));
+}
+
+TEST(ForEachLambdaCapture, IgnoreUnlessSpelledInSource) {
+  auto matcher =
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   lambdaExpr(forEachLambdaCapture(
+   lambdaCapture(capturesVar(varDecl(hasType(isInteger()
+   .bind("LC";
+  EXPECT_TRUE(
+  notMatches("int main() { int x, y; auto f = [=]() { return x + y; }; }",
+ matcher, langCxx11OrLater()));
+  EXPECT_TRUE(
+  notMatches("int main() { int x, y; auto f = [&]() { return x + y; }; }",
+ matcher, langCxx11OrLater()));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  R"cc(
+  int main() {
+int x, y;
+float z;
+auto f = [=, ]() { return x + y + z; };
+  }
+  )cc",
+  matcher, std::make_unique>("LC", 1)));
+}
+
+TEST(ForEachLambdaCapture, MatchImplicitCapturesOnly) {
+  auto matcher =
+  lambdaExpr(forEachLambdaCapture(lambdaCapture(isImplicit()).bind("LC")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "int main() { int x, y, z; auto f = [=, ]() { return x + y + z; }; }",
+  matcher, std::make_unique>("LC", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "int main() { int x, y, z; auto f = [&, z]() { return x + y + z; }; }",
+  matcher, std::make_unique>("LC", 2)));
+}
+
+TEST(ForEachLambdaCapture, MatchExplicitCapturesOnly) {
+  auto matcher = lambdaExpr(
+  forEachLambdaCapture(lambdaCapture(unless(isImplicit())).bind("LC")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "int main() { int x, y, z; auto f = [=, ]() { return x + y + z; }; }",
+  matcher, std::make_unique>("LC", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "int main() { int x, y, z; auto f = [&, z]() { return x + y + z; }; }",
+  matcher, std::make_unique>("LC", 1)));
+}
+
 TEST(HasConditionVariableStatement, DoesNotMatchCondition) {
   EXPECT_TRUE(notMatches(
 "void x() { if(true) {} }",
Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1439,6 +1439,22 @@
   EXPECT_TRUE(notMatches("int X;", M));
 }
 
+TEST_P(ASTMatchersTest, IsInitCapture) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
+  auto M = varDecl(hasName("vd"), isInitCapture());
+  EXPECT_TRUE(notMatches(
+  "int main() { int vd = 3; auto f = [vd]() { return vd; }; }", M));
+
+  if (!GetParam().isCXX14OrLater()) {
+return;
+  }
+  EXPECT_TRUE(matches("int main() { auto f = [vd=3]() { return vd; }; }", M));
+  EXPECT_TRUE(matches(
+  "int main() { int x = 3; auto f = [vd=x]() { return vd; }; }", M));
+}
+
 TEST_P(ASTMatchersTest, StorageDuration) {
   StringRef T =
   "void f() { int x; static int y; } int a;static int b;extern int c;";
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -246,6 +246,7 @@
   REGISTER_MATCHER(forEachArgumentWithParamType);
   REGISTER_MATCHER(forEachConstructorInitializer);
   REGISTER_MATCHER(forEachDescendant);
+  REGISTER_MATCHER(forEachLambdaCapture);
   REGISTER_MATCHER(forEachOverridden);
   REGISTER_MATCHER(forEachSwitchCase);
   REGISTER_MATCHER(forField);

[PATCH] D51650: Implement target_clones multiversioning

2021-11-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 386573.
erichkeane added a comment.

added C++ tests this time, changed how dupes are diagnosed.


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

https://reviews.llvm.org/D51650

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-target-clones.c
  clang/test/CodeGenCXX/attr-target-clones.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-cpuspecific.c
  clang/test/Sema/attr-target-clones.c
  clang/test/SemaCXX/attr-target-clones.cpp

Index: clang/test/SemaCXX/attr-target-clones.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/attr-target-clones.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu  -fsyntax-only -verify -fexceptions -fcxx-exceptions %s -std=c++14
+
+// expected-error@+2 {{attribute 'target_clones' multiversioned functions do not yet support function templates}}
+template
+int __attribute__((target_clones("sse4.2", "default"))) foo(){ return 1;}
+
+void uses_lambda() {
+  // expected-error@+1 {{attribute 'target_clones' multiversioned functions do not yet support lambdas}}
+  auto x = []()__attribute__((target_clones("sse4.2", "arch=ivybridge", "default"))) {};
+  x();
+}
Index: clang/test/Sema/attr-target-clones.c
===
--- /dev/null
+++ clang/test/Sema/attr-target-clones.c
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu  -fsyntax-only -verify %s
+
+// expected-error@+1 {{'target_clones' multiversioning requires a default target}}
+void __attribute__((target_clones("sse4.2", "arch=sandybridge")))
+no_default(void);
+
+// expected-error@+2 {{'target_clones' and 'target' attributes are not compatible}}
+// expected-note@+1 {{conflicting attribute is here}}
+void __attribute__((target("sse4.2"), target_clones("arch=sandybridge")))
+ignored_attr(void);
+// expected-error@+2 {{'target' and 'target_clones' attributes are not compatible}}
+// expected-note@+1 {{conflicting attribute is here}}
+void __attribute__((target_clones("arch=sandybridge,default"), target("sse4.2")))
+ignored_attr2(void);
+
+int redecl(void);
+int __attribute__((target_clones("sse4.2", "default"))) redecl(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2", "default"))) redecl2(void);
+int __attribute__((target_clones("sse4.2", "default"))) redecl2(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2", "default"))) redecl3(void);
+int redecl3(void);
+
+int __attribute__((target_clones("sse4.2", "arch=atom", "default"))) redecl4(void);
+// expected-error@+3 {{'target_clones' attribute does not match previous declaration}}
+// expected-note@-2 {{previous declaration is here}}
+int __attribute__((target_clones("sse4.2", "arch=sandybridge", "default")))
+redecl4(void) { return 1; }
+
+int __attribute__((target("sse4.2"))) redef2(void) { return 1; }
+// expected-error@+2 {{multiversioning attributes cannot be combined}}
+// expected-note@-2 {{previous declaration is here}}
+int __attribute__((target_clones("sse4.2", "default"))) redef2(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2,default"))) redef3(void) { return 1; }
+// expected-error@+2 {{redefinition of 'redef3'}}
+// expected-note@-2 {{previous definition is here}}
+int __attribute__((target_clones("sse4.2,default"))) redef3(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2,default"))) redef4(void) { return 1; }
+// expected-error@+2 {{redefinition of 'redef4'}}
+// expected-note@-2 {{previous definition is here}}
+int __attribute__((target_clones("sse4.2,default"))) redef4(void) { return 1; }
+
+// Duplicates are allowed, however they alter name mangling.
+// expected-warning@+2 {{mixing 'target_clones' specifier mechanisms is permitted for GCC compatibility}}
+// expected-warning@+1 2 {{version list contains duplicate entries}}
+int __attribute__((target_clones("arch=atom,arch=atom", "arch=atom,default")))
+dupes(void) { return 1; }
+
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("")))
+empty_target_1(void);
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones(",default")))
+empty_target_2(void);
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("default,")))
+empty_target_3(void);
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute 

[PATCH] D113691: Comment AST: Recognize function-like objects via return type

2021-11-11 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added a reviewer: gribozavr2.
aaronpuchert requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Instead of pretending that function pointer type aliases or variables
are functions, and thereby losing the information that they are type
aliases or variables, respectively, we use the existence of a return
type in the DeclInfo to signify a "function-like" object.

That seems pretty natural, since it's also the return type (or parameter
list) from the DeclInfo that we compare the documentation with.

Addresses a concern voiced in D111264#3115104 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113691

Files:
  clang/include/clang/AST/Comment.h
  clang/include/clang/AST/CommentSema.h
  clang/lib/AST/Comment.cpp
  clang/lib/AST/CommentSema.cpp

Index: clang/lib/AST/CommentSema.cpp
===
--- clang/lib/AST/CommentSema.cpp
+++ clang/lib/AST/CommentSema.cpp
@@ -86,7 +86,7 @@
   new (Allocator) ParamCommandComment(LocBegin, LocEnd, CommandID,
   CommandMarker);
 
-  if (!isFunctionDecl())
+  if (!involvesFunctionType())
 Diag(Command->getLocation(),
  diag::warn_doc_param_not_attached_to_a_function_decl)
   << CommandMarker
@@ -588,7 +588,7 @@
   // to document the value that the property getter returns.
   if (isObjCPropertyDecl())
 return;
-  if (isFunctionDecl()) {
+  if (involvesFunctionType()) {
 assert(!ThisDeclInfo->ReturnType.isNull() &&
"should have a valid return type");
 if (ThisDeclInfo->ReturnType->isVoidType()) {
@@ -728,7 +728,7 @@
 }
 
 void Sema::resolveParamCommandIndexes(const FullComment *FC) {
-  if (!isFunctionDecl()) {
+  if (!involvesFunctionType()) {
 // We already warned that \\param commands are not attached to a function
 // decl.
 return;
@@ -816,6 +816,14 @@
   }
 }
 
+bool Sema::involvesFunctionType() {
+  if (!ThisDeclInfo)
+return false;
+  if (!ThisDeclInfo->IsFilled)
+inspectThisDecl();
+  return ThisDeclInfo->involvesFunctionType();
+}
+
 bool Sema::isFunctionDecl() {
   if (!ThisDeclInfo)
 return false;
Index: clang/lib/AST/Comment.cpp
===
--- clang/lib/AST/Comment.cpp
+++ clang/lib/AST/Comment.cpp
@@ -250,6 +250,7 @@
   IsClassMethod = !IsInstanceMethod;
 }
 IsVariadic = FD->isVariadic();
+assert(involvesFunctionType());
 break;
   }
   case Decl::ObjCMethod: {
@@ -261,6 +262,7 @@
 IsInstanceMethod = MD->isInstanceMethod();
 IsClassMethod = !IsInstanceMethod;
 IsVariadic = MD->isVariadic();
+assert(involvesFunctionType());
 break;
   }
   case Decl::FunctionTemplate: {
@@ -272,6 +274,7 @@
 ReturnType = FD->getReturnType();
 TemplateParameters = FTD->getTemplateParameters();
 IsVariadic = FD->isVariadic();
+assert(involvesFunctionType());
 break;
   }
   case Decl::ClassTemplate: {
@@ -352,11 +355,11 @@
 TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc();
 FunctionTypeLoc FTL;
 if (getFunctionTypeLoc(TL, FTL)) {
-  Kind = FunctionKind;
   ParamVars = FTL.getParams();
   ReturnType = FTL.getReturnLoc().getType();
   if (const auto *FPT = FTL.getTypePtr()->getAs())
 IsVariadic = FPT->isVariadic();
+  assert(involvesFunctionType());
 }
   }
 
Index: clang/include/clang/AST/CommentSema.h
===
--- clang/include/clang/AST/CommentSema.h
+++ clang/include/clang/AST/CommentSema.h
@@ -201,6 +201,10 @@
   /// Emit diagnostics about unknown parametrs.
   void resolveParamCommandIndexes(const FullComment *FC);
 
+  /// \returns \c true if the declaration that this comment is attached to
+  /// is a pointer to function/method/block type or has such a type.
+  bool involvesFunctionType();
+
   bool isFunctionDecl();
   bool isAnyFunctionDecl();
 
Index: clang/include/clang/AST/Comment.h
===
--- clang/include/clang/AST/Comment.h
+++ clang/include/clang/AST/Comment.h
@@ -1019,9 +1019,6 @@
 /// \li member function template,
 /// \li member function template specialization,
 /// \li ObjC method,
-/// \li variable of function pointer, member function pointer or block type,
-/// \li a typedef for a function pointer, member function pointer,
-/// ObjC block.
 FunctionKind,
 
 /// Something that we consider a "class":
@@ -1089,6 +1086,8 @@
   TemplateDeclKind getTemplateKind() const LLVM_READONLY {
 return static_cast(TemplateKind);
   }
+
+  bool involvesFunctionType() const { return !ReturnType.isNull(); }
 };
 
 /// A full comment attached to a declaration, contains block content.
___
cfe-commits 

[PATCH] D113690: Comment AST: Find out if function is variadic in DeclInfo::fill

2021-11-11 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added a reviewer: gribozavr2.
aaronpuchert requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Then we don't have to look into the declaration again. Also it's only
natural to collect this information alongside parameters and return
type, as it's also just a parameter in some sense.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113690

Files:
  clang/include/clang/AST/Comment.h
  clang/lib/AST/Comment.cpp
  clang/lib/AST/CommentSema.cpp
  clang/test/Sema/warn-documentation.cpp

Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -1448,6 +1448,17 @@
  */
 using VariadicFnType2 = void (*)(int a, ...);
 
+/*!
+ * Function pointer type variable.
+ *
+ * @param a
+ * works
+ *
+ * @param ...
+ * now should work too.
+ */
+void (*variadicFnVar)(int a, ...);
+
 // expected-warning@+2 {{empty paragraph passed to '@note' command}}
 /**
 @note
Index: clang/lib/AST/CommentSema.cpp
===
--- clang/lib/AST/CommentSema.cpp
+++ clang/lib/AST/CommentSema.cpp
@@ -830,26 +830,11 @@
 }
 
 bool Sema::isFunctionOrMethodVariadic() {
-  if (!isFunctionDecl() || !ThisDeclInfo->CurrentDecl)
+  if (!ThisDeclInfo)
 return false;
-  if (const FunctionDecl *FD =
-dyn_cast(ThisDeclInfo->CurrentDecl))
-return FD->isVariadic();
-  if (const FunctionTemplateDecl *FTD =
-dyn_cast(ThisDeclInfo->CurrentDecl))
-return FTD->getTemplatedDecl()->isVariadic();
-  if (const ObjCMethodDecl *MD =
-dyn_cast(ThisDeclInfo->CurrentDecl))
-return MD->isVariadic();
-  if (const TypedefNameDecl *TD =
-  dyn_cast(ThisDeclInfo->CurrentDecl)) {
-QualType Type = TD->getUnderlyingType();
-if (Type->isFunctionPointerType() || Type->isBlockPointerType())
-  Type = Type->getPointeeType();
-if (const auto *FT = Type->getAs())
-  return FT->isVariadic();
-  }
-  return false;
+  if (!ThisDeclInfo->IsFilled)
+inspectThisDecl();
+  return ThisDeclInfo->IsVariadic;
 }
 
 bool Sema::isObjCMethodDecl() {
Index: clang/lib/AST/Comment.cpp
===
--- clang/lib/AST/Comment.cpp
+++ clang/lib/AST/Comment.cpp
@@ -210,6 +210,7 @@
   IsObjCMethod = false;
   IsInstanceMethod = false;
   IsClassMethod = false;
+  IsVariadic = false;
   ParamVars = None;
   TemplateParameters = nullptr;
 
@@ -248,6 +249,7 @@
   IsInstanceMethod = MD->isInstance();
   IsClassMethod = !IsInstanceMethod;
 }
+IsVariadic = FD->isVariadic();
 break;
   }
   case Decl::ObjCMethod: {
@@ -258,6 +260,7 @@
 IsObjCMethod = true;
 IsInstanceMethod = MD->isInstanceMethod();
 IsClassMethod = !IsInstanceMethod;
+IsVariadic = MD->isVariadic();
 break;
   }
   case Decl::FunctionTemplate: {
@@ -268,6 +271,7 @@
 ParamVars = FD->parameters();
 ReturnType = FD->getReturnType();
 TemplateParameters = FTD->getTemplateParameters();
+IsVariadic = FD->isVariadic();
 break;
   }
   case Decl::ClassTemplate: {
@@ -351,6 +355,8 @@
   Kind = FunctionKind;
   ParamVars = FTL.getParams();
   ReturnType = FTL.getReturnLoc().getType();
+  if (const auto *FPT = FTL.getTypePtr()->getAs())
+IsVariadic = FPT->isVariadic();
 }
   }
 
Index: clang/include/clang/AST/Comment.h
===
--- clang/include/clang/AST/Comment.h
+++ clang/include/clang/AST/Comment.h
@@ -1077,6 +1077,9 @@
   /// Can be true only if \c IsFunctionDecl is true.
   unsigned IsClassMethod : 1;
 
+  /// Is \c CommentDecl something we consider a "function" that's variadic.
+  unsigned IsVariadic : 1;
+
   void fill();
 
   DeclKind getKind() const LLVM_READONLY {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112647: [clang-apply-replacements] Correctly handle relative paths

2021-11-11 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

I can land it for you. should be sometime this afternoon, but ping me tomorrow 
if you don't see any activity.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112647

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


[PATCH] D112647: [clang-apply-replacements] Correctly handle relative paths

2021-11-11 Thread Adrian Vogelsgesang via Phabricator via cfe-commits
avogelsgesang added a comment.

Thanks for the reviews, @ymandel and @hokein!

What are the next steps to get this landed?
(I am a first time contributor and have no commit access)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112647

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


[PATCH] D51650: Implement target_clones multiversioning

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

In D51650#3124859 , @erichkeane wrote:

> Did all the things Aaron asked for, but required adding 'lambda not supported 
> yet' logic for this.

I don't see the .cpp test file, did it get dropped by accident?

Also, pre-commit isn't able to apply the patch, so it'd be good to resolve that 
to get the CI testing.




Comment at: clang/lib/Sema/SemaDeclAttr.cpp:1970
+  // confusing behavior.
+  if (checkAttrMutualExclusion(S, D, AL) ||
+  checkAttrMutualExclusion(S, D, AL))

This diagnostic behavior is a bit unfortunate because we'll issue a diagnostic 
like:
```
// expected-error@+2 {{'target_clones' and 'target_clones' attributes are not 
compatible}}
```
Maybe we should add `err_duplicate_attribute` and steal its text from 
`warn_duplicate_attribute` and use `getAttr()` directly here?


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

https://reviews.llvm.org/D51650

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


[PATCH] D51650: Implement target_clones multiversioning

2021-11-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 386542.
erichkeane marked 5 inline comments as done.
erichkeane added a comment.

Did all the things Aaron asked for, but required adding 'lambda not supported 
yet' logic for this.


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

https://reviews.llvm.org/D51650

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-target-clones.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-cpuspecific.c
  clang/test/Sema/attr-target-clones.c

Index: clang/test/Sema/attr-target-clones.c
===
--- /dev/null
+++ clang/test/Sema/attr-target-clones.c
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu  -fsyntax-only -verify %s
+
+// expected-error@+1 {{'target_clones' multiversioning requires a default target}}
+void __attribute__((target_clones("sse4.2", "arch=sandybridge")))
+no_default(void);
+
+// expected-error@+2 {{'target_clones' and 'target' attributes are not compatible}}
+// expected-note@+1 {{conflicting attribute is here}}
+void __attribute__((target("sse4.2"), target_clones("arch=sandybridge")))
+ignored_attr(void);
+// expected-error@+2 {{'target' and 'target_clones' attributes are not compatible}}
+// expected-note@+1 {{conflicting attribute is here}}
+void __attribute__((target_clones("arch=sandybridge,default"), target("sse4.2")))
+ignored_attr2(void);
+
+int redecl(void);
+int __attribute__((target_clones("sse4.2", "default"))) redecl(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2", "default"))) redecl2(void);
+int __attribute__((target_clones("sse4.2", "default"))) redecl2(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2", "default"))) redecl3(void);
+int redecl3(void);
+
+int __attribute__((target_clones("sse4.2", "arch=atom", "default"))) redecl4(void);
+// expected-error@+3 {{'target_clones' attribute does not match previous declaration}}
+// expected-note@-2 {{previous declaration is here}}
+int __attribute__((target_clones("sse4.2", "arch=sandybridge", "default")))
+redecl4(void) { return 1; }
+
+int __attribute__((target("sse4.2"))) redef2(void) { return 1; }
+// expected-error@+2 {{multiversioning attributes cannot be combined}}
+// expected-note@-2 {{previous declaration is here}}
+int __attribute__((target_clones("sse4.2", "default"))) redef2(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2,default"))) redef3(void) { return 1; }
+// expected-error@+2 {{redefinition of 'redef3'}}
+// expected-note@-2 {{previous definition is here}}
+int __attribute__((target_clones("sse4.2,default"))) redef3(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2,default"))) redef4(void) { return 1; }
+// expected-error@+2 {{redefinition of 'redef4'}}
+// expected-note@-2 {{previous definition is here}}
+int __attribute__((target_clones("sse4.2,default"))) redef4(void) { return 1; }
+
+// Duplicates are allowed, however they alter name mangling.
+// expected-warning@+2 {{mixing 'target_clones' specifier mechanisms is permitted for GCC compatibility}}
+// expected-warning@+1 2 {{version list contains duplicate entries}}
+int __attribute__((target_clones("arch=atom,arch=atom", "arch=atom,default")))
+dupes(void) { return 1; }
+
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("")))
+empty_target_1(void);
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones(",default")))
+empty_target_2(void);
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("default,")))
+empty_target_3(void);
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("default, ,avx2")))
+empty_target_4(void);
+
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("default,avx2", "")))
+empty_target_5(void);
+
+// expected-warning@+1 {{version list contains duplicate entries}}
+void __attribute__((target_clones("default", "default")))
+dupe_default(void);
+
+// expected-warning@+1 {{version list contains duplicate entries}}
+void __attribute__((target_clones("avx2,avx2,default")))
+dupe_normal(void);
+
+// expected-error@+2 {{'target_clones' and 'target_clones' attributes are not compatible}}
+// expected-note@+1 {{conflicting attribute is here}}
+void 

[PATCH] D113676: WIP: [clang][lex] Fix search path usage remark with modules

2021-11-11 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 386541.
jansvoboda11 added a comment.

Apply clang-format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113676

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/Preprocessor/search-path-usage-modules.m
  clang/test/Preprocessor/search-path-usage.m

Index: clang/test/Preprocessor/search-path-usage.m
===
--- clang/test/Preprocessor/search-path-usage.m
+++ clang/test/Preprocessor/search-path-usage.m
@@ -128,19 +128,3 @@
 // expected-remark-re {{search path used: '{{.*}}/b-missing.hmap'}}
 #endif
 #endif
-
-// Check that search paths with module maps are reported.
-//
-// RUN: mkdir %t/modulemap_abs
-// RUN: sed "s|DIR|%/S/Inputs/search-path-usage|g"\
-// RUN:   %S/Inputs/search-path-usage/modulemap_abs/module.modulemap.template \
-// RUN: > %t/modulemap_abs/module.modulemap
-// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage   \
-// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules \
-// RUN:   -I %t/modulemap_abs  \
-// RUN:   -I %S/Inputs/search-path-usage/a \
-// RUN:   -DMODMAP_ABS -verify
-#ifdef MODMAP_ABS
-@import b; // \
-// expected-remark-re {{search path used: '{{.*}}/modulemap_abs'}}
-#endif
Index: clang/test/Preprocessor/search-path-usage-modules.m
===
--- /dev/null
+++ clang/test/Preprocessor/search-path-usage-modules.m
@@ -0,0 +1,37 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -Eonly %t/test-both.m   -I %t/sp1 -I %t/sp2 -Rsearch-path-usage \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache 2>&1 | FileCheck %t/test-both.m
+// RUN: %clang_cc1 -Eonly %t/test-first.m  -I %t/sp2 -I %t/sp1 -Rsearch-path-usage \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache 2>&1 | FileCheck %t/test-first.m
+// RUN: %clang_cc1 -Eonly %t/test-second.m -I %t/sp2 -I %t/sp1 -Rsearch-path-usage \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache 2>&1 | FileCheck %t/test-second.m
+
+//--- sp1/module.modulemap
+module mod1 { header "mod1.h" }
+//--- sp1/mod1.h
+int module1();
+
+//--- sp2/module.modulemap
+module mod2 { header "mod2.h" }
+//--- sp2/mod2.h
+int module2();
+
+//--- test-both.m
+@import mod1;
+@import mod2;
+// CHECK: search path used: '{{.*}}/sp1'
+// CHECK: search path used: '{{.*}}/sp2'
+
+//--- test-first.m
+@import mod1;
+// CHECK-NOT: search path used: '{{.*}}/sp2'
+// CHECK: search path used: '{{.*}}/sp1'
+// CHECK-NOT: search path used: '{{.*}}/sp2'
+
+//--- test-second.m
+@import mod2;
+// CHECK-NOT: search path used: '{{.*}}/sp1'
+// CHECK: search path used: '{{.*}}/sp2'
+// CHECK-NOT: search path used: '{{.*}}/sp1'
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -3908,7 +3908,7 @@
 // An implicitly-loaded module file should have its module listed in some
 // module map file that we've already loaded.
 Module *M =
-PP.getHeaderSearchInfo().lookupModule(F.ModuleName, F.ImportLoc);
+PP.getHeaderSearchInfo().lookupModule(F.ModuleName, SourceLocation());
 auto  = PP.getHeaderSearchInfo().getModuleMap();
 const FileEntry *ModMap = M ? Map.getModuleMapFileForUniquing(M) : nullptr;
 // Don't emit module relocation error if we have -fno-validate-pch
Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -824,6 +824,8 @@
   // Create a new module with this name.
   Module *Result = new Module(Name, SourceLocation(), Parent, IsFramework,
   IsExplicit, NumCreatedModules++);
+  for (const auto  : Callbacks)
+Callback->moduleMapModuleCreated(Result);
   if (!Parent) {
 if (LangOpts.CurrentModule == Name)
   SourceModule = Result;
@@ -1023,6 +1025,8 @@
   Module *Result = new Module(ModuleName, SourceLocation(), Parent,
   /*IsFramework=*/true, /*IsExplicit=*/false,
   NumCreatedModules++);
+  for (const auto  : Callbacks)
+Callback->moduleMapModuleCreated(Result);
   InferredModuleAllowedBy[Result] = ModuleMapFile;
   Result->IsInferred = true;
   if (!Parent) {
@@ -1117,6 +1121,8 @@
  /*IsExplicit=*/false, NumCreatedModules++);
   Result->ShadowingModule = ShadowingModule;
   Result->markUnavailable(/*Unimportable*/true);
+  for (const 

[PATCH] D110927: [analyzer] Access stored value of a constant array through a pointer to another type

2021-11-11 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/test/Analysis/initialization.cpp:295-299
+void glob_cast_opposite_sign1() {
+  auto *ptr = (unsigned int *)glob_arr2;
+  auto x1 = ptr[0]; // no-warning
+  auto x2 = ptr[1]; // expected-warning{{garbage or undefined}}
+}

ASDenysPetrov wrote:
> steakhal wrote:
> > ASDenysPetrov wrote:
> > > steakhal wrote:
> > > > I think it's not correct.
> > > > 
> > > > `glob_arr2` refers to an object of dynamic type `int[2]`.
> > > > And the pointer decayed from it is `int *`, which has //similar type// 
> > > > to `unsigned *` what you are using to access the memory.
> > > > Since they are //similar//, this operation should work for all the 
> > > > valid indices, thus `ptr[0]`, `ptr[1]`, `ptr[2]`, `ptr[3]` should all 
> > > > be valid.
> > > > 
> > > > 
> > > > glob_arr2 refers to an object of dynamic type int[2].
> > > `glob_arr2` has an extent of 4.
> > > > And the pointer decayed from it is int *, which has similar type to 
> > > > unsigned * what you are using to access the memory.
> > > Yes, they are the same and it perfectly suits to 
> > > http://eel.is/c++draft/basic.lval#11 . But still you can't access other 
> > > element then the first one according to 
> > > http://eel.is/c++draft/basic.compound#3 : //For purposes of pointer 
> > > arithmetic ([expr.add]) and comparison ([expr.rel], [expr.eq]), [...] an 
> > > object of type T that is not an array element is considered to belong to 
> > > an array with one element of type T. //
> > > `unsigned int` and `int` are different types according to 
> > > http://eel.is/c++draft/basic.fundamental#2 . The object of type `unsigned 
> > > int` is NOT an array, beacuse there is no array of type `unsigned int`. 
> > > Hence you can only only access the first and a single element of type 
> > > `unsigned int`.
> > > 
> > Yes, `glob_arr` has 4 elements, sorry for this typo.
> > 
> > ---
> > I disagree with the second part though. It seems like gcc disagrees as 
> > well: https://godbolt.org/z/5o7ozvPar
> > ```lang=C++
> > auto foo(unsigned ()[4], int ()[4]) {
> > p[0] = 2;
> > q[0] = 1;
> > return p[0]; // memory read! thus, p and q can alias according to g++.
> > }
> > ```
> > `gcc` still thinks that `p` and `q` can refer to the same memory region 
> > even if the `-fstrict-aliasing` flag is present.
> > In other circumstances, it would produce a `mov eax, 2` instead of a memory 
> > load if `p` and `q` cannot alias.
> >I disagree with the second part though. It seems like gcc disagrees as well: 
> >https://godbolt.org/z/5o7ozvPar
> I see how all the compilers handle this. I've switched several vendors on 
> Godbolt. They all have the similar behavior. You are right from compiler 
> perspective, but it's not quite the same in terms of C++ abstract machine.
> Your example is correct, it works OK and is consistent with the Standard:
> ```
> p[0] = 2;
> q[0] = 1;
> ```
> This one also works as expected but goes against the Standard:
> ```
> p[1] = 2;
> q[1] = 1;
> ```
> I want you watch this particular part about access via aliased pointers: 
> https://youtu.be/_qzMpk-22cc?t=2623 For me it seems correct, at least I can't 
> argue against of it now.
But in this example we have an array, thus pointer arithmetic should be fine 
according to the video.
Could you find the mentioned email discussion? I would be really curious.
BTW from the analyzer user's perspective, it would be 'better' to find strict 
aliasing violations which actually matter - now, and risking miscompilations.


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

https://reviews.llvm.org/D110927

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


[PATCH] D113623: [OpenMP][FIX] Pass the num_threads value directly to parallel_51

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

I think this should be the right direction. LGTM. @grokos WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113623

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


[PATCH] D113647: [X86] Honor command line features along with cpu_specific attribute

2021-11-11 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG893efd0d665b: [X86] Honor command line features along with 
cpu_specific attribute (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113647

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/CodeGen/attr-cpuspecific-avx-abi.c


Index: clang/test/CodeGen/attr-cpuspecific-avx-abi.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-cpuspecific-avx-abi.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -target-feature +avx -emit-llvm -o 
- %s | FileCheck %s --check-prefixes=CHECK
+
+// Make sure the features from the command line are honored regardless of what
+// CPU is specified in the cpu_specific attribute.
+// In this test, if the 'avx' feature isn't honored, we'll generate an error 
for
+// the return type having a different ABI without 'avx' being enabled.
+
+typedef double __m256d __attribute__((vector_size(32)));
+
+extern __m256d bar_avx1(void);
+extern __m256d bar_avx2(void);
+
+// AVX1/AVX2 dispatcher
+__attribute__((cpu_dispatch(generic, core_4th_gen_avx)))
+__m256d foo_pd64x4(void);
+
+__attribute__((cpu_specific(generic)))
+__m256d foo(void) { return bar_avx1(); }
+// CHECK: define{{.*}} @foo.A() #[[A:[0-9]+]]
+
+__attribute__((cpu_specific(core_4th_gen_avx)))
+__m256d foo(void) { return bar_avx2(); }
+// CHECK: define{{.*}} @foo.V() #[[V:[0-9]+]]
+
+// CHECK: attributes #[[A]] = 
{{.*}}"target-features"="+avx,+crc32,+cx8,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
+// CHECK: attributes #[[V]] = 
{{.*}}"target-features"="+avx,+avx2,+bmi,+cmov,+crc32,+cx8,+f16c,+fma,+lzcnt,+mmx,+movbe,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -11759,6 +11759,9 @@
 Target->getCPUSpecificCPUDispatchFeatures(
 SD->getCPUName(GD.getMultiVersionIndex())->getName(), FeaturesTmp);
 std::vector Features(FeaturesTmp.begin(), FeaturesTmp.end());
+Features.insert(Features.begin(),
+Target->getTargetOpts().FeaturesAsWritten.begin(),
+Target->getTargetOpts().FeaturesAsWritten.end());
 Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, Features);
   } else {
 FeatureMap = Target->getTargetOpts().FeatureMap;


Index: clang/test/CodeGen/attr-cpuspecific-avx-abi.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-cpuspecific-avx-abi.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -target-feature +avx -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK
+
+// Make sure the features from the command line are honored regardless of what
+// CPU is specified in the cpu_specific attribute.
+// In this test, if the 'avx' feature isn't honored, we'll generate an error for
+// the return type having a different ABI without 'avx' being enabled.
+
+typedef double __m256d __attribute__((vector_size(32)));
+
+extern __m256d bar_avx1(void);
+extern __m256d bar_avx2(void);
+
+// AVX1/AVX2 dispatcher
+__attribute__((cpu_dispatch(generic, core_4th_gen_avx)))
+__m256d foo_pd64x4(void);
+
+__attribute__((cpu_specific(generic)))
+__m256d foo(void) { return bar_avx1(); }
+// CHECK: define{{.*}} @foo.A() #[[A:[0-9]+]]
+
+__attribute__((cpu_specific(core_4th_gen_avx)))
+__m256d foo(void) { return bar_avx2(); }
+// CHECK: define{{.*}} @foo.V() #[[V:[0-9]+]]
+
+// CHECK: attributes #[[A]] = {{.*}}"target-features"="+avx,+crc32,+cx8,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
+// CHECK: attributes #[[V]] = {{.*}}"target-features"="+avx,+avx2,+bmi,+cmov,+crc32,+cx8,+f16c,+fma,+lzcnt,+mmx,+movbe,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -11759,6 +11759,9 @@
 Target->getCPUSpecificCPUDispatchFeatures(
 SD->getCPUName(GD.getMultiVersionIndex())->getName(), FeaturesTmp);
 std::vector Features(FeaturesTmp.begin(), FeaturesTmp.end());
+Features.insert(Features.begin(),
+Target->getTargetOpts().FeaturesAsWritten.begin(),
+Target->getTargetOpts().FeaturesAsWritten.end());
 Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, Features);
   } else {
 FeatureMap = Target->getTargetOpts().FeatureMap;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 893efd0 - [X86] Honor command line features along with cpu_specific attribute

2021-11-11 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-11-11T09:06:22-08:00
New Revision: 893efd0d665becb3478c750b2b4d3751c20ff39d

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

LOG: [X86] Honor command line features along with cpu_specific attribute

If the feature is on the command line we should honor it for all
functions. I don't think we could reliably target a single function
for a less capable processor than what the rest of the program is
compiled for.

Fixes PR52407.

Reviewed By: erichkeane

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

Added: 
clang/test/CodeGen/attr-cpuspecific-avx-abi.c

Modified: 
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 2611295d21a8d..391a0c0b338e6 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -11759,6 +11759,9 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap ,
 Target->getCPUSpecificCPUDispatchFeatures(
 SD->getCPUName(GD.getMultiVersionIndex())->getName(), FeaturesTmp);
 std::vector Features(FeaturesTmp.begin(), FeaturesTmp.end());
+Features.insert(Features.begin(),
+Target->getTargetOpts().FeaturesAsWritten.begin(),
+Target->getTargetOpts().FeaturesAsWritten.end());
 Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, Features);
   } else {
 FeatureMap = Target->getTargetOpts().FeatureMap;

diff  --git a/clang/test/CodeGen/attr-cpuspecific-avx-abi.c 
b/clang/test/CodeGen/attr-cpuspecific-avx-abi.c
new file mode 100644
index 0..ad9c82b5dbc3b
--- /dev/null
+++ b/clang/test/CodeGen/attr-cpuspecific-avx-abi.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -target-feature +avx -emit-llvm -o 
- %s | FileCheck %s --check-prefixes=CHECK
+
+// Make sure the features from the command line are honored regardless of what
+// CPU is specified in the cpu_specific attribute.
+// In this test, if the 'avx' feature isn't honored, we'll generate an error 
for
+// the return type having a 
diff erent ABI without 'avx' being enabled.
+
+typedef double __m256d __attribute__((vector_size(32)));
+
+extern __m256d bar_avx1(void);
+extern __m256d bar_avx2(void);
+
+// AVX1/AVX2 dispatcher
+__attribute__((cpu_dispatch(generic, core_4th_gen_avx)))
+__m256d foo_pd64x4(void);
+
+__attribute__((cpu_specific(generic)))
+__m256d foo(void) { return bar_avx1(); }
+// CHECK: define{{.*}} @foo.A() #[[A:[0-9]+]]
+
+__attribute__((cpu_specific(core_4th_gen_avx)))
+__m256d foo(void) { return bar_avx2(); }
+// CHECK: define{{.*}} @foo.V() #[[V:[0-9]+]]
+
+// CHECK: attributes #[[A]] = 
{{.*}}"target-features"="+avx,+crc32,+cx8,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
+// CHECK: attributes #[[V]] = 
{{.*}}"target-features"="+avx,+avx2,+bmi,+cmov,+crc32,+cx8,+f16c,+fma,+lzcnt,+mmx,+movbe,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"



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


[PATCH] D113359: [Libomptarget][WIP] Introduce VGPU Plugin

2021-11-11 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added inline comments.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:3082
+  if (getTriple().getVendor() == llvm::Triple::OpenMP_VGPU) {
+std::string BitcodeSuffix = "x86_64-vgpu";
+clang::driver::tools::addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args,

Maybe `"x86_64-openmp_vpu"` now?



Comment at: llvm/lib/Support/Triple.cpp:189
+  case OpenMP_VGPU:
+return "vgpu";
   }

`"openmp_vpu"`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113359

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


[PATCH] D113664: [cmake] use project relative paths when generating ASTNodeAPI.json

2021-11-11 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
Herald added a subscriber: mgorny.
mizvekov published this revision for review.
mizvekov added reviewers: steveire, phosek.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Signed-off-by: Matheus Izvekov 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113664

Files:
  clang/lib/Tooling/CMakeLists.txt


Index: clang/lib/Tooling/CMakeLists.txt
===
--- clang/lib/Tooling/CMakeLists.txt
+++ clang/lib/Tooling/CMakeLists.txt
@@ -60,11 +60,11 @@
   $
 # Skip this in debug mode because parsing AST.h is too slow
 --skip-processing=${skip_expensive_processing}
--I ${CMAKE_BINARY_DIR}/lib/clang/${CLANG_VERSION}/include
--I ${CMAKE_SOURCE_DIR}/../clang/include
--I ${CMAKE_BINARY_DIR}/tools/clang/include
--I ${CMAKE_BINARY_DIR}/include
--I ${CMAKE_SOURCE_DIR}/include
+-I ${LLVM_BINARY_DIR}/lib/clang/${CLANG_VERSION}/include
+-I ${CLANG_SOURCE_DIR}/include
+-I ${LLVM_BINARY_DIR}/tools/clang/include
+-I ${LLVM_BINARY_DIR}/include
+-I ${LLVM_SOURCE_DIR}/include
 ${implicitDirs}
 --json-output-path ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
   )


Index: clang/lib/Tooling/CMakeLists.txt
===
--- clang/lib/Tooling/CMakeLists.txt
+++ clang/lib/Tooling/CMakeLists.txt
@@ -60,11 +60,11 @@
   $
 # Skip this in debug mode because parsing AST.h is too slow
 --skip-processing=${skip_expensive_processing}
--I ${CMAKE_BINARY_DIR}/lib/clang/${CLANG_VERSION}/include
--I ${CMAKE_SOURCE_DIR}/../clang/include
--I ${CMAKE_BINARY_DIR}/tools/clang/include
--I ${CMAKE_BINARY_DIR}/include
--I ${CMAKE_SOURCE_DIR}/include
+-I ${LLVM_BINARY_DIR}/lib/clang/${CLANG_VERSION}/include
+-I ${CLANG_SOURCE_DIR}/include
+-I ${LLVM_BINARY_DIR}/tools/clang/include
+-I ${LLVM_BINARY_DIR}/include
+-I ${LLVM_SOURCE_DIR}/include
 ${implicitDirs}
 --json-output-path ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113647: [X86] Honor command line features along with cpu_specific attribute

2021-11-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 386524.
craig.topper added a comment.

Add test file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113647

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/CodeGen/attr-cpuspecific-avx-abi.c


Index: clang/test/CodeGen/attr-cpuspecific-avx-abi.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-cpuspecific-avx-abi.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -target-feature +avx -emit-llvm -o 
- %s | FileCheck %s --check-prefixes=CHECK
+
+// Make sure the features from the command line are honored regardless of what
+// CPU is specified in the cpu_specific attribute.
+// In this test, if the 'avx' feature isn't honored, we'll generate an error 
for
+// the return type having a different ABI without 'avx' being enabled.
+
+typedef double __m256d __attribute__((vector_size(32)));
+
+extern __m256d bar_avx1(void);
+extern __m256d bar_avx2(void);
+
+// AVX1/AVX2 dispatcher
+__attribute__((cpu_dispatch(generic, core_4th_gen_avx)))
+__m256d foo_pd64x4(void);
+
+__attribute__((cpu_specific(generic)))
+__m256d foo(void) { return bar_avx1(); }
+// CHECK: define{{.*}} @foo.A() #[[A:[0-9]+]]
+
+__attribute__((cpu_specific(core_4th_gen_avx)))
+__m256d foo(void) { return bar_avx2(); }
+// CHECK: define{{.*}} @foo.V() #[[V:[0-9]+]]
+
+// CHECK: attributes #[[A]] = 
{{.*}}"target-features"="+avx,+crc32,+cx8,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
+// CHECK: attributes #[[V]] = 
{{.*}}"target-features"="+avx,+avx2,+bmi,+cmov,+crc32,+cx8,+f16c,+fma,+lzcnt,+mmx,+movbe,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -11759,6 +11759,9 @@
 Target->getCPUSpecificCPUDispatchFeatures(
 SD->getCPUName(GD.getMultiVersionIndex())->getName(), FeaturesTmp);
 std::vector Features(FeaturesTmp.begin(), FeaturesTmp.end());
+Features.insert(Features.begin(),
+Target->getTargetOpts().FeaturesAsWritten.begin(),
+Target->getTargetOpts().FeaturesAsWritten.end());
 Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, Features);
   } else {
 FeatureMap = Target->getTargetOpts().FeatureMap;


Index: clang/test/CodeGen/attr-cpuspecific-avx-abi.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-cpuspecific-avx-abi.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -target-feature +avx -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK
+
+// Make sure the features from the command line are honored regardless of what
+// CPU is specified in the cpu_specific attribute.
+// In this test, if the 'avx' feature isn't honored, we'll generate an error for
+// the return type having a different ABI without 'avx' being enabled.
+
+typedef double __m256d __attribute__((vector_size(32)));
+
+extern __m256d bar_avx1(void);
+extern __m256d bar_avx2(void);
+
+// AVX1/AVX2 dispatcher
+__attribute__((cpu_dispatch(generic, core_4th_gen_avx)))
+__m256d foo_pd64x4(void);
+
+__attribute__((cpu_specific(generic)))
+__m256d foo(void) { return bar_avx1(); }
+// CHECK: define{{.*}} @foo.A() #[[A:[0-9]+]]
+
+__attribute__((cpu_specific(core_4th_gen_avx)))
+__m256d foo(void) { return bar_avx2(); }
+// CHECK: define{{.*}} @foo.V() #[[V:[0-9]+]]
+
+// CHECK: attributes #[[A]] = {{.*}}"target-features"="+avx,+crc32,+cx8,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
+// CHECK: attributes #[[V]] = {{.*}}"target-features"="+avx,+avx2,+bmi,+cmov,+crc32,+cx8,+f16c,+fma,+lzcnt,+mmx,+movbe,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -11759,6 +11759,9 @@
 Target->getCPUSpecificCPUDispatchFeatures(
 SD->getCPUName(GD.getMultiVersionIndex())->getName(), FeaturesTmp);
 std::vector Features(FeaturesTmp.begin(), FeaturesTmp.end());
+Features.insert(Features.begin(),
+Target->getTargetOpts().FeaturesAsWritten.begin(),
+Target->getTargetOpts().FeaturesAsWritten.end());
 Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, Features);
   } else {
 FeatureMap = Target->getTargetOpts().FeatureMap;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113647: [X86] Honor command line features along with cpu_specific attribute

2021-11-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D113647#3124363 , @erichkeane 
wrote:

> Is there a lit-test that could be added to make sure this happens?  We put 
> this in an llvm-attribute, so it should be checkable.

Forgot to git add the file I wrote.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113647

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


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

2021-11-11 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added inline comments.



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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112230

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


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

2021-11-11 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.
Herald added a subscriber: Naghasan.

> How about we clarify with Khronos whether it would be sufficient to add a 
> restriction like:
>
>> Program scope blocks are only supported when program scope variables feature 
>> is supported.

That's sounds good to me. Especially because this states nothing about if block 
has captures/no captures. Originally, I was thinking about something like: 
//blocks in constant address space require program scope variables feature 
support//, but that's too much relies on concrete ABI.




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

Anastasia wrote:
> What test case covers this change? It feels like something we should try to 
> diagnose earlier...
The test case which exactly was added. Since blocks in constant address space 
are disallowed at this point, we can treat all other blocks with no captures 
not as constant expressions - it will make CodeGen generate block  literal in 
local scope for blocks with no captures. See `buildGlobalBlock `and 
`CodeGenModule::GetAddrOfGlobalBlock` for details.



Comment at: clang/lib/CodeGen/CGOpenCLRuntime.cpp:191
+// feature support.
+bool CGOpenCLRuntime::blockCanBeGlobal() {
+  const auto  = CGM.getLangOpts();

Anastasia wrote:
> This function feels like something that belongs better to `OpenCLOptions` 
> rather than `CodeGen`?
IIRC we can't query Sema from a CodeGen... The alternative would be to 
introduce a new language option, which is not desirable.



Comment at: clang/lib/Sema/SemaDecl.cpp:8024
 if (T->isBlockPointerType()) {
+  if ((T.getAddressSpace() == LangAS::opencl_constant) &&
+  !getOpenCLOptions().areProgramScopeVariablesSupported(

Anastasia wrote:
> Good spot, I didn't feel the intent was to allow qualifying the block by an 
> address space... but I don't think this was ever clarified. I feel that the 
> assumption was that blocks would always be in global address space...
Well, unfortunately there are already few cases in CTS coverage which rely on 
that... Note that this is an address space of a block, but not a block literal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112230

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


[PATCH] D111443: [Driver] Fix ToolChain::getSanitizerArgs

2021-11-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/lib/Driver/ToolChain.cpp:124
+  }
+  return SanitizerArgs(*this, JobArgs, /*DiagnoseErrors=*/false);
 }

eugenis wrote:
> SanitizerArgs SanArgs(*this, JobArgs, !SanitizerArgsChecked);
> SanitizerArgsChecked = true;
> return SanArgs;
> 
done



Comment at: clang/lib/Driver/ToolChains/FreeBSD.cpp:471
+bool FreeBSD::isPIEDefault(const llvm::opt::ArgList ) const {
+  return getSanitizerArgs(Args).requiresPIE();
+}

eugenis wrote:
> it looks like we do a lot of sanitizerargs recomputing. Is it worth it to try 
> and cache it?
In general, SanitizerArgs is per job arguments, not per toolchain. There is no 
good way to cache it.

On the other hand, I would expect time spent in argument parsing is trivial 
compared to time spent in compilation for common programs.


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

https://reviews.llvm.org/D111443

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


[PATCH] D111443: [Driver] Fix ToolChain::getSanitizerArgs

2021-11-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 386518.
yaxunl marked an inline comment as done.
yaxunl added a comment.

Revised by Evgenii's comments


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

https://reviews.llvm.org/D111443

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/BareMetal.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CloudABI.cpp
  clang/lib/Driver/ToolChains/CloudABI.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CrossWindows.cpp
  clang/lib/Driver/ToolChains/CrossWindows.h
  clang/lib/Driver/ToolChains/Cuda.h
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/FreeBSD.h
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Fuchsia.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Driver/ToolChains/Haiku.h
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  clang/lib/Driver/ToolChains/MSP430.h
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MSVC.h
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/lib/Driver/ToolChains/MinGW.h
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/OpenBSD.h
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/lib/Driver/ToolChains/PS4CPU.h
  clang/lib/Driver/ToolChains/TCE.cpp
  clang/lib/Driver/ToolChains/TCE.h
  clang/lib/Driver/ToolChains/VEToolchain.cpp
  clang/lib/Driver/ToolChains/VEToolchain.h
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Driver/ToolChains/WebAssembly.h
  clang/lib/Driver/ToolChains/XCore.cpp
  clang/lib/Driver/ToolChains/XCore.h
  clang/lib/Driver/ToolChains/ZOS.h
  clang/test/Driver/hip-sanitize-options.hip

Index: clang/test/Driver/hip-sanitize-options.hip
===
--- clang/test/Driver/hip-sanitize-options.hip
+++ clang/test/Driver/hip-sanitize-options.hip
@@ -1,47 +1,67 @@
 // REQUIRES: clang-driver, x86-registered-target, amdgpu-registered-target
 
-// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900 \
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900:xnack+ \
 // RUN:   -fsanitize=address \
 // RUN:   -nogpuinc --rocm-path=%S/Inputs/rocm \
-// RUN:   %s 2>&1 | FileCheck %s
+// RUN:   %s 2>&1 | FileCheck -check-prefixes=NORDC %s
 
-// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900 \
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900:xnack+ \
 // RUN:   -fsanitize=address -fno-gpu-sanitize \
 // RUN:   -nogpuinc --rocm-path=%S/Inputs/rocm \
 // RUN:   %s 2>&1 | FileCheck %s
 
-// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900 \
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900:xnack+ \
 // RUN:   -fsanitize=address -fgpu-sanitize \
 // RUN:   -nogpuinc --rocm-path=%S/Inputs/rocm \
 // RUN:   %s 2>&1 | FileCheck -check-prefixes=NORDC %s
 
-// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900 \
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900:xnack+ \
 // RUN:   -fsanitize=address -fgpu-sanitize -fgpu-rdc \
 // RUN:   -nogpuinc --rocm-path=%S/Inputs/rocm \
 // RUN:   %s 2>&1 | FileCheck -check-prefixes=RDC %s
 
-// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900 \
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900:xnack+ \
 // RUN:   -fsanitize=address -fgpu-sanitize \
 // RUN:   -nogpuinc --rocm-path=%S/Inputs/rocm-invalid \
 // RUN:   %s 2>&1 | FileCheck -check-prefixes=FAIL %s
 
 // RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900:xnack- \
-// RUN:   -fsanitize=address -fgpu-sanitize \
-// RUN:   -nogpuinc --rocm-path=%S/Inputs/rocm \
-// RUN:   %s 2>&1 | FileCheck -check-prefix=XNACK %s
+// RUN:   --offload-arch=gfx900:xnack+ --offload-arch=gfx906 -fsanitize=address -fgpu-sanitize \
+// RUN:   -fsanitize=leak -nogpuinc --rocm-path=%S/Inputs/rocm \
+// RUN:   %s 2>&1 | FileCheck -check-prefixes=XNACK %s
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900:xnack- \
+// RUN:   --offload-arch=gfx900:xnack+ --offload-arch=gfx906 -fsanitize=address -fgpu-sanitize \
+// RUN:   -fsanitize=leak -nogpuinc --rocm-path=%S/Inputs/rocm \
+// RUN:   %s 2>&1 | FileCheck -check-prefixes=XNACKNEG %s
 
 // CHECK-NOT: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address"}}
+// CHECK-NOT: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-mlink-bitcode-file" 

[PATCH] D112285: [PowerPC] PPC backend optimization to lower int_ppc_tdw/int_ppc_tw intrinsics to TDI/TWI machine instructions

2021-11-11 Thread Victor Huang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
NeHuang marked 5 inline comments as done.
Closed by commit rG18fe0a0d9eb1: [PowerPC] PPC backend optimization to lower 
int_ppc_tdw/int_ppc_tw intrinsics… (authored by NeHuang).

Changed prior to commit:
  https://reviews.llvm.org/D112285?vs=384768=386517#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112285

Files:
  llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
  llvm/lib/Target/PowerPC/PPCInstr64Bit.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap-64bit-only.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll
@@ -127,6 +127,213 @@
   ret void
 }
 
+; tw -> twi
+define dso_local void @test__twi_boundary_reg_imm(i32 %a) {
+; CHECK-LABEL: test__twi_boundary_reg_imm:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twi 3, r3, 32767
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 32767, i32 3)
+  ret void
+}
+
+define dso_local void @test__twi_boundary_imm_reg(i32 %a) {
+; CHECK-LABEL: test__twi_boundary_imm_reg:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twi 3, r3, 32767
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 32767, i32 %a, i32 3)
+  ret void
+}
+
+define dso_local void @test__twi_boundary1_reg_imm(i32 %a) {
+; CHECK-LABEL: test__twi_boundary1_reg_imm:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twi 3, r3, -32768
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 -32768, i32 3)
+  ret void
+}
+
+define dso_local void @test__twi_boundary1_imm_reg(i32 %a) {
+; CHECK-LABEL: test__twi_boundary1_imm_reg:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twi 3, r3, -32768
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 -32768, i32 %a, i32 3)
+  ret void
+}
+
+define dso_local void @test__tw_boundary2_reg_imm(i32 %a) {
+; CHECK-LABEL: test__tw_boundary2_reg_imm:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:lis r4, 0
+; CHECK-NEXT:ori r4, r4, 32768
+; CHECK-NEXT:tw 3, r3, r4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 32768, i32 3)
+  ret void
+}
+
+define dso_local void @test__tw_boundary2_imm_reg(i32 %a) {
+; CHECK-LABEL: test__tw_boundary2_imm_reg:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:lis r4, 0
+; CHECK-NEXT:ori r4, r4, 32768
+; CHECK-NEXT:tw 3, r4, r3
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 32768, i32 %a, i32 3)
+  ret void
+}
+
+define dso_local void @test__tw_boundary3_reg_imm(i32 %a) {
+; CHECK-LABEL: test__tw_boundary3_reg_imm:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:lis r4, -1
+; CHECK-NEXT:ori r4, r4, 32767
+; CHECK-NEXT:tw 3, r3, r4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 -32769, i32 3)
+  ret void
+}
+
+define dso_local void @test__tw_boundary3_imm_reg(i32 %a) {
+; CHECK-LABEL: test__tw_boundary3_imm_reg:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:lis r4, -1
+; CHECK-NEXT:ori r4, r4, 32767
+; CHECK-NEXT:tw 3, r4, r3
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 -32769, i32 %a, i32 3)
+  ret void
+}
+
+define dso_local void @test__twlgti_reg_imm(i32 %a) {
+; CHECK-LABEL: test__twlgti_reg_imm:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twlgti r3, 0
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 0, i32 1)
+  ret void
+}
+
+define dso_local void @test__twllti_imm_reg(i32 %a) {
+; CHECK-LABEL: test__twllti_imm_reg:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twllti r3, 0
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 0, i32 %a, i32 1)
+  ret void
+}
+
+define dso_local void @test__twllti_reg_imm(i32 %a) {
+; CHECK-LABEL: test__twllti_reg_imm:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twllti r3, 1
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 1, i32 2)
+  ret void
+}
+
+define dso_local void @test__twlgti_imm_reg(i32 %a) {
+; CHECK-LABEL: test__twlgti_imm_reg:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twlgti r3, 1
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 1, i32 %a, i32 2)
+  ret void
+}
+
+define dso_local void @test__tweqi_reg_imm(i32 %a) {
+; CHECK-LABEL: test__tweqi_reg_imm:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tweqi r3, 2
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 2, i32 4)
+  ret void
+}
+
+define dso_local void @test__tweqi_imm_reg(i32 %a) {
+; CHECK-LABEL: test__tweqi_imm_reg:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tweqi r3, 2
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 2, i32 %a, i32 4)
+  ret void
+}
+
+define dso_local void @test__twgti_reg_imm(i32 %a) {
+; CHECK-LABEL: test__twgti_reg_imm:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twgti r3, 16
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 16, i32 8)
+  ret void
+}
+
+define 

[PATCH] D113654: [AIX] Set D111860's test unsupported on AIX

2021-11-11 Thread Kai Luo via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG72362736c380: [AIX] Set D111860s test unsupported on 
AIX (authored by lkail).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113654

Files:
  clang/test/Modules/merge-objc-protocol-visibility.m


Index: clang/test/Modules/merge-objc-protocol-visibility.m
===
--- clang/test/Modules/merge-objc-protocol-visibility.m
+++ clang/test/Modules/merge-objc-protocol-visibility.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -aix
 // RUN: rm -rf %t
 // RUN: split-file %s %t
 // RUN: %clang_cc1 -emit-llvm -o %t/test.bc -F%t/Frameworks %t/test.m 
-Werror=objc-method-access -DHIDDEN_FIRST=1 \


Index: clang/test/Modules/merge-objc-protocol-visibility.m
===
--- clang/test/Modules/merge-objc-protocol-visibility.m
+++ clang/test/Modules/merge-objc-protocol-visibility.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -aix
 // RUN: rm -rf %t
 // RUN: split-file %s %t
 // RUN: %clang_cc1 -emit-llvm -o %t/test.bc -F%t/Frameworks %t/test.m -Werror=objc-method-access -DHIDDEN_FIRST=1 \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7236273 - [AIX] Set D111860's test unsupported on AIX

2021-11-11 Thread Kai Luo via cfe-commits

Author: Kai Luo
Date: 2021-11-11T15:51:19Z
New Revision: 72362736c380699a79ba43a1411baeab76205c39

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

LOG: [AIX] Set D111860's test unsupported on AIX

Reviewed By: jsji

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

Added: 


Modified: 
clang/test/Modules/merge-objc-protocol-visibility.m

Removed: 




diff  --git a/clang/test/Modules/merge-objc-protocol-visibility.m 
b/clang/test/Modules/merge-objc-protocol-visibility.m
index 04cf60b7e997..8521a60e7adc 100644
--- a/clang/test/Modules/merge-objc-protocol-visibility.m
+++ b/clang/test/Modules/merge-objc-protocol-visibility.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -aix
 // RUN: rm -rf %t
 // RUN: split-file %s %t
 // RUN: %clang_cc1 -emit-llvm -o %t/test.bc -F%t/Frameworks %t/test.m 
-Werror=objc-method-access -DHIDDEN_FIRST=1 \



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


[PATCH] D113676: WIP: [clang][lex] Fix search path usage remark with modules

2021-11-11 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Lex/HeaderSearch.cpp:264
+  if (Module || !AllowSearch || !HSOpts->ImplicitModuleMaps) {
+noteModuleLookupUsage(Module, ImportLoc);
 return Module;

This is the important change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113676

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


[PATCH] D113676: WIP: [clang][lex] Fix search path usage remark with modules

2021-11-11 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added a reviewer: ahoppen.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When looking for module, `HeaderSearch::lookupModule` iterates through search 
paths, parses modulemaps, eagerly creates `Module` instances and caches them in 
`ModuleMap`. When first called, it will correctly note usage of the search path 
that discovered the returned module. On subsequent calls, however, it can pull 
previously created `Module` from `ModuleMap` without noting the search path was 
used.

This patch fixes that. This requires `HeaderSearch` to be able to go from 
`Module` to the index of corresponding search path. This is achieved by adding 
a callback to the modulemap parser, intercepting creations of `Module` 
instances and pairing them with the current search path index.

The outlined solution doesn't handle all corner cases, though. It's possible 
for clients to use `HeaderSearch` to lookup module `B`, which could deserialize 
unrelated modulemap and create instance of module `A`. The client can then look 
up module `A` directly in `ModuleMap`, avoiding the logic in `HeaderSearch` 
that makes `-Rsearch-path-usage` work.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113676

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/Preprocessor/search-path-usage-modules.m
  clang/test/Preprocessor/search-path-usage.m

Index: clang/test/Preprocessor/search-path-usage.m
===
--- clang/test/Preprocessor/search-path-usage.m
+++ clang/test/Preprocessor/search-path-usage.m
@@ -128,19 +128,3 @@
 // expected-remark-re {{search path used: '{{.*}}/b-missing.hmap'}}
 #endif
 #endif
-
-// Check that search paths with module maps are reported.
-//
-// RUN: mkdir %t/modulemap_abs
-// RUN: sed "s|DIR|%/S/Inputs/search-path-usage|g"\
-// RUN:   %S/Inputs/search-path-usage/modulemap_abs/module.modulemap.template \
-// RUN: > %t/modulemap_abs/module.modulemap
-// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage   \
-// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules \
-// RUN:   -I %t/modulemap_abs  \
-// RUN:   -I %S/Inputs/search-path-usage/a \
-// RUN:   -DMODMAP_ABS -verify
-#ifdef MODMAP_ABS
-@import b; // \
-// expected-remark-re {{search path used: '{{.*}}/modulemap_abs'}}
-#endif
Index: clang/test/Preprocessor/search-path-usage-modules.m
===
--- /dev/null
+++ clang/test/Preprocessor/search-path-usage-modules.m
@@ -0,0 +1,37 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -Eonly %t/test-both.m   -I %t/sp1 -I %t/sp2 -Rsearch-path-usage \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache 2>&1 | FileCheck %t/test-both.m
+// RUN: %clang_cc1 -Eonly %t/test-first.m  -I %t/sp2 -I %t/sp1 -Rsearch-path-usage \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache 2>&1 | FileCheck %t/test-first.m
+// RUN: %clang_cc1 -Eonly %t/test-second.m -I %t/sp2 -I %t/sp1 -Rsearch-path-usage \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache 2>&1 | FileCheck %t/test-second.m
+
+//--- sp1/module.modulemap
+module mod1 { header "mod1.h" }
+//--- sp1/mod1.h
+int module1();
+
+//--- sp2/module.modulemap
+module mod2 { header "mod2.h" }
+//--- sp2/mod2.h
+int module2();
+
+//--- test-both.m
+@import mod1;
+@import mod2;
+// CHECK: search path used: '{{.*}}/sp1'
+// CHECK: search path used: '{{.*}}/sp2'
+
+//--- test-first.m
+@import mod1;
+// CHECK-NOT: search path used: '{{.*}}/sp2'
+// CHECK: search path used: '{{.*}}/sp1'
+// CHECK-NOT: search path used: '{{.*}}/sp2'
+
+//--- test-second.m
+@import mod2;
+// CHECK-NOT: search path used: '{{.*}}/sp1'
+// CHECK: search path used: '{{.*}}/sp2'
+// CHECK-NOT: search path used: '{{.*}}/sp1'
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -3908,7 +3908,7 @@
 // An implicitly-loaded module file should have its module listed in some
 // module map file that we've already loaded.
 Module *M =
-PP.getHeaderSearchInfo().lookupModule(F.ModuleName, F.ImportLoc);
+PP.getHeaderSearchInfo().lookupModule(F.ModuleName, SourceLocation());
 auto  = PP.getHeaderSearchInfo().getModuleMap();
 const FileEntry *ModMap = M ? Map.getModuleMapFileForUniquing(M) : nullptr;
 // Don't emit module relocation error if we have -fno-validate-pch
Index: clang/lib/Lex/ModuleMap.cpp

[PATCH] D113201: [clang-tidy] Fix a crash in modernize-loop-convert around conversion operators

2021-11-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM modulo comments from @steakhal!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113201

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


[PATCH] D113201: [clang-tidy] Fix a crash in modernize-loop-convert around conversion operators

2021-11-11 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please wait for @aaron.ballman approval.


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

https://reviews.llvm.org/D113201

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


[PATCH] D51650: Implement target_clones multiversioning

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

Overall, I think this LGTM, but I did find a few nits. Can you fix the 
clang-format issues? Also, I'd like to see some C++ test coverage that shows 
how this works on template (partial) specializations, lambdas (with GNU-style 
syntax), and overloaded functions. If we deviate from the GCC behavior in any 
cases, it'd be great to capture it in comments (unless you think the deviation 
is intentional, at which point we should document it in AttrDocs.td, or you 
think the deviation needs to be fixed before we land it).




Comment at: clang/include/clang/Basic/Attr.td:2706
+  featuresStrs_begin(), featuresStrs_begin() + Index,
+  [ FeatureStr ](StringRef S) { return S == FeatureStr; });
+}





Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11289
+  "or a string literal containing a comma-separated list of versions">,
+  InGroup>;
+def warn_target_clone_duplicate_options

Should this ad hoc group be listed within the `FunctionMultiVersioning` group?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:1968-1972
+  if (checkAttrMutualExclusion(S, D, AL) ||
+  checkAttrMutualExclusion(S, D, AL) ||
+  checkAttrMutualExclusion(S, D, AL) ||
+  checkAttrMutualExclusion(S, D, AL))
+return;

This should be handled in Attr.td via a `def : MutualExclusions<[]>;` if 
possible.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3274
 static void handleTargetAttr(Sema , Decl *D, const ParsedAttr ) {
+  if (checkAttrMutualExclusion(S, D, AL) ||
+  checkAttrMutualExclusion(S, D, AL) ||

Same here.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3342
+static void handleTargetClonesAttr(Sema , Decl *D, const ParsedAttr ) {
+  if (checkAttrMutualExclusion(S, D, AL) ||
+  checkAttrMutualExclusion(S, D, AL) ||

And here


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

https://reviews.llvm.org/D51650

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


[PATCH] D113451: [PowerPC] [Clang] Enable Intel intrinsics support on FreeBSD

2021-11-11 Thread Jinsong Ji via Phabricator via cfe-commits
jsji accepted this revision as: jsji.
jsji added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for enabling this for FreeBSD.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113451

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


[PATCH] D113256: [AArch64][ARM] Enablement of Cortex-A710 Support

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

Thanks. LGTM


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

https://reviews.llvm.org/D113256

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


[PATCH] D64454: [clang-tidy] Adding static analyzer check to list of clang-tidy checks

2021-11-11 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

I was a bit confused as well about the ClangSA support in clang-tidy. What's 
the current status? Is clang-tidy running *all* checks from StaticAnalyzer?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64454

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


[PATCH] D110927: [analyzer] Access stored value of a constant array through a pointer to another type

2021-11-11 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@steakhal

> I think I know.

Great! Thank you!




Comment at: clang/test/Analysis/initialization.cpp:295-299
+void glob_cast_opposite_sign1() {
+  auto *ptr = (unsigned int *)glob_arr2;
+  auto x1 = ptr[0]; // no-warning
+  auto x2 = ptr[1]; // expected-warning{{garbage or undefined}}
+}

steakhal wrote:
> ASDenysPetrov wrote:
> > steakhal wrote:
> > > I think it's not correct.
> > > 
> > > `glob_arr2` refers to an object of dynamic type `int[2]`.
> > > And the pointer decayed from it is `int *`, which has //similar type// to 
> > > `unsigned *` what you are using to access the memory.
> > > Since they are //similar//, this operation should work for all the valid 
> > > indices, thus `ptr[0]`, `ptr[1]`, `ptr[2]`, `ptr[3]` should all be valid.
> > > 
> > > 
> > > glob_arr2 refers to an object of dynamic type int[2].
> > `glob_arr2` has an extent of 4.
> > > And the pointer decayed from it is int *, which has similar type to 
> > > unsigned * what you are using to access the memory.
> > Yes, they are the same and it perfectly suits to 
> > http://eel.is/c++draft/basic.lval#11 . But still you can't access other 
> > element then the first one according to 
> > http://eel.is/c++draft/basic.compound#3 : //For purposes of pointer 
> > arithmetic ([expr.add]) and comparison ([expr.rel], [expr.eq]), [...] an 
> > object of type T that is not an array element is considered to belong to an 
> > array with one element of type T. //
> > `unsigned int` and `int` are different types according to 
> > http://eel.is/c++draft/basic.fundamental#2 . The object of type `unsigned 
> > int` is NOT an array, beacuse there is no array of type `unsigned int`. 
> > Hence you can only only access the first and a single element of type 
> > `unsigned int`.
> > 
> Yes, `glob_arr` has 4 elements, sorry for this typo.
> 
> ---
> I disagree with the second part though. It seems like gcc disagrees as well: 
> https://godbolt.org/z/5o7ozvPar
> ```lang=C++
> auto foo(unsigned ()[4], int ()[4]) {
> p[0] = 2;
> q[0] = 1;
> return p[0]; // memory read! thus, p and q can alias according to g++.
> }
> ```
> `gcc` still thinks that `p` and `q` can refer to the same memory region even 
> if the `-fstrict-aliasing` flag is present.
> In other circumstances, it would produce a `mov eax, 2` instead of a memory 
> load if `p` and `q` cannot alias.
>I disagree with the second part though. It seems like gcc disagrees as well: 
>https://godbolt.org/z/5o7ozvPar
I see how all the compilers handle this. I've switched several vendors on 
Godbolt. They all have the similar behavior. You are right from compiler 
perspective, but it's not quite the same in terms of C++ abstract machine.
Your example is correct, it works OK and is consistent with the Standard:
```
p[0] = 2;
q[0] = 1;
```
This one also works as expected but goes against the Standard:
```
p[1] = 2;
q[1] = 1;
```
I want you watch this particular part about access via aliased pointers: 
https://youtu.be/_qzMpk-22cc?t=2623 For me it seems correct, at least I can't 
argue against of it now.


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

https://reviews.llvm.org/D110927

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


[PATCH] D112903: [C++20] [Module] Fix front end crashes when trying to export a qualified entity which is already declared

2021-11-11 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:7784-7785
   "because namespace %1 does not enclose namespace %2">;
+def err_export_non_namespace_scope_name : Error<"cannot export %0 here since "
+  "only the entities in namespace scope could be exported.">;
+def err_export_qualified_redeclaration : Error<"cannot export redeclaration "

I think the wording is awkward.  'here' carries the implication there is a 
somewhere where it would be ok, but there isn't.
'cannot export %0 as it is not at namespace scope'



Comment at: clang/test/CXX/module/module.interface/p6.cpp:47
+void A::foo();
+export struct A::X;   // expected-error {{cannot export redeclaration 'X' 
here.}}
+export struct A::Y;   // expected-error {{cannot export redeclaration 'Y' 
here.}}

um, is that really invalid?  it looks to me that one's reexporting an already 
exported namespace entity.  It's perfectly valid to write::
namespace A{ export struct X;}
namespace A { export struct X;}
so I don't see why 'export struct A::X;' is invalid.  (I realize this is not a 
change you;ve made).

also applies to foo.



Comment at: clang/test/CXX/module/module.interface/p6.cpp:48
+export struct A::X;   // expected-error {{cannot export redeclaration 'X' 
here.}}
+export struct A::Y;   // expected-error {{cannot export redeclaration 'Y' 
here.}}
+export void A::foo(); // expected-error {{cannot export redeclaration 'foo' 
here.}}

Can we note (a) as the original declaration was not exported, and note where it 
is?
'cannot export redeclaration %0 as it is not exported'
'note: declared here'

also applies to bar


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

https://reviews.llvm.org/D112903

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


[PATCH] D113647: [X86] Honor command line features along with cpu_specific attribute

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

Is there a lit-test that could be added to make sure this happens?  We put this 
in an llvm-attribute, so it should be checkable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113647

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


[PATCH] D51650: Implement target_clones multiversioning

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

In D51650#3121789 , @erichkeane wrote:

> But nit made.

NIT: clang-format issues still present. Maybe you need to update your local 
clang-format.

In D51650#3121789 , @erichkeane wrote:

> For the rest of multiversioning we count on the optimizer to remove variants 
> made irrelevant, but I'm not sure opt can do anything like that yet :)

I think removing the duplicated in opt is harder than just eliminate them here. 
At the end maybe the function does not need ifunc.

LGTM


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

https://reviews.llvm.org/D51650

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


[PATCH] D64454: [clang-tidy] Adding static analyzer check to list of clang-tidy checks

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

In D64454#3122281 , @steakhal wrote:

> It seems like the list got pretty outdated by the time.
> Do you think we should really refer to the clang-analyzer checks in this 
> list? What about simply referring to the clangsa docs instead?
> I fear, this will be a constant problem in the future.

Yeah, I was worried this would get out of sycn and it really did not take long 
for that to happen in practice. I think there's utility in listing the checks 
in clang-tidy's documentation instead of pointing users to the SA documentation 
page. Users should have one website to go to where they can see what clang-tidy 
checks are available to them.

> That being said, a specific grep-like test would suffice to ensure it's 
> always updated, but I would be surprised as a clang static analyzer developer 
> that I need to run the clang-tools-extra tests besides the clang-analysis 
> ones.
> It would cause build bot breakages all the time - and just as many revert 
> commits by choosing that direction.
>
> WDYT? @aaron.ballman @njames93 @whisperity

So long as pre-commit CI runs the test, I think this might be a reasonable path 
forward. You may forget to run the tests locally, but you should still get some 
failure indication before we land a patch. That should also curtail the churn 
from having to revert. WDYT?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64454

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


  1   2   >