[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-06 Thread Tobias Hieta 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 rGb1356504e63a: [LLVM] Update C++ standard to 17 (authored by 
thieta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

Files:
  bolt/runtime/CMakeLists.txt
  clang/CMakeLists.txt
  lld/CMakeLists.txt
  lldb/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/CheckCompilerVersion.cmake
  llvm/docs/CodingStandards.rst
  llvm/docs/ReleaseNotes.rst

Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -47,6 +47,18 @@
 Update on required toolchains to build LLVM
 ---
 
+LLVM is now built with C++17 by default. This means C++17 can be used in
+the code base.
+
+The previous "soft" toolchain requirements have now been changed to "hard".
+This means that the the following versions are now required to build LLVM
+and there is no way to suppress this error.
+
+* GCC >= 7.1
+* Clang >= 5.0
+* Apple Clang >= 9.3
+* Visual Studio 2019 >= 16.7
+
 Changes to the LLVM IR
 --
 
Index: llvm/docs/CodingStandards.rst
===
--- llvm/docs/CodingStandards.rst
+++ llvm/docs/CodingStandards.rst
@@ -53,7 +53,7 @@
 C++ Standard Versions
 -
 
-Unless otherwise documented, LLVM subprojects are written using standard C++14
+Unless otherwise documented, LLVM subprojects are written using standard C++17
 code and avoid unnecessary vendor-specific extensions.
 
 Nevertheless, we restrict ourselves to features which are available in the
@@ -63,7 +63,13 @@
 Each toolchain provides a good reference for what it accepts:
 
 * Clang: https://clang.llvm.org/cxx_status.html
-* GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx14
+
+  * libc++: https://libcxx.llvm.org/Status/Cxx17.html
+
+* GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx17
+
+  * libstdc++: https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2017
+
 * MSVC: https://msdn.microsoft.com/en-us/library/hh567368.aspx
 
 
Index: llvm/cmake/modules/CheckCompilerVersion.cmake
===
--- llvm/cmake/modules/CheckCompilerVersion.cmake
+++ llvm/cmake/modules/CheckCompilerVersion.cmake
@@ -4,21 +4,19 @@
 
 include(CheckCXXSourceCompiles)
 
-set(GCC_MIN 5.1)
+set(GCC_MIN 7.1)
 set(GCC_SOFT_ERROR 7.1)
-set(CLANG_MIN 3.5)
+set(CLANG_MIN 5.0)
 set(CLANG_SOFT_ERROR 5.0)
-set(APPLECLANG_MIN 6.0)
+set(APPLECLANG_MIN 9.3)
 set(APPLECLANG_SOFT_ERROR 9.3)
 
 # https://en.wikipedia.org/wiki/Microsoft_Visual_C#Internal_version_numbering
-# _MSC_VER == 1920 MSVC++ 14.20 Visual Studio 2019 Version 16.0
 # _MSC_VER == 1927 MSVC++ 14.27 Visual Studio 2019 Version 16.7
-set(MSVC_MIN 19.20)
+set(MSVC_MIN 19.27)
 set(MSVC_SOFT_ERROR 19.27)
 
-# Map the above GCC versions to dates: https://gcc.gnu.org/develop.html#timeline
-set(GCC_MIN_DATE 20150422)
+set(LIBSTDCXX_MIN 7)
 set(LIBSTDCXX_SOFT_ERROR 7)
 
 
@@ -76,22 +74,14 @@
 set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
 set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++0x")
-# Test for libstdc++ version of at least 4.8 by checking for _ZNKSt17bad_function_call4whatEv.
-# Note: We should check _GLIBCXX_RELEASE when possible (i.e., for GCC 7.1 and up).
 check_cxx_source_compiles("
 #include 
 #if defined(__GLIBCXX__)
-#if __GLIBCXX__ < ${GCC_MIN_DATE}
+#if !defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE < ${LIBSTDCXX_MIN}
 #error Unsupported libstdc++ version
 #endif
 #endif
-#if defined(__GLIBCXX__)
-extern const char _ZNKSt17bad_function_call4whatEv[];
-const char *chk = _ZNKSt17bad_function_call4whatEv;
-#else
-const char *chk = \"\";
-#endif
-int main() { ++chk; return 0; }
+int main() { return 0; }
 "
   LLVM_LIBSTDCXX_MIN)
 if(NOT LLVM_LIBSTDCXX_MIN)
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -58,7 +58,7 @@
 # Must go after project(..)
 include(GNUInstallDirs)
 
-set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
+set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
 set(CMAKE_CXX_STANDARD_REQUIRED YES)
 if (CYGWIN)
   # Cygwin is a bit stricter and lack things like 'strdup', 'stricmp', etc in
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -20,7 +20,7 @@
 if(LLDB_BUILT_STANDALONE)
   include(LLDBStandalone)
 
-  set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
+  set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to c

[PATCH] D124753: [HLSL] Set main as default entry.

2022-08-06 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 450492.
python3kgae marked an inline comment as done.
python3kgae added a comment.

Rebase and add unit-test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124753

Files:
  clang/include/clang/Driver/Options.td
  clang/unittests/Driver/ToolChainTest.cpp


Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -14,8 +14,10 @@
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/TargetOptions.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Support/Host.h"
@@ -571,6 +573,33 @@
   DiagConsumer->clear();
 }
 
+TEST(DxcModeTest, DefaultEntry) {
+  IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+
+  InMemoryFileSystem->addFile("foo.hlsl", 0,
+  llvm::MemoryBuffer::getMemBuffer("\n"));
+
+  const char *Args[] = {"clang", "--driver-mode=dxc", "-Tcs_6_7", "foo.hlsl"};
+
+  IntrusiveRefCntPtr Diags =
+  CompilerInstance::createDiagnostics(new DiagnosticOptions());
+
+  CreateInvocationOptions CIOpts;
+  CIOpts.Diags = Diags;
+  std::unique_ptr CInvok =
+  createInvocation(Args, std::move(CIOpts));
+  EXPECT_TRUE(CInvok);
+  // Make sure default entry is "main".
+  EXPECT_STREQ(CInvok->getTargetOpts().HLSLEntry.c_str(), "main");
+
+  const char *EntryArgs[] = {"clang", "--driver-mode=dxc", "-Ebar", 
"-Tcs_6_7", "foo.hlsl"};
+  CInvok = createInvocation(EntryArgs, std::move(CIOpts));
+  EXPECT_TRUE(CInvok);
+  // Make sure "-E" will set entry.
+  EXPECT_STREQ(CInvok->getTargetOpts().HLSLEntry.c_str(), "bar");
+}
+
 TEST(ToolChainTest, Toolsets) {
   // Ignore this test on Windows hosts.
   llvm::Triple Host(llvm::sys::getProcessTriple());
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -6912,7 +6912,7 @@
 def hlsl_entrypoint : Option<["-"], "hlsl-entry", KIND_SEPARATE>,
   Group,
   Flags<[CC1Option]>,
-  MarshallingInfoString>,
+  MarshallingInfoString, 
"\"main\"">,
   HelpText<"Entry point name for hlsl">;
 def dxc_entrypoint : Option<["--", "/", "-"], "E", KIND_JOINED_OR_SEPARATE>,
  Group,


Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -14,8 +14,10 @@
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/TargetOptions.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Support/Host.h"
@@ -571,6 +573,33 @@
   DiagConsumer->clear();
 }
 
+TEST(DxcModeTest, DefaultEntry) {
+  IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+
+  InMemoryFileSystem->addFile("foo.hlsl", 0,
+  llvm::MemoryBuffer::getMemBuffer("\n"));
+
+  const char *Args[] = {"clang", "--driver-mode=dxc", "-Tcs_6_7", "foo.hlsl"};
+
+  IntrusiveRefCntPtr Diags =
+  CompilerInstance::createDiagnostics(new DiagnosticOptions());
+
+  CreateInvocationOptions CIOpts;
+  CIOpts.Diags = Diags;
+  std::unique_ptr CInvok =
+  createInvocation(Args, std::move(CIOpts));
+  EXPECT_TRUE(CInvok);
+  // Make sure default entry is "main".
+  EXPECT_STREQ(CInvok->getTargetOpts().HLSLEntry.c_str(), "main");
+
+  const char *EntryArgs[] = {"clang", "--driver-mode=dxc", "-Ebar", "-Tcs_6_7", "foo.hlsl"};
+  CInvok = createInvocation(EntryArgs, std::move(CIOpts));
+  EXPECT_TRUE(CInvok);
+  // Make sure "-E" will set entry.
+  EXPECT_STREQ(CInvok->getTargetOpts().HLSLEntry.c_str(), "bar");
+}
+
 TEST(ToolChainTest, Toolsets) {
   // Ignore this test on Windows hosts.
   llvm::Triple Host(llvm::sys::getProcessTriple());
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -6912,7 +6912,7 @@
 def hlsl_entrypoint : Option<["-"], "hlsl-entry", KIND_SEPARATE>,
   Group,
   Flags<[CC1Option]>,
-  MarshallingInfoString>,
+  MarshallingInfoStr

[PATCH] D131314: [clang] format string checks for `InitListExpr`

2022-08-06 Thread YingChi Long via Phabricator via cfe-commits
inclyc created this revision.
Herald added a project: All.
inclyc added reviewers: aaron.ballman, rsmith, mizvekov, tbaeder.
inclyc added a project: clang.
inclyc added a subscriber: clang.
inclyc published this revision for review.
Herald added a subscriber: cfe-commits.

this patch enhances clang check format strings defined in list
initialization expressions. Before this patch clang just thought these
expressions are not string literal.

Example:

  constexpr const char *foo() { return "%s %d"; }
  
  struct Bar {
static constexpr char value[] = {'%', 's', '%', 'd', '\0'};
  };
  
  constexpr const char *foobar() { return Bar::value; }
  
  constexpr const char *fbar() { return foobar(); }
  
  int main() {
printf(foo(), "abc", "def");
printf(Bar::value, "abc", "def");
printf(foobar(), "abc", "def");
printf(fbar(), "abc", "def");
return 0;
  }

Diagnostics after this patch:

  :14:24: warning: format specifies type 'int' but the argument has 
type 'const char *' [-Wformat]
printf(foo(), "abc", "def");
   ~ ^
  :3:42: note: format string is defined here
  constexpr const char *foo() { return "%s %d"; }
   ^~
   %s
  :15:29: warning: format specifies type 'int' but the argument has 
type 'const char *' [-Wformat]
printf(Bar::value, "abc", "def");
  ^
  :16:27: warning: format specifies type 'int' but the argument has 
type 'const char *' [-Wformat]
printf(foobar(), "abc", "def");
^
  :17:29: warning: format specifies type 'int' but the argument has 
type 'const char *' [-Wformat]
printf(fbar(), "abc", "def");
  ^
  4 warnings generated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131314

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

Index: clang/test/SemaCXX/format-strings.cpp
===
--- clang/test/SemaCXX/format-strings.cpp
+++ clang/test/SemaCXX/format-strings.cpp
@@ -166,6 +166,14 @@
 #if __cplusplus >= 201103L
 namespace evaluated {
 
+struct InitList {
+  static constexpr char value[] = {'%', 's', '%', 'd', '\0'}; // no note here because this is not literal
+};
+
+constexpr const char *init_list_func() { return InitList::value; }
+
+constexpr const char *init_list_func_wrap() { return init_list_func(); }
+
 constexpr const char *basic() { 
   return 
 "%s %d"; // expected-note {{format string is defined here}}
@@ -199,12 +207,15 @@
 
 void f() {
   printf(basic(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
-  printf(correct_fmt(), 1, 2);
+  printf(correct_fmt(), 1, 2); // no warning
   printf(string_linebreak(), 1, 2, 3, 4); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
   printf(not_literal(), 1, 2, 3, 4); // expected-warning {{format string is not a string literal}}
   printf(wrap_constexpr(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(InitList::value, 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(init_list_func(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(init_list_func_wrap(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
 }
 
 
-}
+} // namespace evaluated
 #endif
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8469,25 +8469,26 @@
 Sema &S, const FormatStringLiteral *FExpr, const Expr *OrigFormatExpr,
 ArrayRef Args, Sema::FormatArgumentPassingKind APK,
 unsigned format_idx, unsigned firstDataArg, Sema::FormatStringType Type,
-bool inFunctionCall, Sema::VariadicCallType CallType,
+bool NoNote, Sema::VariadicCallType CallType,
 llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg,
 bool IgnoreStringsWithoutSpecifiers);
 
-static const Expr *maybeConstEvalStringLiteral(ASTContext &Context,
-   const Expr *E);
-
-// Determine if an expression is a string literal or constant string.
-// If this function returns false on the arguments to a function expecting a
-// format string, we will usually need to emit a warning.
-// True string literals are then checked by CheckFormatString.
 static StringLiteralCheckType
-checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef Args,
-  Sema::FormatArgumentPassingKind APK, unsigned format_idx,
-  unsigned firstDataArg, Sema::FormatStringType Type,
-  Sema::VariadicCallType CallType, bool InFunctionCall

[PATCH] D103562: [NFC][compiler-rt][hwasan] Refactor hwasan functions

2022-08-06 Thread Alexey Baturo via Phabricator via cfe-commits
smd added inline comments.



Comment at: compiler-rt/lib/hwasan/hwasan.cpp:205
+  if (registers_frame && stack->trace && stack->size > 0) {
+stack->trace++;
+stack->size--;

fmayer wrote:
> fmayer wrote:
> > fmayer wrote:
> > > vitalybuka wrote:
> > > > maybe we should pop everything up to "pc" to avoid issues with nested 
> > > > calls?
> > > > 
> > > > For most users hwasan frames are not very useful. However if you work 
> > > > on sanitizer, some frames can be a useful info. So I don't mind we just 
> > > > relax test cases to accommodate this nesting.
> > > > 
> > > > cc @smd 
> > > This is probably for another patch though, right? This is already like 
> > > this on the LHS.
> > nevermind. i accidentally had this left, sent 
> > https://reviews.llvm.org/D131279 for that.
> Sorry, please disregard everything I said here (incl the link). I confused 
> myself where this was posted, and this is all nonsense.
@vitalybuka thanks for the reply.

>However if you work on sanitizer, some frames can be a useful info
From my experience most of the time while I'm working on sanitizers I spend in 
gdb, so I don't actually care about what backtrace is being printed. So it 
might be a good idea to avoid confusing regular hwasan user and skip printing 
service hwasan frames.

Maybe we just could keep the current scheme, but get return address and frame 
pointer in __hwasan_tag_mismatch4 like it was before? Something like:
```
void HwasanTagMismatch(uptr addr, uptr pc, uptr frame, uptr access_info, uptr 
*registers_frame, size_t outsize) {
  __hwasan::AccessInfo ai;
  ai.is_store = access_info & 0x10;
  ai.is_load = !ai.is_store;
  ai.recover = access_info & 0x20;
  ai.addr = addr;
  if ((access_info & 0xf) == 0xf)
ai.size = outsize;
  else
ai.size = 1 << (access_info & 0xf);

  HandleTagMismatch(ai, pc, frame, nullptr, registers_frame);
}
...
void __hwasan_tag_mismat(uptr)__builtin_frame_address(0)ch4(uptr addr, uptr 
access_info, uptr *registers_frame,
size_t outsize) {
  uptr ra = (uptr)__builtin_return_address(0);
  uptr fp = (uptr)__builtin_frame_address(0);
  __hwasan::HwasanTagMismatch(addr, ra, fp, access_info, registers_frame, 
outsize);
}
```

@fmayer 
>LTO could conceivably inline this – in which case it would be one, right?
Yes, you're totally right.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103562

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


[PATCH] D131314: [clang] format string checks for `InitListExpr`

2022-08-06 Thread YingChi Long via Phabricator via cfe-commits
inclyc updated this revision to Diff 450494.
inclyc added a comment.

typo fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131314

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

Index: clang/test/SemaCXX/format-strings.cpp
===
--- clang/test/SemaCXX/format-strings.cpp
+++ clang/test/SemaCXX/format-strings.cpp
@@ -166,6 +166,14 @@
 #if __cplusplus >= 201103L
 namespace evaluated {
 
+struct InitList {
+  static constexpr char value[] = {'%', 's', '%', 'd', '\0'}; // no note here because this is not literal
+};
+
+constexpr const char *init_list_func() { return InitList::value; }
+
+constexpr const char *init_list_func_wrap() { return init_list_func(); }
+
 constexpr const char *basic() { 
   return 
 "%s %d"; // expected-note {{format string is defined here}}
@@ -199,12 +207,15 @@
 
 void f() {
   printf(basic(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
-  printf(correct_fmt(), 1, 2);
+  printf(correct_fmt(), 1, 2); // no warning
   printf(string_linebreak(), 1, 2, 3, 4); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
   printf(not_literal(), 1, 2, 3, 4); // expected-warning {{format string is not a string literal}}
   printf(wrap_constexpr(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(InitList::value, 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(init_list_func(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(init_list_func_wrap(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
 }
 
 
-}
+} // namespace evaluated
 #endif
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8469,25 +8469,26 @@
 Sema &S, const FormatStringLiteral *FExpr, const Expr *OrigFormatExpr,
 ArrayRef Args, Sema::FormatArgumentPassingKind APK,
 unsigned format_idx, unsigned firstDataArg, Sema::FormatStringType Type,
-bool inFunctionCall, Sema::VariadicCallType CallType,
+bool NoNote, Sema::VariadicCallType CallType,
 llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg,
 bool IgnoreStringsWithoutSpecifiers);
 
-static const Expr *maybeConstEvalStringLiteral(ASTContext &Context,
-   const Expr *E);
-
-// Determine if an expression is a string literal or constant string.
-// If this function returns false on the arguments to a function expecting a
-// format string, we will usually need to emit a warning.
-// True string literals are then checked by CheckFormatString.
 static StringLiteralCheckType
-checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef Args,
-  Sema::FormatArgumentPassingKind APK, unsigned format_idx,
-  unsigned firstDataArg, Sema::FormatStringType Type,
-  Sema::VariadicCallType CallType, bool InFunctionCall,
-  llvm::SmallBitVector &CheckedVarArgs,
-  UncoveredArgHandler &UncoveredArg, llvm::APSInt Offset,
-  bool IgnoreStringsWithoutSpecifiers = false) {
+checkVarDecl(Sema &S, const Expr *E, ArrayRef Args,
+ Sema::FormatArgumentPassingKind APK, unsigned format_idx,
+ unsigned firstDataArg, Sema::FormatStringType Type,
+ Sema::VariadicCallType CallType, bool NoNote,
+ llvm::SmallBitVector &CheckedVarArgs,
+ UncoveredArgHandler &UncoveredArg, llvm::APSInt Offset, QualType T,
+ const VarDecl *VD, bool IgnoreStringsWithoutSpecifiers);
+
+static StringLiteralCheckType checkFormatStringExprEvaluated(
+Sema &S, const Expr *E, ArrayRef Args,
+Sema::FormatArgumentPassingKind APK, unsigned format_idx,
+unsigned firstDataArg, Sema::FormatStringType Type,
+Sema::VariadicCallType CallType, bool NoNote,
+llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg,
+llvm::APSInt Offset, bool IgnoreStringsWithoutSpecifiers = false) {
   if (S.isConstantEvaluated())
 return SLCT_NotALiteral;
 tryAgain:
@@ -8510,8 +8511,7 @@
   case Stmt::ConditionalOperatorClass: {
 // The expression is a literal if both sub-expressions were, and it was
 // completely checked only if both sub-expressions were checked.
-const AbstractConditionalOperator *C =
-cast(E);
+const AbstractConditionalOperator *C = cast(E);
 
 // Determine whether it is necessary to check both sub-expressions, for
 // example, because the condition expression is a constant that can be
@@ -8535,18 +8535

[PATCH] D131314: [clang] format string checks for `InitListExpr`

2022-08-06 Thread YingChi Long via Phabricator via cfe-commits
inclyc updated this revision to Diff 450495.
inclyc added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131314

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

Index: clang/test/SemaCXX/format-strings.cpp
===
--- clang/test/SemaCXX/format-strings.cpp
+++ clang/test/SemaCXX/format-strings.cpp
@@ -166,6 +166,14 @@
 #if __cplusplus >= 201103L
 namespace evaluated {
 
+struct InitList {
+  static constexpr char value[] = {'%', 's', '%', 'd', '\0'}; // no note here because this is not literal
+};
+
+constexpr const char *init_list_func() { return InitList::value; }
+
+constexpr const char *init_list_func_wrap() { return init_list_func(); }
+
 constexpr const char *basic() { 
   return 
 "%s %d"; // expected-note {{format string is defined here}}
@@ -199,12 +207,15 @@
 
 void f() {
   printf(basic(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
-  printf(correct_fmt(), 1, 2);
+  printf(correct_fmt(), 1, 2); // no warning
   printf(string_linebreak(), 1, 2, 3, 4); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
   printf(not_literal(), 1, 2, 3, 4); // expected-warning {{format string is not a string literal}}
   printf(wrap_constexpr(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(InitList::value, 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(init_list_func(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(init_list_func_wrap(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
 }
 
 
-}
+} // namespace evaluated
 #endif
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8469,25 +8469,26 @@
 Sema &S, const FormatStringLiteral *FExpr, const Expr *OrigFormatExpr,
 ArrayRef Args, Sema::FormatArgumentPassingKind APK,
 unsigned format_idx, unsigned firstDataArg, Sema::FormatStringType Type,
-bool inFunctionCall, Sema::VariadicCallType CallType,
+bool NoNote, Sema::VariadicCallType CallType,
 llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg,
 bool IgnoreStringsWithoutSpecifiers);
 
-static const Expr *maybeConstEvalStringLiteral(ASTContext &Context,
-   const Expr *E);
-
-// Determine if an expression is a string literal or constant string.
-// If this function returns false on the arguments to a function expecting a
-// format string, we will usually need to emit a warning.
-// True string literals are then checked by CheckFormatString.
 static StringLiteralCheckType
-checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef Args,
-  Sema::FormatArgumentPassingKind APK, unsigned format_idx,
-  unsigned firstDataArg, Sema::FormatStringType Type,
-  Sema::VariadicCallType CallType, bool InFunctionCall,
-  llvm::SmallBitVector &CheckedVarArgs,
-  UncoveredArgHandler &UncoveredArg, llvm::APSInt Offset,
-  bool IgnoreStringsWithoutSpecifiers = false) {
+checkVarDecl(Sema &S, const Expr *E, ArrayRef Args,
+ Sema::FormatArgumentPassingKind APK, unsigned format_idx,
+ unsigned firstDataArg, Sema::FormatStringType Type,
+ Sema::VariadicCallType CallType, bool NoNote,
+ llvm::SmallBitVector &CheckedVarArgs,
+ UncoveredArgHandler &UncoveredArg, llvm::APSInt Offset, QualType T,
+ const VarDecl *VD, bool IgnoreStringsWithoutSpecifiers);
+
+static StringLiteralCheckType checkFormatStringExprEvaluated(
+Sema &S, const Expr *E, ArrayRef Args,
+Sema::FormatArgumentPassingKind APK, unsigned format_idx,
+unsigned firstDataArg, Sema::FormatStringType Type,
+Sema::VariadicCallType CallType, bool NoNote,
+llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg,
+llvm::APSInt Offset, bool IgnoreStringsWithoutSpecifiers = false) {
   if (S.isConstantEvaluated())
 return SLCT_NotALiteral;
 tryAgain:
@@ -8510,8 +8511,7 @@
   case Stmt::ConditionalOperatorClass: {
 // The expression is a literal if both sub-expressions were, and it was
 // completely checked only if both sub-expressions were checked.
-const AbstractConditionalOperator *C =
-cast(E);
+const AbstractConditionalOperator *C = cast(E);
 
 // Determine whether it is necessary to check both sub-expressions, for
 // example, because the condition expression is a constant that can be
@@ -8535,18 +8535,18 @@

[PATCH] D131314: [clang] format string checks for `InitListExpr`

2022-08-06 Thread YingChi Long via Phabricator via cfe-commits
inclyc updated this revision to Diff 450496.
inclyc added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131314

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

Index: clang/test/SemaCXX/format-strings.cpp
===
--- clang/test/SemaCXX/format-strings.cpp
+++ clang/test/SemaCXX/format-strings.cpp
@@ -166,6 +166,14 @@
 #if __cplusplus >= 201103L
 namespace evaluated {
 
+struct InitList {
+  static constexpr char value[] = {'%', 's', '%', 'd', '\0'}; // no note here because this is not literal
+};
+
+constexpr const char *init_list_func() { return InitList::value; }
+
+constexpr const char *init_list_func_wrap() { return init_list_func(); }
+
 constexpr const char *basic() { 
   return 
 "%s %d"; // expected-note {{format string is defined here}}
@@ -199,12 +207,15 @@
 
 void f() {
   printf(basic(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
-  printf(correct_fmt(), 1, 2);
+  printf(correct_fmt(), 1, 2); // no warning
   printf(string_linebreak(), 1, 2, 3, 4); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
   printf(not_literal(), 1, 2, 3, 4); // expected-warning {{format string is not a string literal}}
   printf(wrap_constexpr(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(InitList::value, 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(init_list_func(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(init_list_func_wrap(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
 }
 
 
-}
+} // namespace evaluated
 #endif
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8469,25 +8469,26 @@
 Sema &S, const FormatStringLiteral *FExpr, const Expr *OrigFormatExpr,
 ArrayRef Args, Sema::FormatArgumentPassingKind APK,
 unsigned format_idx, unsigned firstDataArg, Sema::FormatStringType Type,
-bool inFunctionCall, Sema::VariadicCallType CallType,
+bool NoNote, Sema::VariadicCallType CallType,
 llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg,
 bool IgnoreStringsWithoutSpecifiers);
 
-static const Expr *maybeConstEvalStringLiteral(ASTContext &Context,
-   const Expr *E);
-
-// Determine if an expression is a string literal or constant string.
-// If this function returns false on the arguments to a function expecting a
-// format string, we will usually need to emit a warning.
-// True string literals are then checked by CheckFormatString.
 static StringLiteralCheckType
-checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef Args,
-  Sema::FormatArgumentPassingKind APK, unsigned format_idx,
-  unsigned firstDataArg, Sema::FormatStringType Type,
-  Sema::VariadicCallType CallType, bool InFunctionCall,
-  llvm::SmallBitVector &CheckedVarArgs,
-  UncoveredArgHandler &UncoveredArg, llvm::APSInt Offset,
-  bool IgnoreStringsWithoutSpecifiers = false) {
+checkVarDecl(Sema &S, const Expr *E, ArrayRef Args,
+ Sema::FormatArgumentPassingKind APK, unsigned format_idx,
+ unsigned firstDataArg, Sema::FormatStringType Type,
+ Sema::VariadicCallType CallType, bool NoNote,
+ llvm::SmallBitVector &CheckedVarArgs,
+ UncoveredArgHandler &UncoveredArg, llvm::APSInt Offset, QualType T,
+ const VarDecl *VD, bool IgnoreStringsWithoutSpecifiers);
+
+static StringLiteralCheckType checkFormatStringExprEvaluated(
+Sema &S, const Expr *E, ArrayRef Args,
+Sema::FormatArgumentPassingKind APK, unsigned format_idx,
+unsigned firstDataArg, Sema::FormatStringType Type,
+Sema::VariadicCallType CallType, bool NoNote,
+llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg,
+llvm::APSInt Offset, bool IgnoreStringsWithoutSpecifiers = false) {
   if (S.isConstantEvaluated())
 return SLCT_NotALiteral;
 tryAgain:
@@ -8510,8 +8511,7 @@
   case Stmt::ConditionalOperatorClass: {
 // The expression is a literal if both sub-expressions were, and it was
 // completely checked only if both sub-expressions were checked.
-const AbstractConditionalOperator *C =
-cast(E);
+const AbstractConditionalOperator *C = cast(E);
 
 // Determine whether it is necessary to check both sub-expressions, for
 // example, because the condition expression is a constant that can be
@@ -8535,18 +8535,18 @@

[PATCH] D131318: [clang-tidy] Add llvm-derefencing-dyn-cast check

2022-08-06 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, JonasToth, LegalizeAdulthood, alexfh.
Herald added subscribers: carlosgalvezp, xazax.hun, mgorny.
Herald added a project: All.
njames93 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Add a check that aims to prevent dereferencing casts that may return nullptr.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131318

Files:
  clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
  clang-tools-extra/clang-tidy/llvm/DereferencingDynCastCheck.cpp
  clang-tools-extra/clang-tidy/llvm/DereferencingDynCastCheck.h
  clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/llvm/dereferencing-dyn-cast.rst
  clang-tools-extra/test/clang-tidy/checkers/llvm/dereferencing-dyn-cast.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/llvm/dereferencing-dyn-cast.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/llvm/dereferencing-dyn-cast.cpp
@@ -0,0 +1,39 @@
+// RUN: %check_clang_tidy %s -std=c++14-or-later llvm-dereferencing-dyn-cast %t
+
+namespace llvm {
+template  X *cast(Y *);
+template  X *dyn_cast(Y *);
+template  X *dyn_cast_or_null(Y *);
+template  X *dyn_cast_if_present(Y *);
+template  X *cast_or_null(Y *);
+template  X *cast_if_present(Y *);
+} // namespace llvm
+
+using namespace llvm;
+
+struct Baz;
+struct Foo {
+  int getX() const;
+};
+
+void test(Baz *Bar) {
+  // CHECK-MESSAGES: :[[@LINE+3]]:29: warning: dereferencing the result of 'dyn_cast' will segfault if the conversion fails; did you mean to call `cast`? [llvm-dereferencing-dyn-cast]
+  // CHECK-MESSAGES: :[[@LINE+3]]:15: warning: dereferencing the result of 'dyn_cast' will segfault if the conversion fails; did you mean to call `cast`? [llvm-dereferencing-dyn-cast]
+  // CHECK-MESSAGES: :[[@LINE+3]]:31: warning: dereferencing the result of 'dyn_cast' will segfault if the conversion fails; did you mean to call `cast`? [llvm-dereferencing-dyn-cast]
+  int X = dyn_cast(Bar)->getX();
+  Foo &FRef = *dyn_cast(Bar);
+  X = llvm::dyn_cast(Bar)->getX();
+  //  CHECK-FIXES: int X = cast(Bar)->getX();
+  // CHECK-FIXES-NEXT: Foo &FRef = *cast(Bar);
+  // CHECK-FIXES-NEXT: X = llvm::cast(Bar)->getX();
+
+  // Warn with no replacement.
+  // CHECK-MESSAGES: :[[@LINE+4]]:33: warning: dereferencing the result of 'dyn_cast_or_null' will segfault if the conversion fails [llvm-dereferencing-dyn-cast]
+  // CHECK-MESSAGES: :[[@LINE+4]]:36: warning: dereferencing the result of 'dyn_cast_if_present' will segfault if the conversion fails [llvm-dereferencing-dyn-cast]
+  // CHECK-MESSAGES: :[[@LINE+4]]:29: warning: dereferencing the result of 'cast_or_null' will segfault if the conversion fails [llvm-dereferencing-dyn-cast]
+  // CHECK-MESSAGES: :[[@LINE+4]]:32: warning: dereferencing the result of 'cast_if_present' will segfault if the conversion fails [llvm-dereferencing-dyn-cast]
+  X = dyn_cast_or_null(Bar)->getX();
+  X = dyn_cast_if_present(Bar)->getX();
+  X = cast_or_null(Bar)->getX();
+  X = cast_if_present(Bar)->getX();
+}
Index: clang-tools-extra/docs/clang-tidy/checks/llvm/dereferencing-dyn-cast.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/llvm/dereferencing-dyn-cast.rst
@@ -0,0 +1,25 @@
+.. title:: clang-tidy - llvm-dereferencing-dyn-cast
+
+llvm-dereferencing-dyn-cast
+===
+
+Finds cases where the result of a ``dyn_cast<>`` is dereferenced. This will 
+segfault if the ``dyn_cast<>`` fails.
+
+If the call was to ``dyn_cast``, It will suggest replacing with ``cast``, For 
+the cases when the call is for r`(dyn_)?cast_(or_null|if_present)` no fix will
+be suggested.
+
+.. code-block::c++
+
+  auto X = dyn_cast(Bar)->getX();
+  auto &FRef = *dyn_cast(Bar);
+  // Replaced with.
+  auto X = cast(Bar)->getX();
+  auto &FRef = *cast(Bar);
+
+  // Warn with no replacement.
+  auto X = dyn_cast_or_null(Bar)->getX();
+  auto X = dyn_cast_if_present(Bar)->getX();
+  auto X = cast_or_null(Bar)->getX();
+  auto X = cast_if_present(Bar)->getX();
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -229,6 +229,7 @@
`hicpp-no-assembler `_,
`hicpp-signed-bitwise `_,
`linuxkernel-must-use-errs `_,
+   `llvm-dereferencing-dyn-cast `_, "Yes"
`llvm-header-guard `_,
`llvm-include-order `_, "Yes"
`llvm-namespace-comment `_,
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-

[PATCH] D131319: [clang-tidy] Update llvm-prefer-isa-or-dyn-cast-in-conditionals with new syntax

2022-08-06 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: alexfh, aaron.ballman, LegalizeAdulthood, JonasToth, 
bzcheeseman.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a project: All.
njames93 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

In D123901 , the `or_null`, `and_nonnull` 
templates were deprecated intended to be replaced with `if_present` and 
`and_present`.
In light of this, The clang-tidy check that enforces correct use of `isa` and 
`dyn_cast` should also be updated with this syntax.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131319

Files:
  clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/llvm/prefer-isa-or-dyn-cast-in-conditionals.rst
  
clang-tools-extra/test/clang-tidy/checkers/llvm/prefer-isa-or-dyn-cast-in-conditionals.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/llvm/prefer-isa-or-dyn-cast-in-conditionals.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvm/prefer-isa-or-dyn-cast-in-conditionals.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvm/prefer-isa-or-dyn-cast-in-conditionals.cpp
@@ -17,6 +17,8 @@
 X *dyn_cast(Y *);
 template 
 X *dyn_cast_or_null(Y *);
+template 
+X *dyn_cast_if_present(Y *);
 
 bool foo(Y *y, Z *z) {
   if (auto x = cast(y))
@@ -63,32 +65,37 @@
 
   if (y && isa(y))
 return true;
-  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred over an explicit test for null followed by calling isa<> [llvm-prefer-isa-or-dyn-cast-in-conditionals]
-  // CHECK-FIXES: if (isa_and_nonnull(y))
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_present<> is preferred over an explicit test for null followed by calling isa<> [llvm-prefer-isa-or-dyn-cast-in-conditionals]
+  // CHECK-FIXES: if (isa_and_present(y))
 
   if (z->bar() && isa(z->bar()))
 return true;
-  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning:  isa_and_nonnull<> is preferred
-  // CHECK-FIXES: if (isa_and_nonnull(z->bar()))
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning:  isa_and_present<> is preferred
+  // CHECK-FIXES: if (isa_and_present(z->bar()))
 
   if (z->bar() && cast(z->bar()))
 return true;
-  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
-  // CHECK-FIXES: if (isa_and_nonnull(z->bar()))
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_present<> is preferred
+  // CHECK-FIXES: if (isa_and_present(z->bar()))
 
   if (z->bar() && dyn_cast(z->bar()))
 return true;
-  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
-  // CHECK-FIXES: if (isa_and_nonnull(z->bar()))
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_present<> is preferred
+  // CHECK-FIXES: if (isa_and_present(z->bar()))
 
   if (z->bar() && dyn_cast_or_null(z->bar()))
 return true;
-  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
-  // CHECK-FIXES: if (isa_and_nonnull(z->bar()))
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_present<> is preferred
+  // CHECK-FIXES: if (isa_and_present(z->bar()))
+
+  if (z->bar() && dyn_cast_if_present(z->bar()))
+return true;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_present<> is preferred
+  // CHECK-FIXES: if (isa_and_present(z->bar()))
 
   bool b = z->bar() && cast(z->bar());
-  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: isa_and_nonnull<> is preferred
-  // CHECK-FIXES: bool b = isa_and_nonnull(z->bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: isa_and_present<> is preferred
+  // CHECK-FIXES: bool b = isa_and_present(z->bar());
 
   // These don't trigger a warning.
   if (auto x = cast(y)->foo())
Index: clang-tools-extra/docs/clang-tidy/checks/llvm/prefer-isa-or-dyn-cast-in-conditionals.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/llvm/prefer-isa-or-dyn-cast-in-conditionals.rst
+++ clang-tools-extra/docs/clang-tidy/checks/llvm/prefer-isa-or-dyn-cast-in-conditionals.rst
@@ -26,7 +26,7 @@
 
   if (var && isa(var)) {}
   // is replaced by:
-  if (isa_and_nonnull(var.foo())) {}
+  if (isa_and_present(var.foo())) {}
 
   // Other cases are ignored, e.g.:
   if (auto f = cast(y)->foo()) {}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -105,6 +105,11 @@
 Changes in existing checks
 ^^
 
+- Updated :doc:`llvm-prefer-isa-or-dyn-cast-in-conditionals
+  ` check to
+  use the `*and_present` and `*if_present` templates added in 
+  `D123901 `_.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-ti

[PATCH] D131062: [docs] Add "C++20 Modules"

2022-08-06 Thread H. Vetinari via Phabricator via cfe-commits
h-vetinari added a comment.

> It would be greatly welcome for such comments!

OK, here goes. Sorry for the large volume of comments. In addition to typos and 
stylistic improvements, I've had a few questions where the content wasn't clear 
to me (but note I'm not experienced with modules at all, so this may be obvious 
to others). I've also added a few line breaks where Phab was awkwardly 
overflowing. The position of the linebreaks is obviously irrelevant, but I 
thought it might help further review.




Comment at: clang/docs/CPlusPlus20Modules.rst:11
+
+Modules have a lot of meanings. For the users of Clang compiler, modules may
+refer to ``Objective-C Modules``, ``Clang C++ Modules`` (or ``Clang Header 
Modules``,





Comment at: clang/docs/CPlusPlus20Modules.rst:13-14
+refer to ``Objective-C Modules``, ``Clang C++ Modules`` (or ``Clang Header 
Modules``,
+etc) and C++20 modules. The implementation of all kinds of the modules in 
Clang 
+share a big part of codes. But from the perspective of users, their semantics 
and
+command line interfaces are very different. So it should be helpful for the 
users





Comment at: clang/docs/CPlusPlus20Modules.rst:15-16
+share a big part of codes. But from the perspective of users, their semantics 
and
+command line interfaces are very different. So it should be helpful for the 
users
+to introduce how to use C++20 modules.
+

Not 100% what the intention of the last sentence is - I presume it sets the 
goal for this document?



Comment at: clang/docs/CPlusPlus20Modules.rst:20-21
+should be helpful to read `Clang modules `_ if you want to know
+more about the general idea of modules. Due to the C++20 modules having very
+different semantics, it might be more friendly for users who care about C++20
+modules only to create a new page.

> Due to the C++20 modules having very different semantics, it might be more 
> friendly for users who care about C++20 modules only to create a new page.

Isn't "C++20 modules" what this page intends to do? Which new page are we 
talking about then?



Comment at: clang/docs/CPlusPlus20Modules.rst:24-26
+Although the term ``modules`` has a unique meaning in C++20 Language 
Specification,
+when people talk about C++20 modules, they may refer to another C++20 feature:
+header units. So this document would try to cover header units too.





Comment at: clang/docs/CPlusPlus20Modules.rst:31-35
+This document was intended to be pure manual. But it should be helpful to
+introduce some language background here for readers who are not familiar with
+the new language feature. This document is not intended to be a language
+tutorial. The document would only introduce concepts about the the
+structure and building of the project.





Comment at: clang/docs/CPlusPlus20Modules.rst:49-51
+In this document, the term ``Clang Modules``/``Clang modules`` refer to Clang
+c++ modules extension. It is also known as ``Clang header modules``,
+``Clang module map modules`` or ``Clang c++ modules``.





Comment at: clang/docs/CPlusPlus20Modules.rst:64-66
+Things in ``[]`` means optional. The syntax of ``module_name`` and 
``partition_name``
+in regex form should be ``[a-zA-Z_][a-zA-Z_0-9.]*``. The dot ``.`` in the name 
has
+no special meaning.

> The dot ``.`` in the name has no special meaning.

Not sure if this is intended to say that the dot in the regex is not needed, or 
that it has no semantic significance.

Also, when wanting to match a literal "." in a regex, I'd consider it 
beneficial for clarity to escape it ("\."), even though it does what's intended 
in the context of [].



Comment at: clang/docs/CPlusPlus20Modules.rst:78-80
+A primary module interface unit is a module unit whose module declaration is
+``export module module_name;``. The ``module_name`` here denotes the name of 
the
+module. A module should have one and only primary module interface unit.





Comment at: clang/docs/CPlusPlus20Modules.rst:94-98
+In this document, we call ``primary module interface unit`` and
+``module partition interface unit`` as ``module interface unit``. We call 
``module
+interface unit`` and ``module partition implementation unit`` as
+``importable module unit``. We call ``module partition interface unit`` and
+``module partition implementation unit`` as ``module partition unit``.

This seems quite important for the terminology of the rest of the document, so 
I'd structure it in a way that stand out visually, e.g. the suggestion above.



Comment at: clang/docs/CPlusPlus20Modules.rst:147
+
+Then let's see a little bit more complex HelloWorld example which uses the 4 
kinds of module units.
+

Missing space

[PATCH] D131318: [clang-tidy] Add llvm-derefencing-dyn-cast check

2022-08-06 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

I had thought about merging this into the prefer-isa-or-dyn-cast in 
conditionals check, however there just isn't enough cross-over between the 2 
and the names wouldn't really match up with what each part of the check does.
There could be merit in merging them both into a new check and removing the old 
one, however I feel that could cause disruption for downstream users.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131318

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


[PATCH] D130108: git-clang-format: format index not worktree when using --staged

2022-08-06 Thread Mészáros Gergely via Phabricator via cfe-commits
Maetveis added a comment.

Friendly Ping.


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

https://reviews.llvm.org/D130108

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


[PATCH] D131314: [clang] format string checks for `InitListExpr`

2022-08-06 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Not a formal review of course, but for the diagnostics, I'm missing something 
that tells the user what the format string ended up looking like; in your 
example, the output never mentions that it checked "%s%d".




Comment at: clang/lib/Sema/SemaChecking.cpp:8707
+if (!HasCStringEnd) {
+  // FIXME: fire a warning that this InitListExprClass does not end with
+  // '\0', with FixIt hints

I'd prefer not to add more FIXME comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131314

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


[PATCH] D131314: [clang] format string checks for `InitListExpr`

2022-08-06 Thread YingChi Long via Phabricator via cfe-commits
inclyc added a comment.

There are too many things changed in this patch, I think the function of 
displaying the evaluation results, `FIXME` warning, these can be done in 
subsequent patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131314

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


[PATCH] D131314: [clang] format string checks for `InitListExpr`

2022-08-06 Thread YingChi Long via Phabricator via cfe-commits
inclyc updated this revision to Diff 450528.
inclyc added a comment.

Use isa<> to check Expr class


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131314

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

Index: clang/test/SemaCXX/format-strings.cpp
===
--- clang/test/SemaCXX/format-strings.cpp
+++ clang/test/SemaCXX/format-strings.cpp
@@ -166,6 +166,14 @@
 #if __cplusplus >= 201103L
 namespace evaluated {
 
+struct InitList {
+  static constexpr char value[] = {'%', 's', '%', 'd', '\0'}; // no note here because this is not literal
+};
+
+constexpr const char *init_list_func() { return InitList::value; }
+
+constexpr const char *init_list_func_wrap() { return init_list_func(); }
+
 constexpr const char *basic() { 
   return 
 "%s %d"; // expected-note {{format string is defined here}}
@@ -199,12 +207,15 @@
 
 void f() {
   printf(basic(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
-  printf(correct_fmt(), 1, 2);
+  printf(correct_fmt(), 1, 2); // no warning
   printf(string_linebreak(), 1, 2, 3, 4); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
   printf(not_literal(), 1, 2, 3, 4); // expected-warning {{format string is not a string literal}}
   printf(wrap_constexpr(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(InitList::value, 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(init_list_func(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(init_list_func_wrap(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
 }
 
 
-}
+} // namespace evaluated
 #endif
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8469,25 +8469,26 @@
 Sema &S, const FormatStringLiteral *FExpr, const Expr *OrigFormatExpr,
 ArrayRef Args, Sema::FormatArgumentPassingKind APK,
 unsigned format_idx, unsigned firstDataArg, Sema::FormatStringType Type,
-bool inFunctionCall, Sema::VariadicCallType CallType,
+bool NoNote, Sema::VariadicCallType CallType,
 llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg,
 bool IgnoreStringsWithoutSpecifiers);
 
-static const Expr *maybeConstEvalStringLiteral(ASTContext &Context,
-   const Expr *E);
-
-// Determine if an expression is a string literal or constant string.
-// If this function returns false on the arguments to a function expecting a
-// format string, we will usually need to emit a warning.
-// True string literals are then checked by CheckFormatString.
 static StringLiteralCheckType
-checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef Args,
-  Sema::FormatArgumentPassingKind APK, unsigned format_idx,
-  unsigned firstDataArg, Sema::FormatStringType Type,
-  Sema::VariadicCallType CallType, bool InFunctionCall,
-  llvm::SmallBitVector &CheckedVarArgs,
-  UncoveredArgHandler &UncoveredArg, llvm::APSInt Offset,
-  bool IgnoreStringsWithoutSpecifiers = false) {
+checkVarDecl(Sema &S, const Expr *E, ArrayRef Args,
+ Sema::FormatArgumentPassingKind APK, unsigned format_idx,
+ unsigned firstDataArg, Sema::FormatStringType Type,
+ Sema::VariadicCallType CallType, bool NoNote,
+ llvm::SmallBitVector &CheckedVarArgs,
+ UncoveredArgHandler &UncoveredArg, llvm::APSInt Offset, QualType T,
+ const VarDecl *VD, bool IgnoreStringsWithoutSpecifiers);
+
+static StringLiteralCheckType checkFormatStringExprEvaluated(
+Sema &S, const Expr *E, ArrayRef Args,
+Sema::FormatArgumentPassingKind APK, unsigned format_idx,
+unsigned firstDataArg, Sema::FormatStringType Type,
+Sema::VariadicCallType CallType, bool NoNote,
+llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg,
+llvm::APSInt Offset, bool IgnoreStringsWithoutSpecifiers = false) {
   if (S.isConstantEvaluated())
 return SLCT_NotALiteral;
 tryAgain:
@@ -8510,8 +8511,7 @@
   case Stmt::ConditionalOperatorClass: {
 // The expression is a literal if both sub-expressions were, and it was
 // completely checked only if both sub-expressions were checked.
-const AbstractConditionalOperator *C =
-cast(E);
+const AbstractConditionalOperator *C = cast(E);
 
 // Determine whether it is necessary to check both sub-expressions, for
 // example, because the condition expression is a constant that can

[PATCH] D128777: clang/cmake: Drop use of llvm-config for LLVM install discovery

2022-08-06 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 450529.
Ericson2314 added a comment.

Add my changes but split to just Clang as @tstellar requested


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128777

Files:
  clang/CMakeLists.txt

Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -15,54 +15,6 @@
   set(CMAKE_CXX_STANDARD_REQUIRED YES)
   set(CMAKE_CXX_EXTENSIONS NO)
 
-  # Rely on llvm-config.
-  set(LLVM_CONFIG_OUTPUT)
-  if(LLVM_CONFIG)
-set (LLVM_CONFIG_FOUND 1)
-message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
-message(DEPRECATION "Using llvm-config to detect the LLVM installation is \
-  deprecated.  The installed cmake files should be used \
-  instead.  CMake should be able to detect your LLVM install \
-  automatically, but you can also use LLVM_DIR to specify \
-  the path containing LLVMConfig.cmake.")
-set(CONFIG_COMMAND ${LLVM_CONFIG}
-  "--includedir"
-  "--prefix"
-  "--src-root"
-  "--cmakedir"
-  "--bindir"
-  "--libdir"
-  "--assertion-mode"
-  )
-execute_process(
-  COMMAND ${CONFIG_COMMAND}
-  RESULT_VARIABLE HAD_ERROR
-  OUTPUT_VARIABLE LLVM_CONFIG_OUTPUT
-)
-if(NOT HAD_ERROR)
-  string(REGEX REPLACE
-"[ \t]*[\r\n]+[ \t]*" ";"
-LLVM_CONFIG_OUTPUT ${LLVM_CONFIG_OUTPUT})
-else()
-  string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
-  message(STATUS "${CONFIG_COMMAND_STR}")
-  message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
-endif()
-
-list(GET LLVM_CONFIG_OUTPUT 0 MAIN_INCLUDE_DIR)
-list(GET LLVM_CONFIG_OUTPUT 1 LLVM_OBJ_ROOT)
-list(GET LLVM_CONFIG_OUTPUT 2 MAIN_SRC_DIR)
-list(GET LLVM_CONFIG_OUTPUT 3 LLVM_CONFIG_CMAKE_DIR)
-list(GET LLVM_CONFIG_OUTPUT 4 TOOLS_BINARY_DIR)
-list(GET LLVM_CONFIG_OUTPUT 5 LIBRARY_DIR)
-list(GET LLVM_CONFIG_OUTPUT 6 ENABLE_ASSERTIONS)
-
-# Normalize LLVM_CMAKE_DIR. --cmakedir might contain backslashes.
-# CMake assumes slashes as PATH.
-file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_DIR} LLVM_CMAKE_DIR)
-  endif()
-
-
   if(NOT MSVC_IDE)
 set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
   CACHE BOOL "Enable assertions")
@@ -73,26 +25,12 @@
   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
   list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
-  # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
-  # LLVM_CONFIG.
-  if (NOT LLVM_CONFIG_FOUND)
-# Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
-# path is removed.
-set(INCLUDE_DIRS ${LLVM_INCLUDE_DIRS})
-set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")
-# N.B. this is just a default value, the CACHE PATHs below can be overriden.
-set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
-set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}")
-set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}")
-  else()
-set(INCLUDE_DIRS "${LLVM_BINARY_DIR}/include" "${MAIN_INCLUDE_DIR}")
-  endif()
-
-  set(LLVM_INCLUDE_DIRS ${INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed")
-  set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree")
-  set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source tree")
-  set(LLVM_TOOLS_BINARY_DIR "${TOOLS_BINARY_DIR}" CACHE PATH "Path to llvm/bin")
-  set(LLVM_LIBRARY_DIR "${LIBRARY_DIR}" CACHE PATH "Path to llvm/lib")
+  # Turn into CACHE PATHs for overwritting
+  set(LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed")
+  set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}" CACHE PATH "Path to LLVM build tree")
+  set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" CACHE PATH "Path to LLVM source tree")
+  set(LLVM_TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}" CACHE PATH "Path to llvm/bin")
+  set(LLVM_LIBRARY_DIR "${LLVM_LIBRARY_DIR}" CACHE PATH "Path to llvm/lib")
 
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)
@@ -777,7 +715,6 @@
   endif()
 
   if(BOOTSTRAP_CMAKE_SYSTEM_NAME)
-set(${CLANG_STAGE}_CONFIG -DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config)
 set(${CLANG_STAGE}_TABLEGEN
   -DLLVM_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-tblgen
   -DCLANG_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-tblgen)
@@ -865,7 +802,6 @@
 ${CLANG_BOOTSTRAP_CMAKE_ARGS}
  -DCLANG_STAGE=${NEXT_CLANG_STAGE}
 ${COMPILER_OPTIONS}
-${${CLANG_STAGE}_CONFIG}
 ${${CLANG_STAGE}_TABLEGEN}
 ${LTO_LIBRARY} ${verbose} ${PGO_OPT}
 ${${CLANG_STAGE}_LINKER}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.l

[PATCH] D131314: [clang] format string checks for `InitListExpr`

2022-08-06 Thread YingChi Long via Phabricator via cfe-commits
inclyc updated this revision to Diff 450530.
inclyc added a comment.

rebase && qualify `const`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131314

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

Index: clang/test/SemaCXX/format-strings.cpp
===
--- clang/test/SemaCXX/format-strings.cpp
+++ clang/test/SemaCXX/format-strings.cpp
@@ -166,6 +166,14 @@
 #if __cplusplus >= 201103L
 namespace evaluated {
 
+struct InitList {
+  static constexpr char value[] = {'%', 's', '%', 'd', '\0'}; // no note here because this is not literal
+};
+
+constexpr const char *init_list_func() { return InitList::value; }
+
+constexpr const char *init_list_func_wrap() { return init_list_func(); }
+
 constexpr const char *basic() { 
   return 
 "%s %d"; // expected-note {{format string is defined here}}
@@ -199,12 +207,15 @@
 
 void f() {
   printf(basic(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
-  printf(correct_fmt(), 1, 2);
+  printf(correct_fmt(), 1, 2); // no warning
   printf(string_linebreak(), 1, 2, 3, 4); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
   printf(not_literal(), 1, 2, 3, 4); // expected-warning {{format string is not a string literal}}
   printf(wrap_constexpr(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(InitList::value, 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(init_list_func(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(init_list_func_wrap(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
 }
 
 
-}
+} // namespace evaluated
 #endif
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8469,25 +8469,26 @@
 Sema &S, const FormatStringLiteral *FExpr, const Expr *OrigFormatExpr,
 ArrayRef Args, Sema::FormatArgumentPassingKind APK,
 unsigned format_idx, unsigned firstDataArg, Sema::FormatStringType Type,
-bool inFunctionCall, Sema::VariadicCallType CallType,
+bool NoNote, Sema::VariadicCallType CallType,
 llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg,
 bool IgnoreStringsWithoutSpecifiers);
 
-static const Expr *maybeConstEvalStringLiteral(ASTContext &Context,
-   const Expr *E);
-
-// Determine if an expression is a string literal or constant string.
-// If this function returns false on the arguments to a function expecting a
-// format string, we will usually need to emit a warning.
-// True string literals are then checked by CheckFormatString.
 static StringLiteralCheckType
-checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef Args,
-  Sema::FormatArgumentPassingKind APK, unsigned format_idx,
-  unsigned firstDataArg, Sema::FormatStringType Type,
-  Sema::VariadicCallType CallType, bool InFunctionCall,
-  llvm::SmallBitVector &CheckedVarArgs,
-  UncoveredArgHandler &UncoveredArg, llvm::APSInt Offset,
-  bool IgnoreStringsWithoutSpecifiers = false) {
+checkVarDecl(Sema &S, const Expr *E, ArrayRef Args,
+ Sema::FormatArgumentPassingKind APK, unsigned format_idx,
+ unsigned firstDataArg, Sema::FormatStringType Type,
+ Sema::VariadicCallType CallType, bool NoNote,
+ llvm::SmallBitVector &CheckedVarArgs,
+ UncoveredArgHandler &UncoveredArg, llvm::APSInt Offset, QualType T,
+ const VarDecl *VD, bool IgnoreStringsWithoutSpecifiers);
+
+static StringLiteralCheckType checkFormatStringExprEvaluated(
+Sema &S, const Expr *E, ArrayRef Args,
+Sema::FormatArgumentPassingKind APK, unsigned format_idx,
+unsigned firstDataArg, Sema::FormatStringType Type,
+Sema::VariadicCallType CallType, bool NoNote,
+llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg,
+llvm::APSInt Offset, bool IgnoreStringsWithoutSpecifiers = false) {
   if (S.isConstantEvaluated())
 return SLCT_NotALiteral;
 tryAgain:
@@ -8510,8 +8511,7 @@
   case Stmt::ConditionalOperatorClass: {
 // The expression is a literal if both sub-expressions were, and it was
 // completely checked only if both sub-expressions were checked.
-const AbstractConditionalOperator *C =
-cast(E);
+const AbstractConditionalOperator *C = cast(E);
 
 // Determine whether it is necessary to check both sub-expressions, for
 // example, because the condition expression is a constant that can be

[PATCH] D131319: [clang-tidy] Update llvm-prefer-isa-or-dyn-cast-in-conditionals with new syntax

2022-08-06 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:110
+  ` check to
+  use the `*and_present` and `*if_present` templates added in 
+  `D123901 `_.

Please use double back-ticks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131319

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


[clang] 486a3c4 - Update the status of some more C DRs

2022-08-06 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-08-06T11:53:40-04:00
New Revision: 486a3c4662cb052329b96537da18893d73138b64

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

LOG: Update the status of some more C DRs

Update some of the C99-era DRs starting in the 300s.

Added: 
clang/test/C/drs/abc_123.h
clang/test/C/drs/dr3xx.c

Modified: 
clang/www/c_dr_status.html

Removed: 




diff  --git a/clang/test/C/drs/abc_123.h b/clang/test/C/drs/abc_123.h
new file mode 100644
index 0..2ce0e2c88045d
--- /dev/null
+++ b/clang/test/C/drs/abc_123.h
@@ -0,0 +1 @@
+#define WE_SUPPORT_DR302

diff  --git a/clang/test/C/drs/dr3xx.c b/clang/test/C/drs/dr3xx.c
new file mode 100644
index 0..de25c4d5e35bc
--- /dev/null
+++ b/clang/test/C/drs/dr3xx.c
@@ -0,0 +1,93 @@
+/* RUN: %clang_cc1 -std=c89 -fsyntax-only -Wvla -verify -pedantic 
-Wno-c11-extensions %s
+   RUN: %clang_cc1 -std=c99 -fsyntax-only -Wvla -verify -pedantic 
-Wno-c11-extensions %s
+   RUN: %clang_cc1 -std=c11 -fsyntax-only -Wvla -verify -pedantic %s
+   RUN: %clang_cc1 -std=c17 -fsyntax-only -Wvla -verify -pedantic %s
+   RUN: %clang_cc1 -std=c2x -fsyntax-only -Wvla -verify -pedantic %s
+ */
+
+/* The following are DRs which do not require tests to demonstrate
+ * conformance or nonconformance.
+ *
+ * WG14 DR300: yes
+ * Translation-time expresssion evaluation
+ *
+ * WG14 DR301: yes
+ * Meaning of FE_* macros in 
+ *
+ * WG14 DR303: yes
+ * Breaking up the very long sentence describing preprocessing directive
+ *
+ * WG14 DR307: yes
+ * Clarifiying arguments vs. parameters
+ *
+ * WG14 DR308: yes
+ * Clarify that source files et al. need not be "files"
+ *
+ * WG14 DR310: yes
+ * Add non-corner case example of trigraphs
+ *
+ * WG14 DR312: yes
+ * Meaning of "known constant size"
+ */
+
+
+/* WG14 DR302: yes
+ * Adding underscore to portable include file name character set
+ */
+#include "./abc_123.h"
+#ifndef WE_SUPPORT_DR302
+#error "Oh no, we don't support DR302 after all!"
+#endif
+
+/* WG14 DR304: yes
+ * Clarifying illegal tokens in #if directives
+ */
+/* expected-error@+3 {{invalid token at start of a preprocessor expression}}
+   expected-warning@+3 {{missing terminating ' character}}
+ */
+#if 'test
+#endif
+
+/* WG14 DR305: yes
+ * Clarifying handling of keywords in #if directives
+ */
+#if int
+#error "We definitely should not have gotten here"
+#endif
+
+/* WG14 DR306: yes
+ * Clarifying that rescanning applies to object-like macros
+ */
+#define REPLACE 1
+#define THIS REPLACE
+#if THIS != 1
+#error "We definitely should not have gotten here"
+#endif
+
+/* WG14 DR309: yes
+ * Clarifying trigraph substitution
+ */
+int dr309??(1??) = { 1 }; /* expected-warning {{trigraph converted to '[' 
character}}
+ expected-warning {{trigraph converted to ']' 
character}}
+   */
+
+/* WG14 DR311: yes
+ * Definition of variably modified types
+ */
+void dr311(int x) {
+  typedef int vla[x]; /* expected-warning {{variable length array}} */
+
+  /* Ensure that a constant array of variable-length arrays are still
+   * considered a variable-length array.
+   */
+  vla y[3]; /* expected-warning {{variable length array}} */
+}
+
+/* WG14 DR313:
+ * Incomplete arrays of VLAs
+ */
+void dr313(int i) {
+  int c[][i] = { 0 }; /* expected-error {{variable-sized object may not be 
initialized}}
+ expected-warning {{variable length array}}
+   */
+}

diff  --git a/clang/www/c_dr_status.html b/clang/www/c_dr_status.html
index 59ed6defa44c0..3d0a64b731500 100644
--- a/clang/www/c_dr_status.html
+++ b/clang/www/c_dr_status.html
@@ -1753,49 +1753,49 @@ C defect report implementation status
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_300.htm";>300
 NAD
 Translation-time expresssion evaluation
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_301.htm";>301
 NAD
 Meaning of FE_* macros in 
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_302.htm";>302
 C99
 6.10.2p5: Adding underscore to portable include file name character 
set
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_303.htm";>303
 C99
 6.10p2: Breaking up the very long sentence describing preprocessing 
directive
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_304.htm";>304
 C99
 Clarifying illegal tokens in #if directives
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_305.htm";>305
 C99
 6.10.1p3: Clarifying handling of keywords in #if directives
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/

[PATCH] D49863: [istream] Fix error flags and exceptions propagated from input stream operations

2022-08-06 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: libcxx/trunk/include/istream:1223
+__state |= ios_base::badbit;
 return -1;
 }

@ldionne, another dubious aspect of this patch is that it initializes `__r` to 
`0` and never sets it. Seems like this line should have been to set `__r` and 
not to return directly.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D49863

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


[PATCH] D128777: clang/cmake: Drop use of llvm-config for LLVM install discovery

2022-08-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny accepted this revision.
mgorny added a comment.

This one LGTM to me as well, and doesn't seem to break Gentoo either ;-).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128777

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


[PATCH] D131307: [Clang] Allow downgrading to a warning the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2022-08-06 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Thank you!

I'm worried that users might miss this if it's only in the release notes, and 
then we'd be in a similar situation again when we try converting it to an 
error. Maybe you could also include the bit about the diagnostic turning into 
error-only in the diagnostic message itself, to make it more likely for people 
to notice it?


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

https://reviews.llvm.org/D131307

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


[PATCH] D131277: clang: fix typo availbility

2022-08-06 Thread YingChi Long via Phabricator via cfe-commits
inclyc accepted this revision.
inclyc added a comment.
This revision is now accepted and ready to land.

LGTM. Could you please provide your real name and email address, like Name 
 ? So that I can commit this for you. Also feel free to ask for 
commit access.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131277

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


[PATCH] D131258: [Sema] Merge variable template specializations

2022-08-06 Thread YingChi Long via Phabricator via cfe-commits
inclyc added inline comments.



Comment at: clang/test/Modules/merge-var-template-spec-cxx-modules.cpp:45
+export import var_def;
\ No newline at end of file


Missing newline



Comment at: clang/test/Modules/merge-var-template-spec.cpp:68
+#endif // VAR2_H
\ No newline at end of file


Missing newline


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131258

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


[PATCH] D131277: clang: fix typo availbility

2022-08-06 Thread Aarush Bhat via Phabricator via cfe-commits
sloorush added a comment.

@inclyc, Here is my real name and email address in the requested format:

Aarush Bhat 

I would love to get commit access. What exactly is the process? Do I have to 
email as mentioned in 
https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131277

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


[PATCH] D131277: clang: fix typo availbility

2022-08-06 Thread YingChi Long via Phabricator via cfe-commits
inclyc added a comment.

In D131277#3704510 , @sloorush wrote:

> @inclyc, Here is my real name and email address in the requested format:
>
> Aarush Bhat 
>
> I would love to get commit access. What exactly is the process? Do I have to 
> email as mentioned in 
> https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access?

Don't worry! Just feel free to send the email to Lattner, he is very fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131277

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


[clang] a6cb841 - clang: fix typo availbility

2022-08-06 Thread YingChi Long via cfe-commits

Author: Aarush Bhat
Date: 2022-08-07T03:44:55+08:00
New Revision: a6cb8419b1757380e3c577477fdc2501484a7245

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

LOG: clang: fix typo availbility

- Fixes [[ https://github.com/llvm/llvm-project/issues/56787 | #56787 ]].

I am fixing the spelling of availability.

I am unsure if this change will have any side effects. If someone can
help on how to check if it has any side effects, I can test those out as
well.

Reviewed By: inclyc

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

Added: 


Modified: 
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp

Removed: 




diff  --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp 
b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 6a88f8d73d4a7..d1bf83c8674f2 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -494,7 +494,7 @@ SymbolGraphSerializer::serializeAPIRecord(const RecordTy 
&Record) const {
   serializeObject(
   Obj, "location",
   serializeSourceLocation(Record.Location, /*IncludeFileURI=*/true));
-  serializeObject(Obj, "availbility",
+  serializeObject(Obj, "availability",
   serializeAvailability(Record.Availability));
   serializeObject(Obj, "docComment", serializeDocComment(Record.Comment));
   serializeArray(Obj, "declarationFragments",



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


[PATCH] D131277: clang: fix typo availbility

2022-08-06 Thread YingChi Long 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 rGa6cb8419b175: clang: fix typo availbility (authored by 
sloorush, committed by inclyc).

Changed prior to commit:
  https://reviews.llvm.org/D131277?vs=450339&id=450565#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131277

Files:
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp


Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -494,7 +494,7 @@
   serializeObject(
   Obj, "location",
   serializeSourceLocation(Record.Location, /*IncludeFileURI=*/true));
-  serializeObject(Obj, "availbility",
+  serializeObject(Obj, "availability",
   serializeAvailability(Record.Availability));
   serializeObject(Obj, "docComment", serializeDocComment(Record.Comment));
   serializeArray(Obj, "declarationFragments",


Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -494,7 +494,7 @@
   serializeObject(
   Obj, "location",
   serializeSourceLocation(Record.Location, /*IncludeFileURI=*/true));
-  serializeObject(Obj, "availbility",
+  serializeObject(Obj, "availability",
   serializeAvailability(Record.Availability));
   serializeObject(Obj, "docComment", serializeDocComment(Record.Comment));
   serializeArray(Obj, "declarationFragments",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131277: clang: fix typo availbility

2022-08-06 Thread Aarush Bhat via Phabricator via cfe-commits
sloorush added a comment.

In D131277#3704519 , @inclyc wrote:

> In D131277#3704510 , @sloorush 
> wrote:
>
>> @inclyc, Here is my real name and email address in the requested format:
>>
>> Aarush Bhat 
>>
>> I would love to get commit access. What exactly is the process? Do I have to 
>> email as mentioned in 
>> https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access?
>
> Don't worry! Just feel free to send the email to Lattner, he is very fine.

Okay! I'll drop them an email. Meanwhile, will you be committing this change on 
my behalf?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131277

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


[PATCH] D131277: clang: fix typo availbility

2022-08-06 Thread YingChi Long via Phabricator via cfe-commits
inclyc added a comment.

Copied from github comments:

Thanks for working on this, changes on serialization may still cause issue 
related to backward compatibility. Even though this patch passed all regression 
tests,  if in the future some one reports clang must give `availbility` (typo), 
we may have to revert this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131277

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


[clang] d2b158e - clang/cmake: Drop use of llvm-config for LLVM install discovery

2022-08-06 Thread John Ericson via cfe-commits

Author: Tom Stellard
Date: 2022-08-06T16:22:59-04:00
New Revision: d2b158e29eedf4a29bf8d2142f2ed21a52fc80a7

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

LOG: clang/cmake: Drop use of llvm-config for LLVM install discovery

This has been deprecated for a while, since D51714 in 2018.

Remove it in favor of using CMake's find_package() function.

Reviewed By: phosek, mgorny

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

Added: 


Modified: 
clang/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index bf1268c08420..f6e860159435 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -15,54 +15,6 @@ if(CLANG_BUILT_STANDALONE)
   set(CMAKE_CXX_STANDARD_REQUIRED YES)
   set(CMAKE_CXX_EXTENSIONS NO)
 
-  # Rely on llvm-config.
-  set(LLVM_CONFIG_OUTPUT)
-  if(LLVM_CONFIG)
-set (LLVM_CONFIG_FOUND 1)
-message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
-message(DEPRECATION "Using llvm-config to detect the LLVM installation is \
-  deprecated.  The installed cmake files should be used \
-  instead.  CMake should be able to detect your LLVM install \
-  automatically, but you can also use LLVM_DIR to specify \
-  the path containing LLVMConfig.cmake.")
-set(CONFIG_COMMAND ${LLVM_CONFIG}
-  "--includedir"
-  "--prefix"
-  "--src-root"
-  "--cmakedir"
-  "--bindir"
-  "--libdir"
-  "--assertion-mode"
-  )
-execute_process(
-  COMMAND ${CONFIG_COMMAND}
-  RESULT_VARIABLE HAD_ERROR
-  OUTPUT_VARIABLE LLVM_CONFIG_OUTPUT
-)
-if(NOT HAD_ERROR)
-  string(REGEX REPLACE
-"[ \t]*[\r\n]+[ \t]*" ";"
-LLVM_CONFIG_OUTPUT ${LLVM_CONFIG_OUTPUT})
-else()
-  string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
-  message(STATUS "${CONFIG_COMMAND_STR}")
-  message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
-endif()
-
-list(GET LLVM_CONFIG_OUTPUT 0 MAIN_INCLUDE_DIR)
-list(GET LLVM_CONFIG_OUTPUT 1 LLVM_OBJ_ROOT)
-list(GET LLVM_CONFIG_OUTPUT 2 MAIN_SRC_DIR)
-list(GET LLVM_CONFIG_OUTPUT 3 LLVM_CONFIG_CMAKE_DIR)
-list(GET LLVM_CONFIG_OUTPUT 4 TOOLS_BINARY_DIR)
-list(GET LLVM_CONFIG_OUTPUT 5 LIBRARY_DIR)
-list(GET LLVM_CONFIG_OUTPUT 6 ENABLE_ASSERTIONS)
-
-# Normalize LLVM_CMAKE_DIR. --cmakedir might contain backslashes.
-# CMake assumes slashes as PATH.
-file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_DIR} LLVM_CMAKE_DIR)
-  endif()
-
-
   if(NOT MSVC_IDE)
 set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
   CACHE BOOL "Enable assertions")
@@ -73,26 +25,12 @@ if(CLANG_BUILT_STANDALONE)
   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
   list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
-  # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
-  # LLVM_CONFIG.
-  if (NOT LLVM_CONFIG_FOUND)
-# Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
-# path is removed.
-set(INCLUDE_DIRS ${LLVM_INCLUDE_DIRS})
-set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")
-# N.B. this is just a default value, the CACHE PATHs below can be 
overriden.
-set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
-set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}")
-set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}")
-  else()
-set(INCLUDE_DIRS "${LLVM_BINARY_DIR}/include" "${MAIN_INCLUDE_DIR}")
-  endif()
-
-  set(LLVM_INCLUDE_DIRS ${INCLUDE_DIRS} CACHE PATH "Path to llvm/include and 
any other header dirs needed")
-  set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree")
-  set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source 
tree")
-  set(LLVM_TOOLS_BINARY_DIR "${TOOLS_BINARY_DIR}" CACHE PATH "Path to 
llvm/bin")
-  set(LLVM_LIBRARY_DIR "${LIBRARY_DIR}" CACHE PATH "Path to llvm/lib")
+  # Turn into CACHE PATHs for overwritting
+  set(LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS} CACHE PATH "Path to llvm/include 
and any other header dirs needed")
+  set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}" CACHE PATH "Path to LLVM build 
tree")
+  set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" CACHE PATH "Path 
to LLVM source tree")
+  set(LLVM_TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}" CACHE PATH "Path to 
llvm/bin")
+  set(LLVM_LIBRARY_DIR "${LLVM_LIBRARY_DIR}" CACHE PATH "Path to llvm/lib")
 
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)
@@ -777,7 +715,6 @@ if (CLANG_ENABLE_BOOTSTRAP)
   endif()
 
   if(BOOTSTRAP_CMAKE_SYSTEM_NAME)
-set(${CLANG_STAGE}_CONFIG 
-DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config)
 set(${CLANG_STAGE}_TABLEGEN
   -DLLVM_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-tblgen
   -DCLA

[PATCH] D128777: clang/cmake: Drop use of llvm-config for LLVM install discovery

2022-08-06 Thread John Ericson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd2b158e29eed: clang/cmake: Drop use of llvm-config for LLVM 
install discovery (authored by tstellar, committed by Ericson2314).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128777

Files:
  clang/CMakeLists.txt

Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -15,54 +15,6 @@
   set(CMAKE_CXX_STANDARD_REQUIRED YES)
   set(CMAKE_CXX_EXTENSIONS NO)
 
-  # Rely on llvm-config.
-  set(LLVM_CONFIG_OUTPUT)
-  if(LLVM_CONFIG)
-set (LLVM_CONFIG_FOUND 1)
-message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
-message(DEPRECATION "Using llvm-config to detect the LLVM installation is \
-  deprecated.  The installed cmake files should be used \
-  instead.  CMake should be able to detect your LLVM install \
-  automatically, but you can also use LLVM_DIR to specify \
-  the path containing LLVMConfig.cmake.")
-set(CONFIG_COMMAND ${LLVM_CONFIG}
-  "--includedir"
-  "--prefix"
-  "--src-root"
-  "--cmakedir"
-  "--bindir"
-  "--libdir"
-  "--assertion-mode"
-  )
-execute_process(
-  COMMAND ${CONFIG_COMMAND}
-  RESULT_VARIABLE HAD_ERROR
-  OUTPUT_VARIABLE LLVM_CONFIG_OUTPUT
-)
-if(NOT HAD_ERROR)
-  string(REGEX REPLACE
-"[ \t]*[\r\n]+[ \t]*" ";"
-LLVM_CONFIG_OUTPUT ${LLVM_CONFIG_OUTPUT})
-else()
-  string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
-  message(STATUS "${CONFIG_COMMAND_STR}")
-  message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
-endif()
-
-list(GET LLVM_CONFIG_OUTPUT 0 MAIN_INCLUDE_DIR)
-list(GET LLVM_CONFIG_OUTPUT 1 LLVM_OBJ_ROOT)
-list(GET LLVM_CONFIG_OUTPUT 2 MAIN_SRC_DIR)
-list(GET LLVM_CONFIG_OUTPUT 3 LLVM_CONFIG_CMAKE_DIR)
-list(GET LLVM_CONFIG_OUTPUT 4 TOOLS_BINARY_DIR)
-list(GET LLVM_CONFIG_OUTPUT 5 LIBRARY_DIR)
-list(GET LLVM_CONFIG_OUTPUT 6 ENABLE_ASSERTIONS)
-
-# Normalize LLVM_CMAKE_DIR. --cmakedir might contain backslashes.
-# CMake assumes slashes as PATH.
-file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_DIR} LLVM_CMAKE_DIR)
-  endif()
-
-
   if(NOT MSVC_IDE)
 set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
   CACHE BOOL "Enable assertions")
@@ -73,26 +25,12 @@
   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
   list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
-  # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
-  # LLVM_CONFIG.
-  if (NOT LLVM_CONFIG_FOUND)
-# Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
-# path is removed.
-set(INCLUDE_DIRS ${LLVM_INCLUDE_DIRS})
-set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")
-# N.B. this is just a default value, the CACHE PATHs below can be overriden.
-set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
-set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}")
-set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}")
-  else()
-set(INCLUDE_DIRS "${LLVM_BINARY_DIR}/include" "${MAIN_INCLUDE_DIR}")
-  endif()
-
-  set(LLVM_INCLUDE_DIRS ${INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed")
-  set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree")
-  set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source tree")
-  set(LLVM_TOOLS_BINARY_DIR "${TOOLS_BINARY_DIR}" CACHE PATH "Path to llvm/bin")
-  set(LLVM_LIBRARY_DIR "${LIBRARY_DIR}" CACHE PATH "Path to llvm/lib")
+  # Turn into CACHE PATHs for overwritting
+  set(LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed")
+  set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}" CACHE PATH "Path to LLVM build tree")
+  set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" CACHE PATH "Path to LLVM source tree")
+  set(LLVM_TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}" CACHE PATH "Path to llvm/bin")
+  set(LLVM_LIBRARY_DIR "${LLVM_LIBRARY_DIR}" CACHE PATH "Path to llvm/lib")
 
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)
@@ -777,7 +715,6 @@
   endif()
 
   if(BOOTSTRAP_CMAKE_SYSTEM_NAME)
-set(${CLANG_STAGE}_CONFIG -DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config)
 set(${CLANG_STAGE}_TABLEGEN
   -DLLVM_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-tblgen
   -DCLANG_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-tblgen)
@@ -865,7 +802,6 @@
 ${CLANG_BOOTSTRAP_CMAKE_ARGS}
  -DCLANG_STAGE=${NEXT_CLANG_STAGE}
 ${COMPILER_OPTIONS}
-${${CLANG_STAGE}_CONFIG}
 ${${CLANG_STAGE}_TABLEGEN}
 ${LTO_LIBRARY} ${verbose} ${PGO_OPT}
 ${${CLANG_STAGE}_LINKER}

[PATCH] D131314: [clang] format string checks for `InitListExpr`

2022-08-06 Thread YingChi Long via Phabricator via cfe-commits
inclyc updated this revision to Diff 450569.
inclyc added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131314

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

Index: clang/test/SemaCXX/format-strings.cpp
===
--- clang/test/SemaCXX/format-strings.cpp
+++ clang/test/SemaCXX/format-strings.cpp
@@ -166,6 +166,14 @@
 #if __cplusplus >= 201103L
 namespace evaluated {
 
+struct InitList {
+  static constexpr char value[] = {'%', 's', '%', 'd', '\0'}; // no note here because this is not literal
+};
+
+constexpr const char *init_list_func() { return InitList::value; }
+
+constexpr const char *init_list_func_wrap() { return init_list_func(); }
+
 constexpr const char *basic() { 
   return 
 "%s %d"; // expected-note {{format string is defined here}}
@@ -199,12 +207,15 @@
 
 void f() {
   printf(basic(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
-  printf(correct_fmt(), 1, 2);
+  printf(correct_fmt(), 1, 2); // no warning
   printf(string_linebreak(), 1, 2, 3, 4); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
   printf(not_literal(), 1, 2, 3, 4); // expected-warning {{format string is not a string literal}}
   printf(wrap_constexpr(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(InitList::value, 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(init_list_func(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(init_list_func_wrap(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
 }
 
 
-}
+} // namespace evaluated
 #endif
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8469,25 +8469,26 @@
 Sema &S, const FormatStringLiteral *FExpr, const Expr *OrigFormatExpr,
 ArrayRef Args, Sema::FormatArgumentPassingKind APK,
 unsigned format_idx, unsigned firstDataArg, Sema::FormatStringType Type,
-bool inFunctionCall, Sema::VariadicCallType CallType,
+bool NoNote, Sema::VariadicCallType CallType,
 llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg,
 bool IgnoreStringsWithoutSpecifiers);
 
-static const Expr *maybeConstEvalStringLiteral(ASTContext &Context,
-   const Expr *E);
-
-// Determine if an expression is a string literal or constant string.
-// If this function returns false on the arguments to a function expecting a
-// format string, we will usually need to emit a warning.
-// True string literals are then checked by CheckFormatString.
 static StringLiteralCheckType
-checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef Args,
-  Sema::FormatArgumentPassingKind APK, unsigned format_idx,
-  unsigned firstDataArg, Sema::FormatStringType Type,
-  Sema::VariadicCallType CallType, bool InFunctionCall,
-  llvm::SmallBitVector &CheckedVarArgs,
-  UncoveredArgHandler &UncoveredArg, llvm::APSInt Offset,
-  bool IgnoreStringsWithoutSpecifiers = false) {
+checkVarDecl(Sema &S, const Expr *E, ArrayRef Args,
+ Sema::FormatArgumentPassingKind APK, unsigned format_idx,
+ unsigned firstDataArg, Sema::FormatStringType Type,
+ Sema::VariadicCallType CallType, bool NoNote,
+ llvm::SmallBitVector &CheckedVarArgs,
+ UncoveredArgHandler &UncoveredArg, llvm::APSInt Offset, QualType T,
+ const VarDecl *VD, bool IgnoreStringsWithoutSpecifiers);
+
+static StringLiteralCheckType checkFormatStringExprEvaluated(
+Sema &S, const Expr *E, ArrayRef Args,
+Sema::FormatArgumentPassingKind APK, unsigned format_idx,
+unsigned firstDataArg, Sema::FormatStringType Type,
+Sema::VariadicCallType CallType, bool NoNote,
+llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg,
+llvm::APSInt Offset, bool IgnoreStringsWithoutSpecifiers = false) {
   if (S.isConstantEvaluated())
 return SLCT_NotALiteral;
 tryAgain:
@@ -8510,8 +8511,7 @@
   case Stmt::ConditionalOperatorClass: {
 // The expression is a literal if both sub-expressions were, and it was
 // completely checked only if both sub-expressions were checked.
-const AbstractConditionalOperator *C =
-cast(E);
+const AbstractConditionalOperator *C = cast(E);
 
 // Determine whether it is necessary to check both sub-expressions, for
 // example, because the condition expression is a constant that can be
@@ -8535,18 +8535,1

[clang] e21202d - [Clang][OpenMP] Fix the issue that `llvm.lifetime.end` is emitted too early for variables captured in linear clause

2022-08-06 Thread Shilei Tian via cfe-commits

Author: Shilei Tian
Date: 2022-08-06T16:50:37-04:00
New Revision: e21202dac18ed7f718d26a0e131f96b399b4891c

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

LOG: [Clang][OpenMP] Fix the issue that `llvm.lifetime.end` is emitted too 
early for variables captured in linear clause

Currently if an OpenMP program uses `linear` clause, and is compiled with
optimization, `llvm.lifetime.end` for variables listed in `linear` clause are
emitted too early such that there could still be uses after that. Let's take the
following code as example:
```
// loop.c
int j;
int *u;

void loop(int n) {
  int i;
  for (i = 0; i < n; ++i) {
++j;
u = &j;
  }
}
```
We compile using the command:
```
clang -cc1 -fopenmp-simd -O3 -x c -triple x86_64-apple-darwin10 -emit-llvm 
loop.c -o loop.ll
```
The following IR (simplified) will be generated:
```
@j = local_unnamed_addr global i32 0, align 4
@u = local_unnamed_addr global ptr null, align 8

define void @loop(i32 noundef %n) local_unnamed_addr {
entry:
  %j = alloca i32, align 4
  %cmp = icmp sgt i32 %n, 0
  br i1 %cmp, label %simd.if.then, label %simd.if.end

simd.if.then: ; preds = %entry
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %j)
  store ptr %j, ptr @u, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %j)
  %0 = load i32, ptr %j, align 4
  store i32 %0, ptr @j, align 4
  br label %simd.if.end

simd.if.end:  ; preds = %simd.if.then, 
%entry
  ret void
}
```
The most important part is:
```
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %j)
  %0 = load i32, ptr %j, align 4
  store i32 %0, ptr @j, align 4
```
`%j` is still loaded after `@llvm.lifetime.end.p0(i64 4, ptr nonnull %j)`. This
could cause the backend incorrectly optimizes the code and further generates
incorrect code. The root cause is, when we emit a construct that could have
`linear` clause, it usually has the following pattern:
```
EmitOMPLinearClauseInit(S)
{
  OMPPrivateScope LoopScope(*this);
  ...
  EmitOMPLinearClause(S, LoopScope);
  ...
  (void)LoopScope.Privatize();
  ...
}
EmitOMPLinearClauseFinal(S, [](CodeGenFunction &) { return nullptr; });
```
Variables that need to be privatized are added into `LoopScope`, which also
serves as a RAII object. When `LoopScope` is destructed and if optimization is
enabled, a `@llvm.lifetime.end` is also emitted for each privatized variable.
However, the writing back to original variables in `linear` clause happens after
the scope in `EmitOMPLinearClauseFinal`, causing the issue we see above.

A quick "fix" seems to be, moving `EmitOMPLinearClauseFinal` inside the scope.
However, it doesn't work. That's because the local variable map has been updated
by `LoopScope` such that a variable declaration is mapped to the privatized
variable, instead of the actual one. In that way, the following code will be
generated:
```
  %0 = load i32, ptr %j, align 4
  store i32 %0, ptr %j, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %j)
```
Well, now the life time is correct, but apparently the writing back is broken.

In this patch, a new function `OMPPrivateScope::restoreMap` is added and called
before calling `EmitOMPLinearClauseFinal`. This can make sure that
`EmitOMPLinearClauseFinal` can find the orignal varaibls to write back.

Fixes #56913.

Reviewed By: ABataev

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

Added: 
clang/test/OpenMP/bug56913.c

Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/test/OpenMP/for_linear_codegen.cpp
clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 962620f43a393..5219b6e39f4e2 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -2582,8 +2582,9 @@ static void emitOMPSimdRegion(CodeGenFunction &CGF, const 
OMPLoopDirective &S,
 CGF.EmitOMPReductionClauseFinal(S, /*ReductionKind=*/OMPD_simd);
 emitPostUpdateForReductionClause(CGF, S,
  [](CodeGenFunction &) { return nullptr; 
});
+LoopScope.restoreMap();
+CGF.EmitOMPLinearClauseFinal(S, [](CodeGenFunction &) { return nullptr; });
   }
-  CGF.EmitOMPLinearClauseFinal(S, [](CodeGenFunction &) { return nullptr; });
   // Emit: if (PreCond) - end.
   if (ContBlock) {
 CGF.EmitBranch(ContBlock);
@@ -3428,11 +3429,12 @@ bool CodeGenFunction::EmitOMPWorksharingLoop(
 EmitOMPLastprivateClauseFinal(
 S, isOpenMPSimdDirective(S.getDirectiveKind()),
 Builder.CreateIsNotNull(EmitLoadOfScalar(IL, S.getBeginLoc(;
+  LoopScope.restoreMap();
+ 

[PATCH] D131272: [Clang][OpenMP] Fix the issue that `llvm.lifetime.end` is emitted too early for variables captured in linear clause

2022-08-06 Thread Shilei Tian via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe21202dac18e: [Clang][OpenMP] Fix the issue that 
`llvm.lifetime.end` is emitted too early for… (authored by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131272

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/bug56913.c
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp

Index: clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp
===
--- clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp
+++ clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp
@@ -1847,8 +1847,12 @@
 // CHECK6-NEXT:[[TMP38:%.*]] = icmp ne i32 [[TMP37]], 0
 // CHECK6-NEXT:br i1 [[TMP38]], label [[DOTOMP_LINEAR_PU_I:%.*]], label [[DOTOMP_OUTLINED__1_EXIT:%.*]]
 // CHECK6:   .omp.linear.pu.i:
-// CHECK6-NEXT:[[TMP39:%.*]] = load i32, i32* [[J_I]], align 4, !noalias !14
-// CHECK6-NEXT:store i32 [[TMP39]], i32* [[J_I]], align 4, !noalias !14
+// CHECK6-NEXT:[[TMP39:%.*]] = getelementptr inbounds [[STRUCT_ANON]], %struct.anon* [[TMP20]], i32 0, i32 0
+// CHECK6-NEXT:[[TMP40:%.*]] = load i32*, i32** [[TMP39]], align 8
+// CHECK6-NEXT:[[TMP41:%.*]] = getelementptr inbounds [[STRUCT_ANON]], %struct.anon* [[TMP20]], i32 0, i32 1
+// CHECK6-NEXT:[[TMP42:%.*]] = load i32*, i32** [[TMP41]], align 8
+// CHECK6-NEXT:[[TMP43:%.*]] = load i32, i32* [[J_I]], align 4, !noalias !14
+// CHECK6-NEXT:store i32 [[TMP43]], i32* [[TMP42]], align 4
 // CHECK6-NEXT:br label [[DOTOMP_OUTLINED__1_EXIT]]
 // CHECK6:   .omp_outlined..1.exit:
 // CHECK6-NEXT:ret i32 0
Index: clang/test/OpenMP/for_linear_codegen.cpp
===
--- clang/test/OpenMP/for_linear_codegen.cpp
+++ clang/test/OpenMP/for_linear_codegen.cpp
@@ -322,18 +322,18 @@
 // CHECK1-NEXT:br label [[OMP_LOOP_EXIT:%.*]]
 // CHECK1:   omp.loop.exit:
 // CHECK1-NEXT:call void @__kmpc_for_static_fini(%struct.ident_t* @[[GLOB2]], i32 [[TMP5]])
-// CHECK1-NEXT:[[TMP19:%.*]] = bitcast i64* [[DOTLVAR__ADDR]] to i8*
-// CHECK1-NEXT:call void @__kmpc_free(i32 [[TMP5]], i8* [[TMP19]], i8* inttoptr (i64 5 to i8*))
-// CHECK1-NEXT:[[TMP20:%.*]] = load i32, i32* [[DOTOMP_IS_LAST]], align 4
-// CHECK1-NEXT:[[TMP21:%.*]] = icmp ne i32 [[TMP20]], 0
-// CHECK1-NEXT:br i1 [[TMP21]], label [[DOTOMP_LINEAR_PU:%.*]], label [[DOTOMP_LINEAR_PU_DONE:%.*]]
+// CHECK1-NEXT:[[TMP19:%.*]] = load i32, i32* [[DOTOMP_IS_LAST]], align 4
+// CHECK1-NEXT:[[TMP20:%.*]] = icmp ne i32 [[TMP19]], 0
+// CHECK1-NEXT:br i1 [[TMP20]], label [[DOTOMP_LINEAR_PU:%.*]], label [[DOTOMP_LINEAR_PU_DONE:%.*]]
 // CHECK1:   .omp.linear.pu:
-// CHECK1-NEXT:[[TMP22:%.*]] = load float*, float** [[PVAR2]], align 8
-// CHECK1-NEXT:store float* [[TMP22]], float** [[TMP0]], align 8
-// CHECK1-NEXT:[[TMP23:%.*]] = load i64, i64* [[DOTLVAR__ADDR]], align 8
-// CHECK1-NEXT:store i64 [[TMP23]], i64* [[TMP1]], align 8
+// CHECK1-NEXT:[[TMP21:%.*]] = load float*, float** [[PVAR2]], align 8
+// CHECK1-NEXT:store float* [[TMP21]], float** [[TMP0]], align 8
+// CHECK1-NEXT:[[TMP22:%.*]] = load i64, i64* [[DOTLVAR__ADDR]], align 8
+// CHECK1-NEXT:store i64 [[TMP22]], i64* [[TMP1]], align 8
 // CHECK1-NEXT:br label [[DOTOMP_LINEAR_PU_DONE]]
 // CHECK1:   .omp.linear.pu.done:
+// CHECK1-NEXT:[[TMP23:%.*]] = bitcast i64* [[DOTLVAR__ADDR]] to i8*
+// CHECK1-NEXT:call void @__kmpc_free(i32 [[TMP5]], i8* [[TMP23]], i8* inttoptr (i64 5 to i8*))
 // CHECK1-NEXT:call void @__kmpc_barrier(%struct.ident_t* @[[GLOB1]], i32 [[TMP5]])
 // CHECK1-NEXT:ret void
 //
Index: clang/test/OpenMP/bug56913.c
===
--- /dev/null
+++ clang/test/OpenMP/bug56913.c
@@ -0,0 +1,32 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --prefix-filecheck-ir-name _
+// RUN: %clang_cc1 -fopenmp-simd -O1 -x c -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+
+int j;
+int *u;
+
+void loop(int n) {
+  int i;
+#pragma omp parallel master taskloop simd linear(j)
+  for (i = 0; i < n; ++i) {
+++j;
+u = &j;
+  }
+}
+// CHECK-LABEL: define {{[^@]+}}@loop
+// CHECK-SAME: (i32 noundef [[N:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[J:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[CMP:%.*]] = icmp sgt i32 [[N]], 0
+// CHECK-NEXT:br i1 [[CMP]], label [[SIMD_IF_THEN:%.*]], label [[SIMD_IF_END:%.*]]
+// CHECK:   simd.if.then:
+// CHE

[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-06 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

Your change is causing a build failure on the PS4 linux build bot using GCC 
9.3. Can you take a look?
https://lab.llvm.org/buildbot/#/builders/139/builds/26186

  FAILED: 
tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/obj.clangTidyBugproneModule.dir/SignalHandlerCheck.cpp.o
 
  CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/g++ 
-DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/tools/extra/clang-tidy/bugprone
 
-I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/clang-tidy/bugprone
 
-I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/tools/extra/clang-tidy
 
-I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/include
 
-I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/include
 -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/include 
-I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden 
-Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings 
-Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long 
-Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess 
-Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment 
-Wmisleading-indentation -fdiagnostics-color -ffunction-sections 
-fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3 
-DNDEBUG  -fno-exceptions -fno-rtti -UNDEBUG -std=c++17 -MD -MT 
tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/obj.clangTidyBugproneModule.dir/SignalHandlerCheck.cpp.o
 -MF 
tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/obj.clangTidyBugproneModule.dir/SignalHandlerCheck.cpp.o.d
 -o 
tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/obj.clangTidyBugproneModule.dir/SignalHandlerCheck.cpp.o
 -c 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
  
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:17:45:
 error: modification of ‘’ is not a constant expression
 17 | "signal", "abort", "_Exit", "quick_exit"};
| ^
  
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:217:12:
 error: modification of ‘’ is not a constant expression
217 | "write"};
|^


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-06 Thread Trass3r via Phabricator via cfe-commits
Trass3r added a comment.

Also fails on gcc 11.2: https://github.com/Trass3r/llvm-project/runs/7703302032


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[clang-tools-extra] c7ec86b - [clang-tidy] Fix g++ -DCMAKE_CXX_STANDARD=17 build

2022-08-06 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-08-06T23:12:18Z
New Revision: c7ec86b13c461f6a8ce11f8443c1b6242013d26f

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

LOG: [clang-tidy] Fix g++ -DCMAKE_CXX_STANDARD=17 build

`constexpr std::initializer_list` leads to
```
error: modification of '' is not a constant expression
```
Related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102921

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
index dcc01589f1162..132fbf85c1fe6 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
@@ -13,7 +13,7 @@
 
 // This is the minimal set of safe functions.
 // 
https://wiki.sei.cmu.edu/confluence/display/c/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlers
-constexpr std::initializer_list MinimalConformingFunctions = {
+constexpr llvm::StringLiteral MinimalConformingFunctions[] = {
 "signal", "abort", "_Exit", "quick_exit"};
 
 // The POSIX-defined set of safe functions.
@@ -22,7 +22,7 @@ constexpr std::initializer_list 
MinimalConformingFunctions = {
 // mentioned POSIX specification was not updated after 'quick_exit' appeared
 // in the C11 standard.
 // Also, we want to keep the "minimal set" a subset of the "POSIX set".
-constexpr std::initializer_list POSIXConformingFunctions = {
+constexpr llvm::StringLiteral POSIXConformingFunctions[] = {
 "_Exit",
 "_exit",
 "abort",
@@ -300,12 +300,16 @@ AST_MATCHER(FunctionDecl, isStandardFunction) {
 SignalHandlerCheck::SignalHandlerCheck(StringRef Name,
ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  AsyncSafeFunctionSet(
-  Options.get("AsyncSafeFunctionSet", 
AsyncSafeFunctionSetKind::POSIX)),
-  ConformingFunctions(AsyncSafeFunctionSet ==
-  AsyncSafeFunctionSetKind::Minimal
-  ? MinimalConformingFunctions
-  : POSIXConformingFunctions) {}
+  AsyncSafeFunctionSet(Options.get("AsyncSafeFunctionSet",
+   AsyncSafeFunctionSetKind::POSIX)) {
+  if (AsyncSafeFunctionSet == AsyncSafeFunctionSetKind::Minimal) {
+for (StringRef v : MinimalConformingFunctions)
+  ConformingFunctions.insert(v);
+  } else {
+for (StringRef v : POSIXConformingFunctions)
+  ConformingFunctions.insert(v);
+  }
+}
 
 void SignalHandlerCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "AsyncSafeFunctionSet", AsyncSafeFunctionSet);

diff  --git a/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h 
b/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h
index 182afd717baec..01b63614163c1 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h
@@ -60,7 +60,7 @@ class SignalHandlerCheck : public ClangTidyCheck {
   clang::CallGraph CG;
 
   AsyncSafeFunctionSetKind AsyncSafeFunctionSet;
-  const llvm::StringSet<> ConformingFunctions;
+  llvm::StringSet<> ConformingFunctions;
 };
 
 } // namespace bugprone



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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D130689#3704581 , @dyung wrote:

> Your change is causing a build failure on the PS4 linux build bot using GCC 
> 9.3. Can you take a look?
> https://lab.llvm.org/buildbot/#/builders/139/builds/26186
>
>   FAILED: 
> tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/obj.clangTidyBugproneModule.dir/SignalHandlerCheck.cpp.o
>  
>   CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/g++ 
> -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
> -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/tools/extra/clang-tidy/bugprone
>  
> -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/clang-tidy/bugprone
>  
> -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/tools/extra/clang-tidy
>  
> -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/include
>  
> -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/include
>  
> -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/include
>  
> -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/include
>  -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden 
> -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings 
> -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long 
> -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess 
> -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type 
> -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment 
> -Wmisleading-indentation -fdiagnostics-color -ffunction-sections 
> -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3 
> -DNDEBUG  -fno-exceptions -fno-rtti -UNDEBUG -std=c++17 -MD -MT 
> tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/obj.clangTidyBugproneModule.dir/SignalHandlerCheck.cpp.o
>  -MF 
> tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/obj.clangTidyBugproneModule.dir/SignalHandlerCheck.cpp.o.d
>  -o 
> tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/obj.clangTidyBugproneModule.dir/SignalHandlerCheck.cpp.o
>  -c 
> /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
>   
> /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:17:45:
>  error: modification of ‘’ is not a constant expression
>  17 | "signal", "abort", "_Exit", "quick_exit"};
> | ^
>   
> /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:217:12:
>  error: modification of ‘’ is not a constant expression
> 217 | "write"};
> |^

Fixed by c7ec86b13c461f6a8ce11f8443c1b6242013d26f 
 .
May be related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102921


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130867: [clang] adds builtin `std::invoke` and `std::invoke_r`

2022-08-06 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb updated this revision to Diff 450581.
cjdb retitled this revision from "WORK-IN-PROGRESS [clang] adds builtin 
`std::invoke` and `std::invoke_r`" to "[clang] adds builtin `std::invoke` and 
`std::invoke_r`".
cjdb edited the summary of this revision.
cjdb added a comment.

updates commit message

- changes message so that it's accurate
- no longer adding type traits in this commit
- adds bechmark

updates diagnoses so that they're more accurate


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130867

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/builtin-std-invoke.cpp

Index: clang/test/SemaCXX/builtin-std-invoke.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/builtin-std-invoke.cpp
@@ -0,0 +1,468 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
+
+namespace std {
+template 
+void invoke(F &&, Args &&...); // expected-note{{requires at least 1 argument, but 0 were provided}}
+
+template 
+R invoke_r(F &&, Args &&...); // expected-note{{requires at least 1 argument, but 0 were provided}}
+
+// Slightly different to the real deal to simplify test.
+template 
+class reference_wrapper {
+public:
+  constexpr reference_wrapper(T &t) : data(&t) {}
+
+  constexpr operator T &() const noexcept { return *data; }
+
+private:
+  T *data;
+};
+} // namespace std
+
+#define assert(...)   \
+  if (!(__VA_ARGS__)) \
+__builtin_unreachable();
+
+struct ThrowingInt {
+  constexpr ThrowingInt(int x) : value(x) {}
+
+  int value;
+};
+
+template 
+constexpr void bullet_1(F f, T &&t, Args... args) {
+  assert(std::invoke(f, static_cast(t), args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke(f, static_cast(t), args...)), Returns));
+  static_assert(noexcept(std::invoke(f, static_cast(t), args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, static_cast(t), args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, static_cast(t), args...)), double));
+  static_assert(noexcept(std::invoke_r(f, static_cast(t), args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, static_cast(t), args...).value == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, static_cast(t), args...)), ThrowingInt));
+  static_assert(!noexcept(std::invoke_r(f, static_cast(t), args...)));
+}
+
+template 
+constexpr void bullet_2(F f, T &t, Args... args) {
+  std::reference_wrapper rw(t);
+  assert(std::invoke(f, rw, args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke(f, rw, args...)), Returns));
+  static_assert(noexcept(std::invoke(f, rw, args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, rw, args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, rw, args...)), double));
+  static_assert(noexcept(std::invoke_r(f, rw, args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, rw, args...).value == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, rw, args...)), ThrowingInt));
+  static_assert(!noexcept(std::invoke_r(f, rw, args...)));
+}
+
+template 
+class PointerWrapper {
+public:
+  constexpr explicit PointerWrapper(T &t) noexcept : p(&t) {}
+
+  constexpr T &operator*() const noexcept { return *p; }
+
+private:
+  T *p;
+};
+
+template 
+constexpr void bullet_3(F f, T &t, Args... args) {
+  assert(std::invoke(f, &t, args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke(f, &t, args...)), Returns));
+  static_assert(noexcept(std::invoke(f, &t, args...)) == IsNoexcept);
+
+  assert(std::invoke(f, PointerWrapper(t), args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke(f, PointerWrapper(t), args...)), Returns));
+  static_assert(noexcept(std::invoke(f, PointerWrapper(t), args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, &t, args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, &t, args...)), double));
+  static_assert(noexcept(std::invoke_r(f, &t, args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, PointerWrapper(t), args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, PointerWrapper(t), args...)), double));
+  static_assert(noexcept(std::invoke_r(f, PointerWrapper(t), args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, &t, args...).value == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, &t, args...)), ThrowingInt));
+  static_assert(!noexcept(std::invoke_r(f, &t, args...)));
+
+  assert(std::invoke_r(f, PointerWrapper(t), args...).value == ExpectedResult);
+  static

[PATCH] D131346: [clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFC

2022-08-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added a reviewer: aaron.ballman.
Herald added subscribers: steakhal, kosarev, pmatos, asb, StephenFan, martong, 
kerbowa, arphaman, kbarton, jgravelle-google, sbc100, jvesely, nemanjai, 
dschuff.
Herald added a reviewer: dang.
Herald added a reviewer: NoQ.
Herald added a reviewer: ributzka.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added subscribers: cfe-commits, aheejin.
Herald added a project: clang.

With C++17 there is no Clang pedantic warning or MSVC C5051.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131346

Files:
  clang/include/clang/AST/JSONNodeDumper.h
  clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
  clang/lib/ARCMigrate/TransformActions.cpp
  clang/lib/AST/APValue.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTDiagnostic.cpp
  clang/lib/AST/ASTDumper.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Comment.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/FormatString.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/NestedNameSpecifier.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/ScanfFormatString.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Analysis/CalledOnceCheck.cpp
  clang/lib/Analysis/ReachableCode.cpp
  clang/lib/Analysis/ThreadSafety.cpp
  clang/lib/Basic/BuiltinTargetFeatures.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Basic/Targets/SystemZ.cpp
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGCoroutine.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGObjCRuntime.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MacroPPCallbacks.cpp
  clang/lib/CodeGen/VarBypassDetector.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Myriad.cpp
  clang/lib/Edit/RewriteObjCFoundationAPI.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/SerializedDiagnosticReader.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Lex/InitHeaderSearch.cpp
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Lex/TokenConcatenation.cpp
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseInit.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Rewrite/HTMLRewrite.cpp
  clang/lib/Sema/CodeCompleteConsumer.cpp
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/utils/TableGen/NeonEmitter.cpp
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -523,7 +523,7 @@
 break;
   case 'c':
 Constant = true;
-LLVM_FAL

[PATCH] D131307: [Clang] Allow downgrading to a warning the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2022-08-06 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

It's already an error, but it's a warning default-mapped to an error. You can 
-Wno-error=name to downgrade it into a warning, but that requires an explicit 
action. So people are unlikely to miss it.

This is how we usually handle these breaking changes.

Maybe there could be a test for the -Wno-error= case? But this looks roughly 
right to me overall. I haven't looked in detail.


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

https://reviews.llvm.org/D131307

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


[PATCH] D130867: [clang] adds builtin `std::invoke` and `std::invoke_r`

2022-08-06 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb updated this revision to Diff 450584.
cjdb added a comment.

adds logic to diagnose misqualified pointer-to-member functions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130867

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/builtin-std-invoke.cpp

Index: clang/test/SemaCXX/builtin-std-invoke.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/builtin-std-invoke.cpp
@@ -0,0 +1,496 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
+
+namespace std {
+template 
+void invoke(F &&, Args &&...); // expected-note{{requires at least 1 argument, but 0 were provided}}
+
+template 
+R invoke_r(F &&, Args &&...); // expected-note{{requires at least 1 argument, but 0 were provided}}
+
+// Slightly different to the real deal to simplify test.
+template 
+class reference_wrapper {
+public:
+  constexpr reference_wrapper(T &t) : data(&t) {}
+
+  constexpr operator T &() const noexcept { return *data; }
+
+private:
+  T *data;
+};
+} // namespace std
+
+#define assert(...)   \
+  if (!(__VA_ARGS__)) \
+__builtin_unreachable();
+
+struct ThrowingInt {
+  constexpr ThrowingInt(int x) : value(x) {}
+
+  int value;
+};
+
+template 
+constexpr void bullet_1(F f, T &&t, Args... args) {
+  assert(std::invoke(f, static_cast(t), args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke(f, static_cast(t), args...)), Returns));
+  static_assert(noexcept(std::invoke(f, static_cast(t), args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, static_cast(t), args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, static_cast(t), args...)), double));
+  static_assert(noexcept(std::invoke_r(f, static_cast(t), args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, static_cast(t), args...).value == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, static_cast(t), args...)), ThrowingInt));
+  static_assert(!noexcept(std::invoke_r(f, static_cast(t), args...)));
+}
+
+template 
+constexpr void bullet_2(F f, T &t, Args... args) {
+  std::reference_wrapper rw(t);
+  assert(std::invoke(f, rw, args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke(f, rw, args...)), Returns));
+  static_assert(noexcept(std::invoke(f, rw, args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, rw, args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, rw, args...)), double));
+  static_assert(noexcept(std::invoke_r(f, rw, args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, rw, args...).value == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, rw, args...)), ThrowingInt));
+  static_assert(!noexcept(std::invoke_r(f, rw, args...)));
+}
+
+template 
+class PointerWrapper {
+public:
+  constexpr explicit PointerWrapper(T &t) noexcept : p(&t) {}
+
+  constexpr T &operator*() const noexcept { return *p; }
+
+private:
+  T *p;
+};
+
+template 
+constexpr void bullet_3(F f, T &t, Args... args) {
+  assert(std::invoke(f, &t, args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke(f, &t, args...)), Returns));
+  static_assert(noexcept(std::invoke(f, &t, args...)) == IsNoexcept);
+
+  assert(std::invoke(f, PointerWrapper(t), args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke(f, PointerWrapper(t), args...)), Returns));
+  static_assert(noexcept(std::invoke(f, PointerWrapper(t), args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, &t, args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, &t, args...)), double));
+  static_assert(noexcept(std::invoke_r(f, &t, args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, PointerWrapper(t), args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, PointerWrapper(t), args...)), double));
+  static_assert(noexcept(std::invoke_r(f, PointerWrapper(t), args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, &t, args...).value == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, &t, args...)), ThrowingInt));
+  static_assert(!noexcept(std::invoke_r(f, &t, args...)));
+
+  assert(std::invoke_r(f, PointerWrapper(t), args...).value == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, PointerWrapper(t), args...)), ThrowingInt));
+  static_assert(!noexcept(std::invoke_r(f, PointerWrapper(t), args...)));
+}
+
+template 
+constexpr bool bullets_1_through_3(T t) {
+  bullet_1(&T::plus, t, 3, -3);
+  bullet_1(&T::minus, static_cast(t), 1, 2, 3);
+  bullet_1(&T::sq

[PATCH] D116280: [clang] adds unary type trait checks as compiler built-ins

2022-08-06 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb updated this revision to Diff 450585.
cjdb added a comment.

fixes commit update mistake and rebases to ToT


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116280

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/type-traits.cpp

Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -345,11 +345,19 @@
 }
 
 typedef Enum EnumType;
+typedef EnumClass EnumClassType;
 
 void is_enum()
 {
   { int arr[T(__is_enum(Enum))]; }
   { int arr[T(__is_enum(EnumType))]; }
+  { int arr[T(__is_enum(SignedEnum))]; }
+  { int arr[T(__is_enum(UnsignedEnum))]; }
+
+  { int arr[T(__is_enum(EnumClass))]; }
+  { int arr[T(__is_enum(EnumClassType))]; }
+  { int arr[T(__is_enum(SignedEnumClass))]; }
+  { int arr[T(__is_enum(UnsignedEnumClass))]; }
 
   { int arr[F(__is_enum(int))]; }
   { int arr[F(__is_enum(Union))]; }
@@ -363,6 +371,29 @@
   { int arr[F(__is_enum(HasAnonymousUnion))]; }
 }
 
+void is_scoped_enum() {
+  { int arr[F(__is_scoped_enum(Enum))]; }
+  { int arr[F(__is_scoped_enum(EnumType))]; }
+  { int arr[F(__is_scoped_enum(SignedEnum))]; }
+  { int arr[F(__is_scoped_enum(UnsignedEnum))]; }
+
+  { int arr[T(__is_scoped_enum(EnumClass))]; }
+  { int arr[T(__is_scoped_enum(EnumClassType))]; }
+  { int arr[T(__is_scoped_enum(SignedEnumClass))]; }
+  { int arr[T(__is_scoped_enum(UnsignedEnumClass))]; }
+
+  { int arr[F(__is_scoped_enum(int))]; }
+  { int arr[F(__is_scoped_enum(Union))]; }
+  { int arr[F(__is_scoped_enum(Int))]; }
+  { int arr[F(__is_scoped_enum(IntAr))]; }
+  { int arr[F(__is_scoped_enum(UnionAr))]; }
+  { int arr[F(__is_scoped_enum(Derives))]; }
+  { int arr[F(__is_scoped_enum(ClassType))]; }
+  { int arr[F(__is_scoped_enum(cvoid))]; }
+  { int arr[F(__is_scoped_enum(IntArNB))]; }
+  { int arr[F(__is_scoped_enum(HasAnonymousUnion))]; }
+}
+
 struct FinalClass final {
 };
 
@@ -702,6 +733,106 @@
   int t31[F(__is_array(cvoid*))];
 }
 
+void is_bounded_array(int n) {
+  int t01[T(__is_bounded_array(IntAr))];
+  int t02[F(__is_bounded_array(IntArNB))];
+  int t03[T(__is_bounded_array(UnionAr))];
+
+  int t10[F(__is_bounded_array(void))];
+  int t11[F(__is_bounded_array(cvoid))];
+  int t12[F(__is_bounded_array(float))];
+  int t13[F(__is_bounded_array(double))];
+  int t14[F(__is_bounded_array(long double))];
+  int t15[F(__is_bounded_array(bool))];
+  int t16[F(__is_bounded_array(char))];
+  int t17[F(__is_bounded_array(signed char))];
+  int t18[F(__is_bounded_array(unsigned char))];
+  int t19[F(__is_bounded_array(wchar_t))];
+  int t20[F(__is_bounded_array(short))];
+  int t21[F(__is_bounded_array(unsigned short))];
+  int t22[F(__is_bounded_array(int))];
+  int t23[F(__is_bounded_array(unsigned int))];
+  int t24[F(__is_bounded_array(long))];
+  int t25[F(__is_bounded_array(unsigned long))];
+  int t26[F(__is_bounded_array(Union))];
+  int t27[F(__is_bounded_array(Derives))];
+  int t28[F(__is_bounded_array(ClassType))];
+  int t29[F(__is_bounded_array(Enum))];
+  int t30[F(__is_bounded_array(void *))];
+  int t31[F(__is_bounded_array(cvoid *))];
+
+  int t32[n];
+  (void)__is_bounded_array(decltype(t32)); // expected-error{{variable length arrays are not supported for '__is_bounded_array'}}
+}
+
+void is_unbounded_array(int n) {
+  int t01[F(__is_unbounded_array(IntAr))];
+  int t02[T(__is_unbounded_array(IntArNB))];
+  int t03[F(__is_unbounded_array(UnionAr))];
+
+  int t10[F(__is_unbounded_array(void))];
+  int t11[F(__is_unbounded_array(cvoid))];
+  int t12[F(__is_unbounded_array(float))];
+  int t13[F(__is_unbounded_array(double))];
+  int t14[F(__is_unbounded_array(long double))];
+  int t15[F(__is_unbounded_array(bool))];
+  int t16[F(__is_unbounded_array(char))];
+  int t17[F(__is_unbounded_array(signed char))];
+  int t18[F(__is_unbounded_array(unsigned char))];
+  int t19[F(__is_unbounded_array(wchar_t))];
+  int t20[F(__is_unbounded_array(short))];
+  int t21[F(__is_unbounded_array(unsigned short))];
+  int t22[F(__is_unbounded_array(int))];
+  int t23[F(__is_unbounded_array(unsigned int))];
+  int t24[F(__is_unbounded_array(long))];
+  int t25[F(__is_unbounded_array(unsigned long))];
+  int t26[F(__is_unbounded_array(Union))];
+  int t27[F(__is_unbounded_array(Derives))];
+  int t28[F(__is_unbounded_array(ClassType))];
+  int t29[F(__is_unbounded_array(Enum))];
+  int t30[F(__is_unbounded_array(void *))];
+  int t31[F(__is_unbounded_array(cvoid *))];
+
+  int t32[n];
+  (void)__is_unbounded_array(decltype(t32)); // expected-error{{variable length arrays are not supported for '__is_unbounded_array'}}
+}
+
+void is_referenceable() {
+  { int a[T(__is_referenceable(int)

[PATCH] D130867: [clang] adds builtin `std::invoke` and `std::invoke_r`

2022-08-06 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb updated this revision to Diff 450587.
cjdb added a comment.

rebases to ToT


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130867

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/builtin-std-invoke.cpp

Index: clang/test/SemaCXX/builtin-std-invoke.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/builtin-std-invoke.cpp
@@ -0,0 +1,496 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
+
+namespace std {
+template 
+void invoke(F &&, Args &&...); // expected-note{{requires at least 1 argument, but 0 were provided}}
+
+template 
+R invoke_r(F &&, Args &&...); // expected-note{{requires at least 1 argument, but 0 were provided}}
+
+// Slightly different to the real deal to simplify test.
+template 
+class reference_wrapper {
+public:
+  constexpr reference_wrapper(T &t) : data(&t) {}
+
+  constexpr operator T &() const noexcept { return *data; }
+
+private:
+  T *data;
+};
+} // namespace std
+
+#define assert(...)   \
+  if (!(__VA_ARGS__)) \
+__builtin_unreachable();
+
+struct ThrowingInt {
+  constexpr ThrowingInt(int x) : value(x) {}
+
+  int value;
+};
+
+template 
+constexpr void bullet_1(F f, T &&t, Args... args) {
+  assert(std::invoke(f, static_cast(t), args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke(f, static_cast(t), args...)), Returns));
+  static_assert(noexcept(std::invoke(f, static_cast(t), args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, static_cast(t), args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, static_cast(t), args...)), double));
+  static_assert(noexcept(std::invoke_r(f, static_cast(t), args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, static_cast(t), args...).value == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, static_cast(t), args...)), ThrowingInt));
+  static_assert(!noexcept(std::invoke_r(f, static_cast(t), args...)));
+}
+
+template 
+constexpr void bullet_2(F f, T &t, Args... args) {
+  std::reference_wrapper rw(t);
+  assert(std::invoke(f, rw, args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke(f, rw, args...)), Returns));
+  static_assert(noexcept(std::invoke(f, rw, args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, rw, args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, rw, args...)), double));
+  static_assert(noexcept(std::invoke_r(f, rw, args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, rw, args...).value == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, rw, args...)), ThrowingInt));
+  static_assert(!noexcept(std::invoke_r(f, rw, args...)));
+}
+
+template 
+class PointerWrapper {
+public:
+  constexpr explicit PointerWrapper(T &t) noexcept : p(&t) {}
+
+  constexpr T &operator*() const noexcept { return *p; }
+
+private:
+  T *p;
+};
+
+template 
+constexpr void bullet_3(F f, T &t, Args... args) {
+  assert(std::invoke(f, &t, args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke(f, &t, args...)), Returns));
+  static_assert(noexcept(std::invoke(f, &t, args...)) == IsNoexcept);
+
+  assert(std::invoke(f, PointerWrapper(t), args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke(f, PointerWrapper(t), args...)), Returns));
+  static_assert(noexcept(std::invoke(f, PointerWrapper(t), args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, &t, args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, &t, args...)), double));
+  static_assert(noexcept(std::invoke_r(f, &t, args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, PointerWrapper(t), args...) == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, PointerWrapper(t), args...)), double));
+  static_assert(noexcept(std::invoke_r(f, PointerWrapper(t), args...)) == IsNoexcept);
+
+  assert(std::invoke_r(f, &t, args...).value == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, &t, args...)), ThrowingInt));
+  static_assert(!noexcept(std::invoke_r(f, &t, args...)));
+
+  assert(std::invoke_r(f, PointerWrapper(t), args...).value == ExpectedResult);
+  static_assert(__is_same(decltype(std::invoke_r(f, PointerWrapper(t), args...)), ThrowingInt));
+  static_assert(!noexcept(std::invoke_r(f, PointerWrapper(t), args...)));
+}
+
+template 
+constexpr bool bullets_1_through_3(T t) {
+  bullet_1(&T::plus, t, 3, -3);
+  bullet_1(&T::minus, static_cast(t), 1, 2, 3);
+  bullet_1(&T::square, static_cast<__remove_reference(T) &&>(t), 7

[clang] 1f54006 - [clang][docs] use `Fixes` instead of `This fixes` in ReleaseNotes [NFC]

2022-08-06 Thread YingChi Long via cfe-commits

Author: YingChi Long
Date: 2022-08-07T12:42:15+08:00
New Revision: 1f54006bcacf3967b03f9851edf7f9cd773d53e8

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

LOG: [clang][docs] use `Fixes` instead of `This fixes` in ReleaseNotes [NFC]

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a2d7526bb770c..4f34b2f946b6e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -74,7 +74,7 @@ Improvements to Clang's diagnostics
   the enumeration's values. Fixes
   `Issue 50055: `_.
 - Clang will now check compile-time determinable string literals as format 
strings.
-  This fixes `Issue 55805: 
`_.
+  Fixes `Issue 55805: `_.
 - ``-Wformat`` now recognizes ``%b`` for the ``printf``/``scanf`` family of
   functions and ``%B`` for the ``printf`` family of functions. Fixes
   `Issue 56885: `_.



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