[PATCH] D133160: [cmake] Append CLANG_LIBDIR_SUFFIX to scan-build-py installation destination.

2022-09-02 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133160

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


[PATCH] D132810: [clang][MinGW] Add `-mguard=cf` and `-mguard=cf-nochecks`

2022-09-02 Thread Alvin Wong via Phabricator via cfe-commits
alvinhochun updated this revision to Diff 457523.
alvinhochun added a comment.

Applied suggestions. Thanks for the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132810

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/lib/Driver/ToolChains/MinGW.h
  clang/test/Driver/mingw-cfguard.c

Index: clang/test/Driver/mingw-cfguard.c
===
--- /dev/null
+++ clang/test/Driver/mingw-cfguard.c
@@ -0,0 +1,28 @@
+// RUN: %clang -target=x86_64-w64-windows-gnu -### %s 2>&1 | FileCheck -check-prefixes=NO_CF,DEFAULT %s
+// RUN: %clang -target=x86_64-w64-windows-gnu -### %s -mguard=none 2>&1 | FileCheck -check-prefixes=NO_CF,GUARD_NONE %s
+// NO_CF: "-cc1"
+// NO_CF-NOT: "-cfguard"
+// NO_CF-NOT: "-cfguard-no-checks"
+// NO_CF-NEXT: ld"
+// NO_CF-NOT: "--guard-cf"
+// DEFAULT-NOT: "--no-guard-cf"
+// GUARD_NONE-SAME: "--no-guard-cf"
+
+// RUN: %clang -target=x86_64-w64-windows-gnu -### %s -mguard=cf 2>&1 | FileCheck -check-prefix=GUARD_CF %s
+// GUARD_CF: "-cc1"
+// GUARD_CF-SAME: "-cfguard"
+// GUARD_CF-NEXT: ld"
+// GUARD_CF-SAME: "--guard-cf"
+// GUARD_CF-NOT: "--no-guard-cf"
+
+// RUN: %clang -target=x86_64-w64-windows-gnu -### %s -mguard=cf-nochecks 2>&1 | FileCheck -check-prefix=GUARD_NOCHECKS %s
+// GUARD_NOCHECKS: "-cc1"
+// GUARD_NOCHECKS-NOT: "-cfguard"
+// GUARD_NOCHECKS-SAME: "-cfguard-no-checks"
+// GUARD_NOCHECKS-NOT: "-cfguard"
+// GUARD_NOCHECKS-NEXT: ld"
+// GUARD_NOCHECKS-SAME: "--guard-cf"
+// GUARD_NOCHECKS-NOT: "--no-guard-cf"
+
+// RUN: %clang -target=x86_64-w64-windows-gnu -### %s -mguard=xxx 2>&1 | FileCheck -check-prefix=GUARD_UNKNOWN %s
+// GUARD_UNKNOWN: error: unsupported argument 'xxx' to option '--mguard='
Index: clang/lib/Driver/ToolChains/MinGW.h
===
--- clang/lib/Driver/ToolChains/MinGW.h
+++ clang/lib/Driver/ToolChains/MinGW.h
@@ -79,6 +79,10 @@
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args) const override;
+  void
+  addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args,
+Action::OffloadKind DeviceOffloadKind) const override;
   void AddClangCXXStdlibIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -169,6 +169,17 @@
   if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
 CmdArgs.push_back("--no-demangle");
 
+  if (Arg *A = Args.getLastArg(options::OPT_mguard_EQ)) {
+StringRef GuardArgs = A->getValue();
+if (GuardArgs == "none")
+  CmdArgs.push_back("--no-guard-cf");
+else if (GuardArgs == "cf" || GuardArgs == "cf-nochecks")
+  CmdArgs.push_back("--guard-cf");
+else
+  D.Diag(diag::err_drv_unsupported_option_argument)
+  << A->getSpelling() << GuardArgs;
+  }
+
   CmdArgs.push_back("-o");
   const char *OutputFile = Output.getFilename();
   // GCC implicitly adds an .exe extension if it is given an output file name
@@ -607,6 +618,26 @@
   addSystemInclude(DriverArgs, CC1Args, Base + "include");
 }
 
+void toolchains::MinGW::addClangTargetOptions(
+const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
+Action::OffloadKind DeviceOffloadKind) const {
+  if (Arg *A = DriverArgs.getLastArg(options::OPT_mguard_EQ)) {
+StringRef GuardArgs = A->getValue();
+if (GuardArgs == "none") {
+  // Do nothing.
+} else if (GuardArgs == "cf") {
+  // Emit CFG instrumentation and the table of address-taken functions.
+  CC1Args.push_back("-cfguard");
+} else if (GuardArgs == "cf-nochecks") {
+  // Emit only the table of address-taken functions.
+  CC1Args.push_back("-cfguard-no-checks");
+} else {
+  getDriver().Diag(diag::err_drv_unsupported_option_argument)
+  << A->getSpelling() << GuardArgs;
+}
+  }
+}
+
 void toolchains::MinGW::AddClangCXXStdlibIncludeArgs(
 const ArgList &DriverArgs, ArgStringList &CC1Args) const {
   if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3360,6 +3360,9 @@
 def mdll : Joined<["-"], "mdll">, Group, Flags<[NoXarchOption]>;
 def municode : Joined<["-"], "municode">, Group, Flags<[NoXarchOption]>;
 def mthreads : Joined<["-"], "mthreads">, Group, Flags<[NoXarchOption]>;
+def mguard_EQ : Joined<["-"], "mguard=">, Group, Fla

[clang] 66f332b - [X86] Add missing key feature for core2

2022-09-02 Thread Freddy Ye via cfe-commits

Author: Freddy Ye
Date: 2022-09-02T16:06:07+08:00
New Revision: 66f332bc1ac04430580a8498ab5537b392f3ea1e

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

LOG: [X86] Add missing key feature for core2

Reviewed By: erichkeane

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

Added: 


Modified: 
clang/test/CodeGen/attr-target-mv.c
llvm/lib/Support/X86TargetParser.cpp

Removed: 




diff  --git a/clang/test/CodeGen/attr-target-mv.c 
b/clang/test/CodeGen/attr-target-mv.c
index 8ab2f992fc1fe..07235eaeebdd5 100644
--- a/clang/test/CodeGen/attr-target-mv.c
+++ b/clang/test/CodeGen/attr-target-mv.c
@@ -14,6 +14,7 @@ int __attribute__((target("arch=tigerlake"))) foo(void) 
{return 9;}
 int __attribute__((target("arch=sapphirerapids"))) foo(void) {return 10;}
 int __attribute__((target("arch=alderlake"))) foo(void) {return 11;}
 int __attribute__((target("arch=rocketlake"))) foo(void) {return 12;}
+int __attribute__((target("arch=core2"))) foo(void) {return 13;}
 int __attribute__((target("default"))) foo(void) { return 2; }
 
 int bar(void) {
@@ -146,6 +147,8 @@ void calls_pr50025c(void) { pr50025c(); }
 // LINUX: ret i32 11
 // LINUX: define{{.*}} i32 @foo.arch_rocketlake()
 // LINUX: ret i32 12
+// LINUX: define{{.*}} i32 @foo.arch_core2()
+// LINUX: ret i32 13
 // LINUX: define{{.*}} i32 @foo()
 // LINUX: ret i32 2
 // LINUX: define{{.*}} i32 @bar()
@@ -175,6 +178,8 @@ void calls_pr50025c(void) { pr50025c(); }
 // WINDOWS: ret i32 11
 // WINDOWS: define dso_local i32 @foo.arch_rocketlake()
 // WINDOWS: ret i32 12
+// WINDOWS: define dso_local i32 @foo.arch_core2()
+// WINDOWS: ret i32 13
 // WINDOWS: define dso_local i32 @foo()
 // WINDOWS: ret i32 2
 // WINDOWS: define dso_local i32 @bar()

diff  --git a/llvm/lib/Support/X86TargetParser.cpp 
b/llvm/lib/Support/X86TargetParser.cpp
index 2567f3ed8034b..bb62102ba0aeb 100644
--- a/llvm/lib/Support/X86TargetParser.cpp
+++ b/llvm/lib/Support/X86TargetParser.cpp
@@ -321,7 +321,7 @@ constexpr ProcInfo Processors[] = {
   { {"prescott"}, CK_Prescott, ~0U, FeaturesPrescott },
   { {"nocona"}, CK_Nocona, ~0U, FeaturesNocona },
   // Core microarchitecture based processors.
-  { {"core2"}, CK_Core2, ~0U, FeaturesCore2 },
+  { {"core2"}, CK_Core2, FEATURE_SSSE3, FeaturesCore2 },
   { {"penryn"}, CK_Penryn, ~0U, FeaturesPenryn },
   // Atom processors
   { {"bonnell"}, CK_Bonnell, FEATURE_SSSE3, FeaturesBonnell },



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


[PATCH] D133094: [X86] Add missing key feature for core2

2022-09-02 Thread Freddy, Ye 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 rG66f332bc1ac0: [X86] Add missing key feature for core2 
(authored by FreddyYe).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133094

Files:
  clang/test/CodeGen/attr-target-mv.c
  llvm/lib/Support/X86TargetParser.cpp


Index: llvm/lib/Support/X86TargetParser.cpp
===
--- llvm/lib/Support/X86TargetParser.cpp
+++ llvm/lib/Support/X86TargetParser.cpp
@@ -321,7 +321,7 @@
   { {"prescott"}, CK_Prescott, ~0U, FeaturesPrescott },
   { {"nocona"}, CK_Nocona, ~0U, FeaturesNocona },
   // Core microarchitecture based processors.
-  { {"core2"}, CK_Core2, ~0U, FeaturesCore2 },
+  { {"core2"}, CK_Core2, FEATURE_SSSE3, FeaturesCore2 },
   { {"penryn"}, CK_Penryn, ~0U, FeaturesPenryn },
   // Atom processors
   { {"bonnell"}, CK_Bonnell, FEATURE_SSSE3, FeaturesBonnell },
Index: clang/test/CodeGen/attr-target-mv.c
===
--- clang/test/CodeGen/attr-target-mv.c
+++ clang/test/CodeGen/attr-target-mv.c
@@ -14,6 +14,7 @@
 int __attribute__((target("arch=sapphirerapids"))) foo(void) {return 10;}
 int __attribute__((target("arch=alderlake"))) foo(void) {return 11;}
 int __attribute__((target("arch=rocketlake"))) foo(void) {return 12;}
+int __attribute__((target("arch=core2"))) foo(void) {return 13;}
 int __attribute__((target("default"))) foo(void) { return 2; }
 
 int bar(void) {
@@ -146,6 +147,8 @@
 // LINUX: ret i32 11
 // LINUX: define{{.*}} i32 @foo.arch_rocketlake()
 // LINUX: ret i32 12
+// LINUX: define{{.*}} i32 @foo.arch_core2()
+// LINUX: ret i32 13
 // LINUX: define{{.*}} i32 @foo()
 // LINUX: ret i32 2
 // LINUX: define{{.*}} i32 @bar()
@@ -175,6 +178,8 @@
 // WINDOWS: ret i32 11
 // WINDOWS: define dso_local i32 @foo.arch_rocketlake()
 // WINDOWS: ret i32 12
+// WINDOWS: define dso_local i32 @foo.arch_core2()
+// WINDOWS: ret i32 13
 // WINDOWS: define dso_local i32 @foo()
 // WINDOWS: ret i32 2
 // WINDOWS: define dso_local i32 @bar()


Index: llvm/lib/Support/X86TargetParser.cpp
===
--- llvm/lib/Support/X86TargetParser.cpp
+++ llvm/lib/Support/X86TargetParser.cpp
@@ -321,7 +321,7 @@
   { {"prescott"}, CK_Prescott, ~0U, FeaturesPrescott },
   { {"nocona"}, CK_Nocona, ~0U, FeaturesNocona },
   // Core microarchitecture based processors.
-  { {"core2"}, CK_Core2, ~0U, FeaturesCore2 },
+  { {"core2"}, CK_Core2, FEATURE_SSSE3, FeaturesCore2 },
   { {"penryn"}, CK_Penryn, ~0U, FeaturesPenryn },
   // Atom processors
   { {"bonnell"}, CK_Bonnell, FEATURE_SSSE3, FeaturesBonnell },
Index: clang/test/CodeGen/attr-target-mv.c
===
--- clang/test/CodeGen/attr-target-mv.c
+++ clang/test/CodeGen/attr-target-mv.c
@@ -14,6 +14,7 @@
 int __attribute__((target("arch=sapphirerapids"))) foo(void) {return 10;}
 int __attribute__((target("arch=alderlake"))) foo(void) {return 11;}
 int __attribute__((target("arch=rocketlake"))) foo(void) {return 12;}
+int __attribute__((target("arch=core2"))) foo(void) {return 13;}
 int __attribute__((target("default"))) foo(void) { return 2; }
 
 int bar(void) {
@@ -146,6 +147,8 @@
 // LINUX: ret i32 11
 // LINUX: define{{.*}} i32 @foo.arch_rocketlake()
 // LINUX: ret i32 12
+// LINUX: define{{.*}} i32 @foo.arch_core2()
+// LINUX: ret i32 13
 // LINUX: define{{.*}} i32 @foo()
 // LINUX: ret i32 2
 // LINUX: define{{.*}} i32 @bar()
@@ -175,6 +178,8 @@
 // WINDOWS: ret i32 11
 // WINDOWS: define dso_local i32 @foo.arch_rocketlake()
 // WINDOWS: ret i32 12
+// WINDOWS: define dso_local i32 @foo.arch_core2()
+// WINDOWS: ret i32 13
 // WINDOWS: define dso_local i32 @foo()
 // WINDOWS: ret i32 2
 // WINDOWS: define dso_local i32 @bar()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133170: [Driver] Unsupport --print-multiarch

2022-09-02 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133170

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


[clang] 1334e12 - [cmake] Append CLANG_LIBDIR_SUFFIX to scan-build-py installation destination

2022-09-02 Thread Chuanqi Xu via cfe-commits

Author: Sinan Lin
Date: 2022-09-02T16:18:15+08:00
New Revision: 1334e129a39cb427e7b855e9a711a3e7604e50e5

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

LOG: [cmake] Append CLANG_LIBDIR_SUFFIX to scan-build-py installation 
destination

met this issue when building llvm with config LLVM_LIBDIR_SUFFIX=64, and
the installation destination of scan-build-py does not respect the given
suffix.

Reviewed By: phosek

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

Added: 


Modified: 
clang/tools/scan-build-py/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/scan-build-py/CMakeLists.txt 
b/clang/tools/scan-build-py/CMakeLists.txt
index 061dc7ef4dd9e..a087f87974cb8 100644
--- a/clang/tools/scan-build-py/CMakeLists.txt
+++ b/clang/tools/scan-build-py/CMakeLists.txt
@@ -88,7 +88,7 @@ foreach(lib ${LibScanbuild})
  DEPENDS 
${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/${lib})
   list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libscanbuild/${lib})
   install(PROGRAMS lib/libscanbuild/${lib}
-  DESTINATION lib/libscanbuild
+  DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libscanbuild
   COMPONENT scan-build-py)
 endforeach()
 
@@ -106,7 +106,7 @@ foreach(resource ${LibScanbuildResources})
  DEPENDS 
${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/resources/${resource})
   list(APPEND Depends 
${CMAKE_BINARY_DIR}/lib/libscanbuild/resources/${resource})
   install(PROGRAMS lib/libscanbuild/resources/${resource}
-  DESTINATION lib/libscanbuild/resources
+  DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libscanbuild/resources
   COMPONENT scan-build-py)
 endforeach()
 
@@ -122,7 +122,7 @@ foreach(lib ${LibEar})
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libear/${lib})
   list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libear/${lib})
   install(PROGRAMS lib/libear/${lib}
-  DESTINATION lib/libear
+  DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libear
   COMPONENT scan-build-py)
 endforeach()
 



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


[PATCH] D133160: [cmake] Append CLANG_LIBDIR_SUFFIX to scan-build-py installation destination.

2022-09-02 Thread Chuanqi Xu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1334e129a39c: [cmake] Append CLANG_LIBDIR_SUFFIX to 
scan-build-py installation destination (authored by sinan, committed by 
ChuanqiXu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133160

Files:
  clang/tools/scan-build-py/CMakeLists.txt


Index: clang/tools/scan-build-py/CMakeLists.txt
===
--- clang/tools/scan-build-py/CMakeLists.txt
+++ clang/tools/scan-build-py/CMakeLists.txt
@@ -88,7 +88,7 @@
  DEPENDS 
${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/${lib})
   list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libscanbuild/${lib})
   install(PROGRAMS lib/libscanbuild/${lib}
-  DESTINATION lib/libscanbuild
+  DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libscanbuild
   COMPONENT scan-build-py)
 endforeach()
 
@@ -106,7 +106,7 @@
  DEPENDS 
${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/resources/${resource})
   list(APPEND Depends 
${CMAKE_BINARY_DIR}/lib/libscanbuild/resources/${resource})
   install(PROGRAMS lib/libscanbuild/resources/${resource}
-  DESTINATION lib/libscanbuild/resources
+  DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libscanbuild/resources
   COMPONENT scan-build-py)
 endforeach()
 
@@ -122,7 +122,7 @@
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libear/${lib})
   list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libear/${lib})
   install(PROGRAMS lib/libear/${lib}
-  DESTINATION lib/libear
+  DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libear
   COMPONENT scan-build-py)
 endforeach()
 


Index: clang/tools/scan-build-py/CMakeLists.txt
===
--- clang/tools/scan-build-py/CMakeLists.txt
+++ clang/tools/scan-build-py/CMakeLists.txt
@@ -88,7 +88,7 @@
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/${lib})
   list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libscanbuild/${lib})
   install(PROGRAMS lib/libscanbuild/${lib}
-  DESTINATION lib/libscanbuild
+  DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libscanbuild
   COMPONENT scan-build-py)
 endforeach()
 
@@ -106,7 +106,7 @@
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/resources/${resource})
   list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libscanbuild/resources/${resource})
   install(PROGRAMS lib/libscanbuild/resources/${resource}
-  DESTINATION lib/libscanbuild/resources
+  DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libscanbuild/resources
   COMPONENT scan-build-py)
 endforeach()
 
@@ -122,7 +122,7 @@
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libear/${lib})
   list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libear/${lib})
   install(PROGRAMS lib/libear/${lib}
-  DESTINATION lib/libear
+  DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libear
   COMPONENT scan-build-py)
 endforeach()
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133036: [InstCombine] Treat passing undef to noundef params as UB

2022-09-02 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

FYI, this change broke Wine (at least on arm and aarch64). Not saying that it 
is legit breakage of code that actually was UB to begin with though - it's 
going to take some time to figure out what's broken though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133036

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


[clang] 085e8cd - [NFC] Cleanup lookup for coroutine allocation/deallocation

2022-09-02 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-09-02T17:24:52+08:00
New Revision: 085e8cd8d32c9104abbc2c1345a1483f19d25d36

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

LOG: [NFC] Cleanup lookup for coroutine allocation/deallocation

Added: 


Modified: 
clang/lib/Sema/SemaCoroutine.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCoroutine.cpp 
b/clang/lib/Sema/SemaCoroutine.cpp
index a738befdd6ce..1fca15a31951 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -1031,10 +1031,8 @@ static Expr *buildStdNoThrowDeclRef(Sema &S, 
SourceLocation Loc) {
 }
 
 // Find an appropriate delete for the promise.
-static FunctionDecl *findDeleteForPromise(Sema &S, SourceLocation Loc,
-  QualType PromiseType) {
-  FunctionDecl *OperatorDelete = nullptr;
-
+static bool findDeleteForPromise(Sema &S, SourceLocation Loc, QualType 
PromiseType,
+ FunctionDecl *&OperatorDelete) {
   DeclarationName DeleteName =
   S.Context.DeclarationNames.getCXXOperatorName(OO_Delete);
 
@@ -1046,25 +1044,31 @@ static FunctionDecl *findDeleteForPromise(Sema &S, 
SourceLocation Loc,
   // scope of the promise type. If nothing is found, a search is performed in
   // the global scope.
   if (S.FindDeallocationFunction(Loc, PointeeRD, DeleteName, OperatorDelete))
-return nullptr;
+return false;
 
-  // FIXME: We didn't implement following selection:
   // [dcl.fct.def.coroutine]p12
   //   If both a usual deallocation function with only a pointer parameter and 
a
   //   usual deallocation function with both a pointer parameter and a size
   //   parameter are found, then the selected deallocation function shall be 
the
   //   one with two parameters. Otherwise, the selected deallocation function
   //   shall be the function with one parameter.
-
   if (!OperatorDelete) {
 // Look for a global declaration.
-const bool CanProvideSize = S.isCompleteType(Loc, PromiseType);
+// Coroutines can always provide their required size.
+const bool CanProvideSize = true;
 const bool Overaligned = false;
+// Sema::FindUsualDeallocationFunction will try to find the one with two
+// parameters first. It will return the deallocation function with one
+// parameter if failed.
 OperatorDelete = S.FindUsualDeallocationFunction(Loc, CanProvideSize,
  Overaligned, DeleteName);
+
+if (!OperatorDelete)
+  return false;
   }
+
   S.MarkFunctionReferenced(Loc, OperatorDelete);
-  return OperatorDelete;
+  return true;
 }
 
 
@@ -1319,8 +1323,6 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() {
   // lvalue that denotes the parameter copy corresponding to p_i.
 
   FunctionDecl *OperatorNew = nullptr;
-  FunctionDecl *OperatorDelete = nullptr;
-  FunctionDecl *UnusedResult = nullptr;
   bool PassAlignment = false;
   SmallVector PlacementArgs;
 
@@ -1344,11 +1346,13 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() {
 // is performed in the global scope.
 Sema::AllocationFunctionScope NewScope =
 PromiseContainsNew ? Sema::AFS_Class : Sema::AFS_Global;
+FunctionDecl *UnusedResult = nullptr;
 S.FindAllocationFunctions(Loc, SourceRange(),
   NewScope,
   /*DeleteScope*/ Sema::AFS_Both, PromiseType,
   /*isArray*/ false, PassAlignment, PlacementArgs,
-  OperatorNew, UnusedResult, /*Diagnose*/ false);
+  OperatorNew, UnusedResult,
+  /*Diagnose*/ false);
   };
 
   // We don't expect to call to global operator new with (size, p0, …, pn).
@@ -1379,6 +1383,7 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() {
   return false;
 PlacementArgs = {StdNoThrow};
 OperatorNew = nullptr;
+FunctionDecl *UnusedResult = nullptr;
 S.FindAllocationFunctions(Loc, SourceRange(), /*NewScope*/ Sema::AFS_Both,
   /*DeleteScope*/ Sema::AFS_Both, PromiseType,
   /*isArray*/ false, PassAlignment, PlacementArgs,
@@ -1404,7 +1409,8 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() {
 }
   }
 
-  if ((OperatorDelete = findDeleteForPromise(S, Loc, PromiseType)) == nullptr) 
{
+  FunctionDecl *OperatorDelete = nullptr;
+  if (!findDeleteForPromise(S, Loc, PromiseType, OperatorDelete)) {
 // FIXME: We should add an error here. According to:
 // [dcl.fct.def.coroutine]p12
 //   If no usual deallocation function is found, the program is ill-formed.



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

[PATCH] D133191: Driver test: remove `REQUIRES: x86-registered-target` and set `--sysroot=""` to support clang with `DEFAULT_SYSROOT`.

2022-09-02 Thread Ying Yi via Phabricator via cfe-commits
MaggieYi created this revision.
MaggieYi added reviewers: probinson, wristow, dyung.
Herald added a subscriber: pengfei.
Herald added a project: All.
MaggieYi requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When testing clang that has been compiled with -DDEFAULT_SYSROOT set to some 
path, ps4-ps5-header-search.c would fail.

The test needs to be updated.

1. Remove unnecessary REQUIRES: x86-registered-target.
2. Override sysroot to be empty string for the test to succeed when clang is 
configured with DEFAULT_SYSROOT.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133191

Files:
  clang/test/Driver/ps4-ps5-header-search.c


Index: clang/test/Driver/ps4-ps5-header-search.c
===
--- clang/test/Driver/ps4-ps5-header-search.c
+++ clang/test/Driver/ps4-ps5-header-search.c
@@ -1,8 +1,6 @@
-// REQUIRES: x86-registered-target
-
 /// PS4 and PS5 use the same SDK layout, so use the same tree for both.
-// RUN: env SCE_ORBIS_SDK_DIR=%S/Inputs/scei-ps4_tree %clang -target 
x86_64-scei-ps4 -E -v %s 2>&1 | FileCheck %s --check-prefix=ENVPS4
-// RUN: env SCE_PROSPERO_SDK_DIR=%S/Inputs/scei-ps4_tree %clang -target 
x86_64-sie-ps5 -E -v %s 2>&1 | FileCheck %s --check-prefix=ENVPS4
+// RUN: env SCE_ORBIS_SDK_DIR=%S/Inputs/scei-ps4_tree %clang -target 
x86_64-scei-ps4 --sysroot="" -E -v %s 2>&1 | FileCheck %s --check-prefix=ENVPS4
+// RUN: env SCE_PROSPERO_SDK_DIR=%S/Inputs/scei-ps4_tree %clang -target 
x86_64-sie-ps5 --sysroot="" -E -v %s 2>&1 | FileCheck %s --check-prefix=ENVPS4
 // ENVPS4: Inputs/scei-ps4_tree/target/include{{$}}
 // ENVPS4: Inputs/scei-ps4_tree/target/include_common{{$}}
 // ENVPS4-NOT: /usr/include


Index: clang/test/Driver/ps4-ps5-header-search.c
===
--- clang/test/Driver/ps4-ps5-header-search.c
+++ clang/test/Driver/ps4-ps5-header-search.c
@@ -1,8 +1,6 @@
-// REQUIRES: x86-registered-target
-
 /// PS4 and PS5 use the same SDK layout, so use the same tree for both.
-// RUN: env SCE_ORBIS_SDK_DIR=%S/Inputs/scei-ps4_tree %clang -target x86_64-scei-ps4 -E -v %s 2>&1 | FileCheck %s --check-prefix=ENVPS4
-// RUN: env SCE_PROSPERO_SDK_DIR=%S/Inputs/scei-ps4_tree %clang -target x86_64-sie-ps5 -E -v %s 2>&1 | FileCheck %s --check-prefix=ENVPS4
+// RUN: env SCE_ORBIS_SDK_DIR=%S/Inputs/scei-ps4_tree %clang -target x86_64-scei-ps4 --sysroot="" -E -v %s 2>&1 | FileCheck %s --check-prefix=ENVPS4
+// RUN: env SCE_PROSPERO_SDK_DIR=%S/Inputs/scei-ps4_tree %clang -target x86_64-sie-ps5 --sysroot="" -E -v %s 2>&1 | FileCheck %s --check-prefix=ENVPS4
 // ENVPS4: Inputs/scei-ps4_tree/target/include{{$}}
 // ENVPS4: Inputs/scei-ps4_tree/target/include_common{{$}}
 // ENVPS4-NOT: /usr/include
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130888: [Clang] Introduce -fexperimental-sanitize-metadata=

2022-09-02 Thread Marco Elver via Phabricator via cfe-commits
melver updated this revision to Diff 457543.
melver added a comment.

Add CodeGen test.

PTAL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130888

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/sanitize-metadata.c
  clang/test/Driver/fsanitize-metadata.c

Index: clang/test/Driver/fsanitize-metadata.c
===
--- /dev/null
+++ clang/test/Driver/fsanitize-metadata.c
@@ -0,0 +1,34 @@
+// RUN: %clang --target=x86_64-linux-gnu \
+// RUN:   -fexperimental-sanitize-metadata=all \
+// RUN:   -fno-experimental-sanitize-metadata=all %s -### 2>&1 | FileCheck %s
+// CHECK-NOT: -fexperimental-sanitize-metadata
+
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=bad_arg %s -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-INVALID %s
+// CHECK-INVALID: error: unsupported argument 'bad_arg' to option '-fexperimental-sanitize-metadata='
+
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=covered %s -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-COVERED %s
+// RUN: %clang --target=x86_64-linux-gnu \
+// RUN:   -fexperimental-sanitize-metadata=atomics \
+// RUN:   -fno-experimental-sanitize-metadata=atomics \
+// RUN:   -fexperimental-sanitize-metadata=covered %s -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-COVERED %s
+// CHECK-COVERED: "-fexperimental-sanitize-metadata=covered"
+// CHECK-COVERED-NOT: "-fexperimental-sanitize-metadata=atomics"
+
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=atomics %s -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-ATOMICS %s
+// CHECK-ATOMICS: "-fexperimental-sanitize-metadata=atomics"
+
+// RUN: %clang --target=x86_64-linux-gnu \
+// RUN:   -fexperimental-sanitize-metadata=covered,atomics %s -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-ALL %s
+// RUN: %clang --target=x86_64-linux-gnu \
+// RUN:   -fexperimental-sanitize-metadata=covered \
+// RUN:   -fexperimental-sanitize-metadata=atomics %s -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-ALL %s
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=all %s -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-ALL %s
+// CHECK-ALL: "-fexperimental-sanitize-metadata=covered"
+// CHECK-ALL: "-fexperimental-sanitize-metadata=atomics"
Index: clang/test/CodeGen/sanitize-metadata.c
===
--- /dev/null
+++ clang/test/CodeGen/sanitize-metadata.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -O -fexperimental-sanitize-metadata=atomics -triple x86_64-gnu-linux -x c -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,ATOMICS
+// RUN: %clang_cc1 -O -fexperimental-sanitize-metadata=atomics -triple aarch64-gnu-linux -x c -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,ATOMICS
+
+int x, y;
+
+void empty() {
+// CHECK-NOT: define dso_local void @empty() {{.*}} !pcsections
+}
+
+int atomics() {
+// ATOMICS-LABEL: define dso_local i32 @atomics()
+// ATOMICS-SAME:  !pcsections ![[ATOMICS_COVERED:[0-9]+]]
+// ATOMICS-NEXT:  entry:
+// ATOMICS-NEXT:atomicrmw add {{.*}} !pcsections ![[ATOMIC_OP:[0-9]+]]
+// ATOMICS-NOT: load {{.*}} !pcsections
+  __atomic_fetch_add(&x, 1, __ATOMIC_RELAXED);
+  return y;
+}
+// ATOMICS-LABEL: __sanitizer_metadata_atomics.module_ctor
+// ATOMICS: call void @__sanitizer_metadata_atomics_add(i32 1, ptr @__start_sanmd_atomics, ptr @__stop_sanmd_atomics)
+// ATOMICS-LABEL: __sanitizer_metadata_atomics.module_dtor
+// ATOMICS: call void @__sanitizer_metadata_atomics_del(i32 1, ptr @__start_sanmd_atomics, ptr @__stop_sanmd_atomics)
+
+// CHECK-LABEL: __sanitizer_metadata_covered.module_ctor
+// CHECK: call void @__sanitizer_metadata_covered_add(i32 1, ptr @__start_sanmd_covered, ptr @__stop_sanmd_covered)
+// CHECK-LABEL: __sanitizer_metadata_covered.module_dtor
+// CHECK: call void @__sanitizer_metadata_covered_del(i32 1, ptr @__start_sanmd_covered, ptr @__stop_sanmd_covered)
+
+// ATOMICS: ![[ATOMICS_COVERED]] = !{!"sanmd_covered", ![[ATOMICS_COVERED_AUX:[0-9]+]]}
+// ATOMICS: ![[ATOMICS_COVERED_AUX]] = !{i32 1}
+// ATOMICS: ![[ATOMIC_OP]] = !{!"sanmd_atomics"}
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -100,6 +100,11 @@
   CoverageTraceStores = 1 << 17,
 };
 
+enum BinaryMetadataFeature {
+  BinaryMetadataCovered = 1 << 0,
+  BinaryMetadataAtomics = 1 << 1,
+};
+
 /// Parse a -fsanitize= or -fno-sanitize= argument's values, diagnosing any
 /// invalid compone

[PATCH] D132945: [clang] Skip re-building lambda expressions in parameters to consteval fns.

2022-09-02 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 457546.
usaxena95 marked 2 inline comments as done.
usaxena95 added a comment.

Addressed comments and added more tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132945

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp

Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -939,3 +939,82 @@
 static_assert(max(1,2)==2);
 static_assert(mid(1,2,3)==2);
 } // namespace GH51182
+
+// https://github.com/llvm/llvm-project/issues/56183
+namespace GH56183 {
+consteval auto Foo(auto c) { return c; }
+consteval auto Bar(auto f) { return f(); }
+void test() {
+  constexpr auto x = Foo(Bar([] { return 'a'; }));
+  static_assert(x == 'a');
+}
+}  // namespace GH56183
+
+// https://github.com/llvm/llvm-project/issues/51695
+namespace GH51695 {
+// Original 
+template 
+struct type_t {};
+
+template 
+struct list_t {};
+
+template 
+consteval auto pop_front(list_t) -> auto {
+  return list_t{};
+}
+
+template 
+consteval auto apply(list_t, F fn) -> auto {
+  return fn(type_t{}...);
+}
+
+void test1() {
+  constexpr auto x = apply(pop_front(list_t{}),
+[](type_t...) { return 42; });
+  static_assert(x == 42);
+}
+// Reduced 1 
+consteval bool zero() { return false; }
+
+template 
+consteval bool foo(bool, F f) {
+  return f();
+}
+
+void test2() {
+  constexpr auto x = foo(zero(), []() { return true; });
+  static_assert(x);
+}
+
+// Reduced 2 
+template 
+consteval auto bar(F f) { return f;}
+
+void test3() {
+  constexpr auto t1 = bar(bar(bar(bar([]() { return true; }();
+  static_assert(t1);
+
+  int a = 1; // expected-note {{declared here}}
+  auto t2 = bar(bar(bar(bar([=]() { return a; }(); // expected-error-re {{call to consteval function 'GH51695::bar<(lambda at {{.*}})>' is not a constant expression}}
+  // expected-note@-1 {{read of non-const variable 'a' is not allowed in a constant expression}}
+
+  constexpr auto t3 = bar(bar([x=bar(42)]() { return x; }))();
+  static_assert(t3==42);
+  constexpr auto t4 = bar(bar([x=bar(42)]() consteval { return x; }))();
+  static_assert(t4==42);
+}
+
+}  // namespace GH51695
+
+// https://github.com/llvm/llvm-project/issues/50455
+namespace GH50455 {
+void f() {
+  []() consteval { int i{}; }();
+  []() consteval { int i{}; ++i; }();
+}
+void g() {
+  (void)[](int i) consteval { return i; }(0);
+  (void)[](int i) consteval { return i; }(0);
+}
+}  // namespace GH50455
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -17598,6 +17598,11 @@
   DRSet.erase(E);
   return E;
 }
+ExprResult TransformLambdaExpr(LambdaExpr *E) {
+  // Do not rebuild lambdas to avoid creating a new type.
+  // Lambdas have already been processed inside their eval context.
+  return E;
+}
 bool AlwaysRebuild() { return false; }
 bool ReplacingOriginal() { return true; }
 bool AllowSkippingCXXConstructExpr() {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -191,8 +191,14 @@
 
 - Correctly set expression evaluation context as 'immediate function context' in
   consteval functions.
-  This fixes `GH51182 `
-
+  This fixes `GH51182 `_.
+
+- Skip rebuilding lambda expressions in arguments of immediate invocations.
+  This fixes `GH56183 `_,
+  `GH51695 `_,
+  `GH50455 `_,
+  `GH54872 `_,
+  `GH54587 `_.
 
 C++2b Feature Support
 ^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133194: rewording note note_constexpr_invalid_cast

2022-09-02 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman created this revision.
Codesbyusman added reviewers: aaron.ballman, erichkeane, xgupta.
Herald added a project: All.
Codesbyusman requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The diagnostics here are correct, but the note is really silly. It talks about 
reinterpret_cast in C code. So rewording it for c mode by using more select.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133194

Files:
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/ExprConstant.cpp


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -13566,7 +13566,8 @@
   }
 
   case CK_PointerToIntegral: {
-CCEDiag(E, diag::note_constexpr_invalid_cast) << 2;
+CCEDiag(E, diag::note_constexpr_invalid_cast)
+<< 2 << Info.Ctx.getLangOpts().CPlusPlus;
 
 LValue LV;
 if (!EvaluatePointer(SubExpr, LV, Info))
Index: clang/include/clang/Basic/DiagnosticASTKinds.td
===
--- clang/include/clang/Basic/DiagnosticASTKinds.td
+++ clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -11,8 +11,9 @@
 // Constant expression diagnostics. These (and their users) belong in Sema.
 def note_expr_divide_by_zero : Note<"division by zero">;
 def note_constexpr_invalid_cast : Note<
-  "%select{reinterpret_cast|dynamic_cast|cast that performs the conversions of"
-  " a reinterpret_cast|cast from %1}0 is not allowed in a constant expression"
+  "%select{reinterpret_cast|dynamic_cast|%select{this conversion|cast that"
+  " performs the conversions of a reinterpret_cast}1|cast from %1}0"
+  " is not allowed in a constant expression"
   "%select{| in C++ standards before C++20||}0">;
 def note_constexpr_invalid_downcast : Note<
   "cannot cast object of dynamic type %0 to type %1">;


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -13566,7 +13566,8 @@
   }
 
   case CK_PointerToIntegral: {
-CCEDiag(E, diag::note_constexpr_invalid_cast) << 2;
+CCEDiag(E, diag::note_constexpr_invalid_cast)
+<< 2 << Info.Ctx.getLangOpts().CPlusPlus;
 
 LValue LV;
 if (!EvaluatePointer(SubExpr, LV, Info))
Index: clang/include/clang/Basic/DiagnosticASTKinds.td
===
--- clang/include/clang/Basic/DiagnosticASTKinds.td
+++ clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -11,8 +11,9 @@
 // Constant expression diagnostics. These (and their users) belong in Sema.
 def note_expr_divide_by_zero : Note<"division by zero">;
 def note_constexpr_invalid_cast : Note<
-  "%select{reinterpret_cast|dynamic_cast|cast that performs the conversions of"
-  " a reinterpret_cast|cast from %1}0 is not allowed in a constant expression"
+  "%select{reinterpret_cast|dynamic_cast|%select{this conversion|cast that"
+  " performs the conversions of a reinterpret_cast}1|cast from %1}0"
+  " is not allowed in a constant expression"
   "%select{| in C++ standards before C++20||}0">;
 def note_constexpr_invalid_downcast : Note<
   "cannot cast object of dynamic type %0 to type %1">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D132131: [clang-format] Adds a formatter for aligning trailing comments over empty lines

2022-09-02 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Is there a technical reason for reusing the struct rather than introducing a 
new one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132131

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


[clang] e7eec38 - [clang] Skip re-building lambda expressions in parameters to consteval fns.

2022-09-02 Thread Utkarsh Saxena via cfe-commits

Author: Utkarsh Saxena
Date: 2022-09-02T12:30:52+02:00
New Revision: e7eec38246560781e0a4020b19c7eb038a8c5655

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

LOG: [clang] Skip re-building lambda expressions in parameters to consteval fns.

As discussed in this 
[comment](https://github.com/llvm/llvm-project/issues/56183#issuecomment-1224331699),
we end up building the lambda twice: once while parsing the function calls and 
then again while handling the immediate invocation.

This happens specially during removing nested immediate invocation.
Eg: When we have another consteval function as the parameter along with this 
lambda expression. Eg: `foo(bar([]{}))`, `foo(bar(), []{})`

While removing such nested immediate invocations, we should not rebuild this 
lambda. (IIUC, rebuilding a lambda would always generate a new type which will 
never match the original type from parsing)

Fixes: https://github.com/llvm/llvm-project/issues/56183
Fixes: https://github.com/llvm/llvm-project/issues/51695
Fixes: https://github.com/llvm/llvm-project/issues/50455
Fixes: https://github.com/llvm/llvm-project/issues/54872
Fixes: https://github.com/llvm/llvm-project/issues/54587

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/cxx2a-consteval.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 41fb9e4035e69..2a92f65cc04fc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -211,9 +211,16 @@ C++20 Feature Support
 - Correctly set expression evaluation context as 'immediate function context' 
in
   consteval functions.
   This fixes `GH51182 `
+
 - Fixes an assert crash caused by looking up missing vtable information on 
``consteval``
   virtual functions. Fixes `GH55065 
`_.
 
+- Skip rebuilding lambda expressions in arguments of immediate invocations.
+  This fixes `GH56183 `_,
+  `GH51695 `_,
+  `GH50455 `_,
+  `GH54872 `_,
+  `GH54587 `_.
 
 C++2b Feature Support
 ^

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 80ac6733cbef2..f124ad3bc08d0 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -17598,6 +17598,11 @@ static void RemoveNestedImmediateInvocation(
   DRSet.erase(E);
   return E;
 }
+ExprResult TransformLambdaExpr(LambdaExpr *E) {
+  // Do not rebuild lambdas to avoid creating a new type.
+  // Lambdas have already been processed inside their eval context.
+  return E;
+}
 bool AlwaysRebuild() { return false; }
 bool ReplacingOriginal() { return true; }
 bool AllowSkippingCXXConstructExpr() {

diff  --git a/clang/test/SemaCXX/cxx2a-consteval.cpp 
b/clang/test/SemaCXX/cxx2a-consteval.cpp
index 09129a27818d3..1a8097797bc3c 100644
--- a/clang/test/SemaCXX/cxx2a-consteval.cpp
+++ b/clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -939,3 +939,82 @@ consteval T mid(const T& a, const T& b, const T& c) {
 static_assert(max(1,2)==2);
 static_assert(mid(1,2,3)==2);
 } // namespace GH51182
+
+// https://github.com/llvm/llvm-project/issues/56183
+namespace GH56183 {
+consteval auto Foo(auto c) { return c; }
+consteval auto Bar(auto f) { return f(); }
+void test() {
+  constexpr auto x = Foo(Bar([] { return 'a'; }));
+  static_assert(x == 'a');
+}
+}  // namespace GH56183
+
+// https://github.com/llvm/llvm-project/issues/51695
+namespace GH51695 {
+// Original 
+template 
+struct type_t {};
+
+template 
+struct list_t {};
+
+template 
+consteval auto pop_front(list_t) -> auto {
+  return list_t{};
+}
+
+template 
+consteval auto apply(list_t, F fn) -> auto {
+  return fn(type_t{}...);
+}
+
+void test1() {
+  constexpr auto x = apply(pop_front(list_t{}),
+[](type_t...) { return 42; });
+  static_assert(x == 42);
+}
+// Reduced 1 
+consteval bool zero() { return false; }
+
+template 
+consteval bool foo(bool, F f) {
+  return f();
+}
+
+void test2() {
+  constexpr auto x = foo(zero(), []() { return true; });
+  static_assert(x);
+}
+
+// Reduced 2 
+template 
+consteval auto bar(F f) { return f;}
+
+void test3() {
+  constexpr auto t1 = bar(bar(bar(bar([]() { return true; }();
+  static_assert(t1);
+
+  int a

[PATCH] D132945: [clang] Skip re-building lambda expressions in parameters to consteval fns.

2022-09-02 Thread Utkarsh Saxena 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 rGe7eec3824656: [clang] Skip re-building lambda expressions in 
parameters to consteval fns. (authored by usaxena95).

Changed prior to commit:
  https://reviews.llvm.org/D132945?vs=457546&id=457555#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132945

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp

Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -939,3 +939,82 @@
 static_assert(max(1,2)==2);
 static_assert(mid(1,2,3)==2);
 } // namespace GH51182
+
+// https://github.com/llvm/llvm-project/issues/56183
+namespace GH56183 {
+consteval auto Foo(auto c) { return c; }
+consteval auto Bar(auto f) { return f(); }
+void test() {
+  constexpr auto x = Foo(Bar([] { return 'a'; }));
+  static_assert(x == 'a');
+}
+}  // namespace GH56183
+
+// https://github.com/llvm/llvm-project/issues/51695
+namespace GH51695 {
+// Original 
+template 
+struct type_t {};
+
+template 
+struct list_t {};
+
+template 
+consteval auto pop_front(list_t) -> auto {
+  return list_t{};
+}
+
+template 
+consteval auto apply(list_t, F fn) -> auto {
+  return fn(type_t{}...);
+}
+
+void test1() {
+  constexpr auto x = apply(pop_front(list_t{}),
+[](type_t...) { return 42; });
+  static_assert(x == 42);
+}
+// Reduced 1 
+consteval bool zero() { return false; }
+
+template 
+consteval bool foo(bool, F f) {
+  return f();
+}
+
+void test2() {
+  constexpr auto x = foo(zero(), []() { return true; });
+  static_assert(x);
+}
+
+// Reduced 2 
+template 
+consteval auto bar(F f) { return f;}
+
+void test3() {
+  constexpr auto t1 = bar(bar(bar(bar([]() { return true; }();
+  static_assert(t1);
+
+  int a = 1; // expected-note {{declared here}}
+  auto t2 = bar(bar(bar(bar([=]() { return a; }(); // expected-error-re {{call to consteval function 'GH51695::bar<(lambda at {{.*}})>' is not a constant expression}}
+  // expected-note@-1 {{read of non-const variable 'a' is not allowed in a constant expression}}
+
+  constexpr auto t3 = bar(bar([x=bar(42)]() { return x; }))();
+  static_assert(t3==42);
+  constexpr auto t4 = bar(bar([x=bar(42)]() consteval { return x; }))();
+  static_assert(t4==42);
+}
+
+}  // namespace GH51695
+
+// https://github.com/llvm/llvm-project/issues/50455
+namespace GH50455 {
+void f() {
+  []() consteval { int i{}; }();
+  []() consteval { int i{}; ++i; }();
+}
+void g() {
+  (void)[](int i) consteval { return i; }(0);
+  (void)[](int i) consteval { return i; }(0);
+}
+}  // namespace GH50455
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -17598,6 +17598,11 @@
   DRSet.erase(E);
   return E;
 }
+ExprResult TransformLambdaExpr(LambdaExpr *E) {
+  // Do not rebuild lambdas to avoid creating a new type.
+  // Lambdas have already been processed inside their eval context.
+  return E;
+}
 bool AlwaysRebuild() { return false; }
 bool ReplacingOriginal() { return true; }
 bool AllowSkippingCXXConstructExpr() {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -211,9 +211,16 @@
 - Correctly set expression evaluation context as 'immediate function context' in
   consteval functions.
   This fixes `GH51182 `
+
 - Fixes an assert crash caused by looking up missing vtable information on ``consteval``
   virtual functions. Fixes `GH55065 `_.
 
+- Skip rebuilding lambda expressions in arguments of immediate invocations.
+  This fixes `GH56183 `_,
+  `GH51695 `_,
+  `GH50455 `_,
+  `GH54872 `_,
+  `GH54587 `_.
 
 C++2b Feature Support
 ^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D132256: [clang-format] Add DefinitionBlockSpacing option

2022-09-02 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:2429
+  This determines the number of empty lines to use when
+  SeparateDefinitionBlocks == SeparateDefinitionStyle::SDS_Always.
+

Can you write this not in terms of the code variables and enumerated but in 
terms of what they put in the .clang-format file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132256

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


[PATCH] D67949: [clang-format] [PR36858] Add missing .hh and .cs extensions from python support utilities

2022-09-02 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.
Herald added a project: All.

We are also missing json


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67949

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


[PATCH] D133109: [LLVM][ARM] Remove options for armv2, 2A, 3 and 3M

2022-09-02 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

This is probably overkill but I posted an RFC just in case 
https://discourse.llvm.org/t/rfc-removal-of-armv2-2a-3-3m-target-options/65040. 
Like I said, no rush to land this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133109

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


[PATCH] D133109: [LLVM][ARM] Remove options for armv2, 2A, 3 and 3M

2022-09-02 Thread Renato Golin via Phabricator via cfe-commits
rengolin accepted this revision.
rengolin added a comment.

Agree. Even 10 years ago we made the concerted effort not to care about pre-v4, 
so I'd be a little surprised if people are actually using modern clang to 
target those platforms.

Projects that rely on it can work in the same way as gcc and pick an older 
version of the toolchains.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133109

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


[PATCH] D132056: [HLSL] Restrict to supported targets

2022-09-02 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

This makes sense. I believe the same applies to some other languages i.e. 
OpenCL, as the way clang evolved currently not all targets are compatible with 
all languages. In the future we might want to generalize this diagnostics to 
use in other cases too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132056

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


[PATCH] D133195: Expose QualType::getNonReferenceType in libclang

2022-09-02 Thread Luca Di sera via Phabricator via cfe-commits
diseraluca created this revision.
diseraluca added a reviewer: aaron.ballman.
Herald added a subscriber: arphaman.
Herald added a project: All.
diseraluca requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The method is now wrapped by clang_getNonReferenceType.

A declaration for clang_getNonReferenceType was added to clang-c/Index.h
to expose it to user of the library.

An implementation for clang_getNonReferenceType was introduced in
CXType.cpp, wrapping the equivalent method of the underlying QualType of
a CXType.

An export symbol for the new function was added to libclang.map under
the LLVM_16 version entry.

A test was added to LibclangTest.cpp that tests the removal of
ref-qualifiers for some CXTypes.

The release-notes for the clang project was updated to include a
notification of the new addition under the "libclang" section.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133195

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang-c/Index.h
  clang/tools/libclang/CXType.cpp
  clang/tools/libclang/libclang.map
  clang/unittests/libclang/LibclangTest.cpp

Index: clang/unittests/libclang/LibclangTest.cpp
===
--- clang/unittests/libclang/LibclangTest.cpp
+++ clang/unittests/libclang/LibclangTest.cpp
@@ -891,6 +891,46 @@
   });
 }
 
+TEST_F(LibclangParseTest, clang_getNonReferenceTypeRemovesRefQualifiers) {
+  std::string Header = "header.h";
+  WriteFile(Header, "void foo1(int&);\n"
+"void foo2(int&&);\n");
+
+  auto is_ref_qualified = [](CXType type) -> bool {
+return (type.kind == CXType_LValueReference) ||
+   (type.kind == CXType_RValueReference);
+  };
+
+  auto from_CXString = [](CXString cx_string) -> std::string {
+std::string string{clang_getCString(cx_string)};
+
+clang_disposeString(cx_string);
+
+return string;
+  };
+
+  const char *Args[] = {"-xc++"};
+  ClangTU = clang_parseTranslationUnit(Index, Header.c_str(), Args, 1, nullptr,
+   0, TUFlags);
+
+  Traverse([&is_ref_qualified, &from_CXString](CXCursor cursor, CXCursor) {
+if (clang_getCursorKind(cursor) == CXCursor_FunctionDecl) {
+  CXType arg_type = clang_getArgType(clang_getCursorType(cursor), 0);
+  EXPECT_TRUE(is_ref_qualified(arg_type))
+  << "Input data '" << from_CXString(clang_getCursorSpelling(cursor))
+  << "' first argument does not have a ref-qualified type.";
+
+  CXType non_reference_arg_type = clang_getNonReferenceType(arg_type);
+  EXPECT_FALSE(is_ref_qualified(non_reference_arg_type))
+  << "The type '" << from_CXString(clang_getTypeSpelling(arg_type))
+  << "' ref-qualifier was not removed after a call to "
+ "clang_getNonReferenceType.";
+}
+
+return CXChildVisit_Continue;
+  });
+}
+
 class LibclangRewriteTest : public LibclangParseTest {
 public:
   CXRewriter Rew = nullptr;
Index: clang/tools/libclang/libclang.map
===
--- clang/tools/libclang/libclang.map
+++ clang/tools/libclang/libclang.map
@@ -408,6 +408,7 @@
 LLVM_16 {
   global:
 clang_getUnqualifiedType;
+clang_getNonReferenceType;
 };
 
 # Example of how to add a new symbol version entry.  If you do add a new symbol
Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -488,6 +488,10 @@
   return MakeCXType(GetQualType(CT).getUnqualifiedType(), GetTU(CT));
 }
 
+CXType clang_getNonReferenceType(CXType CT) {
+  return MakeCXType(GetQualType(CT).getNonReferenceType(), GetTU(CT));
+}
+
 CXCursor clang_getTypeDeclaration(CXType CT) {
   if (CT.kind == CXType_Invalid)
 return cxcursor::MakeCXCursorInvalid(CXCursor_NoDeclFound);
Index: clang/include/clang-c/Index.h
===
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -3797,6 +3797,17 @@
  */
 CINDEX_LINKAGE CXType clang_getUnqualifiedType(CXType CT);
 
+/**
+ * For reference types (e.g., "const int&"), returns the type that the
+ * reference refers to (e.g "const int").
+ *
+ * Otherwise, returns the type itself.
+ *
+ * A type that has kind \c CXType_LValueReference or
+ * \c CXType_RValueReference is a reference type.
+ */
+CINDEX_LINKAGE CXType clang_getNonReferenceType(CXType CT);
+
 /**
  * Return the cursor for the declaration of the given type.
  */
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -282,6 +282,8 @@
 
 - Introduced the new function `clang_getUnqualifiedType`, which mimics
   the behavior of `QualType::getUnqualifiedType` for `CXType`.
+- Introduced the new function `clang_getNonReferenceType`

[clang] 18de7c6 - Revert "[InstCombine] Treat passing undef to noundef params as UB"

2022-09-02 Thread Muhammad Omair Javaid via cfe-commits

Author: Muhammad Omair Javaid
Date: 2022-09-02T16:09:50+05:00
New Revision: 18de7c6a3b3689bf69215429bde1fb2330a3e69d

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

LOG: Revert "[InstCombine] Treat passing undef to noundef params as UB"

This reverts commit c911befaec494c52a63e3b957e28d449262656fb.

It has broken LLDB Arm/AArch64 Linux buildbots. I dont really understand
the underlying reason. Reverting for now make buildbot green.

https://reviews.llvm.org/D133036

Added: 


Modified: 
clang/test/CodeGenOpenCL/overload.cl
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Transforms/InstCombine/call-undef.ll
llvm/test/Transforms/InstCombine/out-of-bounds-indexes.ll

Removed: 




diff  --git a/clang/test/CodeGenOpenCL/overload.cl 
b/clang/test/CodeGenOpenCL/overload.cl
index 193b9cb0df41a..f9e69c6d11540 100644
--- a/clang/test/CodeGenOpenCL/overload.cl
+++ b/clang/test/CodeGenOpenCL/overload.cl
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -disable-llvm-passes -no-opaque-pointers -cl-std=CL2.0 
-emit-llvm -o - -triple spir-unknown-unknown %s | FileCheck %s
-// RUN: %clang_cc1 -disable-llvm-passes -no-opaque-pointers -cl-std=CL3.0 
-cl-ext=+__opencl_c_generic_address_space -emit-llvm -o - -triple 
spir-unknown-unknown %s | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -cl-std=CL2.0 -emit-llvm -o - -triple 
spir-unknown-unknown %s | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -cl-std=CL3.0 
-cl-ext=+__opencl_c_generic_address_space -emit-llvm -o - -triple 
spir-unknown-unknown %s | FileCheck %s
 
 typedef short short4 __attribute__((ext_vector_type(4)));
 
@@ -21,18 +21,18 @@ void kernel test1() {
   generic int *generic *gengen;
   generic int *local *genloc;
   generic int *global *genglob;
-  // CHECK-DAG: call spir_func void @_Z3fooPU3AS1iS0_(i32 addrspace(1)* 
noundef {{.*}}, i32 addrspace(1)* noundef {{.*}})
+  // CHECK-DAG: call spir_func void @_Z3fooPU3AS1iS0_(i32 addrspace(1)* 
noundef undef, i32 addrspace(1)* noundef undef)
   foo(a, b);
-  // CHECK-DAG: call spir_func void @_Z3fooPU3AS4iS0_(i32 addrspace(4)* 
noundef {{.*}}, i32 addrspace(4)* noundef {{.*}})
+  // CHECK-DAG: call spir_func void @_Z3fooPU3AS4iS0_(i32 addrspace(4)* 
noundef undef, i32 addrspace(4)* noundef undef)
   foo(b, c);
-  // CHECK-DAG: call spir_func void @_Z3fooPU3AS4iS0_(i32 addrspace(4)* 
noundef {{.*}}, i32 addrspace(4)* noundef {{.*}})
+  // CHECK-DAG: call spir_func void @_Z3fooPU3AS4iS0_(i32 addrspace(4)* 
noundef undef, i32 addrspace(4)* noundef undef)
   foo(a, d);
 
-  // CHECK-DAG: call spir_func void @_Z3barPU3AS4PU3AS4iS2_(i32 addrspace(4)* 
addrspace(4)* noundef {{.*}}, i32 addrspace(4)* addrspace(4)* noundef {{.*}})
+  // CHECK-DAG: call spir_func void @_Z3barPU3AS4PU3AS4iS2_(i32 addrspace(4)* 
addrspace(4)* noundef undef, i32 addrspace(4)* addrspace(4)* noundef undef)
   bar(gengen, genloc);
-  // CHECK-DAG: call spir_func void @_Z3barPU3AS4PU3AS4iS2_(i32 addrspace(4)* 
addrspace(4)* noundef {{.*}}, i32 addrspace(4)* addrspace(4)* noundef {{.*}})
+  // CHECK-DAG: call spir_func void @_Z3barPU3AS4PU3AS4iS2_(i32 addrspace(4)* 
addrspace(4)* noundef undef, i32 addrspace(4)* addrspace(4)* noundef undef)
   bar(gengen, genglob);
-  // CHECK-DAG: call spir_func void @_Z3barPU3AS1PU3AS4iS2_(i32 addrspace(4)* 
addrspace(1)* noundef {{.*}}, i32 addrspace(4)* addrspace(1)* noundef {{.*}})
+  // CHECK-DAG: call spir_func void @_Z3barPU3AS1PU3AS4iS2_(i32 addrspace(4)* 
addrspace(1)* noundef undef, i32 addrspace(4)* addrspace(1)* noundef undef)
   bar(genglob, genglob);
 }
 
@@ -40,8 +40,8 @@ void kernel test1() {
 void kernel test2() {
   short4 e0=0;
 
-  // CHECK-DAG: call spir_func <4 x i16> @_Z5clampDv4_sss(<4 x i16> noundef 
{{.*}}, i16 noundef signext 0, i16 noundef signext 255)
+  // CHECK-DAG: call spir_func <4 x i16> @_Z5clampDv4_sss(<4 x i16> noundef 
zeroinitializer, i16 noundef signext 0, i16 noundef signext 255)
   clamp(e0, 0, 255);
-  // CHECK-DAG: call spir_func <4 x i16> @_Z5clampDv4_sS_S_(<4 x i16> noundef 
{{.*}}, <4 x i16> noundef {{.*}}, <4 x i16> noundef {{.*}})
+  // CHECK-DAG: call spir_func <4 x i16> @_Z5clampDv4_sS_S_(<4 x i16> noundef 
zeroinitializer, <4 x i16> noundef zeroinitializer, <4 x i16> noundef 
zeroinitializer)
   clamp(e0, e0, e0);
 }

diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index d3b9afdeb4787..dea91c26e8516 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -2900,15 +2900,6 @@ static IntrinsicInst *findInitTrampoline(Value *Callee) {
   return nullptr;
 }
 
-static bool callPassesUndefToPassingUndefUBParam(CallBase &Call) {
-  for (unsigned I = 0; I < Call.arg_si

[PATCH] D132851: Further update -Wbitfield-constant-conversion for 1-bit bitfield

2022-09-02 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added inline comments.



Comment at: clang/test/Sema/constant-conversion.c:30
+  s.b = 1; // one-bit-warning {{implicit truncation from 'int' to a 
one-bit wide bit-field changes value from 1 to -1}}
+  s.b = true;  // no-warning (we suppress it manually to reduce false 
positives)
+  s.b = false; // no-warning

aaron.ballman wrote:
> bjope wrote:
> > (Sorry for being late to the party, with post commit comments. I'm just 
> > trying to understand the reasoning about always suppressing the warning 
> > based on "true".)
> > 
> > Isn't the code a bit suspicious when using true/false from stdbool.h, while 
> > using a signed bitfield?
> > 
> > When doing things like 
> > ```
> > (s.b == true) ? 1 : 0
> > ```
> > the result would always be zero if s.b is a signed 1-bit bitfield.
> > 
> > So wouldn't it make more sense to actually use an unsigned bitfield (such 
> > as the bool type from stdbool.h) when the intent is to store a boolean 
> > value and using defines from stdbool.h?
> > 
> > Is perhaps the idea that we will get warnings about `(s.b == true)` being 
> > redundant in situations like this, and then we do not need a warning on the 
> > bitfield assignment? Such a reasoning would actually make some sense, since 
> > `(s.b == true)` never would be true even when the bitfield is assigned a 
> > non-constant value, so we can't rely on catching the problem by only 
> > looking at bitfield assignments involving true/false.
> > Isn't the code a bit suspicious when using true/false from stdbool.h, while 
> > using a signed bitfield?
> 
> Yes and no...
> 
> > When doing things like
> > ```
> > (s.b == true) ? 1 : 0
> > ```
> > the result would always be zero if s.b is a signed 1-bit bitfield.
> 
> You're correct, but that's a bit of a code smell because of `== true`.
> 
> > So wouldn't it make more sense to actually use an unsigned bitfield (such 
> > as the bool type from stdbool.h) when the intent is to store a boolean 
> > value and using defines from stdbool.h?
> 
> Yes, ideally.
> 
> > Is perhaps the idea that we will get warnings about (s.b == true) being 
> > redundant in situations like this, and then we do not need a warning on the 
> > bitfield assignment? Such a reasoning would actually make some sense, since 
> > (s.b == true) never would be true even when the bitfield is assigned a 
> > non-constant value, so we can't rely on catching the problem by only 
> > looking at bitfield assignments involving true/false.
> 
> The idea is more that someone using `true` is more likely to be treating the 
> field as a boolean and so they won't be comparing the bit-field against a 
> specific value, but instead testing it for its boolean value. This also 
> unifies the behavior between C and C++:  https://godbolt.org/z/WKP4xcPzT
> 
> We don't currently issue a diagnostic on `== true`, but that sure seems like 
> something `-Wtautological-compare` should pick up on (for bit-fields in 
> general, not just for one-bit bit-fields): https://godbolt.org/z/Tj4711Ysc
> 
> (Note, godbolt seems to have a Clang trunk that's ~8 days old, so diagnostic 
> behavior doesn't match actual trunk yet. That caught me by surprise.)
Ok, thanks! Sounds reasonable to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132851

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


[PATCH] D133036: [InstCombine] Treat passing undef to noundef params as UB

2022-09-02 Thread Muhammad Omair Javaid via Phabricator via cfe-commits
omjavaid reopened this revision.
omjavaid added a comment.
This revision is now accepted and ready to land.

This change has broken LLDB Arm/AArch64 Linux buildbots. I dont really 
understand
the underlying reason. Reverting for now to make buildbot green.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133036

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


[PATCH] D133036: [InstCombine] Treat passing undef to noundef params as UB

2022-09-02 Thread Muhammad Omair Javaid via Phabricator via cfe-commits
omjavaid added a comment.

Apparently some problem occuring due to trouble with ASAN exception
https://lab.llvm.org/buildbot/#/builders/96/builds/28300


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133036

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


[clang] 7c232b0 - [Clang][Comments] Fix `Index/comment-lots-of-unknown-commands.c`

2022-09-02 Thread Egor Zhdan via cfe-commits

Author: Egor Zhdan
Date: 2022-09-02T12:34:38+01:00
New Revision: 7c232b0867209a8f487bbcabca9289e9ef313bef

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

LOG: [Clang][Comments] Fix `Index/comment-lots-of-unknown-commands.c`

This re-enables a test after it was disabled in 
https://reviews.llvm.org/D133009.

Fixes #57484.

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

Added: 


Modified: 
clang/test/Index/comment-lots-of-unknown-commands.c

Removed: 




diff  --git a/clang/test/Index/comment-lots-of-unknown-commands.c 
b/clang/test/Index/comment-lots-of-unknown-commands.c
index 41a03d394488c..1de96762dc4ae 100644
--- a/clang/test/Index/comment-lots-of-unknown-commands.c
+++ b/clang/test/Index/comment-lots-of-unknown-commands.c
@@ -1,7 +1,5 @@
 // RUN: c-index-test -test-load-source-reparse 1 local %s | FileCheck %s
 
-// XFAIL: *
-
 // See PR 21254. We had too few bits to encode command IDs so if you created
 // enough of them the ID codes would wrap around. This test creates commands up
 // to an ID of 258. Ideally we should check for large numbers, but that would
@@ -37,7 +35,7 @@
 @ei
 @oun
 @ou
-@nl
+@nlnl
 @ien
 @fr
 @en
@@ -58,7 +56,7 @@
 @fro
 @ast
 @ae
-@nN
+@nNnN
 @pc
 @tae
 @ws
@@ -122,10 +120,10 @@
 @an
 @de
 @tel
-@nd
-@dic
+@ndnd
+@dict
 @Lo
-@il
+@ilil
 @tle
 @axt
 @ba
@@ -137,7 +135,7 @@
 @ru
 @m
 @tG
-@it
+@itit
 @rh
 @G
 @rpc
@@ -183,7 +181,7 @@ void f();
 // CHECK: (CXComment_InlineCommand CommandName=[ei] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[oun] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[ou] RenderNormal 
HasTrailingNewline)
-// CHECK: (CXComment_InlineCommand CommandName=[nl] RenderNormal 
HasTrailingNewline)
+// CHECK: (CXComment_InlineCommand CommandName=[nlnl] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[ien] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[fr] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[en] RenderNormal 
HasTrailingNewline)
@@ -204,7 +202,7 @@ void f();
 // CHECK: (CXComment_InlineCommand CommandName=[fro] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[ast] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[ae] RenderNormal 
HasTrailingNewline)
-// CHECK: (CXComment_InlineCommand CommandName=[nN] RenderNormal 
HasTrailingNewline)
+// CHECK: (CXComment_InlineCommand CommandName=[nNnN] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[pc] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[tae] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[ws] RenderNormal 
HasTrailingNewline)
@@ -268,10 +266,10 @@ void f();
 // CHECK: (CXComment_InlineCommand CommandName=[an] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[de] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[tel] RenderNormal 
HasTrailingNewline)
-// CHECK: (CXComment_InlineCommand CommandName=[nd] RenderNormal 
HasTrailingNewline)
-// CHECK: (CXComment_InlineCommand CommandName=[dic] RenderNormal 
HasTrailingNewline)
+// CHECK: (CXComment_InlineCommand CommandName=[ndnd] RenderNormal 
HasTrailingNewline)
+// CHECK: (CXComment_InlineCommand CommandName=[dict] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[Lo] RenderNormal 
HasTrailingNewline)
-// CHECK: (CXComment_InlineCommand CommandName=[il] RenderNormal 
HasTrailingNewline)
+// CHECK: (CXComment_InlineCommand CommandName=[ilil] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[tle] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[axt] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[ba] RenderNormal 
HasTrailingNewline)
@@ -283,7 +281,7 @@ void f();
 // CHECK: (CXComment_InlineCommand CommandName=[ru] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[m] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[tG] RenderNormal 
HasTrailingNewline)
-// CHECK: (CXComment_InlineCommand CommandName=[it] RenderNormal 
HasTrailingNewline)
+// CHECK: (CXComment_InlineCommand CommandName=[itit] RenderNormal 
HasTrailingNewline)
 // CHECK:  

[PATCH] D133105: [Clang][Comments] Fix `Index/comment-lots-of-unknown-commands.c`

2022-09-02 Thread Egor Zhdan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7c232b086720: [Clang][Comments] Fix 
`Index/comment-lots-of-unknown-commands.c` (authored by egorzhdan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133105

Files:
  clang/test/Index/comment-lots-of-unknown-commands.c


Index: clang/test/Index/comment-lots-of-unknown-commands.c
===
--- clang/test/Index/comment-lots-of-unknown-commands.c
+++ clang/test/Index/comment-lots-of-unknown-commands.c
@@ -1,7 +1,5 @@
 // RUN: c-index-test -test-load-source-reparse 1 local %s | FileCheck %s
 
-// XFAIL: *
-
 // See PR 21254. We had too few bits to encode command IDs so if you created
 // enough of them the ID codes would wrap around. This test creates commands up
 // to an ID of 258. Ideally we should check for large numbers, but that would
@@ -37,7 +35,7 @@
 @ei
 @oun
 @ou
-@nl
+@nlnl
 @ien
 @fr
 @en
@@ -58,7 +56,7 @@
 @fro
 @ast
 @ae
-@nN
+@nNnN
 @pc
 @tae
 @ws
@@ -122,10 +120,10 @@
 @an
 @de
 @tel
-@nd
-@dic
+@ndnd
+@dict
 @Lo
-@il
+@ilil
 @tle
 @axt
 @ba
@@ -137,7 +135,7 @@
 @ru
 @m
 @tG
-@it
+@itit
 @rh
 @G
 @rpc
@@ -183,7 +181,7 @@
 // CHECK: (CXComment_InlineCommand CommandName=[ei] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[oun] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[ou] RenderNormal 
HasTrailingNewline)
-// CHECK: (CXComment_InlineCommand CommandName=[nl] RenderNormal 
HasTrailingNewline)
+// CHECK: (CXComment_InlineCommand CommandName=[nlnl] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[ien] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[fr] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[en] RenderNormal 
HasTrailingNewline)
@@ -204,7 +202,7 @@
 // CHECK: (CXComment_InlineCommand CommandName=[fro] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[ast] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[ae] RenderNormal 
HasTrailingNewline)
-// CHECK: (CXComment_InlineCommand CommandName=[nN] RenderNormal 
HasTrailingNewline)
+// CHECK: (CXComment_InlineCommand CommandName=[nNnN] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[pc] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[tae] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[ws] RenderNormal 
HasTrailingNewline)
@@ -268,10 +266,10 @@
 // CHECK: (CXComment_InlineCommand CommandName=[an] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[de] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[tel] RenderNormal 
HasTrailingNewline)
-// CHECK: (CXComment_InlineCommand CommandName=[nd] RenderNormal 
HasTrailingNewline)
-// CHECK: (CXComment_InlineCommand CommandName=[dic] RenderNormal 
HasTrailingNewline)
+// CHECK: (CXComment_InlineCommand CommandName=[ndnd] RenderNormal 
HasTrailingNewline)
+// CHECK: (CXComment_InlineCommand CommandName=[dict] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[Lo] RenderNormal 
HasTrailingNewline)
-// CHECK: (CXComment_InlineCommand CommandName=[il] RenderNormal 
HasTrailingNewline)
+// CHECK: (CXComment_InlineCommand CommandName=[ilil] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[tle] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[axt] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[ba] RenderNormal 
HasTrailingNewline)
@@ -283,7 +281,7 @@
 // CHECK: (CXComment_InlineCommand CommandName=[ru] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[m] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[tG] RenderNormal 
HasTrailingNewline)
-// CHECK: (CXComment_InlineCommand CommandName=[it] RenderNormal 
HasTrailingNewline)
+// CHECK: (CXComment_InlineCommand CommandName=[itit] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[rh] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[G] RenderNormal 
HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[rpc] RenderNormal 
HasTrailingNewline)


Index: clang/test/Index/comment-lots-of-unknown-commands.c

[PATCH] D133197: [clang] Fix crash when parsing scanf format string with missing arguments

2022-09-02 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
Herald added a project: All.
serge-sans-paille requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When parsing a format string with less argument than specified, one should check
argument access because there may be no such argument.

This fixes #57517


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133197

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/format-strings-scanf.c


Index: clang/test/Sema/format-strings-scanf.c
===
--- clang/test/Sema/format-strings-scanf.c
+++ clang/test/Sema/format-strings-scanf.c
@@ -69,6 +69,11 @@
   scanf("%#.2Lf", ld); // expected-warning{{invalid conversion specifier '#'}}
 }
 
+void missing_argument_with_length_modifier() {
+  char buf[30];
+  scanf("%s:%900s", buf); // expected-warning{{more '%' conversions than data 
arguments}}
+}
+
 // Test that the scanf call site is where the warning is attached.  If the
 // format string is somewhere else, point to it in a note.
 void pr9751(void) {
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1066,6 +1066,9 @@
   return llvm::None;
 unsigned NewIndex = *IndexOptional;
 
+if (NewIndex >= TheCall->getNumArgs())
+  return llvm::None;
+
 const Expr *ObjArg = TheCall->getArg(NewIndex);
 uint64_t Result;
 if (!ObjArg->tryEvaluateObjectSize(Result, getASTContext(), BOSType))


Index: clang/test/Sema/format-strings-scanf.c
===
--- clang/test/Sema/format-strings-scanf.c
+++ clang/test/Sema/format-strings-scanf.c
@@ -69,6 +69,11 @@
   scanf("%#.2Lf", ld); // expected-warning{{invalid conversion specifier '#'}}
 }
 
+void missing_argument_with_length_modifier() {
+  char buf[30];
+  scanf("%s:%900s", buf); // expected-warning{{more '%' conversions than data arguments}}
+}
+
 // Test that the scanf call site is where the warning is attached.  If the
 // format string is somewhere else, point to it in a note.
 void pr9751(void) {
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1066,6 +1066,9 @@
   return llvm::None;
 unsigned NewIndex = *IndexOptional;
 
+if (NewIndex >= TheCall->getNumArgs())
+  return llvm::None;
+
 const Expr *ObjArg = TheCall->getArg(NewIndex);
 uint64_t Result;
 if (!ObjArg->tryEvaluateObjectSize(Result, getASTContext(), BOSType))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D132918: [clang] Fix a crash in constant evaluation

2022-09-02 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 457566.
kadircet added a comment.

Add reproducer.

I think the issue is about keeping constexpr functions valid even when their
bodies contain invalid decls under certain instantiations, which I believe is
the right behaviour. As the function body might be invalid for a certain
instantiation at constexpr time, but might be valid for others (or even for the
same instantiation later on in the TU).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132918

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constexpr-value-init.cpp


Index: clang/test/SemaCXX/constexpr-value-init.cpp
===
--- clang/test/SemaCXX/constexpr-value-init.cpp
+++ clang/test/SemaCXX/constexpr-value-init.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -Wno-uninitialized -std=c++11 -fsyntax-only -verify
+// RUN: %clang_cc1 %s -Wno-uninitialized -std=c++17 -fsyntax-only -verify
 
 struct A {
   constexpr A() : a(b + 1), b(a + 1) {} // expected-note 5{{outside its 
lifetime}}
@@ -46,3 +46,17 @@
 static_assert(e2.a[0].b == 2, "");
 static_assert(e2.a[1].a == 1, "");
 static_assert(e2.a[1].b == 2, "");
+
+namespace InvalidDeclInsideConstExpr {
+template  struct i; // expected-note {{template is declared here}}
+template <> struct i<0> {};
+
+template  constexpr auto c() {
+  // i is valid, but it might be incomplete. g would be invalid in that 
case.
+  i g; // expected-error {{implicit instantiation of undefined template 
'InvalidDeclInsideConstExpr::i<1>'}}
+  return 0;
+}
+
+auto y = c<1>(); // expected-note {{in instantiation of function template 
specialization 'InvalidDeclInsideConstExpr::c<1>' requested here}}
+auto x = c<0>(); // this is valid.
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4844,6 +4844,8 @@
 }
 
 static bool EvaluateVarDecl(EvalInfo &Info, const VarDecl *VD) {
+  if (VD->isInvalidDecl())
+return false;
   // We don't need to evaluate the initializer for a static local.
   if (!VD->hasLocalStorage())
 return true;


Index: clang/test/SemaCXX/constexpr-value-init.cpp
===
--- clang/test/SemaCXX/constexpr-value-init.cpp
+++ clang/test/SemaCXX/constexpr-value-init.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -Wno-uninitialized -std=c++11 -fsyntax-only -verify
+// RUN: %clang_cc1 %s -Wno-uninitialized -std=c++17 -fsyntax-only -verify
 
 struct A {
   constexpr A() : a(b + 1), b(a + 1) {} // expected-note 5{{outside its lifetime}}
@@ -46,3 +46,17 @@
 static_assert(e2.a[0].b == 2, "");
 static_assert(e2.a[1].a == 1, "");
 static_assert(e2.a[1].b == 2, "");
+
+namespace InvalidDeclInsideConstExpr {
+template  struct i; // expected-note {{template is declared here}}
+template <> struct i<0> {};
+
+template  constexpr auto c() {
+  // i is valid, but it might be incomplete. g would be invalid in that case.
+  i g; // expected-error {{implicit instantiation of undefined template 'InvalidDeclInsideConstExpr::i<1>'}}
+  return 0;
+}
+
+auto y = c<1>(); // expected-note {{in instantiation of function template specialization 'InvalidDeclInsideConstExpr::c<1>' requested here}}
+auto x = c<0>(); // this is valid.
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4844,6 +4844,8 @@
 }
 
 static bool EvaluateVarDecl(EvalInfo &Info, const VarDecl *VD) {
+  if (VD->isInvalidDecl())
+return false;
   // We don't need to evaluate the initializer for a static local.
   if (!VD->hasLocalStorage())
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133036: [InstCombine] Treat passing undef to noundef params as UB

2022-09-02 Thread Tim Neumann via Phabricator via cfe-commits
TimNN added a comment.

This also broke Rust when compiled at LLVM head: 
https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/13166#0182fb4a-0f2d-4f2e-830f-f62b463b8d48.
 (I don't know whether this was some existing UB that got only exposed by this 
patch or not, but wanted to make you aware. Reproduces with 2+ codegen units 
and a 1+ optimization level).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133036

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


[PATCH] D133155: Update the docs about IRC

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3da23970ed75: Update the docs about IRC (authored by 
aaron.ballman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133155

Files:
  llvm/docs/GettingInvolved.rst


Index: llvm/docs/GettingInvolved.rst
===
--- llvm/docs/GettingInvolved.rst
+++ llvm/docs/GettingInvolved.rst
@@ -341,19 +341,16 @@
 ---
 
 Users and developers of the LLVM project (including subprojects such as Clang)
-can be found in #llvm on `irc.oftc.net `_.
-
-This channel has several bots.
-
-* Buildbot reporters
-
-  * llvmbb - Bot for the main LLVM buildbot master.
-http://lab.llvm.org/buildbot/#/console
-
-* robot - Bugzilla linker. %bug 
-
-* clang-bot - A `geordi `_ instance running
-  near-trunk clang instead of gcc.
+can be found in #llvm on `irc.oftc.net `_. The channel
+is actively moderated.
+
+The #llvm-build channel has a bot for
+`LLVM buildbot `_ status changes. The
+bot will post a message with a link to a build bot and a blamelist when a build
+goes from passing to failing and again (without the blamelist) when the build
+goes from failing back to passing. It is a good channel for actively monitoring
+build statuses, but it is a noisy channel due to the automated messages. The
+channel is not actively moderated.
 
 In addition to the traditional IRC there is a
 `Discord `_


Index: llvm/docs/GettingInvolved.rst
===
--- llvm/docs/GettingInvolved.rst
+++ llvm/docs/GettingInvolved.rst
@@ -341,19 +341,16 @@
 ---
 
 Users and developers of the LLVM project (including subprojects such as Clang)
-can be found in #llvm on `irc.oftc.net `_.
-
-This channel has several bots.
-
-* Buildbot reporters
-
-  * llvmbb - Bot for the main LLVM buildbot master.
-http://lab.llvm.org/buildbot/#/console
-
-* robot - Bugzilla linker. %bug 
-
-* clang-bot - A `geordi `_ instance running
-  near-trunk clang instead of gcc.
+can be found in #llvm on `irc.oftc.net `_. The channel
+is actively moderated.
+
+The #llvm-build channel has a bot for
+`LLVM buildbot `_ status changes. The
+bot will post a message with a link to a build bot and a blamelist when a build
+goes from passing to failing and again (without the blamelist) when the build
+goes from failing back to passing. It is a good channel for actively monitoring
+build statuses, but it is a noisy channel due to the automated messages. The
+channel is not actively moderated.
 
 In addition to the traditional IRC there is a
 `Discord `_
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D132851: Further update -Wbitfield-constant-conversion for 1-bit bitfield

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/Sema/constant-conversion.c:30
+  s.b = 1; // one-bit-warning {{implicit truncation from 'int' to a 
one-bit wide bit-field changes value from 1 to -1}}
+  s.b = true;  // no-warning (we suppress it manually to reduce false 
positives)
+  s.b = false; // no-warning

bjope wrote:
> aaron.ballman wrote:
> > bjope wrote:
> > > (Sorry for being late to the party, with post commit comments. I'm just 
> > > trying to understand the reasoning about always suppressing the warning 
> > > based on "true".)
> > > 
> > > Isn't the code a bit suspicious when using true/false from stdbool.h, 
> > > while using a signed bitfield?
> > > 
> > > When doing things like 
> > > ```
> > > (s.b == true) ? 1 : 0
> > > ```
> > > the result would always be zero if s.b is a signed 1-bit bitfield.
> > > 
> > > So wouldn't it make more sense to actually use an unsigned bitfield (such 
> > > as the bool type from stdbool.h) when the intent is to store a boolean 
> > > value and using defines from stdbool.h?
> > > 
> > > Is perhaps the idea that we will get warnings about `(s.b == true)` being 
> > > redundant in situations like this, and then we do not need a warning on 
> > > the bitfield assignment? Such a reasoning would actually make some sense, 
> > > since `(s.b == true)` never would be true even when the bitfield is 
> > > assigned a non-constant value, so we can't rely on catching the problem 
> > > by only looking at bitfield assignments involving true/false.
> > > Isn't the code a bit suspicious when using true/false from stdbool.h, 
> > > while using a signed bitfield?
> > 
> > Yes and no...
> > 
> > > When doing things like
> > > ```
> > > (s.b == true) ? 1 : 0
> > > ```
> > > the result would always be zero if s.b is a signed 1-bit bitfield.
> > 
> > You're correct, but that's a bit of a code smell because of `== true`.
> > 
> > > So wouldn't it make more sense to actually use an unsigned bitfield (such 
> > > as the bool type from stdbool.h) when the intent is to store a boolean 
> > > value and using defines from stdbool.h?
> > 
> > Yes, ideally.
> > 
> > > Is perhaps the idea that we will get warnings about (s.b == true) being 
> > > redundant in situations like this, and then we do not need a warning on 
> > > the bitfield assignment? Such a reasoning would actually make some sense, 
> > > since (s.b == true) never would be true even when the bitfield is 
> > > assigned a non-constant value, so we can't rely on catching the problem 
> > > by only looking at bitfield assignments involving true/false.
> > 
> > The idea is more that someone using `true` is more likely to be treating 
> > the field as a boolean and so they won't be comparing the bit-field against 
> > a specific value, but instead testing it for its boolean value. This also 
> > unifies the behavior between C and C++:  https://godbolt.org/z/WKP4xcPzT
> > 
> > We don't currently issue a diagnostic on `== true`, but that sure seems 
> > like something `-Wtautological-compare` should pick up on (for bit-fields 
> > in general, not just for one-bit bit-fields): 
> > https://godbolt.org/z/Tj4711Ysc
> > 
> > (Note, godbolt seems to have a Clang trunk that's ~8 days old, so 
> > diagnostic behavior doesn't match actual trunk yet. That caught me by 
> > surprise.)
> Ok, thanks! Sounds reasonable to me.
Great! Thank you for the discussion! (FWIW, it's *totally* fine to give post 
commit feedback, so no need to apologize. You're never late to the "why does 
this work that way?" party.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132851

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


[PATCH] D133194: rewording note note_constexpr_invalid_cast

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

Thanks for the cleanup here! Precommit CI pointed out places where test 
coverage found issues, and you're missing new test coverage for the change. If 
you run the failing `constant-expression-cxx11.cpp` test in an asserts build, 
it'll help you to narrow down where the issue is. I think the problem is that 
there are more instances of issuing `diag::note_constexpr_invalid_cast` with 
the trailing argument `2` that weren't updated to pass the additional trailing 
argument you added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133194

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


[PATCH] D132550: Changes to code ownership in clang and clang-tidy

2022-09-02 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

+1 to the rst format


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

https://reviews.llvm.org/D132550

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


[PATCH] D133197: [clang] Fix crash when parsing scanf format string with missing arguments

2022-09-02 Thread YingChi Long via Phabricator via cfe-commits
inclyc added a reviewer: aaron.ballman.
inclyc accepted this revision.
inclyc added a subscriber: aaron.ballman.
inclyc added a comment.
This revision is now accepted and ready to land.

Thanks @serge-sans-paille! Basically LGTM. Maybe we need to backport this patch 
though? @aaron.ballman


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133197

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


[PATCH] D133202: [Clang][CodeGen] Fix __builtin_assume_aligned crash

2022-09-02 Thread Lin Yurong via Phabricator via cfe-commits
yronglin created this revision.
yronglin added a reviewer: rjmccall.
Herald added a project: All.
yronglin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Clang will crash when __builtin_assume_aligned's 1st arg is array type(or 
string literal).
Open issue: https://github.com/llvm/llvm-project/issues/57169


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133202

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/catch-alignment-assumption-array.c
  clang/test/CodeGen/catch-alignment-assumption-ignorelist.c

Index: clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
===
--- clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
+++ clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
@@ -26,3 +26,9 @@
 void *ignore_volatiles(volatile void * x) {
   return __builtin_assume_aligned(x, 1);
 }
+
+// CHECK-LABEL: ignore_array_volatiles
+void *ignore_array_volatiles() {
+  volatile int arr[] = {1};
+  return __builtin_assume_aligned(arr, 4);
+}
Index: clang/test/CodeGen/catch-alignment-assumption-array.c
===
--- /dev/null
+++ clang/test/CodeGen/catch-alignment-assumption-array.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -fsanitize=alignment -fno-sanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER,CHECK-SANITIZE-UNREACHABLE
+// RUN: %clang_cc1 -no-opaque-pointers -fsanitize=alignment -fsanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-RECOVER
+// RUN: %clang_cc1 -no-opaque-pointers -fsanitize=alignment -fsanitize-trap=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-TRAP,CHECK-SANITIZE-UNREACHABLE
+
+// CHECK-SANITIZE-ANYRECOVER: @[[CHAR:.*]] = {{.*}} c"'char *'\00" }
+// CHECK-SANITIZE-ANYRECOVER: @[[ALIGNMENT_ASSUMPTION:.*]] = {{.*}}, i32 31, i32 35 }, {{.*}}* @[[CHAR]] }
+
+void *caller(void) {
+  char str[] = "";
+  // CHECK:   define{{.*}}
+  // CHECK-NEXT:  entry:
+  // CHECK-NEXT:%[[STR:.*]] = alloca [1 x i8], align 1
+  // CHECK-NEXT:%[[BITCAST:.*]] = bitcast [1 x i8]* %[[STR]] to i8*
+  // CHECK-NEXT:call void @llvm.memset.p0i8.i64(i8* align 1 %[[BITCAST]], i8 0, i64 1, i1 false)
+  // CHECK-NEXT:%[[ARRAYDECAY:.*]] = getelementptr inbounds [1 x i8], [1 x i8]* %[[STR]], i64 0, i64 0
+  // CHECK-SANITIZE-NEXT:   %[[PTRINT:.*]] = ptrtoint i8* %[[ARRAYDECAY]] to i64
+  // CHECK-SANITIZE-NEXT:   %[[MASKEDPTR:.*]] = and i64 %[[PTRINT]], 0
+  // CHECK-SANITIZE-NEXT:   %[[MASKCOND:.*]] = icmp eq i64 %[[MASKEDPTR]], 0
+  // CHECK-SANITIZE-NEXT:   %[[PTRINT_DUP:.*]] = ptrtoint i8* %[[ARRAYDECAY]] to i64, !nosanitize
+  // CHECK-SANITIZE-NEXT:   br i1 %[[MASKCOND]], label %[[CONT:.*]], label %[[HANDLER_ALIGNMENT_ASSUMPTION:[^,]+]],{{.*}} !nosanitize
+  // CHECK-SANITIZE:  [[HANDLER_ALIGNMENT_ASSUMPTION]]:
+  // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_alignment_assumption_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 1, i64 0){{.*}}, !nosanitize
+  // CHECK-SANITIZE-RECOVER-NEXT:   call void @__ubsan_handle_alignment_assumption(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 1, i64 0){{.*}}, !nosanitize
+  // CHECK-SANITIZE-TRAP-NEXT:  call void @llvm.ubsantrap(i8 23){{.*}}, !nosanitize
+  // CHECK-SANITIZE-UNREACHABLE-NEXT:   unreachable, !nosanitize
+  // CHECK-SANITIZE:  [[CONT]]:
+  // CHECK-NEXT:call void @llvm.assume(i1 true) [ "align"(i8* %[[ARRAYDECAY]], i64 1) ] 
+  // CHECK-NEXT:ret i8* %[[ARRAYDECAY]]
+  // CHECK-NEXT:  }
+  return __builtin_assume_aligned(str, 1);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -128,6 +128,28 @@
  << Call->getSource

[PATCH] D133202: [Clang][CodeGen] Fix __builtin_assume_aligned crash

2022-09-02 Thread Lin Yurong via Phabricator via cfe-commits
yronglin added a comment.

Hi John, I just have a new account, we continue here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133202

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


[PATCH] D133052: [clang] Avoid crash when expanding conversion templates in concepts.

2022-09-02 Thread Luke Nihlen via Phabricator via cfe-commits
luken-google updated this revision to Diff 457579.
luken-google marked an inline comment as done.
luken-google added a comment.

Rebase and lazily check condition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133052

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaInit.cpp
  clang/test/SemaTemplate/concepts.cpp


Index: clang/test/SemaTemplate/concepts.cpp
===
--- clang/test/SemaTemplate/concepts.cpp
+++ clang/test/SemaTemplate/concepts.cpp
@@ -256,3 +256,20 @@
 C auto **&j2 = g();  // expected-error {{deduced type 'int' does not satisfy 
'C'}}
 C auto **&&j3 = g(); // expected-error {{deduced type 'int' does not satisfy 
'C'}}
 }
+
+namespace Issue50891 {
+
+template 
+concept Numeric =
+requires(T a) {
+foo(a);
+};
+
+struct Deferred {
+friend void foo(Deferred);
+template  operator TO();
+};
+
+static_assert(Numeric); // should not crash clang
+
+} // namespace Issue50891
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -4020,8 +4020,14 @@
   //
   // Note: SecondStepOfCopyInit is only ever true in this case when
   // evaluating whether to produce a C++98 compatibility warning.
+  //
+  // The last check avoids an infinite template expansion loop in
+  // requirements checking by skipping the conversion functions check.
   if (S.getLangOpts().CPlusPlus17 && Args.size() == 1 &&
-  !SecondStepOfCopyInit) {
+  !SecondStepOfCopyInit &&
+  (S.CodeSynthesisContexts.empty() ||
+   S.CodeSynthesisContexts.back().Kind !=
+   Sema::CodeSynthesisContext::RequirementInstantiation)) {
 Expr *Initializer = Args[0];
 auto *SourceRD = Initializer->getType()->getAsCXXRecordDecl();
 if (SourceRD && S.isCompleteType(DeclLoc, Initializer->getType())) {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -211,16 +211,16 @@
 - Correctly set expression evaluation context as 'immediate function context' 
in
   consteval functions.
   This fixes `GH51182 `
-
 - Fixes an assert crash caused by looking up missing vtable information on 
``consteval``
   virtual functions. Fixes `GH55065 
`_.
-
 - Skip rebuilding lambda expressions in arguments of immediate invocations.
   This fixes `GH56183 `_,
   `GH51695 `_,
   `GH50455 `_,
   `GH54872 `_,
   `GH54587 `_.
+- Fixed a crash during template instantiation on a conversion operator during 
constraint
+  evaulation. Fixes `GH50891 
`_.
 
 C++2b Feature Support
 ^


Index: clang/test/SemaTemplate/concepts.cpp
===
--- clang/test/SemaTemplate/concepts.cpp
+++ clang/test/SemaTemplate/concepts.cpp
@@ -256,3 +256,20 @@
 C auto **&j2 = g();  // expected-error {{deduced type 'int' does not satisfy 'C'}}
 C auto **&&j3 = g(); // expected-error {{deduced type 'int' does not satisfy 'C'}}
 }
+
+namespace Issue50891 {
+
+template 
+concept Numeric =
+requires(T a) {
+foo(a);
+};
+
+struct Deferred {
+friend void foo(Deferred);
+template  operator TO();
+};
+
+static_assert(Numeric); // should not crash clang
+
+} // namespace Issue50891
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -4020,8 +4020,14 @@
   //
   // Note: SecondStepOfCopyInit is only ever true in this case when
   // evaluating whether to produce a C++98 compatibility warning.
+  //
+  // The last check avoids an infinite template expansion loop in
+  // requirements checking by skipping the conversion functions check.
   if (S.getLangOpts().CPlusPlus17 && Args.size() == 1 &&
-  !SecondStepOfCopyInit) {
+  !SecondStepOfCopyInit &&
+  (S.CodeSynthesisContexts.empty() ||
+   S.CodeSynthesisContexts.back().Kind !=
+   Sema::CodeSynthesisContext::RequirementInstantiation)) {
 Expr *Initializer = Args[0];
 auto *SourceRD = Initializer->getType()->getAsCXXRecordDecl();
 if (SourceRD && S.isCompleteType(DeclLoc, Initializer->getType())) {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -211,16 +211,16 @

[PATCH] D133197: [clang] Fix crash when parsing scanf format string with missing arguments

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!

In D133197#3766797 , @inclyc wrote:

> Thanks @serge-sans-paille! Basically LGTM. Maybe we need to backport this 
> patch though? @aaron.ballman

Clang 15 is closed for backports that aren't critical at this point AFAIK 
(we're slated to release Clang 15 in a few days). I believe this isn't fixing a 
recent regression, so the change should also have a release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133197

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


[PATCH] D133052: [clang] Avoid crash when expanding conversion templates in concepts.

2022-09-02 Thread Luke Nihlen via Phabricator via cfe-commits
luken-google added a comment.

In D133052#3765753 , @ychen wrote:

> Oh, one more thing, we probably need to handle nested levels too, for 
> example, `foo(a);` might be triggered by a template which may be in turn 
> triggered by the concept check. So only checking 
> `S.CodeSynthesisContexts.back()` seems not enough. We need to check if we're 
> in concept check context regardless of instantiation levels.

I'll defer to your expertise on this one, but wanted to raise two concerns 
about this approach before proceeding:

a) The documentation around CodeSynthesisContexts asserts it should be treated 
as a stack (see 
https://github.com/llvm/llvm-project/blob/a5880b5f9c4a7ee543fbc38d528d2830fc27753e/clang/include/clang/Sema/Sema.h#L9131-L9132)

b) Given this is a heuristic fix, does it make sense to keep it as narrow as 
possible, to avoid unintended consequences? I share your confidence we will 
encounter other infinite template expansion bugs, but if we're not going to 
solve the general problem I would think that each individual fix should be 
conservative in its coverage.

Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133052

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


[PATCH] D133202: [Clang][CodeGen] Fix __builtin_assume_aligned crash

2022-09-02 Thread Lin Yurong via Phabricator via cfe-commits
yronglin updated this revision to Diff 457580.
yronglin added a comment.

Format code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133202

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/catch-alignment-assumption-array.c
  clang/test/CodeGen/catch-alignment-assumption-ignorelist.c

Index: clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
===
--- clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
+++ clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
@@ -26,3 +26,9 @@
 void *ignore_volatiles(volatile void * x) {
   return __builtin_assume_aligned(x, 1);
 }
+
+// CHECK-LABEL: ignore_array_volatiles
+void *ignore_array_volatiles() {
+  volatile int arr[] = {1};
+  return __builtin_assume_aligned(arr, 4);
+}
Index: clang/test/CodeGen/catch-alignment-assumption-array.c
===
--- /dev/null
+++ clang/test/CodeGen/catch-alignment-assumption-array.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -fsanitize=alignment -fno-sanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER,CHECK-SANITIZE-UNREACHABLE
+// RUN: %clang_cc1 -no-opaque-pointers -fsanitize=alignment -fsanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-RECOVER
+// RUN: %clang_cc1 -no-opaque-pointers -fsanitize=alignment -fsanitize-trap=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-TRAP,CHECK-SANITIZE-UNREACHABLE
+
+// CHECK-SANITIZE-ANYRECOVER: @[[CHAR:.*]] = {{.*}} c"'char *'\00" }
+// CHECK-SANITIZE-ANYRECOVER: @[[ALIGNMENT_ASSUMPTION:.*]] = {{.*}}, i32 31, i32 35 }, {{.*}}* @[[CHAR]] }
+
+void *caller(void) {
+  char str[] = "";
+  // CHECK:   define{{.*}}
+  // CHECK-NEXT:  entry:
+  // CHECK-NEXT:%[[STR:.*]] = alloca [1 x i8], align 1
+  // CHECK-NEXT:%[[BITCAST:.*]] = bitcast [1 x i8]* %[[STR]] to i8*
+  // CHECK-NEXT:call void @llvm.memset.p0i8.i64(i8* align 1 %[[BITCAST]], i8 0, i64 1, i1 false)
+  // CHECK-NEXT:%[[ARRAYDECAY:.*]] = getelementptr inbounds [1 x i8], [1 x i8]* %[[STR]], i64 0, i64 0
+  // CHECK-SANITIZE-NEXT:   %[[PTRINT:.*]] = ptrtoint i8* %[[ARRAYDECAY]] to i64
+  // CHECK-SANITIZE-NEXT:   %[[MASKEDPTR:.*]] = and i64 %[[PTRINT]], 0
+  // CHECK-SANITIZE-NEXT:   %[[MASKCOND:.*]] = icmp eq i64 %[[MASKEDPTR]], 0
+  // CHECK-SANITIZE-NEXT:   %[[PTRINT_DUP:.*]] = ptrtoint i8* %[[ARRAYDECAY]] to i64, !nosanitize
+  // CHECK-SANITIZE-NEXT:   br i1 %[[MASKCOND]], label %[[CONT:.*]], label %[[HANDLER_ALIGNMENT_ASSUMPTION:[^,]+]],{{.*}} !nosanitize
+  // CHECK-SANITIZE:  [[HANDLER_ALIGNMENT_ASSUMPTION]]:
+  // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_alignment_assumption_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 1, i64 0){{.*}}, !nosanitize
+  // CHECK-SANITIZE-RECOVER-NEXT:   call void @__ubsan_handle_alignment_assumption(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 1, i64 0){{.*}}, !nosanitize
+  // CHECK-SANITIZE-TRAP-NEXT:  call void @llvm.ubsantrap(i8 23){{.*}}, !nosanitize
+  // CHECK-SANITIZE-UNREACHABLE-NEXT:   unreachable, !nosanitize
+  // CHECK-SANITIZE:  [[CONT]]:
+  // CHECK-NEXT:call void @llvm.assume(i1 true) [ "align"(i8* %[[ARRAYDECAY]], i64 1) ] 
+  // CHECK-NEXT:ret i8* %[[ARRAYDECAY]]
+  // CHECK-NEXT:  }
+  return __builtin_assume_aligned(str, 1);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -128,6 +128,28 @@
  << Call->getSourceRange();
 }
 
+/// Checks that a call expression's argument count is at most the desired
+/// number. This is useful when doing custom type-checking on a variadic
+/// function. Returns true on error.
+static bool c

[PATCH] D133195: Expose QualType::getNonReferenceType in libclang

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

LGTM! The precommit CI failure on Debian looks to be unrelated, so I will land 
this on your behalf.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133195

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


[clang] e7d9917 - Expose QualType::getNonReferenceType in libclang

2022-09-02 Thread Aaron Ballman via cfe-commits

Author: Luca Di Sera
Date: 2022-09-02T09:54:10-04:00
New Revision: e7d9917a60dca60da05d0114de9858ed7acb015c

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

LOG: Expose QualType::getNonReferenceType in libclang

The method is now wrapped by clang_getNonReferenceType.

A declaration for clang_getNonReferenceType was added to clang-c/Index.h
to expose it to user of the library.

An implementation for clang_getNonReferenceType was introduced in
CXType.cpp, wrapping the equivalent method of the underlying QualType of
a CXType.

An export symbol for the new function was added to libclang.map under
the LLVM_16 version entry.

A test was added to LibclangTest.cpp that tests the removal of
ref-qualifiers for some CXTypes.

The release-notes for the clang project was updated to include a
notification of the new addition under the "libclang" section.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang-c/Index.h
clang/tools/libclang/CXType.cpp
clang/tools/libclang/libclang.map
clang/unittests/libclang/LibclangTest.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2a92f65cc04fc..41371fe0e04f2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -289,6 +289,8 @@ libclang
 
 - Introduced the new function `clang_getUnqualifiedType`, which mimics
   the behavior of `QualType::getUnqualifiedType` for `CXType`.
+- Introduced the new function `clang_getNonReferenceType`, which mimics
+  the behavior of `QualType::getNonReferenceType` for `CXType`.
 
 Static Analyzer
 ---

diff  --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 41efc57823d3c..c0dbad869114b 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -3797,6 +3797,17 @@ CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
  */
 CINDEX_LINKAGE CXType clang_getUnqualifiedType(CXType CT);
 
+/**
+ * For reference types (e.g., "const int&"), returns the type that the
+ * reference refers to (e.g "const int").
+ *
+ * Otherwise, returns the type itself.
+ *
+ * A type that has kind \c CXType_LValueReference or
+ * \c CXType_RValueReference is a reference type.
+ */
+CINDEX_LINKAGE CXType clang_getNonReferenceType(CXType CT);
+
 /**
  * Return the cursor for the declaration of the given type.
  */

diff  --git a/clang/tools/libclang/CXType.cpp b/clang/tools/libclang/CXType.cpp
index e50a471b94098..a62163c64d097 100644
--- a/clang/tools/libclang/CXType.cpp
+++ b/clang/tools/libclang/CXType.cpp
@@ -488,6 +488,10 @@ CXType clang_getUnqualifiedType(CXType CT) {
   return MakeCXType(GetQualType(CT).getUnqualifiedType(), GetTU(CT));
 }
 
+CXType clang_getNonReferenceType(CXType CT) {
+  return MakeCXType(GetQualType(CT).getNonReferenceType(), GetTU(CT));
+}
+
 CXCursor clang_getTypeDeclaration(CXType CT) {
   if (CT.kind == CXType_Invalid)
 return cxcursor::MakeCXCursorInvalid(CXCursor_NoDeclFound);

diff  --git a/clang/tools/libclang/libclang.map 
b/clang/tools/libclang/libclang.map
index 9ed81722fa341..911292a81c27b 100644
--- a/clang/tools/libclang/libclang.map
+++ b/clang/tools/libclang/libclang.map
@@ -408,6 +408,7 @@ LLVM_13 {
 LLVM_16 {
   global:
 clang_getUnqualifiedType;
+clang_getNonReferenceType;
 };
 
 # Example of how to add a new symbol version entry.  If you do add a new symbol

diff  --git a/clang/unittests/libclang/LibclangTest.cpp 
b/clang/unittests/libclang/LibclangTest.cpp
index e6084859ade71..d020fa9af61c5 100644
--- a/clang/unittests/libclang/LibclangTest.cpp
+++ b/clang/unittests/libclang/LibclangTest.cpp
@@ -891,6 +891,46 @@ TEST_F(LibclangParseTest, 
clang_getUnqualifiedTypeRemovesQualifiers) {
   });
 }
 
+TEST_F(LibclangParseTest, clang_getNonReferenceTypeRemovesRefQualifiers) {
+  std::string Header = "header.h";
+  WriteFile(Header, "void foo1(int&);\n"
+"void foo2(int&&);\n");
+
+  auto is_ref_qualified = [](CXType type) -> bool {
+return (type.kind == CXType_LValueReference) ||
+   (type.kind == CXType_RValueReference);
+  };
+
+  auto from_CXString = [](CXString cx_string) -> std::string {
+std::string string{clang_getCString(cx_string)};
+
+clang_disposeString(cx_string);
+
+return string;
+  };
+
+  const char *Args[] = {"-xc++"};
+  ClangTU = clang_parseTranslationUnit(Index, Header.c_str(), Args, 1, nullptr,
+   0, TUFlags);
+
+  Traverse([&is_ref_qualified, &from_CXString](CXCursor cursor, CXCursor) {
+if (clang_getCursorKind(cursor) == CXCursor_FunctionDecl) {
+  CXType arg_type = clang_getArgType(clang_getCursorType(cursor), 0);
+  EXPECT_TRUE(is_ref_qualified(arg_type))
+  

[PATCH] D133195: Expose QualType::getNonReferenceType in libclang

2022-09-02 Thread Aaron Ballman 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 rGe7d9917a60dc: Expose QualType::getNonReferenceType in 
libclang (authored by diseraluca, committed by aaron.ballman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133195

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang-c/Index.h
  clang/tools/libclang/CXType.cpp
  clang/tools/libclang/libclang.map
  clang/unittests/libclang/LibclangTest.cpp

Index: clang/unittests/libclang/LibclangTest.cpp
===
--- clang/unittests/libclang/LibclangTest.cpp
+++ clang/unittests/libclang/LibclangTest.cpp
@@ -891,6 +891,46 @@
   });
 }
 
+TEST_F(LibclangParseTest, clang_getNonReferenceTypeRemovesRefQualifiers) {
+  std::string Header = "header.h";
+  WriteFile(Header, "void foo1(int&);\n"
+"void foo2(int&&);\n");
+
+  auto is_ref_qualified = [](CXType type) -> bool {
+return (type.kind == CXType_LValueReference) ||
+   (type.kind == CXType_RValueReference);
+  };
+
+  auto from_CXString = [](CXString cx_string) -> std::string {
+std::string string{clang_getCString(cx_string)};
+
+clang_disposeString(cx_string);
+
+return string;
+  };
+
+  const char *Args[] = {"-xc++"};
+  ClangTU = clang_parseTranslationUnit(Index, Header.c_str(), Args, 1, nullptr,
+   0, TUFlags);
+
+  Traverse([&is_ref_qualified, &from_CXString](CXCursor cursor, CXCursor) {
+if (clang_getCursorKind(cursor) == CXCursor_FunctionDecl) {
+  CXType arg_type = clang_getArgType(clang_getCursorType(cursor), 0);
+  EXPECT_TRUE(is_ref_qualified(arg_type))
+  << "Input data '" << from_CXString(clang_getCursorSpelling(cursor))
+  << "' first argument does not have a ref-qualified type.";
+
+  CXType non_reference_arg_type = clang_getNonReferenceType(arg_type);
+  EXPECT_FALSE(is_ref_qualified(non_reference_arg_type))
+  << "The type '" << from_CXString(clang_getTypeSpelling(arg_type))
+  << "' ref-qualifier was not removed after a call to "
+ "clang_getNonReferenceType.";
+}
+
+return CXChildVisit_Continue;
+  });
+}
+
 class LibclangRewriteTest : public LibclangParseTest {
 public:
   CXRewriter Rew = nullptr;
Index: clang/tools/libclang/libclang.map
===
--- clang/tools/libclang/libclang.map
+++ clang/tools/libclang/libclang.map
@@ -408,6 +408,7 @@
 LLVM_16 {
   global:
 clang_getUnqualifiedType;
+clang_getNonReferenceType;
 };
 
 # Example of how to add a new symbol version entry.  If you do add a new symbol
Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -488,6 +488,10 @@
   return MakeCXType(GetQualType(CT).getUnqualifiedType(), GetTU(CT));
 }
 
+CXType clang_getNonReferenceType(CXType CT) {
+  return MakeCXType(GetQualType(CT).getNonReferenceType(), GetTU(CT));
+}
+
 CXCursor clang_getTypeDeclaration(CXType CT) {
   if (CT.kind == CXType_Invalid)
 return cxcursor::MakeCXCursorInvalid(CXCursor_NoDeclFound);
Index: clang/include/clang-c/Index.h
===
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -3797,6 +3797,17 @@
  */
 CINDEX_LINKAGE CXType clang_getUnqualifiedType(CXType CT);
 
+/**
+ * For reference types (e.g., "const int&"), returns the type that the
+ * reference refers to (e.g "const int").
+ *
+ * Otherwise, returns the type itself.
+ *
+ * A type that has kind \c CXType_LValueReference or
+ * \c CXType_RValueReference is a reference type.
+ */
+CINDEX_LINKAGE CXType clang_getNonReferenceType(CXType CT);
+
 /**
  * Return the cursor for the declaration of the given type.
  */
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -289,6 +289,8 @@
 
 - Introduced the new function `clang_getUnqualifiedType`, which mimics
   the behavior of `QualType::getUnqualifiedType` for `CXType`.
+- Introduced the new function `clang_getNonReferenceType`, which mimics
+  the behavior of `QualType::getNonReferenceType` for `CXType`.
 
 Static Analyzer
 ---
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D132918: [clang] Fix a crash in constant evaluation

2022-09-02 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

I was just passing by, but wanted to add more context from our investigation 
with @kadircet.
If variables with incomplete types appear inside non-template `constexpr` 
function this gets detected by a call to `CheckConstexprFunctionDefinition` 
inside `ActOnFinishFunctionBody`:

  if (!IsInstantiation && FD && FD->isConstexpr() && !FD->isInvalidDecl() &&
  !CheckConstexprFunctionDefinition(FD, CheckConstexprKind::Diagnose))
FD->setInvalidDecl();

So the resulting `constexpr` function is marked as invalid and Clang does not 
attempt to evaluate its body.
However, `CheckConstexprFunctionDefinition` does not run for template function 
instantiation, so the `VarDecl` marked invalid ends up inside a valid 
`constexpr` function and Clang does run the evaluation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132918

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


[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-09-02 Thread dongjunduo via Phabricator via cfe-commits
dongjunduo added a comment.

@jamieschmeiser @Whitney

For now, the time-trace file's name is corresponding to the output file's name 
([demo].o => [demo].json).

The only fly in the ointment is that when the user hasn't given the object 
file's name by "-o", 
the object file may be stored in `/tmp` and its name may be append a random 
string.
The main logic of storing it to a temporary file is here: link 
.
The random string is created by createUniquePath 
.

It has guaranteed the object files' name is unique in the `/tmp`.
If the time-trace file's name follows its corresponding object file's name, it 
may also be unique.
But if the time-trace file's name follows its corresponding source file's name, 
it will cause a naming conflict.

Think about a demo common case:

  $ clang++ -ftime-trace dir1/source.cpp dir2/source.cpp main.cpp

The object files'name of `dir1/source.cpp` and `dir2/source.cpp` must be 
different, but...

1. If the time-trace file's name follows the object file, 
"source-[random-string-1].json" and "source-[random-string-2].json" may be 
created independently.
2. If the time-trace file's name follows the source file, "source.json" will be 
created twice and the first one may be overwritten.

I **prefer** the first one, which is implemented now.
While this method adds an annoying random string, it is guaranteed not to cause 
data overwrites in normal use.

So do we need to change it to the second approach?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

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


[PATCH] D132136: [clang] Perform implicit lvalue-to-rvalue cast with new interpreter

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D132136#3766140 , @tbaeder wrote:

> @aaron.ballman Can you comment on my last question? I'd like to land this 
> patch since the others depend on it.

Sorry for the delay!

In D132136#3760738 , @tbaeder wrote:

> In D132136#3755724 , @aaron.ballman 
> wrote:
>
>> The existing test coverage being wrong seems like all the more reason to add 
>> correct test coverage. LValue to RValue conversions are important to get 
>> right (lol here's a wonderful demonstration of where we didn't bother to see 
>> if we got it right that I accidentally stumbled into when trying to give you 
>> a constexpr test case: https://godbolt.org/z/bdxbers3M), especially because 
>> they're going to impact which overload gets called when picking between an 
>> `&&` and `&` overload.
>
> To be clear, can I land this patch without the unittest? I tried adding this 
> to `EvaluateAsRValueTest.cpp` but I just run into other problems in the new 
> interpreter :) So more unittests would definitely be good.

On the one hand, I'm not comfortable landing this without adequate testing, 
especially because you want to build more stuff on top of it. I think we need 
to make sure the foundational bits of evaluation are rock solid before building 
things on top of them. However, on the other hand, this is foundational enough 
that it's hard to test this bit without other parts of the interpreter being 
ready. So my preference is to try to add test coverage even if it's failing 
currently because other parts of the interpreter aren't ready yet. e.g., 
(imaginary test case, feel free to use better ones)

  template 
  struct is_same { static constexpr bool value = false; };
  
  template 
  struct is_same { static constexpr bool value = true; };
  
  const volatile int i = 0;
  // Test that lvalue to rvalue conversion ends up stripping top-level 
qualifiers.
  // FIXME: this isn't correct yet because we don't have support for qualifier 
conversions yet.
  static_assert(is_same::value, "oh no!"); // expected-error 
{{static assertion failed: oh no!}}

This way, we can start getting extensive test cases written while thinking 
about the situations specific to lvalue to rvalue conversion (or whatever else 
is being implemented at the moment) instead of trying to come back and remember 
to write them later.

Is that reasonable, or is the interpreter in such a state where even this kind 
of testing is basically impossible to come up with?


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

https://reviews.llvm.org/D132136

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


[PATCH] D133092: [clang] fix generation of .debug_aranges with LTO

2022-09-02 Thread Azat Khuzhin via Phabricator via cfe-commits
azat added a comment.

@Orlando thanks for taking a look!

> When constructing the compiler command line (here in Clang.cpp) there's a 
> special case for SCE debugger tuning:

Yeah, but it seems that it is not possible to use `lld` for PS4 (only 
`orbis-ld`), according to 
https://github.com/llvm/llvm-project/blob/0dcbe0e1df407ce0e6d9e3df3d177a669723faa8/clang/lib/Driver/ToolChains/PS4CPU.cpp#L203-L206

Refs: https://reviews.llvm.org/D81970


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133092

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


[PATCH] D133209: [clang] Document environment variables used by the driver

2022-09-02 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
Herald added a project: All.
mizvekov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We also mention limitations with regards to character encoding support.

Signed-off-by: Matheus Izvekov 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133209

Files:
  clang/docs/ClangCommandLineReference.rst

Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -5,7 +5,7 @@
   ---
 
 =
-Clang command line argument reference
+Clang command line reference
 =
 .. contents::
:local:
@@ -13,7 +13,7 @@
 Introduction
 
 
-This page lists the command line arguments currently supported by the
+This page lists the command line arguments and environment variables currently supported by the
 GCC-compatible ``clang`` and ``clang++`` drivers.
 
 
@@ -22,6 +22,11 @@
 
 Search $prefix$file for executables, libraries, and data files. If $prefix is a directory, search $prefix/$file
 
+.. envvar:: COMPILER_PATH=
+
+Search $paths for executables, libraries, and data files. The value is a list of paths separated by a system standard
+separator. On Windows and Unix, this separator should be colon, just like ``PATH``.
+
 .. option:: -F
 
 Add directory to framework include search path
@@ -349,8 +354,51 @@
 
 Run the migrator
 
+.. option:: -mmacosx-version-min=
+
+Sets the deployment target version (macOS only)
+
+.. evnvar:: MACOSX_DEPLOYMENT_TARGET
+
+Sets the deployment target version (macOS only).
+This variable might not correctly handle non-ASCII characters in some hosts.
+
 .. option:: -mios-simulator-version-min=, -miphonesimulator-version-min=
 
+Sets the deployment target version (iOS only)
+
+.. evnvar:: IPHONEOS_DEPLOYMENT_TARGET
+
+Sets the deployment target version (iOS only).
+This variable might not correctly handle non-ASCII characters in some hosts.
+
+.. option:: -mtvos-version-min=
+
+Sets the deployment target version (tvOS only)
+
+.. evnvar:: TVOS_DEPLOYMENT_TARGET
+
+Sets the deployment target version (tvOS only).
+This variable might not correctly handle non-ASCII characters in some hosts.
+
+.. option:: -mwatchos-version-min=
+
+Sets the deployment target version (watchOS only)
+
+.. evnvar:: WATCHOS_DEPLOYMENT_TARGET
+
+Sets the deployment target version (watchOS only).
+This variable might not correctly handle non-ASCII characters in some hosts.
+
+.. option:: -mdriverkit-version-min=
+
+Sets the deployment target version (DriverKit only)
+
+.. evnvar:: DRIVERKIT_DEPLOYMENT_TARGET
+
+Sets the deployment target version (DriverKit only).
+This variable might not correctly handle non-ASCII characters in some hosts.
+
 .. option:: -mlinker-version=
 
 .. option:: -mlittle-endian, -EL
@@ -1166,6 +1214,14 @@
 paths, for example if also specified with -isystem, the -I option
 will be ignored
 
+.. envvar:: CPATH=
+
+Takes a list of paths to add to the include search path, like :option:`-I`.
+The value is a list of paths separated by a system standard separator.
+On Windows and Unix, this separator should be colon, just like ``PATH``.
+
+This variable might not correctly handle non-ASCII characters in some hosts.
+
 .. option:: -I-, --include-barrier
 
 Restrict all prior -I flags to double-quoted inclusion and remove current directory from include path
@@ -1182,10 +1238,6 @@
 
 CUDA installation path
 
-.. option:: -cxx-isystem
-
-Add directory to the C++ SYSTEM include search path
-
 .. option:: -fbuild-session-file=
 
 Use the last modification time of  as the build session timestamp
@@ -1202,6 +1254,12 @@
 
 Specify the module cache path
 
+.. envvar:: CLANG_MODULE_CACHE_PATH=
+
+Specify the module cache path.
+Will be used as a fallback if ::option::`-fmodules-cache-path=` is not specified.
+This variable might not correctly handle non-ASCII characters in some hosts.
+
 .. option:: -fmodules-disable-diagnostic-validation
 
 Disable validation of the diagnostic options when loading the module
@@ -1270,6 +1328,31 @@
 
 Set the system root directory (usually /)
 
+.. envvar:: SDKROOT=
+
+Set the system root directory, with a lower precedence than :option:`-isysroot` (Darwin only).
+This variable might not correctly handle non-ASCII characters in some hosts.
+
+.. envvar:: RC_DEBUG_OPTIONS=
+
+Sets DWARF debug flag if $val is not empty (Darwin only).
+This variable might not correctly handle non-ASCII characters in some hosts.
+
+.. envvar:: RC_DEBUG_PREFIX_MAP=
+
+Sets debug path remapping (Darwin only).
+This variable might not correctly handle non-ASCII characters in some hosts.
+
+.. envvar:: SCE_ORBIS_SDK_DIR=
+
+Determine where to find the libraries (PS4 only).
+This variable might not correctly handle no

[PATCH] D126864: [clang] Introduce -fstrict-flex-arrays= for stricter handling of flexible arrays

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:2646
 
+.. option:: -fstrict-flex-arrays=, -fno-strict-flex-arrays
+

From the top of this file:
```
  ---
  NOTE: This file is automatically generated by running clang-tblgen
  -gen-opt-docs. Do not edit this file by hand!!
  ---
```
so none of these changes are reflected at: 
https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fstrict-flex-arrays

This documentation needs to live alongside the option.



Comment at: clang/docs/ClangCommandLineReference.rst:2648
+
+Control which arrays are considered as flexible arrays members. 
+can be 1 (array of size 0, 1 and undefined are considered) or 2 (array of size 0

This phrasing is problematic because it uses the term "flexible array members" 
which is a term of art in the standard when it's really talking about something 
else. We don't want `int trailing[1];` to be considered a flexible array member 
in terms of the language rules.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126864

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


[PATCH] D133209: [clang] Document environment variables used by the driver

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added subscribers: jansvoboda11, aaron.ballman.
aaron.ballman added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:2-5
   ---
   NOTE: This file is automatically generated by running clang-tblgen
   -gen-opt-docs. Do not edit this file by hand!!
   ---

I think you might have missed this bit. ;-)

@jansvoboda11 -- do you know of an ergonomic way for people to associate extra 
documentation along with the command line reference to support adding 
documentation like this? This is the second time in the past hour I've seen 
people adding documentation directly to this file and the docs would be kind of 
onerous to put in `HelpText<>` directly. I'm wondering if the FE options can 
support something along the lines of AttrDocs.td where we can specify some 
out-of-line documentation in another .td for things that are nontrivial to 
document?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133209

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


[PATCH] D133209: [clang] Document environment variables used by the driver

2022-09-02 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:2-5
   ---
   NOTE: This file is automatically generated by running clang-tblgen
   -gen-opt-docs. Do not edit this file by hand!!
   ---

aaron.ballman wrote:
> I think you might have missed this bit. ;-)
> 
> @jansvoboda11 -- do you know of an ergonomic way for people to associate 
> extra documentation along with the command line reference to support adding 
> documentation like this? This is the second time in the past hour I've seen 
> people adding documentation directly to this file and the docs would be kind 
> of onerous to put in `HelpText<>` directly. I'm wondering if the FE options 
> can support something along the lines of AttrDocs.td where we can specify 
> some out-of-line documentation in another .td for things that are nontrivial 
> to document?
Ooops!

Why do we even commit this file then? :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133209

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


[PATCH] D133209: [clang] Document environment variables used by the driver

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:2-5
   ---
   NOTE: This file is automatically generated by running clang-tblgen
   -gen-opt-docs. Do not edit this file by hand!!
   ---

mizvekov wrote:
> aaron.ballman wrote:
> > I think you might have missed this bit. ;-)
> > 
> > @jansvoboda11 -- do you know of an ergonomic way for people to associate 
> > extra documentation along with the command line reference to support adding 
> > documentation like this? This is the second time in the past hour I've seen 
> > people adding documentation directly to this file and the docs would be 
> > kind of onerous to put in `HelpText<>` directly. I'm wondering if the FE 
> > options can support something along the lines of AttrDocs.td where we can 
> > specify some out-of-line documentation in another .td for things that are 
> > nontrivial to document?
> Ooops!
> 
> Why do we even commit this file then? :-)
+1 -- we automatically generate the document from the cmake sphinx target, so I 
think it's reasonable to remove this file from version control (same as we did 
for AttributeReference.rst and DiagnosticReference.rst).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133209

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


[PATCH] D133066: fix a typo in comment of AddConversionCandidate

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D133066#3765503 , @zhouyizhou 
wrote:

> In D133066#3764384 , @aaron.ballman 
> wrote:
>
>> The existing comment is correct according to my copy of the C++11 standard, 
>> but the standard has changed since C++11 and those words no longer appear in 
>> http://eel.is/c++draft/dcl.init.ref#5. Some more investigation is needed, 
>> but I suspect the correct action to take here is to update the comment based 
>> on the current standards wording or to see if there's a bug because the code 
>> does not match the comment.
>
> thank Aaron for review my patch, 
> I am a passionate beginner,

Welcome to the community, we're glad to have you here!

> this is a very good learning experience for me ;-)  I am looking forward to 
> seeing the final change.

Happy to help, but to be clear on the next steps: are you planning to do the 
investigation work, or were you hoping someone else would do it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133066

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


[PATCH] D133158: [NFC] Make MultiplexExternalSemaSource own sources

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM aside from some minor nits (also, please run clang-format over the patch 
before landing).




Comment at: clang/lib/Sema/MultiplexExternalSemaSource.cpp:32
+MultiplexExternalSemaSource::~MultiplexExternalSemaSource() {
+  for (auto &S : Sources)
+S->Release();





Comment at: clang/lib/Sema/Sema.cpp:548
 
-  if (isMultiplexExternalSource)
-static_cast(ExternalSource)->addSource(*E);
-  else {
-ExternalSource = new MultiplexExternalSemaSource(*ExternalSource, *E);
-isMultiplexExternalSource = true;
-  }
+  if (auto Ex = dyn_cast(ExternalSource))
+Ex->AddSource(E);




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133158

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


[PATCH] D130513: [Flang] Add -fconvert option to swap endianness for unformatted files

2022-09-02 Thread Peixin Qiao via Phabricator via cfe-commits
peixin added a comment.

Mostly LGTM. Have several more comments.




Comment at: flang/lib/Lower/Bridge.cpp:279
+// are compiled separately.
+if (hasMainProgram) {
+  createGlobalOutsideOfFunctionLowering([&]() {

Nit



Comment at: flang/lib/Optimizer/Builder/Runtime/EnvironmentDefaults.cpp:19
+const std::vector &envDefaults) {
+  std::string envDefaultListPtrName =
+  fir::NameUniquer::doEnvironmentDefaultList().str();

```
  if (builder.getNamedGlobal(envDefaultListPtrName))
return;
```
I don't think this and doEnvironmentDefaultList are necessary.



Comment at: flang/test/Driver/emit-mlir.f90:16
 ! CHECK-NEXT: }
+! CHECK-NEXT: fir.global @_QQEnvironmentDefaults constant : 
!fir.ref, 
!fir.ref> {
+! CHECK-NEXT:  %[[VAL_0:.*]] = fir.zero_bits !fir.ref, !fir.ref>

Is it possible not to generated this global variable if `fconvert=` is not 
specified?


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

https://reviews.llvm.org/D130513

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


[PATCH] D126172: [clang] Fix comparison of TemplateArgument when they are of template kind

2022-09-02 Thread Robert Esclapez via Phabricator via cfe-commits
roberteg16 added a comment.

In D126172#3754221 , @mizvekov wrote:

> Hello, @roberteg16, are you still interested in working on this patch?
>
> I might need a fix for this myself, and also it happened recently that 
> someone else attempted a fix for the same bug.
>
> If you are not abandoning it, please let us know!

Hey @mizvekov! Sorry for the late response.

Yes, I am still interested and I am working on this. I'll let you know ASAP if 
I find something that resembles a valid fix.

I would be very grateful if you could give me some tips for debuging better 
clang or if you could point me towards documents, links, whatever that could 
give me nice information about how to reason about the code of the parser/sema 
of clang.

If you are in a hurry and need to fix it yourself and it happens that you 
finish the path first, please @ me so I can get to see how an error like this 
would be fixed, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126172

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


[PATCH] D131701: [CodeGen][ObjC] Call synthesized copy constructor/assignment operator functions in getter/setter functions of non-trivial C struct properties

2022-09-02 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 457620.
ahatanak added a comment.

Call the move assignment operator in the setter instead of calling the copy 
assignment operator and the destructor.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131701

Files:
  clang/include/clang/AST/Decl.h
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/test/CodeGenObjC/nontrivial-c-struct-property.m

Index: clang/test/CodeGenObjC/nontrivial-c-struct-property.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/nontrivial-c-struct-property.m
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -emit-llvm -o - %s | FileCheck %s
+
+typedef struct {
+  id x;
+} S0;
+
+@interface C {
+  S0 _p1;
+}
+@property(nonatomic) S0 nonatomic;
+@property S0 atomic0;
+@property S0 p1;
+-(S0)p1;
+-(void)setP1:(S0)s0;
+@end
+
+@implementation C
+-(S0)p1 {
+  return _p1;
+}
+-(void)setP1:(S0)s0 {
+  _p1 = s0;
+}
+@end
+
+// CHECK: %[[STRUCT_S0:.*]] = type { ptr }
+
+// Check that parameters of user-defined setters are destructed.
+
+// CHECK-LABEL: define internal void @"\01-[C setP1:]"(
+// CHECK: %[[S0:.*]] = alloca %[[STRUCT_S0]], align 8
+// CHECK: call void @__copy_assignment_8_8_s0(ptr %{{.*}}, ptr %[[S0]])
+// CHECK: call void @__destructor_8_s0(ptr %[[S0]])
+
+// CHECK: define internal i64 @"\01-[C nonatomic]"(ptr noundef %[[SELF:.*]], {{.*}})
+// CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_S0]], align 8
+// CHECK: %[[SELF_ADDR:.*]] = alloca ptr, align 8
+// CHECK: store ptr %[[SELF]], ptr %[[SELF_ADDR]], align 8
+// CHECK: %[[V0:.*]] = load ptr, ptr %[[SELF_ADDR]], align 8
+// CHECK: %[[IVAR:.*]] = load i32, ptr @"OBJC_IVAR_$_C._nonatomic", align 8
+// CHECK: %[[IVAR_CONV:.*]] = sext i32 %[[IVAR]] to i64
+// CHECK: %[[ADD_PTR:.*]] = getelementptr inbounds i8, ptr %[[V0]], i64 %[[IVAR_CONV]]
+// CHECK: call void @__copy_constructor_8_8_s0(ptr %[[RETVAL]], ptr %[[ADD_PTR]])
+// CHECK-NOT: call
+// CHECK: ret i64
+
+// CHECK: define internal void @"\01-[C setNonatomic:]"(ptr noundef %[[SELF:.*]], {{.*}}, i64 %[[NONATOMIC_COERCE:.*]])
+// CHECK: %[[NONATOMIC:.*]] = alloca %[[STRUCT_S0]], align 8
+// CHECK: %[[SELF_ADDR:.*]] = alloca ptr, align 8
+// CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_S0]], ptr %[[NONATOMIC]], i32 0, i32 0
+// CHECK: %[[COERCE_VAL_IP:.*]] = inttoptr i64 %[[NONATOMIC_COERCE]] to ptr
+// CHECK: store ptr %[[COERCE_VAL_IP]], ptr %[[COERCE_DIVE]], align 8
+// CHECK: store ptr %[[SELF]], ptr %[[SELF_ADDR]], align 8
+// CHECK: %[[V0:.*]] = load ptr, ptr %[[SELF_ADDR]], align 8
+// CHECK: %[[IVAR:.*]] = load i32, ptr @"OBJC_IVAR_$_C._nonatomic", align 8
+// CHECK: %[[IVAR_CONV:.*]] = sext i32 %[[IVAR]] to i64
+// CHECK: %[[ADD_PTR:.*]] = getelementptr inbounds i8, ptr %[[V0]], i64 %[[IVAR_CONV]]
+// CHECK: call void @__move_assignment_8_8_s0(ptr %[[ADD_PTR]], ptr %[[NONATOMIC]])
+// CHECK-NOT: call
+// CHECK: ret void
+
+// CHECK-LABEL: define internal i64 @"\01-[C atomic0]"(
+// CHECK: call void @objc_copyCppObjectAtomic({{.*}}, {{.*}}, ptr noundef @__copy_constructor_8_8_s0)
+// CHECK-NOT: call
+// CHECK: ret i64
+
+// CHECK-LABEL: define internal void @"\01-[C setAtomic0:]"(
+// CHECK: call void @objc_copyCppObjectAtomic({{.*}}, {{.*}}, ptr noundef @__move_assignment_8_8_s0)
+// CHECK-NOT: call
+// CHECK: ret void
Index: clang/lib/CodeGen/CGObjC.cpp
===
--- clang/lib/CodeGen/CGObjC.cpp
+++ clang/lib/CodeGen/CGObjC.cpp
@@ -22,6 +22,7 @@
 #include "clang/AST/StmtObjC.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
+#include "clang/CodeGen/CodeGenABITypes.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Analysis/ObjCARCUtil.h"
 #include "llvm/BinaryFormat/MachO.h"
@@ -1115,6 +1116,23 @@
 const ObjCPropertyImplDecl *propImpl,
 const ObjCMethodDecl *GetterMethodDecl,
 llvm::Constant *AtomicHelperFn) {
+
+  ObjCIvarDecl *ivar = propImpl->getPropertyIvarDecl();
+
+  if (ivar->getType().isNonTrivialToPrimitiveCopy() == QualType::PCK_Struct) {
+if (!AtomicHelperFn) {
+  LValue Src =
+  EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(), ivar, 0);
+  LValue Dst = MakeAddrLValue(ReturnValue, ivar->getType());
+  callCStructCopyConstructor(Dst, Src);
+} else {
+  ObjCIvarDecl *ivar = propImpl->getPropertyIvarDecl();
+  emitCPPObjectAtomicGetterCall(*this, ReturnValue.getPointer(), ivar,
+AtomicHelperFn);
+}
+return;
+  }
+
   // If there's a non-trivial 'get' expression, we just have to emit that.
   if (!hasTrivialGetExpr(propImpl)) {
 if (!AtomicHelperFn) {
@@ -1135,8 +1153,6 @@
   QualType propType = pro

[clang] e05edb1 - [Driver] Unsupport --print-multiarch

2022-09-02 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-09-02T09:51:02-07:00
New Revision: e05edb19adbfd1b24f58d583e4b5b4d742f982ee

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

LOG: [Driver] Unsupport --print-multiarch

* If GCC is configured with `--disable-multi-arch`, `--print-multiarch` output 
is an empty line.
* If GCC is configured with `--enable-multi-arch`, `--print-multiarch` output 
may be a normalized triple or (on Debian, 'vendor' is omitted) 
`x86_64-linux-gnu`.

The Clang support D101400 just prints the Debian multiarch style triple
unconditionally, but the string is not really expected for non-Debian systems.

AIUI many Linux distributions and non-Linux OSes don't configure GCC with 
`--enable-multi-arch`.
Instead of getting us in the trouble of supporting all kinds of variants, drop 
the support as before D101400.

Close https://github.com/llvm/llvm-project/issues/51469

Reviewed By: phosek

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/test/Driver/print-multiarch.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d921ea5d5da99..1112e0187758e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4069,8 +4069,9 @@ def print_target_triple : Flag<["-", "--"], 
"print-target-triple">,
   HelpText<"Print the normalized target triple">, Flags<[FlangOption]>;
 def print_effective_triple : Flag<["-", "--"], "print-effective-triple">,
   HelpText<"Print the effective target triple">, Flags<[FlangOption]>;
-def print_multiarch : Flag<["-", "--"], "print-multiarch">,
-  HelpText<"Print the multiarch target triple">;
+// GCC --disable-multiarch, GCC --enable-multiarch (upstream and Debian
+// specific) have 
diff erent behaviors. We choose not to support the option.
+def : Flag<["-", "--"], "print-multiarch">, Flags<[Unsupported]>;
 def print_prog_name_EQ : Joined<["-", "--"], "print-prog-name=">,
   HelpText<"Print the full program path of ">, MetaVarName<"">;
 def print_resource_dir : Flag<["-", "--"], "print-resource-dir">,

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 554e6b890281f..ba359a1d31a53 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2152,12 +2152,6 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
 return false;
   }
 
-  if (C.getArgs().hasArg(options::OPT_print_multiarch)) {
-llvm::outs() << TC.getMultiarchTriple(*this, TC.getTriple(), SysRoot)
- << "\n";
-return false;
-  }
-
   if (C.getArgs().hasArg(options::OPT_print_targets)) {
 llvm::TargetRegistry::printRegisteredTargetsForVersion(llvm::outs());
 return false;

diff  --git a/clang/test/Driver/print-multiarch.c 
b/clang/test/Driver/print-multiarch.c
index 8638c9a155a3d..5bbfcb0030c27 100644
--- a/clang/test/Driver/print-multiarch.c
+++ b/clang/test/Driver/print-multiarch.c
@@ -1,6 +1,6 @@
-// Check the output of -print-multiarch.
+/// GCC --disable-multiarch, GCC --enable-multiarch (upstream and Debian 
specific) have 
diff erent behaviors.
+/// We choose not to support the option.
 
-// RUN: %clang -print-multiarch --target=x86_64-unknown-linux-gnu \
-// RUN:-resource-dir=%S/Inputs/resource_dir \
-// RUN:  | FileCheck --check-prefix=PRINT-MULTIARCH %s
-// PRINT-MULTIARCH: {{^}}x86_64-linux-gnu{{$}}
+// RUN: not %clang -print-multiarch --target=x86_64-unknown-linux-gnu 2>&1 | 
FileCheck %s
+
+// CHECK: error: unsupported option '-print-multiarch'



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


[PATCH] D133170: [Driver] Unsupport --print-multiarch

2022-09-02 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe05edb19adbf: [Driver] Unsupport --print-multiarch (authored 
by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133170

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/print-multiarch.c


Index: clang/test/Driver/print-multiarch.c
===
--- clang/test/Driver/print-multiarch.c
+++ clang/test/Driver/print-multiarch.c
@@ -1,6 +1,6 @@
-// Check the output of -print-multiarch.
+/// GCC --disable-multiarch, GCC --enable-multiarch (upstream and Debian 
specific) have different behaviors.
+/// We choose not to support the option.
 
-// RUN: %clang -print-multiarch --target=x86_64-unknown-linux-gnu \
-// RUN:-resource-dir=%S/Inputs/resource_dir \
-// RUN:  | FileCheck --check-prefix=PRINT-MULTIARCH %s
-// PRINT-MULTIARCH: {{^}}x86_64-linux-gnu{{$}}
+// RUN: not %clang -print-multiarch --target=x86_64-unknown-linux-gnu 2>&1 | 
FileCheck %s
+
+// CHECK: error: unsupported option '-print-multiarch'
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2152,12 +2152,6 @@
 return false;
   }
 
-  if (C.getArgs().hasArg(options::OPT_print_multiarch)) {
-llvm::outs() << TC.getMultiarchTriple(*this, TC.getTriple(), SysRoot)
- << "\n";
-return false;
-  }
-
   if (C.getArgs().hasArg(options::OPT_print_targets)) {
 llvm::TargetRegistry::printRegisteredTargetsForVersion(llvm::outs());
 return false;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4069,8 +4069,9 @@
   HelpText<"Print the normalized target triple">, Flags<[FlangOption]>;
 def print_effective_triple : Flag<["-", "--"], "print-effective-triple">,
   HelpText<"Print the effective target triple">, Flags<[FlangOption]>;
-def print_multiarch : Flag<["-", "--"], "print-multiarch">,
-  HelpText<"Print the multiarch target triple">;
+// GCC --disable-multiarch, GCC --enable-multiarch (upstream and Debian
+// specific) have different behaviors. We choose not to support the option.
+def : Flag<["-", "--"], "print-multiarch">, Flags<[Unsupported]>;
 def print_prog_name_EQ : Joined<["-", "--"], "print-prog-name=">,
   HelpText<"Print the full program path of ">, MetaVarName<"">;
 def print_resource_dir : Flag<["-", "--"], "print-resource-dir">,


Index: clang/test/Driver/print-multiarch.c
===
--- clang/test/Driver/print-multiarch.c
+++ clang/test/Driver/print-multiarch.c
@@ -1,6 +1,6 @@
-// Check the output of -print-multiarch.
+/// GCC --disable-multiarch, GCC --enable-multiarch (upstream and Debian specific) have different behaviors.
+/// We choose not to support the option.
 
-// RUN: %clang -print-multiarch --target=x86_64-unknown-linux-gnu \
-// RUN:-resource-dir=%S/Inputs/resource_dir \
-// RUN:  | FileCheck --check-prefix=PRINT-MULTIARCH %s
-// PRINT-MULTIARCH: {{^}}x86_64-linux-gnu{{$}}
+// RUN: not %clang -print-multiarch --target=x86_64-unknown-linux-gnu 2>&1 | FileCheck %s
+
+// CHECK: error: unsupported option '-print-multiarch'
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2152,12 +2152,6 @@
 return false;
   }
 
-  if (C.getArgs().hasArg(options::OPT_print_multiarch)) {
-llvm::outs() << TC.getMultiarchTriple(*this, TC.getTriple(), SysRoot)
- << "\n";
-return false;
-  }
-
   if (C.getArgs().hasArg(options::OPT_print_targets)) {
 llvm::TargetRegistry::printRegisteredTargetsForVersion(llvm::outs());
 return false;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4069,8 +4069,9 @@
   HelpText<"Print the normalized target triple">, Flags<[FlangOption]>;
 def print_effective_triple : Flag<["-", "--"], "print-effective-triple">,
   HelpText<"Print the effective target triple">, Flags<[FlangOption]>;
-def print_multiarch : Flag<["-", "--"], "print-multiarch">,
-  HelpText<"Print the multiarch target triple">;
+// GCC --disable-multiarch, GCC --enable-multiarch (upstream and Debian
+// specific) have different behaviors. We choose not to support the option.
+def : Flag<["-", "--"], "print-multiarch">, Flags<[Unsupported]>;
 def print_prog_name_EQ : Joined<["-", "--"], "print-prog-name=">,
   HelpText<"Print the full program path of ">, MetaVarName<"">;
 def print_resource_dir : Fl

[PATCH] D127284: [clang-repl] Support statements on global scope in incremental mode.

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

> The patch conceptually models the possible "top-level" statements between two 
> top-level declarations into a block which is emitted as part of the global 
> init function.
> Currently we model this "statement block" as a function body to a void 
> function taking no arguments. We attach this function to the global 
> initializer list to execute the statement blocks in the correct order.

I think some of the tests have confusing behavior based on this conceptual 
model because the tests do things like declare namespaces and call functions; 
you can declare a namespace at file scope, not at function scope; you can't 
call a function at file scope (unless it's part of an initializer). So it the 
semantics wind up feeling confused because you can't tell whether you're at 
file scope or at function scope because you seem to be in both at the same time.




Comment at: clang/include/clang/AST/ASTConsumer.h:54-59
+  /// HandleTopLevelStmts - Handle the specified top-level statements. This is
+  /// called by the parser to process every top-level Stmt* in incremental
+  /// compilation mode.
+  ///
+  /// \returns true to continue parsing, or false to abort parsing.
+  virtual bool HandleTopLevelStmts(const llvm::SmallVectorImpl &Stmts) 
{

In C and C++, the only thing that's at file scope (that the parser sees) are 
declarations, not statements, so the phrasing here seems off. I suspect this is 
because you don't *know* you're only going to get declarations (because it 
could be that we're trying to parse in the context of an imaginary function 
body)? If so, perhaps the comments could be updated to clarify that.



Comment at: clang/include/clang/Parse/Parser.h:466
+  /// A SmallVector of statements, with stack size 32 (as that is the only one
+  /// used.)
+  typedef SmallVector StmtVector;

Drive by punctuation fix. I'm not certain I understand "as that is the only one 
used", but that's from the original comment. It's possible the comment holds no 
real weight any longer?



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5107-5111
+  static unsigned id = 0;
+  ASTContext &C = getContext();
+  TranslationUnitDecl *TUDecl = C.getTranslationUnitDecl();
+
+  IdentifierInfo *name = &C.Idents.get("_stmts" + std::to_string(id++));

You should fix the other identifiers in this function to match the usual coding 
style.



Comment at: clang/lib/Parse/ParseDecl.cpp:5514-5521
+  // FIXME: this returns true for NS::f();
   // A right parenthesis, or ellipsis followed by a right parenthesis signals
   // that we have a constructor.
   if (Tok.is(tok::r_paren) ||
   (Tok.is(tok::ellipsis) && NextToken().is(tok::r_paren))) {
 TPA.Revert();
 return true;

rsmith wrote:
> I think we'll need to work out whether we're disambiguating versus a 
> statement here. I think the key observation is that either:
> 
> 1) We know we're parsing a declaration, because we're inside a class body or 
> parsing after `template` or `template<...>` or similar.
> 2) A constructor declaration must be a definition, so if we don't see a `{`, 
> `:`, or `try` after the declarator then it's an expression, not a declaration.
> 
> I'd suggest passing in a flag to say whether we know we're parsing a 
> declaration, which is true unless we're disambiguating against a top-level 
> statement; in that case, don't return here and instead keep going until we 
> hit one of the relevant cases below.
> A constructor declaration must be a definition, so if we don't see a {, :, or 
> try after the declarator then it's an expression, not a declaration.

Consider: 
```
struct S {
  S();
};

S::S() = default;
```
The out-of-line constructor definition is still a kind of declaration despite 
not ending in `{`, `:`, or `try`.



Comment at: clang/lib/Parse/ParseTentative.cpp:54
+case tok::semi:
+  return true; // Not a stmt but can be extra terminator in `namespace{};`
+case tok::kw_template:

http://eel.is/c++draft/dcl.dcl#nt:empty-declaration



Comment at: clang/lib/Parse/ParseTentative.cpp:60
+case tok::identifier:
+  if (getLangOpts().CPlusPlus) {
+if (isConstructorDeclarator(/*Unqualified=*/false,

You should assert this at the top of the file; we shouldn't call into here for 
C code.



Comment at: clang/lib/Parse/ParseTentative.cpp:61
+  if (getLangOpts().CPlusPlus) {
+if (isConstructorDeclarator(/*Unqualified=*/false,
+/*DeductionGuide=*/false,

Do you need special handling for:
```
struct S {
  operator int();
};

S::operator int() { return 0; }
```



Comment at: clang/lib/Parse/Parser.cpp:729-730
 
+  // FIXME: Remove the incremental processing pre-condition and verify clang
+  // still can pass its t

[PATCH] D133180: [MinGW] Ignore -fvisibility/-fvisibility-inlines-hidden for dllexport

2022-09-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 457625.
MaskRay marked an inline comment as done.
MaskRay added a comment.

rename test to dllstorage-visibility.cpp
use -fdeclspec instead of -fms-extensions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133180

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/dllstorage-visibility.cpp
  clang/test/CodeGenCXX/hidden-dllimport.cpp


Index: clang/test/CodeGenCXX/hidden-dllimport.cpp
===
--- clang/test/CodeGenCXX/hidden-dllimport.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-pc-windows-msvc 
-emit-llvm -fvisibility-inlines-hidden -o - %s | FileCheck %s
-
-// We used to declare this hidden dllimport, which is contradictory.
-
-// CHECK: declare dllimport void @"?bar@foo@@QEAAXXZ"(%struct.foo* {{[^,]*}})
-
-struct __attribute__((dllimport)) foo {
-  void bar() {}
-};
-void zed(foo *p) { p->bar(); }
Index: clang/test/CodeGenCXX/dllstorage-visibility.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllstorage-visibility.cpp
@@ -0,0 +1,26 @@
+/// dllimport and dllexport express non-hidden intention. Don't apply hidden 
visibility.
+
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-msvc -fdeclspec 
-fvisibility-inlines-hidden -o - %s | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-gnu -fdeclspec 
-fvisibility-inlines-hidden -o - %s | FileCheck %s --check-prefix=GNU
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-gnu -fdeclspec 
-fvisibility hidden -o - %s | FileCheck %s --check-prefix=GNU
+
+#define CONCAT2(x, y) x##y
+#define CONCAT(x, y) CONCAT2(x, y)
+#define USE(func) void CONCAT(use, __LINE__)() { func(); }
+
+// MSVC-DAG: declare dllimport void @"?bar@foo@@QEAAXXZ"(
+// GNU-DAG: define linkonce_odr hidden void @_ZN3foo3barEv(
+
+struct __attribute__((dllimport)) foo {
+  void bar() {}
+};
+void zed(foo *p) { p->bar(); }
+
+// MSVC-DAG: define dso_local dllexport void @"?exported@@YAXXZ"(
+// GNU-DAG: define dso_local dllexport void @_Z8exportedv(
+__attribute__((dllexport)) void exported() {}
+
+// MSVC-DAG: define weak_odr dso_local dllexport void 
@"?exported_inline@@YAXXZ"(
+// GNU-DAG: define weak_odr dso_local dllexport void @_Z15exported_inlinev(
+__declspec(dllexport) inline void exported_inline() {}
+USE(exported_inline)
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1099,7 +1099,7 @@
 
 void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
 const NamedDecl *D) const {
-  if (GV->hasDLLImportStorageClass())
+  if (GV->hasDLLExportStorageClass() || GV->hasDLLImportStorageClass())
 return;
   // Internal definitions always have default visibility.
   if (GV->hasLocalLinkage()) {


Index: clang/test/CodeGenCXX/hidden-dllimport.cpp
===
--- clang/test/CodeGenCXX/hidden-dllimport.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-pc-windows-msvc -emit-llvm -fvisibility-inlines-hidden -o - %s | FileCheck %s
-
-// We used to declare this hidden dllimport, which is contradictory.
-
-// CHECK: declare dllimport void @"?bar@foo@@QEAAXXZ"(%struct.foo* {{[^,]*}})
-
-struct __attribute__((dllimport)) foo {
-  void bar() {}
-};
-void zed(foo *p) { p->bar(); }
Index: clang/test/CodeGenCXX/dllstorage-visibility.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllstorage-visibility.cpp
@@ -0,0 +1,26 @@
+/// dllimport and dllexport express non-hidden intention. Don't apply hidden visibility.
+
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-msvc -fdeclspec -fvisibility-inlines-hidden -o - %s | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-gnu -fdeclspec -fvisibility-inlines-hidden -o - %s | FileCheck %s --check-prefix=GNU
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-gnu -fdeclspec -fvisibility hidden -o - %s | FileCheck %s --check-prefix=GNU
+
+#define CONCAT2(x, y) x##y
+#define CONCAT(x, y) CONCAT2(x, y)
+#define USE(func) void CONCAT(use, __LINE__)() { func(); }
+
+// MSVC-DAG: declare dllimport void @"?bar@foo@@QEAAXXZ"(
+// GNU-DAG: define linkonce_odr hidden void @_ZN3foo3barEv(
+
+struct __attribute__((dllimport)) foo {
+  void bar() {}
+};
+void zed(foo *p) { p->bar(); }
+
+// MSVC-DAG: define dso_local dllexport void @"?exported@@YAXXZ"(
+// GNU-DAG: define dso_local dllexport void @_Z8exportedv(
+__attribute__((dllexport)) void exported() {}
+
+// MSVC-DAG: define weak_odr dso_local dllexport void @"?exported_inline@@YAXXZ"(
+// GNU

[PATCH] D130888: [Clang] Introduce -fexperimental-sanitize-metadata=

2022-09-02 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/Driver/fsanitize-metadata.c:24
+
+// RUN: %clang --target=x86_64-linux-gnu \
+// RUN:   -fexperimental-sanitize-metadata=covered,atomics %s -### 2>&1 | \

If possible, don't split long RUN: line
it's much easier to see a difference between different invocations

clang format is configured to ignore line length in tests nowadays anyway


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130888

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


[clang] 1a4d851 - [MinGW] Ignore -fvisibility/-fvisibility-inlines-hidden for dllexport

2022-09-02 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-09-02T09:59:16-07:00
New Revision: 1a4d851d272d141fb39ff9a0b2572dfa4411c5c5

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

LOG: [MinGW] Ignore -fvisibility/-fvisibility-inlines-hidden for dllexport

Similar to 123ce97fac78bc4519afd5d2aba17c59c5717aad for dllimport: dllexport
expresses a non-hidden visibility intention. We can consider it explicit and
therefore it should override the global visibility setting (see AST/Decl.cpp
"NamedDecl Implementation").

Adding the special case to CodeGenModule::setGlobalVisibility is somewhat weird,
but allows we to add the code in one place instead of many in AST/Decl.cpp.

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

Added: 
clang/test/CodeGenCXX/dllstorage-visibility.cpp

Modified: 
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 
clang/test/CodeGenCXX/hidden-dllimport.cpp



diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index bb0970e3e36fa..f9087cdd5d4dc 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1099,7 +1099,7 @@ llvm::ConstantInt *CodeGenModule::getSize(CharUnits size) 
{
 
 void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
 const NamedDecl *D) const {
-  if (GV->hasDLLImportStorageClass())
+  if (GV->hasDLLExportStorageClass() || GV->hasDLLImportStorageClass())
 return;
   // Internal definitions always have default visibility.
   if (GV->hasLocalLinkage()) {

diff  --git a/clang/test/CodeGenCXX/dllstorage-visibility.cpp 
b/clang/test/CodeGenCXX/dllstorage-visibility.cpp
new file mode 100644
index 0..af164edc24820
--- /dev/null
+++ b/clang/test/CodeGenCXX/dllstorage-visibility.cpp
@@ -0,0 +1,26 @@
+/// dllimport and dllexport express non-hidden intention. Don't apply hidden 
visibility.
+
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-msvc -fdeclspec 
-fvisibility-inlines-hidden -o - %s | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-gnu -fdeclspec 
-fvisibility-inlines-hidden -o - %s | FileCheck %s --check-prefix=GNU
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-gnu -fdeclspec 
-fvisibility hidden -o - %s | FileCheck %s --check-prefix=GNU
+
+#define CONCAT2(x, y) x##y
+#define CONCAT(x, y) CONCAT2(x, y)
+#define USE(func) void CONCAT(use, __LINE__)() { func(); }
+
+// MSVC-DAG: declare dllimport void @"?bar@foo@@QEAAXXZ"(
+// GNU-DAG: define linkonce_odr hidden void @_ZN3foo3barEv(
+
+struct __attribute__((dllimport)) foo {
+  void bar() {}
+};
+void zed(foo *p) { p->bar(); }
+
+// MSVC-DAG: define dso_local dllexport void @"?exported@@YAXXZ"(
+// GNU-DAG: define dso_local dllexport void @_Z8exportedv(
+__attribute__((dllexport)) void exported() {}
+
+// MSVC-DAG: define weak_odr dso_local dllexport void 
@"?exported_inline@@YAXXZ"(
+// GNU-DAG: define weak_odr dso_local dllexport void @_Z15exported_inlinev(
+__declspec(dllexport) inline void exported_inline() {}
+USE(exported_inline)

diff  --git a/clang/test/CodeGenCXX/hidden-dllimport.cpp 
b/clang/test/CodeGenCXX/hidden-dllimport.cpp
deleted file mode 100644
index c9e0304b6ff4d..0
--- a/clang/test/CodeGenCXX/hidden-dllimport.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-pc-windows-msvc 
-emit-llvm -fvisibility-inlines-hidden -o - %s | FileCheck %s
-
-// We used to declare this hidden dllimport, which is contradictory.
-
-// CHECK: declare dllimport void @"?bar@foo@@QEAAXXZ"(%struct.foo* {{[^,]*}})
-
-struct __attribute__((dllimport)) foo {
-  void bar() {}
-};
-void zed(foo *p) { p->bar(); }



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


[PATCH] D133180: [MinGW] Ignore -fvisibility/-fvisibility-inlines-hidden for dllexport

2022-09-02 Thread Fangrui Song 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 rG1a4d851d272d: [MinGW] Ignore 
-fvisibility/-fvisibility-inlines-hidden for dllexport (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133180

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/dllstorage-visibility.cpp
  clang/test/CodeGenCXX/hidden-dllimport.cpp


Index: clang/test/CodeGenCXX/hidden-dllimport.cpp
===
--- clang/test/CodeGenCXX/hidden-dllimport.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-pc-windows-msvc 
-emit-llvm -fvisibility-inlines-hidden -o - %s | FileCheck %s
-
-// We used to declare this hidden dllimport, which is contradictory.
-
-// CHECK: declare dllimport void @"?bar@foo@@QEAAXXZ"(%struct.foo* {{[^,]*}})
-
-struct __attribute__((dllimport)) foo {
-  void bar() {}
-};
-void zed(foo *p) { p->bar(); }
Index: clang/test/CodeGenCXX/dllstorage-visibility.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllstorage-visibility.cpp
@@ -0,0 +1,26 @@
+/// dllimport and dllexport express non-hidden intention. Don't apply hidden 
visibility.
+
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-msvc -fdeclspec 
-fvisibility-inlines-hidden -o - %s | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-gnu -fdeclspec 
-fvisibility-inlines-hidden -o - %s | FileCheck %s --check-prefix=GNU
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-gnu -fdeclspec 
-fvisibility hidden -o - %s | FileCheck %s --check-prefix=GNU
+
+#define CONCAT2(x, y) x##y
+#define CONCAT(x, y) CONCAT2(x, y)
+#define USE(func) void CONCAT(use, __LINE__)() { func(); }
+
+// MSVC-DAG: declare dllimport void @"?bar@foo@@QEAAXXZ"(
+// GNU-DAG: define linkonce_odr hidden void @_ZN3foo3barEv(
+
+struct __attribute__((dllimport)) foo {
+  void bar() {}
+};
+void zed(foo *p) { p->bar(); }
+
+// MSVC-DAG: define dso_local dllexport void @"?exported@@YAXXZ"(
+// GNU-DAG: define dso_local dllexport void @_Z8exportedv(
+__attribute__((dllexport)) void exported() {}
+
+// MSVC-DAG: define weak_odr dso_local dllexport void 
@"?exported_inline@@YAXXZ"(
+// GNU-DAG: define weak_odr dso_local dllexport void @_Z15exported_inlinev(
+__declspec(dllexport) inline void exported_inline() {}
+USE(exported_inline)
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1099,7 +1099,7 @@
 
 void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
 const NamedDecl *D) const {
-  if (GV->hasDLLImportStorageClass())
+  if (GV->hasDLLExportStorageClass() || GV->hasDLLImportStorageClass())
 return;
   // Internal definitions always have default visibility.
   if (GV->hasLocalLinkage()) {


Index: clang/test/CodeGenCXX/hidden-dllimport.cpp
===
--- clang/test/CodeGenCXX/hidden-dllimport.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-pc-windows-msvc -emit-llvm -fvisibility-inlines-hidden -o - %s | FileCheck %s
-
-// We used to declare this hidden dllimport, which is contradictory.
-
-// CHECK: declare dllimport void @"?bar@foo@@QEAAXXZ"(%struct.foo* {{[^,]*}})
-
-struct __attribute__((dllimport)) foo {
-  void bar() {}
-};
-void zed(foo *p) { p->bar(); }
Index: clang/test/CodeGenCXX/dllstorage-visibility.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllstorage-visibility.cpp
@@ -0,0 +1,26 @@
+/// dllimport and dllexport express non-hidden intention. Don't apply hidden visibility.
+
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-msvc -fdeclspec -fvisibility-inlines-hidden -o - %s | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-gnu -fdeclspec -fvisibility-inlines-hidden -o - %s | FileCheck %s --check-prefix=GNU
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-gnu -fdeclspec -fvisibility hidden -o - %s | FileCheck %s --check-prefix=GNU
+
+#define CONCAT2(x, y) x##y
+#define CONCAT(x, y) CONCAT2(x, y)
+#define USE(func) void CONCAT(use, __LINE__)() { func(); }
+
+// MSVC-DAG: declare dllimport void @"?bar@foo@@QEAAXXZ"(
+// GNU-DAG: define linkonce_odr hidden void @_ZN3foo3barEv(
+
+struct __attribute__((dllimport)) foo {
+  void bar() {}
+};
+void zed(foo *p) { p->bar(); }
+
+// MSVC-DAG: define dso_local dllexport void @"?exported@@YAXXZ"(
+// GNU-DAG: define dso_local dllexport void @_Z8exportedv(
+__attribute__((dllexport)) void exported() {}
+
+// MSVC-DAG: define weak_odr d

[PATCH] D132550: Changes to code ownership in clang and clang-tidy

2022-09-02 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

LGTM


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

https://reviews.llvm.org/D132550

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


[PATCH] D133202: [Clang][CodeGen] Avoid __builtin_assume_aligned crash when the 1st arg is array type

2022-09-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Other than the one thing, this looks good.




Comment at: clang/lib/Sema/SemaChecking.cpp:7697
   // The alignment must be a constant integer.
-  Expr *Arg = TheCall->getArg(1);
+  Expr *SecondArg = TheCall->getArg(1);
 

This should be:

```
Expr *SecondArg = TheCall->getArg(1);
if (convertArgumentToType(*this, SecondArg, Context.getSizeType()))
  return true;
TheCall->setArg(1, SecondArg);

if (!SecondArg->isValueDependent()) {
  llvm::APSInt Result;
  
}
```

Test case is to pass a floating-point expression or something like that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133202

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


[PATCH] D131268: [HLSL] Generate buffer subscript operators

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

LGTM aside from a nit that was missed. Thanks for switching to static_cast, 
that makes me happier. :-)




Comment at: clang/lib/Sema/HLSLExternalSemaSource.cpp:109
+if (Template) {
+  if (const auto TTD = dyn_cast(
+  Template->getTemplateParameters()->getParam(0)))

Missed from the previous suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131268

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


[clang] a931edd - [docs] Regenerate clang/docs/ClangCommandLineReference.rst

2022-09-02 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-09-02T10:29:38-07:00
New Revision: a931eddd09145c340966db0561159a8e7cdb212e

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

LOG: [docs] Regenerate clang/docs/ClangCommandLineReference.rst

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 7f9ef3783f9d..370a7a327a81 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -76,10 +76,6 @@ Pass  to fatbinary invocation
 
 Pass  to the ptxas assembler
 
-.. option:: -Z
-
-.. option:: -a, --profile-blocks
-
 .. option:: -all\_load
 
 .. option:: -allowable\_client 
@@ -579,10 +575,6 @@ Print the library path for the currently used compiler 
runtime library ("libgcc.
 
 .. option:: -print-multi-lib, --print-multi-lib
 
-.. option:: -print-multiarch, --print-multiarch
-
-Print the multiarch target triple
-
 .. option:: -print-prog-name=, --print-prog-name=, 
--print-prog-name 
 
 Print the full program path of 
@@ -859,9 +851,9 @@ no effect during actions that do not perform compilation.
 
 Pass  to the assembler
 
-.. option:: -Xclang 
+.. option:: -Xclang , -Xclang=
 
-Pass  to the clang compiler
+Pass  to clang -cc1
 
 .. option:: -Xopenmp-target 
 
@@ -947,10 +939,6 @@ Inline suitable functions
 
 Inline functions which are (explicitly or implicitly) marked inline
 
-.. option:: -finline-max-stacksize=
-
-Suppress inlining of functions with a stacksize larger than  bytes.
-
 .. option:: -fno-legacy-pass-manager, -fexperimental-new-pass-manager
 
 .. option:: -fno-sanitize-ignorelist, -fno-sanitize-blacklist
@@ -1913,6 +1901,10 @@ Implicitly search the file system for module map files.
 
 .. option:: -fimplicit-modules, -fno-implicit-modules
 
+.. option:: -finline-max-stacksize=
+
+Suppress inlining of functions whose stack size exceeds the given value
+
 .. option:: -finput-charset=
 
 Specify the default character set for source files
@@ -2785,11 +2777,7 @@ Only instrument 1 of N groups
 
 Don't instrument functions with loops unless they also meet the minimum 
function size
 
-.. option:: -fxray-instruction-threshold
-
-.. program:: clang1
 .. option:: -fxray-instruction-threshold=
-.. program:: clang
 
 Sets the minimum function size to instrument with XRay
 
@@ -3205,6 +3193,10 @@ Not emit the visibility attribute for asm in AIX OS or 
give all symbols 'unspeci
 
 (integrated-as) Emit an object file which can be used with an incremental 
linker
 
+.. option:: -mindirect-branch-cs-prefix
+
+Add cs prefix to call and jmp to indirect thunk
+
 .. option:: -mios-version-min=, -miphoneos-version-min=
 
 Set iOS deployment target
@@ -4301,9 +4293,7 @@ Pass  to the linker
 
 Pass  to the offload linkers or the ones idenfied by -
 
-.. program:: clang1
 .. option:: -Z
-.. program:: clang
 
 .. option:: -b
 
@@ -4390,18 +4380,28 @@ CL.EXE COMPATIBILITY OPTIONS
 dxc compatibility options
 
 .. program:: clang4
+.. option:: --E, /E, -E
+.. program:: clang
+
+Entry point name
+
+.. program:: clang5
 .. option:: /T, -T
 .. program:: clang
 
 Set target profile.  must be 'ps_6_0', ' ps_6_1', ' ps_6_2', ' 
ps_6_3', ' ps_6_4', ' ps_6_5', ' ps_6_6', ' ps_6_7', 'vs_6_0', ' vs_6_1', ' 
vs_6_2', ' vs_6_3', ' vs_6_4', ' vs_6_5', ' vs_6_6', ' vs_6_7', 'gs_6_0', ' 
gs_6_1', ' gs_6_2', ' gs_6_3', ' gs_6_4', ' gs_6_5', ' gs_6_6', ' gs_6_7', 
'hs_6_0', ' hs_6_1', ' hs_6_2', ' hs_6_3', ' hs_6_4', ' hs_6_5', ' hs_6_6', ' 
hs_6_7', 'ds_6_0', ' ds_6_1', ' ds_6_2', ' ds_6_3', ' ds_6_4', ' ds_6_5', ' 
ds_6_6', ' ds_6_7', 'cs_6_0', ' cs_6_1', ' cs_6_2', ' cs_6_3', ' cs_6_4', ' 
cs_6_5', ' cs_6_6', ' cs_6_7', 'lib_6_3', ' lib_6_4', ' lib_6_5', ' lib_6_6', ' 
lib_6_7', ' lib_6_x', 'ms_6_5', ' ms_6_6', ' ms_6_7', 'as_6_5', ' as_6_6' or ' 
as_6_7'.
 
-.. program:: clang5
+.. program:: clang6
 .. option:: /emit-pristine-llvm, -emit-pristine-llvm, /fcgl, -fcgl
 .. program:: clang
 
 Emit pristine LLVM IR from the frontend by not running any LLVM passes at 
all.Same as -S + -emit-llvm + -disable-llvm-passes.
 
-.. program:: clang6
+.. option:: -hlsl-entry 
+
+Entry point name for hlsl
+
+.. program:: clang7
 .. option:: /hlsl-no-stdinc, -hlsl-no-stdinc
 .. program:: clang
 



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


[clang] 8899c3c - [docs] -fivisibility= allows protected and internal

2022-09-02 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-09-02T10:49:10-07:00
New Revision: 8899c3c4e15ea3681b0c423b44313163f5370abd

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

LOG: [docs] -fivisibility= allows protected and internal

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 370a7a327a816..141c1464638a5 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -2729,7 +2729,7 @@ The visibility for definitions without an explicit DLL 
export class \[-fvisibili
 
 .. option:: -fvisibility=
 
-Set the default symbol visibility for all global declarations.  must be 
'hidden' or 'default'.
+Set the default symbol visibility for all global definitions.  must be 
'default', 'protected', 'internal' or 'hidden'.
 
 .. option:: -fwasm-exceptions
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 1112e0187758e..9949f903ae6f9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2953,7 +2953,7 @@ def fvisibility_externs_nodllstorageclass_EQ : 
Joined<["-"], "fvisibility-extern
   MarshallingInfoVisibility, 
"HiddenVisibility">,
   ShouldParseIf;
 def fvisibility_EQ : Joined<["-"], "fvisibility=">, Group,
-  HelpText<"Set the default symbol visibility for all global declarations">, 
Values<"hidden,default">;
+  HelpText<"Set the default symbol visibility for all global definitions">, 
Values<"default,protected,internal,hidden">;
 defm visibility_inlines_hidden : BoolFOption<"visibility-inlines-hidden",
   LangOpts<"InlineVisibilityHidden">, DefaultFalse,
   PosFlag,



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


[PATCH] D133194: rewording note note_constexpr_invalid_cast

2022-09-02 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

I can't find any C tests that exercise this diagnostic. We should add a C test 
as well to confirm that we obtain the diagnostic we expect in a C context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133194

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


[PATCH] D130888: [Clang] Introduce -fexperimental-sanitize-metadata=

2022-09-02 Thread Marco Elver via Phabricator via cfe-commits
melver updated this revision to Diff 457637.
melver added a comment.

Don't split RUN lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130888

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/sanitize-metadata.c
  clang/test/Driver/fsanitize-metadata.c

Index: clang/test/Driver/fsanitize-metadata.c
===
--- /dev/null
+++ clang/test/Driver/fsanitize-metadata.c
@@ -0,0 +1,19 @@
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=all -fno-experimental-sanitize-metadata=all %s -### 2>&1 | FileCheck %s
+// CHECK-NOT: -fexperimental-sanitize-metadata
+
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=bad_arg %s -### 2>&1 | FileCheck -check-prefix=CHECK-INVALID %s
+// CHECK-INVALID: error: unsupported argument 'bad_arg' to option '-fexperimental-sanitize-metadata='
+
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=covered %s -### 2>&1 | FileCheck -check-prefix=CHECK-COVERED %s
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=atomics -fno-experimental-sanitize-metadata=atomics -fexperimental-sanitize-metadata=covered %s -### 2>&1 | FileCheck -check-prefix=CHECK-COVERED %s
+// CHECK-COVERED: "-fexperimental-sanitize-metadata=covered"
+// CHECK-COVERED-NOT: "-fexperimental-sanitize-metadata=atomics"
+
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=atomics %s -### 2>&1 | FileCheck -check-prefix=CHECK-ATOMICS %s
+// CHECK-ATOMICS: "-fexperimental-sanitize-metadata=atomics"
+
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=covered,atomics %s -### 2>&1 | FileCheck -check-prefix=CHECK-ALL %s
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=covered -fexperimental-sanitize-metadata=atomics %s -### 2>&1 | FileCheck -check-prefix=CHECK-ALL %s
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=all %s -### 2>&1 | FileCheck -check-prefix=CHECK-ALL %s
+// CHECK-ALL: "-fexperimental-sanitize-metadata=covered"
+// CHECK-ALL: "-fexperimental-sanitize-metadata=atomics"
Index: clang/test/CodeGen/sanitize-metadata.c
===
--- /dev/null
+++ clang/test/CodeGen/sanitize-metadata.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -O -fexperimental-sanitize-metadata=atomics -triple x86_64-gnu-linux -x c -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,ATOMICS
+// RUN: %clang_cc1 -O -fexperimental-sanitize-metadata=atomics -triple aarch64-gnu-linux -x c -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,ATOMICS
+
+int x, y;
+
+void empty() {
+// CHECK-NOT: define dso_local void @empty() {{.*}} !pcsections
+}
+
+int atomics() {
+// ATOMICS-LABEL: define dso_local i32 @atomics()
+// ATOMICS-SAME:  !pcsections ![[ATOMICS_COVERED:[0-9]+]]
+// ATOMICS-NEXT:  entry:
+// ATOMICS-NEXT:atomicrmw add {{.*}} !pcsections ![[ATOMIC_OP:[0-9]+]]
+// ATOMICS-NOT: load {{.*}} !pcsections
+  __atomic_fetch_add(&x, 1, __ATOMIC_RELAXED);
+  return y;
+}
+// ATOMICS-LABEL: __sanitizer_metadata_atomics.module_ctor
+// ATOMICS: call void @__sanitizer_metadata_atomics_add(i32 1, ptr @__start_sanmd_atomics, ptr @__stop_sanmd_atomics)
+// ATOMICS-LABEL: __sanitizer_metadata_atomics.module_dtor
+// ATOMICS: call void @__sanitizer_metadata_atomics_del(i32 1, ptr @__start_sanmd_atomics, ptr @__stop_sanmd_atomics)
+
+// CHECK-LABEL: __sanitizer_metadata_covered.module_ctor
+// CHECK: call void @__sanitizer_metadata_covered_add(i32 1, ptr @__start_sanmd_covered, ptr @__stop_sanmd_covered)
+// CHECK-LABEL: __sanitizer_metadata_covered.module_dtor
+// CHECK: call void @__sanitizer_metadata_covered_del(i32 1, ptr @__start_sanmd_covered, ptr @__stop_sanmd_covered)
+
+// ATOMICS: ![[ATOMICS_COVERED]] = !{!"sanmd_covered", ![[ATOMICS_COVERED_AUX:[0-9]+]]}
+// ATOMICS: ![[ATOMICS_COVERED_AUX]] = !{i32 1}
+// ATOMICS: ![[ATOMIC_OP]] = !{!"sanmd_atomics"}
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -100,6 +100,11 @@
   CoverageTraceStores = 1 << 17,
 };
 
+enum BinaryMetadataFeature {
+  BinaryMetadataCovered = 1 << 0,
+  BinaryMetadataAtomics = 1 << 1,
+};
+
 /// Parse a -fsanitize= or -fno-sanitize= argument's values, diagnosing any
 /// invalid components. Returns a SanitizerMask.
 static SanitizerMask parseArgValues(const Driver &D, const llvm::opt::Arg *A,
@@ -110,6 +115,11 @@
 static int parseCoverageFeatures(const Driver &D, const llvm::opt:

[PATCH] D131701: [CodeGen][ObjC] Call synthesized copy constructor/assignment operator functions in getter/setter functions of non-trivial C struct properties

2022-09-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Can we check for the right conditions when emitting the setter body and just 
deactivate the cleanup?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131701

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


[PATCH] D133202: [Clang][CodeGen] Avoid __builtin_assume_aligned crash when the 1st arg is array type

2022-09-02 Thread Lin Yurong via Phabricator via cfe-commits
yronglin updated this revision to Diff 457643.
yronglin added a comment.

Update patch with john's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133202

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/catch-alignment-assumption-array.c
  clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
  clang/test/Sema/builtin-assume-aligned.c

Index: clang/test/Sema/builtin-assume-aligned.c
===
--- clang/test/Sema/builtin-assume-aligned.c
+++ clang/test/Sema/builtin-assume-aligned.c
@@ -66,6 +66,11 @@
 }
 #endif
 
+int test13(int *a) {
+  a = (int *)__builtin_assume_aligned(a, 2 * 2.0); // expected-error {{argument to '__builtin_assume_aligned' must be a constant integer}}
+  return a[0];
+}
+
 void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
 int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // no-warning
Index: clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
===
--- clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
+++ clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
@@ -26,3 +26,9 @@
 void *ignore_volatiles(volatile void * x) {
   return __builtin_assume_aligned(x, 1);
 }
+
+// CHECK-LABEL: ignore_array_volatiles
+void *ignore_array_volatiles() {
+  volatile int arr[] = {1};
+  return __builtin_assume_aligned(arr, 4);
+}
Index: clang/test/CodeGen/catch-alignment-assumption-array.c
===
--- /dev/null
+++ clang/test/CodeGen/catch-alignment-assumption-array.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -fsanitize=alignment -fno-sanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER,CHECK-SANITIZE-UNREACHABLE
+// RUN: %clang_cc1 -no-opaque-pointers -fsanitize=alignment -fsanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-RECOVER
+// RUN: %clang_cc1 -no-opaque-pointers -fsanitize=alignment -fsanitize-trap=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-TRAP,CHECK-SANITIZE-UNREACHABLE
+
+// CHECK-SANITIZE-ANYRECOVER: @[[CHAR:.*]] = {{.*}} c"'char *'\00" }
+// CHECK-SANITIZE-ANYRECOVER: @[[ALIGNMENT_ASSUMPTION:.*]] = {{.*}}, i32 31, i32 35 }, {{.*}}* @[[CHAR]] }
+
+void *caller(void) {
+  char str[] = "";
+  // CHECK:   define{{.*}}
+  // CHECK-NEXT:  entry:
+  // CHECK-NEXT:%[[STR:.*]] = alloca [1 x i8], align 1
+  // CHECK-NEXT:%[[BITCAST:.*]] = bitcast [1 x i8]* %[[STR]] to i8*
+  // CHECK-NEXT:call void @llvm.memset.p0i8.i64(i8* align 1 %[[BITCAST]], i8 0, i64 1, i1 false)
+  // CHECK-NEXT:%[[ARRAYDECAY:.*]] = getelementptr inbounds [1 x i8], [1 x i8]* %[[STR]], i64 0, i64 0
+  // CHECK-SANITIZE-NEXT:   %[[PTRINT:.*]] = ptrtoint i8* %[[ARRAYDECAY]] to i64
+  // CHECK-SANITIZE-NEXT:   %[[MASKEDPTR:.*]] = and i64 %[[PTRINT]], 0
+  // CHECK-SANITIZE-NEXT:   %[[MASKCOND:.*]] = icmp eq i64 %[[MASKEDPTR]], 0
+  // CHECK-SANITIZE-NEXT:   %[[PTRINT_DUP:.*]] = ptrtoint i8* %[[ARRAYDECAY]] to i64, !nosanitize
+  // CHECK-SANITIZE-NEXT:   br i1 %[[MASKCOND]], label %[[CONT:.*]], label %[[HANDLER_ALIGNMENT_ASSUMPTION:[^,]+]],{{.*}} !nosanitize
+  // CHECK-SANITIZE:  [[HANDLER_ALIGNMENT_ASSUMPTION]]:
+  // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_alignment_assumption_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 1, i64 0){{.*}}, !nosanitize
+  // CHECK-SANITIZE-RECOVER-NEXT:   call void @__ubsan_handle_alignment_assumption(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 1, i64 0){{.*}}, !nosanitize

[PATCH] D133202: [Clang][CodeGen] Avoid __builtin_assume_aligned crash when the 1st arg is array type

2022-09-02 Thread Lin Yurong via Phabricator via cfe-commits
yronglin added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:7697
   // The alignment must be a constant integer.
-  Expr *Arg = TheCall->getArg(1);
+  Expr *SecondArg = TheCall->getArg(1);
 

rjmccall wrote:
> This should be:
> 
> ```
> Expr *SecondArg = TheCall->getArg(1);
> if (convertArgumentToType(*this, SecondArg, Context.getSizeType()))
>   return true;
> TheCall->setArg(1, SecondArg);
> 
> if (!SecondArg->isValueDependent()) {
>   llvm::APSInt Result;
>   
> }
> ```
> 
> Test case is to pass a floating-point expression or something like that.
+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133202

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


[PATCH] D133202: [Clang][CodeGen] Avoid __builtin_assume_aligned crash when the 1st arg is array type

2022-09-02 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133202

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


[PATCH] D133202: [Clang][CodeGen] Avoid __builtin_assume_aligned crash when the 1st arg is array type

2022-09-02 Thread Lin Yurong via Phabricator via cfe-commits
yronglin added a comment.

In D133202#3767414 , @rjmccall wrote:

> Thanks, LGTM

Thanks for your review John, but I don’t have commit access, can you land this 
patch for me? Please use "yronglin " to commit the 
change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133202

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


[PATCH] D125419: [Arm64EC 7/?] clang side of Arm64EC varargs ABI.

2022-09-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:2457
+/*IsVectorCall=*/false, /*IsRegCall=*/false);
+  }
+

Hmm.  Doesn't EC ABI lowering need to preserve this same state, or else you'll 
get incompatibilities when you exhaust SSE registers?

Should you just be calling over to this at a higher-level point, like in 
`computeInfo`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125419

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


[PATCH] D133158: [NFC] Make MultiplexExternalSemaSource own sources

2022-09-02 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 457651.
beanz added a comment.
Herald added a project: clang-tools-extra.

Updating with changes based on review feedback, and fixups for clang-tools-extra


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133158

Files:
  clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
  clang/include/clang/Sema/MultiplexExternalSemaSource.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/ChainedIncludesSource.cpp
  clang/lib/Sema/MultiplexExternalSemaSource.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/unittests/Sema/ExternalSemaSourceTest.cpp

Index: clang/unittests/Sema/ExternalSemaSourceTest.cpp
===
--- clang/unittests/Sema/ExternalSemaSourceTest.cpp
+++ clang/unittests/Sema/ExternalSemaSourceTest.cpp
@@ -219,6 +219,8 @@
   void PushWatcher(DiagnosticWatcher *Watcher) { Watchers.push_back(Watcher); }
 };
 
+using llvm::makeIntrusiveRefCnt;
+
 // Make sure that the DiagnosticWatcher is not miscounting.
 TEST(ExternalSemaSource, DiagCheck) {
   auto Installer = std::make_unique();
@@ -234,14 +236,14 @@
 // instead of the usual suggestion we would use above.
 TEST(ExternalSemaSource, ExternalTypoCorrectionPrioritized) {
   auto Installer = std::make_unique();
-  NamespaceTypoProvider Provider("AAB", "BBB");
+  auto Provider = makeIntrusiveRefCnt("AAB", "BBB");
   DiagnosticWatcher Watcher("AAB", "BBB");
-  Installer->PushSource(&Provider);
+  Installer->PushSource(Provider.get());
   Installer->PushWatcher(&Watcher);
   std::vector Args(1, "-std=c++11");
   ASSERT_TRUE(clang::tooling::runToolOnCodeWithArgs(
   std::move(Installer), "namespace AAA { } using namespace AAB;", Args));
-  ASSERT_LE(0, Provider.CallCount);
+  ASSERT_LE(0, Provider->CallCount);
   ASSERT_EQ(1, Watcher.SeenCount);
 }
 
@@ -249,34 +251,34 @@
 // ExternalSemaSource.
 TEST(ExternalSemaSource, ExternalTypoCorrectionOrdering) {
   auto Installer = std::make_unique();
-  NamespaceTypoProvider First("XXX", "BBB");
-  NamespaceTypoProvider Second("AAB", "CCC");
-  NamespaceTypoProvider Third("AAB", "DDD");
+  auto First = makeIntrusiveRefCnt("XXX", "BBB");
+  auto Second = makeIntrusiveRefCnt("AAB", "CCC");
+  auto Third = makeIntrusiveRefCnt("AAB", "DDD");
   DiagnosticWatcher Watcher("AAB", "CCC");
-  Installer->PushSource(&First);
-  Installer->PushSource(&Second);
-  Installer->PushSource(&Third);
+  Installer->PushSource(First.get());
+  Installer->PushSource(Second.get());
+  Installer->PushSource(Third.get());
   Installer->PushWatcher(&Watcher);
   std::vector Args(1, "-std=c++11");
   ASSERT_TRUE(clang::tooling::runToolOnCodeWithArgs(
   std::move(Installer), "namespace AAA { } using namespace AAB;", Args));
-  ASSERT_LE(1, First.CallCount);
-  ASSERT_LE(1, Second.CallCount);
-  ASSERT_EQ(0, Third.CallCount);
+  ASSERT_LE(1, First->CallCount);
+  ASSERT_LE(1, Second->CallCount);
+  ASSERT_EQ(0, Third->CallCount);
   ASSERT_EQ(1, Watcher.SeenCount);
 }
 
 TEST(ExternalSemaSource, ExternalDelayedTypoCorrection) {
   auto Installer = std::make_unique();
-  FunctionTypoProvider Provider("aaa", "bbb");
+  auto Provider = makeIntrusiveRefCnt("aaa", "bbb");
   DiagnosticWatcher Watcher("aaa", "bbb");
-  Installer->PushSource(&Provider);
+  Installer->PushSource(Provider.get());
   Installer->PushWatcher(&Watcher);
   std::vector Args(1, "-std=c++11");
   ASSERT_TRUE(clang::tooling::runToolOnCodeWithArgs(
   std::move(Installer), "namespace AAA { } void foo() { AAA::aaa(); }",
   Args));
-  ASSERT_LE(0, Provider.CallCount);
+  ASSERT_LE(0, Provider->CallCount);
   ASSERT_EQ(1, Watcher.SeenCount);
 }
 
@@ -284,8 +286,8 @@
 // solve the problem.
 TEST(ExternalSemaSource, TryOtherTacticsBeforeDiagnosing) {
   auto Installer = std::make_unique();
-  CompleteTypeDiagnoser Diagnoser(false);
-  Installer->PushSource(&Diagnoser);
+  auto Diagnoser = makeIntrusiveRefCnt(false);
+  Installer->PushSource(Diagnoser.get());
   std::vector Args(1, "-std=c++11");
   // This code hits the class template specialization/class member of a class
   // template specialization checks in Sema::RequireCompleteTypeImpl.
@@ -293,26 +295,26 @@
   std::move(Installer),
   "template  struct S { class C { }; }; S::C SCInst;",
   Args));
-  ASSERT_EQ(0, Diagnoser.CallCount);
+  ASSERT_EQ(0, Diagnoser->CallCount);
 }
 
 // The first ExternalSemaSource where MaybeDiagnoseMissingCompleteType returns
 // true should be the last one called.
 TEST(ExternalSemaSource, FirstDiagnoserTaken) {
   auto Installer = std::make_unique();
-  CompleteTypeDiagnoser First(false);
-  CompleteTypeDiagnoser Second(true);
-  CompleteTypeDiagnoser Third(true);
-  Installer->PushSource(&First);
-  Installer->PushSource(&Second);
-  Installer->PushSource(&Third);
+  auto First = makeIntrusiveRefCnt(false);
+  auto Second = makeIntrusiveRefCnt(true);
+  auto Thir

[PATCH] D132975: [clang][BOLT] Add clang-bolt target

2022-09-02 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D132975#3765541 , @Amir wrote:

> Hi Petr, thank you for your comments!
>
> In D132975#3763264 , @phosek wrote:
>
>> This was already on my list of build system features I'd like to implement 
>> and I'm glad someone else is already looking into it, thank you! I have two 
>> high level comments about your approach.
>>
>> The first one is related to the use of Clang build as the training data. I 
>> think that Clang build is both unnecessarily heavyweight, but also not 
>> particularly representative of typical workloads (most Clang users don't use 
>> it to build Clang). Ideally, we would give vendors the flexibility to supply 
>> their own training data. I'd prefer reusing the existing perf-training 
>>  
>> setup to do so. In fact, I'd imagine most vendors would likely use the same 
>> training data for both PGO and BOLT and that use case should be supported.
>
> Agree that perf-training might be useful for vendors. I'll try to enable it 
> in a follow-up diff.
>
> Please note that the target for profile collection is not hardcoded to clang, 
> it's configurable via CLANG_BOLT_INSTRUMENT_PROJECTS and 
> CLANG_BOLT_INSTRUMENT_TARGETS. Right now it's the llvm/not tool (the smallest 
> possible).
>
>> The second one is related to applicability. I don't think this mechanism 
>> should be limited only to Clang. Ideally, it should be possible to 
>> instrument and optimize other tools in the toolchain distribution as well; 
>> LLD is likely going to be the most common one after Clang.
>
> I thought about it, and I think we can accommodate optimizing arbitrary 
> targets by providing an interface to instrument specified target(s) via 
> `-DBOLT_INSTRUMENT_TARGETS`. For each of the target binaries, CMake would 
> create targets like `bolt-instrument-$TARGET` and `bolt-optimize-$TARGET`. 
> For `bolt-instrument-$TARGET`, BOLT would instrument the target binary, 
> placing instrumented binary next to the original one (e.g. 
> `$target-bolt.inst`). End users would use those instrumented binaries on 
> representative workloads to collect the profile. For `bolt-optimize-$TARGET`, 
> BOLT would post-process the profiles and create optimized binary 
> (`$target-bolt`).
>
> I appreciate your suggestions. Do you think we can move incrementally from 
> this diff towards more general uses in follow-up diffs?

That's fine with me. Do you envision replacing the use of LLVM build for 
training with perf-training or supporting both? I'd lean towards the former for 
simplicity but would be curious to hear about your use cases and plans.




Comment at: clang/CMakeLists.txt:881
 
+if (CLANG_BOLT_INSTRUMENT)
+  set(CLANG_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)

We could consider moving this block to a separate file which would then be 
included here since this file is already getting pretty large and the logic in 
this block is self-contained. That could be done in a follow up change though.



Comment at: clang/CMakeLists.txt:955
+WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+COMMAND sh -c "$ prof.fdata.* -o prof.fdata"
+COMMENT "Preparing BOLT profile"

I'd like to avoid dependency on shell to make this compatible with Windows. Can 
we move this logic into a Python script akin to 
https://github.com/llvm/llvm-project/blob/607f14d9605da801034e7119c297c3f58ebce603/clang/utils/perf-training/perf-helper.py?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132975

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


[PATCH] D132829: [clang][Interp] Handle ImplictValueInitExprs

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!




Comment at: clang/test/AST/Interp/arrays.cpp:13
+///   currently evaluate other parts of it.
+#if 0
+struct fred {

I wish we could find some solution that didn't require this so that the test 
case breaks when we do get around to implementing support for the other bits. 
But this is at least a good start!


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

https://reviews.llvm.org/D132829

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


[PATCH] D133158: [NFC] Make MultiplexExternalSemaSource own sources

2022-09-02 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

I built LLDB and ran its tests. I see no additional failures after applying my 
change, but LLDB's tests do not execute successfully on my local system (22 
failures).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133158

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


[clang] 10194a5 - [HLSL] Restrict to supported targets

2022-09-02 Thread Chris Bieneman via cfe-commits

Author: Chris Bieneman
Date: 2022-09-02T13:36:23-05:00
New Revision: 10194a51a9d304ab9f68432f244749c672f9012a

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

LOG: [HLSL] Restrict to supported targets

Someday we would like to support HLSL on a wider range of targets, but
today targeting anything other than `dxil` is likly to cause lots of
headaches. This adds an error and tests to validate that the expected
target is `dxil-?-shadermodel`.

We will continue to do a best effort to ensure the code we write makes
it easy to support other targets (like SPIR-V), but this error will
prevent users from hitting frustrating errors for unsupported cases.

Reviewed By: jcranmer-intel, Anastasia

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

Added: 
clang/test/Driver/hlsl-lang-targets.hlsl

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGenHLSL/validator_version.hlsl
clang/test/Preprocessor/predefined-macros-hlsl.hlsl

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 63be59082e7e0..df85139c3ca22 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -666,6 +666,8 @@ def err_drv_invalid_directx_shader_module : Error<
   "invalid profile : %0">;
 def err_drv_dxc_missing_target_profile : Error<
   "target profile option (-T) is missing">;
+def err_drv_hlsl_unsupported_target : Error<
+  "HLSL code generation is unsupported for target '%0'">;
 
 def err_drv_invalid_range_dxil_validator_version : Error<
   "invalid validator version : %0\n"

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 574514bdd0b0a..9ac522adfd9a9 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4107,6 +4107,14 @@ bool CompilerInvocation::ParseLangArgs(LangOptions 
&Opts, ArgList &Args,
   if (const Arg *A = Args.getLastArg(OPT_frandomize_layout_seed_EQ))
 Opts.RandstructSeed = A->getValue(0);
 
+  // Validate options for HLSL
+  if (Opts.HLSL) {
+bool SupportedTarget = T.getArch() == llvm::Triple::dxil &&
+   T.getOS() == llvm::Triple::ShaderModel;
+if (!SupportedTarget)
+  Diags.Report(diag::err_drv_hlsl_unsupported_target) << T.str();
+  }
+
   return Diags.getNumErrors() == NumErrorsBefore;
 }
 

diff  --git a/clang/test/CodeGenHLSL/validator_version.hlsl 
b/clang/test/CodeGenHLSL/validator_version.hlsl
index 426918a7221c4..0d2cbb96dbe48 100644
--- a/clang/test/CodeGenHLSL/validator_version.hlsl
+++ b/clang/test/CodeGenHLSL/validator_version.hlsl
@@ -1,5 +1,7 @@
 // RUN: %clang -cc1 -S -triple dxil-pc-shadermodel6.3-library -S -emit-llvm 
-xhlsl -validator-version 1.1 -o - %s | FileCheck %s
-// RUN: %clang -cc1 -S -triple spirv32 -S -emit-llvm -xhlsl -validator-version 
1.1 -o - %s | FileCheck %s --check-prefix=NOT_DXIL
+
+// FIXME:The following line should work once SPIR-V support for HLSL is added.
+// DISABLED: %clang -cc1 -S -triple spirv32 -S -emit-llvm -xhlsl 
-validator-version 1.1 -o - %s | FileCheck %s --check-prefix=NOT_DXIL
 
 // CHECK:!dx.valver = !{![[valver:[0-9]+]]}
 // CHECK:![[valver]] = !{i32 1, i32 1}

diff  --git a/clang/test/Driver/hlsl-lang-targets.hlsl 
b/clang/test/Driver/hlsl-lang-targets.hlsl
new file mode 100644
index 0..a757e2a3cdf74
--- /dev/null
+++ b/clang/test/Driver/hlsl-lang-targets.hlsl
@@ -0,0 +1,14 @@
+// RUN: not %clang -target x86_64-unknown-unknown %s 2>&1 | FileCheck %s 
--check-prefix=X86
+// RUN: not %clang -target dxil-unknown-unknown %s 2>&1 | FileCheck %s 
--check-prefix=DXIL
+// RUN: not %clang -target x86_64-unknown-shadermodel %s 2>&1 | FileCheck %s 
--check-prefix=SM
+// RUN: not %clang -target spirv64-unknown-unknown %s 2>&1 | FileCheck %s 
--check-prefix=SPIRV
+
+
+// A completely unsupported target...
+// X86: error: HLSL code generation is unsupported for target 
'x86_64-unknown-unknown'
+
+// Poorly specified targets
+// DXIL: error: HLSL code generation is unsupported for target 
'dxil-unknown-unknown'
+// SM: error: HLSL code generation is unsupported for target 
'x86_64-unknown-shadermodel'
+
+// FIXME// SPIRV: error: HLSL code generation is unsupported for target 
'spirv64-unknown-unknown'

diff  --git a/clang/test/Preprocessor/predefined-macros-hlsl.hlsl 
b/clang/test/Preprocessor/predefined-macros-hlsl.hlsl
index 03239fdab18f2..251362cd03c0f 100644
--- a/clang/test/Preprocessor/predefined-macros-hlsl.hlsl
+++ b/clang/test/Preprocessor/predefined-macros-hlsl.hlsl
@@ -29,20 +29,20 @@
 // PIXEL: #define __SHADER_TARGET_STAGE 0
 // VERTEX: #define _

[PATCH] D132056: [HLSL] Restrict to supported targets

2022-09-02 Thread Chris Bieneman 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 rG10194a51a9d3: [HLSL] Restrict to supported targets (authored 
by beanz).

Changed prior to commit:
  https://reviews.llvm.org/D132056?vs=456746&id=457655#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132056

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenHLSL/validator_version.hlsl
  clang/test/Driver/hlsl-lang-targets.hlsl
  clang/test/Preprocessor/predefined-macros-hlsl.hlsl


Index: clang/test/Preprocessor/predefined-macros-hlsl.hlsl
===
--- clang/test/Preprocessor/predefined-macros-hlsl.hlsl
+++ clang/test/Preprocessor/predefined-macros-hlsl.hlsl
@@ -29,20 +29,20 @@
 // PIXEL: #define __SHADER_TARGET_STAGE 0
 // VERTEX: #define __SHADER_TARGET_STAGE 1
 
-// RUN: %clang_cc1 %s -E -dM -o - -std=hlsl2015 | FileCheck -match-full-lines 
%s --check-prefixes=STD2015
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library %s -E -dM -o - -x 
hlsl -std=hlsl2015 | FileCheck -match-full-lines %s --check-prefixes=STD2015
 // STD2015: #define __HLSL_VERSION 2015
 
-// RUN: %clang_cc1 %s -E -dM -o - -std=hlsl2016 | FileCheck -match-full-lines 
%s --check-prefixes=STD2016
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library %s -E -dM -o - -x 
hlsl -std=hlsl2016 | FileCheck -match-full-lines %s --check-prefixes=STD2016
 // STD2016: #define __HLSL_VERSION 2016
 
-// RUN: %clang_cc1 %s -E -dM -o - -std=hlsl2017 | FileCheck -match-full-lines 
%s --check-prefixes=STD2017
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library %s -E -dM -o - -x 
hlsl -std=hlsl2017 | FileCheck -match-full-lines %s --check-prefixes=STD2017
 // STD2017: #define __HLSL_VERSION 2017
 
-// RUN: %clang_cc1 %s -E -dM -o - -std=hlsl2018 | FileCheck -match-full-lines 
%s --check-prefixes=STD2018
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library %s -E -dM -o - -x 
hlsl -std=hlsl2018 | FileCheck -match-full-lines %s --check-prefixes=STD2018
 // STD2018: #define __HLSL_VERSION 2018
 
-// RUN: %clang_cc1 %s -E -dM -o - -std=hlsl2021 | FileCheck -match-full-lines 
%s --check-prefixes=STD2021
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library %s -E -dM -o - -x 
hlsl -std=hlsl2021 | FileCheck -match-full-lines %s --check-prefixes=STD2021
 // STD2021: #define __HLSL_VERSION 2021
 
-// RUN: %clang_cc1 %s -E -dM -o - -std=hlsl202x | FileCheck -match-full-lines 
%s --check-prefixes=STD202x
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library %s -E -dM -o - -x 
hlsl -std=hlsl202x | FileCheck -match-full-lines %s --check-prefixes=STD202x
 // STD202x: #define __HLSL_VERSION 2029
Index: clang/test/Driver/hlsl-lang-targets.hlsl
===
--- /dev/null
+++ clang/test/Driver/hlsl-lang-targets.hlsl
@@ -0,0 +1,14 @@
+// RUN: not %clang -target x86_64-unknown-unknown %s 2>&1 | FileCheck %s 
--check-prefix=X86
+// RUN: not %clang -target dxil-unknown-unknown %s 2>&1 | FileCheck %s 
--check-prefix=DXIL
+// RUN: not %clang -target x86_64-unknown-shadermodel %s 2>&1 | FileCheck %s 
--check-prefix=SM
+// RUN: not %clang -target spirv64-unknown-unknown %s 2>&1 | FileCheck %s 
--check-prefix=SPIRV
+
+
+// A completely unsupported target...
+// X86: error: HLSL code generation is unsupported for target 
'x86_64-unknown-unknown'
+
+// Poorly specified targets
+// DXIL: error: HLSL code generation is unsupported for target 
'dxil-unknown-unknown'
+// SM: error: HLSL code generation is unsupported for target 
'x86_64-unknown-shadermodel'
+
+// FIXME// SPIRV: error: HLSL code generation is unsupported for target 
'spirv64-unknown-unknown'
Index: clang/test/CodeGenHLSL/validator_version.hlsl
===
--- clang/test/CodeGenHLSL/validator_version.hlsl
+++ clang/test/CodeGenHLSL/validator_version.hlsl
@@ -1,5 +1,7 @@
 // RUN: %clang -cc1 -S -triple dxil-pc-shadermodel6.3-library -S -emit-llvm 
-xhlsl -validator-version 1.1 -o - %s | FileCheck %s
-// RUN: %clang -cc1 -S -triple spirv32 -S -emit-llvm -xhlsl -validator-version 
1.1 -o - %s | FileCheck %s --check-prefix=NOT_DXIL
+
+// FIXME:The following line should work once SPIR-V support for HLSL is added.
+// DISABLED: %clang -cc1 -S -triple spirv32 -S -emit-llvm -xhlsl 
-validator-version 1.1 -o - %s | FileCheck %s --check-prefix=NOT_DXIL
 
 // CHECK:!dx.valver = !{![[valver:[0-9]+]]}
 // CHECK:![[valver]] = !{i32 1, i32 1}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4107,6 +4107,14 @@
   if (const Arg *A = Args.getLastArg(OPT_frandomize_layout_se

[PATCH] D133191: Driver test: remove `REQUIRES: x86-registered-target` and set `--sysroot=""` to support clang with `DEFAULT_SYSROOT`.

2022-09-02 Thread Warren Ristow via Phabricator via cfe-commits
wristow accepted this revision.
wristow added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133191

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


[clang] 1491282 - [clang] Change cc1 -fvisibility's canonical spelling to -fvisibility=

2022-09-02 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-09-02T11:49:38-07:00
New Revision: 1491282165bfb87b15bd806ab53b3e9910ee7b29

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

LOG: [clang] Change cc1 -fvisibility's canonical spelling to -fvisibility=

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/HIPAMD.cpp
clang/lib/Driver/ToolChains/HIPSPV.cpp
clang/test/CodeGenCXX/visibility-ms-compat.cpp
clang/test/Driver/amdgpu-visibility.cl
clang/test/Driver/clang-translation.c
clang/test/Driver/hip-rdc-device-only.hip
clang/test/Driver/hip-toolchain-no-rdc.hip
clang/test/Driver/hip-toolchain-rdc-separate.hip
clang/test/Driver/hip-toolchain-rdc.hip
clang/test/Driver/hipspv-toolchain-rdc.hip
clang/test/Driver/visibility.cpp
clang/test/Driver/wasm-toolchain.c
clang/test/Driver/wasm-toolchain.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9949f903ae6f9..6d08a27c60037 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2952,8 +2952,9 @@ def fvisibility_externs_nodllstorageclass_EQ : 
Joined<["-"], "fvisibility-extern
   HelpText<"The visibility for external declarations without an explicit DLL 
dllstorageclass [-fvisibility-from-dllstorageclass]">,
   MarshallingInfoVisibility, 
"HiddenVisibility">,
   ShouldParseIf;
-def fvisibility_EQ : Joined<["-"], "fvisibility=">, Group,
-  HelpText<"Set the default symbol visibility for all global definitions">, 
Values<"default,protected,internal,hidden">;
+def fvisibility_EQ : Joined<["-"], "fvisibility=">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Set the default symbol visibility for all global definitions">,
+  MarshallingInfoVisibility, 
"DefaultVisibility">;
 defm visibility_inlines_hidden : BoolFOption<"visibility-inlines-hidden",
   LangOpts<"InlineVisibilityHidden">, DefaultFalse,
   PosFlag,
@@ -6065,12 +6066,10 @@ def stack_protector : Separate<["-"], 
"stack-protector">,
 def stack_protector_buffer_size : Separate<["-"], 
"stack-protector-buffer-size">,
   HelpText<"Lower bound for a buffer to be considered for stack protection">,
   MarshallingInfoInt, "8">;
-def fvisibility : Separate<["-"], "fvisibility">,
-  HelpText<"Default type and symbol visibility">,
-  MarshallingInfoVisibility, 
"DefaultVisibility">;
-def ftype_visibility : Separate<["-"], "ftype-visibility">,
+def : Separate<["-"], "fvisibility">, Alias;
+def ftype_visibility : Joined<["-"], "ftype-visibility=">,
   HelpText<"Default type visibility">,
-  MarshallingInfoVisibility, 
fvisibility.KeyPath>;
+  MarshallingInfoVisibility, 
fvisibility_EQ.KeyPath>;
 def fapply_global_visibility_to_externs : Flag<["-"], 
"fapply-global-visibility-to-externs">,
   HelpText<"Apply global symbol visibility to external declarations without an 
explicit visibility">,
   MarshallingInfoFlag>;

diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 89f8e482ded6f..6246568710916 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -707,8 +707,7 @@ void AMDGPUToolChain::addClangTargetOptions(
   // supported for the foreseeable future.
   if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
  options::OPT_fvisibility_ms_compat)) {
-CC1Args.push_back("-fvisibility");
-CC1Args.push_back("hidden");
+CC1Args.push_back("-fvisibility=hidden");
 CC1Args.push_back("-fapply-global-visibility-to-externs");
   }
 }

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index eb7ad39d7edc7..2dd9ac01b3ef9 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2386,10 +2386,8 @@ void Clang::AddWebAssemblyTargetArgs(const ArgList &Args,
  ArgStringList &CmdArgs) const {
   // Default to "hidden" visibility.
   if (!Args.hasArg(options::OPT_fvisibility_EQ,
-   options::OPT_fvisibility_ms_compat)) {
-CmdArgs.push_back("-fvisibility");
-CmdArgs.push_back("hidden");
-  }
+   options::OPT_fvisibility_ms_compat))
+CmdArgs.push_back("-fvisibility=hidden");
 }
 
 void Clang::AddVETargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const 
{
@@ -5982,21 +5980,17 @@ void Clang::ConstructJob(Compilation &C, const 
JobAction &JA,
   if (const Arg *A = Args.getLastArg(options::OPT_fvisibility_EQ,
  options::OPT_fvisibility_ms_compat)) {
 if (A->getOption().matches(options::OPT_fvisibility_EQ)) {
-  CmdArgs.push_back

[PATCH] D132727: [clang][Interp] Implement array initializers and subscript expressions

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:277
+template 
+bool ByteCodeExprGen::VisitConstantExpr (const ConstantExpr *E) {
+  // TODO: Check if the ConstantExpr already has a value set and if so,





Comment at: clang/lib/AST/Interp/ByteCodeStmtGen.cpp:246
 
-auto Off = this->allocateLocalPrimitive(VD, *T, DT.isConstQualified());
+auto Offset =
+this->allocateLocalPrimitive(VD, *T, VD->getType().isConstQualified());





Comment at: clang/lib/AST/Interp/ByteCodeStmtGen.cpp:256
+return this->emitSetLocal(*T, Offset, VD);
   } else {
 // Composite types - allocate storage and initialize it.

You can drop this `else` because of the preceding unconditional `return`.



Comment at: clang/lib/AST/Interp/ByteCodeStmtGen.cpp:258
 // Composite types - allocate storage and initialize it.
-if (auto Off = this->allocateLocal(VD)) {
-  return this->visitLocalInitializer(VD->getInit(), *Off);
-} else {
+if (auto Offset = this->allocateLocal(VD))
+  return this->visitLocalInitializer(VD->getInit(), *Offset);





Comment at: clang/lib/AST/Interp/ByteCodeStmtGen.cpp:260
+  return this->visitLocalInitializer(VD->getInit(), *Offset);
+else
   return this->bail(VD);

You should drop this `else` as well.



Comment at: clang/lib/AST/Interp/Pointer.cpp:158
+
+  if (Desc->isArray() || Desc->isPrimitiveArray()) {
 if (!Pointee->IsStatic) {

`isArray()` already covers `isPrimitiveArray()` so this change looks 
unnecessary.


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

https://reviews.llvm.org/D132727

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


[PATCH] D133087: [clang-format][NFC][Docs] fix wrong example of warping class definitions

2022-09-02 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.

Thanks.


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

https://reviews.llvm.org/D133087

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


[clang] 5b5329b - [NFC] Make MultiplexExternalSemaSource own sources

2022-09-02 Thread Chris Bieneman via cfe-commits

Author: Chris Bieneman
Date: 2022-09-02T13:57:39-05:00
New Revision: 5b5329bd41ba977459fcd7abb7cf438fd98c98e0

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

LOG: [NFC] Make MultiplexExternalSemaSource own sources

This change refactors the MuiltiplexExternalSemaSource to take ownership
of the underlying sources. As a result it makes a larger cleanup of
external source ownership in Sema and the ChainedIncludesSource.

Reviewed By: aaron.ballman, aprantl

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

Added: 


Modified: 
clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
clang/include/clang/Sema/MultiplexExternalSemaSource.h
clang/include/clang/Sema/Sema.h
clang/lib/Frontend/ChainedIncludesSource.cpp
clang/lib/Sema/MultiplexExternalSemaSource.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/unittests/Sema/ExternalSemaSourceTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp 
b/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
index 2af1f622aa92f..45fc15619ecab 100644
--- a/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
+++ b/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
@@ -27,13 +27,14 @@ namespace {
 class Action : public clang::ASTFrontendAction {
 public:
   explicit Action(SymbolIndexManager &SymbolIndexMgr, bool 
MinimizeIncludePaths)
-  : SemaSource(SymbolIndexMgr, MinimizeIncludePaths,
-   /*GenerateDiagnostics=*/false) {}
+  : SemaSource(new IncludeFixerSemaSource(SymbolIndexMgr,
+  MinimizeIncludePaths,
+  /*GenerateDiagnostics=*/false)) 
{}
 
   std::unique_ptr
   CreateASTConsumer(clang::CompilerInstance &Compiler,
 StringRef InFile) override {
-SemaSource.setFilePath(InFile);
+SemaSource->setFilePath(InFile);
 return std::make_unique();
   }
 
@@ -51,8 +52,8 @@ class Action : public clang::ASTFrontendAction {
   CompletionConsumer = &Compiler->getCodeCompletionConsumer();
 
 Compiler->createSema(getTranslationUnitKind(), CompletionConsumer);
-SemaSource.setCompilerInstance(Compiler);
-Compiler->getSema().addExternalSource(&SemaSource);
+SemaSource->setCompilerInstance(Compiler);
+Compiler->getSema().addExternalSource(SemaSource.get());
 
 clang::ParseAST(Compiler->getSema(), Compiler->getFrontendOpts().ShowStats,
 Compiler->getFrontendOpts().SkipFunctionBodies);
@@ -61,12 +62,12 @@ class Action : public clang::ASTFrontendAction {
   IncludeFixerContext
   getIncludeFixerContext(const clang::SourceManager &SourceManager,
  clang::HeaderSearch &HeaderSearch) const {
-return SemaSource.getIncludeFixerContext(SourceManager, HeaderSearch,
- SemaSource.getMatchedSymbols());
+return SemaSource->getIncludeFixerContext(SourceManager, HeaderSearch,
+  SemaSource->getMatchedSymbols());
   }
 
 private:
-  IncludeFixerSemaSource SemaSource;
+  IntrusiveRefCntPtr SemaSource;
 };
 
 } // namespace

diff  --git a/clang/include/clang/Sema/MultiplexExternalSemaSource.h 
b/clang/include/clang/Sema/MultiplexExternalSemaSource.h
index 78658dcf990c4..704925577d269 100644
--- a/clang/include/clang/Sema/MultiplexExternalSemaSource.h
+++ b/clang/include/clang/Sema/MultiplexExternalSemaSource.h
@@ -40,25 +40,24 @@ class MultiplexExternalSemaSource : public 
ExternalSemaSource {
   static char ID;
 
 private:
-  SmallVector Sources; // doesn't own them.
+  SmallVector Sources;
 
 public:
-
-  ///Constructs a new multiplexing external sema source and appends the
+  /// Constructs a new multiplexing external sema source and appends the
   /// given element to it.
   ///
-  ///\param[in] s1 - A non-null (old) ExternalSemaSource.
-  ///\param[in] s2 - A non-null (new) ExternalSemaSource.
+  ///\param[in] S1 - A non-null (old) ExternalSemaSource.
+  ///\param[in] S2 - A non-null (new) ExternalSemaSource.
   ///
-  MultiplexExternalSemaSource(ExternalSemaSource& s1, ExternalSemaSource& s2);
+  MultiplexExternalSemaSource(ExternalSemaSource *S1, ExternalSemaSource *S2);
 
   ~MultiplexExternalSemaSource() override;
 
-  ///Appends new source to the source list.
+  /// Appends new source to the source list.
   ///
   ///\param[in] source - An ExternalSemaSource.
   ///
-  void addSource(ExternalSemaSource &source);
+  void AddSource(ExternalSemaSource *Source);
 
   
//======//
   // ExternalASTSource.

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index bd81d3a7e5ee5..45

[PATCH] D133158: [NFC] Make MultiplexExternalSemaSource own sources

2022-09-02 Thread Chris Bieneman 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 rG5b5329bd41ba: [NFC] Make MultiplexExternalSemaSource own 
sources (authored by beanz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133158

Files:
  clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
  clang/include/clang/Sema/MultiplexExternalSemaSource.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/ChainedIncludesSource.cpp
  clang/lib/Sema/MultiplexExternalSemaSource.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/unittests/Sema/ExternalSemaSourceTest.cpp

Index: clang/unittests/Sema/ExternalSemaSourceTest.cpp
===
--- clang/unittests/Sema/ExternalSemaSourceTest.cpp
+++ clang/unittests/Sema/ExternalSemaSourceTest.cpp
@@ -219,6 +219,8 @@
   void PushWatcher(DiagnosticWatcher *Watcher) { Watchers.push_back(Watcher); }
 };
 
+using llvm::makeIntrusiveRefCnt;
+
 // Make sure that the DiagnosticWatcher is not miscounting.
 TEST(ExternalSemaSource, DiagCheck) {
   auto Installer = std::make_unique();
@@ -234,14 +236,14 @@
 // instead of the usual suggestion we would use above.
 TEST(ExternalSemaSource, ExternalTypoCorrectionPrioritized) {
   auto Installer = std::make_unique();
-  NamespaceTypoProvider Provider("AAB", "BBB");
+  auto Provider = makeIntrusiveRefCnt("AAB", "BBB");
   DiagnosticWatcher Watcher("AAB", "BBB");
-  Installer->PushSource(&Provider);
+  Installer->PushSource(Provider.get());
   Installer->PushWatcher(&Watcher);
   std::vector Args(1, "-std=c++11");
   ASSERT_TRUE(clang::tooling::runToolOnCodeWithArgs(
   std::move(Installer), "namespace AAA { } using namespace AAB;", Args));
-  ASSERT_LE(0, Provider.CallCount);
+  ASSERT_LE(0, Provider->CallCount);
   ASSERT_EQ(1, Watcher.SeenCount);
 }
 
@@ -249,34 +251,34 @@
 // ExternalSemaSource.
 TEST(ExternalSemaSource, ExternalTypoCorrectionOrdering) {
   auto Installer = std::make_unique();
-  NamespaceTypoProvider First("XXX", "BBB");
-  NamespaceTypoProvider Second("AAB", "CCC");
-  NamespaceTypoProvider Third("AAB", "DDD");
+  auto First = makeIntrusiveRefCnt("XXX", "BBB");
+  auto Second = makeIntrusiveRefCnt("AAB", "CCC");
+  auto Third = makeIntrusiveRefCnt("AAB", "DDD");
   DiagnosticWatcher Watcher("AAB", "CCC");
-  Installer->PushSource(&First);
-  Installer->PushSource(&Second);
-  Installer->PushSource(&Third);
+  Installer->PushSource(First.get());
+  Installer->PushSource(Second.get());
+  Installer->PushSource(Third.get());
   Installer->PushWatcher(&Watcher);
   std::vector Args(1, "-std=c++11");
   ASSERT_TRUE(clang::tooling::runToolOnCodeWithArgs(
   std::move(Installer), "namespace AAA { } using namespace AAB;", Args));
-  ASSERT_LE(1, First.CallCount);
-  ASSERT_LE(1, Second.CallCount);
-  ASSERT_EQ(0, Third.CallCount);
+  ASSERT_LE(1, First->CallCount);
+  ASSERT_LE(1, Second->CallCount);
+  ASSERT_EQ(0, Third->CallCount);
   ASSERT_EQ(1, Watcher.SeenCount);
 }
 
 TEST(ExternalSemaSource, ExternalDelayedTypoCorrection) {
   auto Installer = std::make_unique();
-  FunctionTypoProvider Provider("aaa", "bbb");
+  auto Provider = makeIntrusiveRefCnt("aaa", "bbb");
   DiagnosticWatcher Watcher("aaa", "bbb");
-  Installer->PushSource(&Provider);
+  Installer->PushSource(Provider.get());
   Installer->PushWatcher(&Watcher);
   std::vector Args(1, "-std=c++11");
   ASSERT_TRUE(clang::tooling::runToolOnCodeWithArgs(
   std::move(Installer), "namespace AAA { } void foo() { AAA::aaa(); }",
   Args));
-  ASSERT_LE(0, Provider.CallCount);
+  ASSERT_LE(0, Provider->CallCount);
   ASSERT_EQ(1, Watcher.SeenCount);
 }
 
@@ -284,8 +286,8 @@
 // solve the problem.
 TEST(ExternalSemaSource, TryOtherTacticsBeforeDiagnosing) {
   auto Installer = std::make_unique();
-  CompleteTypeDiagnoser Diagnoser(false);
-  Installer->PushSource(&Diagnoser);
+  auto Diagnoser = makeIntrusiveRefCnt(false);
+  Installer->PushSource(Diagnoser.get());
   std::vector Args(1, "-std=c++11");
   // This code hits the class template specialization/class member of a class
   // template specialization checks in Sema::RequireCompleteTypeImpl.
@@ -293,26 +295,26 @@
   std::move(Installer),
   "template  struct S { class C { }; }; S::C SCInst;",
   Args));
-  ASSERT_EQ(0, Diagnoser.CallCount);
+  ASSERT_EQ(0, Diagnoser->CallCount);
 }
 
 // The first ExternalSemaSource where MaybeDiagnoseMissingCompleteType returns
 // true should be the last one called.
 TEST(ExternalSemaSource, FirstDiagnoserTaken) {
   auto Installer = std::make_unique();
-  CompleteTypeDiagnoser First(false);
-  CompleteTypeDiagnoser Second(true);
-  CompleteTypeDiagnoser Third(true);
-  Installer->PushSource(&First);
-  Installer->PushSource(&Second);
-  Installer->PushSource(&Third);
+  auto First = makeIntrusiveRefCnt(false);
+  auto Secon

[PATCH] D132975: [clang][BOLT] Add clang-bolt target

2022-09-02 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang/CMakeLists.txt:930-937
+-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
+-DCMAKE_C_COMPILER=${CLANG_INSTRUMENTED}
+-DCMAKE_CXX_COMPILER=${CLANGXX_INSTRUMENTED}
+-DCMAKE_ASM_COMPILER=${CLANG_INSTRUMENTED}
+-DCMAKE_ASM_COMPILER_ID=Clang
+-DCMAKE_BUILD_TYPE=Release
+-DLLVM_ENABLE_PROJECTS=${CLANG_BOLT_INSTRUMENT_PROJECTS}

I don't think this is sufficient in the general case, we would need to pass 
additional variables like `CMAKE_AR` the same way we do for the existing 
bootstrap logic, see 
https://github.com/llvm/llvm-project/blob/dc549bf0013e11e8fcccba8a8d59c3a4bb052a3b/clang/CMakeLists.txt#L825.

For example, on Fuchsia builders we don't have any system-wide toolchain 
installation, instead we manually set  all necessary `CMAKE_` variables 
for the first stage, so this call will fail for us because it won't be able to 
find tools like the archiver.

Since handling this properly would likely duplicate a lot of the existing logic 
from the existing bootstrap logic, I'm wondering if we should instead try to 
refactor the existing logic and break it up into macros/functions which could 
then be reused here as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132975

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


[PATCH] D130513: [Flang] Add -fconvert option to swap endianness for unformatted files

2022-09-02 Thread Jonathon Penix via Phabricator via cfe-commits
jpenix-quic added inline comments.



Comment at: flang/test/Driver/emit-mlir.f90:16
 ! CHECK-NEXT: }
+! CHECK-NEXT: fir.global @_QQEnvironmentDefaults constant : 
!fir.ref, 
!fir.ref> {
+! CHECK-NEXT:  %[[VAL_0:.*]] = fir.zero_bits !fir.ref, !fir.ref>

peixin wrote:
> Is it possible not to generated this global variable if `fconvert=` is not 
> specified?
I'm not entirely sure--the issue I was running into was how to handle this in 
Fortran_main.c in a way which worked for all of GCC/Clang/Visual Studio (and 
maybe others?). I was originally thinking of doing this by using a weak 
definition of _QQEnvironmentDefaults set to nullptr so fconvert, etc. could 
override this definition without explicitly generating the fallback case. For 
GCC/clang, I think I could use __attribute__((weak)), but I wasn't sure how to 
handle this if someone tried to build with Visual Studio (or maybe another 
toolchain). I saw a few workarounds (ex: 
https://devblogs.microsoft.com/oldnewthing/20200731-00/?p=104024) but I shied 
away from this since it seems to be an undocumented feature (and presumably 
only helps with Visual Studio). 

Do you know of a better or more general way I could do this? (Or, is there 
non-weak symbol approach that might be better that I'm missing?)


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

https://reviews.llvm.org/D130513

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


[PATCH] D132131: [clang-format] Adds a formatter for aligning trailing comments over empty lines

2022-09-02 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D132131#3766590 , @MyDeveloperDay 
wrote:

> Is there a technical reason for reusing the struct rather than introducing a 
> new one?

I see, good point. Really only if one would port the implementation to 
`AlignTokens`. If that's feasible (or sensible) I don't know. Otherwise one 
will only reuse the parsing code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132131

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


[PATCH] D126172: [clang] Fix comparison of TemplateArgument when they are of template kind

2022-09-02 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D126172#3767188 , @roberteg16 
wrote:

> Hey @mizvekov! Sorry for the late response.
>
> Yes, I am still interested and I am working on this. I'll let you know ASAP 
> if I find something that resembles a valid fix.
>
> I would be very grateful if you could give me some tips for debuging better 
> clang or if you could point me towards documents, links, whatever that could 
> give me nice information about how to reason about the code of the 
> parser/sema of clang.
>
> If you are in a hurry and need to fix it yourself and it happens that you 
> finish the path first, please @ me so I can get to see how an error like this 
> would be fixed, thanks!

Hello! Yeah you were just a bit too late, I have a patch that is accepted and 
should go in soon: https://reviews.llvm.org/D133072
I had run into this problem while making changes around 
CheckTemplateArgumentList, and I have this big patch which I am trying to 
offload into smaller chunks to expedite review.

I don't have any documents to recommend besides the obvious things, like the 
Clang docs auto-generated from the source code.
If you do want to get started, I can only recommend what worked for me, which 
is to try fixing bugs first, much like you tried here.
Though perhaps it's not very productive to get stuck in any one for a very long 
time, instead just ask for help or move on :)

I think that if you want to implement something new or a more substantial 
change, being able to debug quickly certainly helps.
There is no way you are going to be able to understand what is going on early 
on, so you will make a big mess, break hundreds of tests and so on, and being 
able to quickly go over and understand what is going on with them is important.
Invest in isolating bugs before working on them, it always pays off.

When fixing stuff, beware of changing assertions, most of the times the 
assertion is correct.
Also, if a bug fix is too local and seems easy, it's always worth spending some 
extra time to be sure.

And lots and lots and lots of free time, patience and being able to work 
without distractions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126172

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


[PATCH] D132990: [Clang] Fix compat diagnostic to detect a nontype template parameter has a placeholder type using getContainedAutoType()

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Can you also add a release note for the changes?




Comment at: clang/lib/Sema/SemaTemplate.cpp:1534-1538
+  if (const auto *T = TInfo->getType()->getContainedDeducedType())
+if (isa(T))
+  Diag(D.getIdentifierLoc(),
+   diag::warn_cxx14_compat_template_nontype_parm_auto_type)
+  << QualType(TInfo->getType()->getContainedAutoType(), 0);

Let's get fancy!



Comment at: clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx1z.cpp:1
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wpre-c++17-compat %s
+

Please rename the file to end in cxx17 instead of cxx1z :-)


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

https://reviews.llvm.org/D132990

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


[PATCH] D132831: [clang][Interp] Handle SubstNonTypeTemplateParmExprs

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM on the assumption that the extra test coverage doesn't find anything.




Comment at: clang/test/AST/Interp/functions.cpp:68-69
 static_assert(recursion(10) == 0, "");
+
+
+template





Comment at: clang/test/AST/Interp/functions.cpp:70-75
+template
+constexpr decltype(N) getNum() {
+  return N;
+}
+static_assert(getNum<-2>() == -2, "");
+static_assert(getNum<10>() == 10, "");

Can you also add a use where there's a default argument for the NTTP just to 
make sure we get that right too? (I'd be surprised if it didn't.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132831

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


[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-09-02 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser accepted this revision.
jamieschmeiser added a comment.

If the source is specified with a partial path, I would expect the .json file 
to be in the same directory as the source, so dir1/f.C and dir2/f.C would 
result in dir1/f.json and dir2/f.json.  But this can be a later improvement.  
Let's get this landed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

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


[PATCH] D132779: Enforce module decl-use restrictions and private header restrictions in textual headers

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

The changes look reasonable to me, though if you think the flag is a temporary 
one, we might want to consider changes to document that explicitly.




Comment at: clang/docs/ReleaseNotes.rst:126
+  `_ are now
+  diagnosed even when the includer is a textual header.
 

You should mention `-fno-modules-validate-textual-header-includes` here so that 
users know there's a transition flag available. Do you expect we'd like to 
remove that flag in the future, or do you expect we'll need to carry it around 
"forever"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132779

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


[clang] 7474214 - [test] Change cc1 -fvisibility to -fvisibility=

2022-09-02 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-09-02T12:36:44-07:00
New Revision: 74742147ee27659dc3b0bc713d61ea9218bf29d0

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

LOG: [test] Change cc1 -fvisibility to -fvisibility=

Added: 


Modified: 
clang/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.cpp
clang/test/CodeGen/PowerPC/aix-visibility-inlines-hidden.cpp
clang/test/CodeGen/attr-availability.c
clang/test/CodeGen/available-externally-hidden.cpp
clang/test/CodeGen/cfi-unrelated-cast.cpp
clang/test/CodeGen/construction-vtable-visibility.cpp
clang/test/CodeGen/hidden-visibility.c
clang/test/CodeGen/private-extern.c
clang/test/CodeGen/set-visibility-for-decls.c
clang/test/CodeGen/visibility.c
clang/test/CodeGenCUDA/amdgpu-visibility.cu
clang/test/CodeGenCXX/RelativeVTablesABI/no-alias-when-dso-local.cpp
clang/test/CodeGenCXX/cfi-cast.cpp
clang/test/CodeGenCXX/cfi-ignorelist.cpp
clang/test/CodeGenCXX/cfi-mfcall-incomplete.cpp
clang/test/CodeGenCXX/cfi-mfcall.cpp
clang/test/CodeGenCXX/cfi-multiple-inheritance.cpp
clang/test/CodeGenCXX/cfi-nvcall.cpp
clang/test/CodeGenCXX/cfi-stats.cpp
clang/test/CodeGenCXX/cfi-vcall-check-after-args.cpp
clang/test/CodeGenCXX/cfi-vcall-no-trap.cpp
clang/test/CodeGenCXX/dllstorage-visibility.cpp
clang/test/CodeGenCXX/implicit-record-visibility.cpp
clang/test/CodeGenCXX/lto-visibility-inference.cpp
clang/test/CodeGenCXX/mdefault-visibility-export-mapping-rtti.cpp
clang/test/CodeGenCXX/no-lto-unit.cpp
clang/test/CodeGenCXX/pr11797.cpp
clang/test/CodeGenCXX/pr24097.cpp
clang/test/CodeGenCXX/rtti-fundamental.cpp
clang/test/CodeGenCXX/rtti-linkage.cpp
clang/test/CodeGenCXX/template-inner-struct-visibility-hidden.cpp
clang/test/CodeGenCXX/type-metadata-memfun.cpp
clang/test/CodeGenCXX/type-metadata-thinlto.cpp
clang/test/CodeGenCXX/type-metadata.cpp
clang/test/CodeGenCXX/type_visibility.cpp
clang/test/CodeGenCXX/visibility-dllstorageclass.cpp
clang/test/CodeGenCXX/visibility-hidden-extern-templates.cpp
clang/test/CodeGenCXX/visibility-inlines-hidden-staticvar.cpp
clang/test/CodeGenCXX/visibility-pr36810.cpp
clang/test/CodeGenCXX/visibility.cpp
clang/test/CodeGenObjC/attr-availability.m
clang/test/CodeGenObjC/attr-exception.m
clang/test/CodeGenObjC/availability-dso-local.m
clang/test/CodeGenObjC/exceptions-asm-attribute.m
clang/test/CodeGenObjC/hidden-visibility.m
clang/test/CodeGenObjC/metadata_symbols.m
clang/test/CodeGenOpenCL/visibility.cl
clang/test/InterfaceStubs/externstatic.c
clang/test/InterfaceStubs/object.c
clang/test/InterfaceStubs/visibility.cpp
clang/test/OpenMP/declare_target_codegen.cpp
clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
clang/test/OpenMP/nvptx_target_pure_deleted_codegen.cpp
clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
clang/test/OpenMP/target_attribute_convergent.cpp

Removed: 




diff  --git a/clang/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.cpp 
b/clang/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.cpp
index c5b7c77a78603..baa8ece05e553 100644
--- a/clang/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.cpp
+++ b/clang/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.cpp
@@ -4,16 +4,16 @@
 // RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix -emit-llvm 
-round-trip-args -o - -x c++ %s  | \
 // RUN: FileCheck -check-prefix=VISIBILITY-IR %s
 
-// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix 
-mignore-xcoff-visibility -fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix 
-mignore-xcoff-visibility -fvisibility=default -emit-llvm -o - -x c++ %s  | \
 // RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
-// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix 
-mignore-xcoff-visibility -fvisibility default -emit-llvm -round-trip-args -o - 
-x c++ %s  | \
+// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix 
-mignore-xcoff-visibility -fvisibility=default -emit-llvm -round-trip-args -o - 
-x c++ %s  | \
 // RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
-// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix 
-fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix 
-fvisibility=default -emit-llvm -o - -x c++ %s  | \
 // RUN: FileCheck -check-prefix=VISIBILITY-IR %s
 
-// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix 
-fvisibility default -round-trip-args -emit-llvm -o - -x c++ %s  | \
+// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix 
-fvisibility=default -r

  1   2   >