[PATCH] D124341: [clang-tidy][NFC] Replace many instances of std::string where a StringRef would suffice.

2022-04-24 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
Herald added subscribers: carlosgalvezp, arphaman, kbarton, xazax.hun, nemanjai.
Herald added a project: All.
njames93 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124341

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.h
  clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
  clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.h
  clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.h
  clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.h
  clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.h
  clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.h
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h
  clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.h
  clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.h
  clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.h
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
  clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.h
  clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
  clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
  clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/NoMallocCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/NoMallocCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.h
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h
  clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.h
  clang-tools-extra/clang-tidy/google/IntegerTypesCheck.h
  clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
  clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h
  
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.h
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.h
  clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.h
  clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.h
  clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h
  clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.h
  clang-tools-extra/clang-tidy/objc/ForbiddenSubclassingCheck.cpp
  clang-tools-extra/clang-tidy/objc/ForbiddenSubclassingCheck.h
  clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
  clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.h
  clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.h
  clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
  clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h
  clang-tools-extra/clang-tidy/performance/NoAutomaticMoveCheck.h
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.h
  clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.h
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
  clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h
  clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
  clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.h
  clang-tools-extra/clang-tidy/readability/SimplifySubscriptEx

[clang] 3566bbe - [analyzer] Add option for AddrSpace in core.NullDereference check

2022-04-24 Thread via cfe-commits

Author: Vince Bridgers
Date: 2022-04-24T03:51:49-05:00
New Revision: 3566bbe62f2ef2bf1b736d04a9d6b3c669a66297

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

LOG: [analyzer] Add option for AddrSpace in core.NullDereference check

This change adds an option to detect all null dereferences for
non-default address spaces, except for address spaces 256, 257 and 258.
Those address spaces are special since null dereferences are not errors.

All address spaces can be considered (except for 256, 257, and 258) by
using -analyzer-config
core.NullDereference:DetectAllNullDereferences=true. This option is
false by default, retaining the original behavior.

A LIT test was enhanced to cover this case, and the rst documentation
was updated to describe this behavior.

Reviewed By: steakhal

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

Added: 


Modified: 
clang/docs/analyzer/checkers.rst
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
clang/test/Analysis/analyzer-config.c
clang/test/Analysis/cast-value-notes.cpp

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index 6e42544c05808..2f5336ae6a67f 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -66,7 +66,20 @@ Check for null pointers passed as arguments to a function 
whose arguments are re
 
 core.NullDereference (C, C++, ObjC)
 """
-Check for dereferences of null pointers.
+Check for dereferences of null pointers. 
+
+This checker specifically does
+not report null pointer dereferences for x86 and x86-64 targets when the
+address space is 256 (x86 GS Segment), 257 (x86 FS Segment), or 258 (x86 SS
+segment). See `X86/X86-64 Language Extensions
+`__
+for reference.
+
+The ``SuppressAddressSpaces`` option suppresses 
+warnings for null dereferences of all pointers with address spaces. You can
+disable this behavior with the option
+``-analyzer-config core.NullDereference:SuppressAddressSpaces=false``.
+*Defaults to true*.
 
 .. code-block:: objc
 

diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index b5ce1eda200c7..1bcbab4985156 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -191,6 +191,13 @@ def CallAndMessageChecker : Checker<"CallAndMessage">,
 
 def DereferenceChecker : Checker<"NullDereference">,
   HelpText<"Check for dereferences of null pointers">,
+  CheckerOptions<[
+CmdLineOption
+  ]>,
   Documentation;
 
 def NonNullParamChecker : Checker<"NonNullParamChecker">,

diff  --git a/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
index 4a9c7ce3c66d8..bb5216266de81 100644
--- a/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
@@ -11,9 +11,10 @@
 //
 
//===--===//
 
-#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/ExprOpenMP.h"
+#include "clang/Basic/TargetInfo.h"
+#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
@@ -39,6 +40,8 @@ class DereferenceChecker
   void reportBug(DerefKind K, ProgramStateRef State, const Stmt *S,
  CheckerContext &C) const;
 
+  bool suppressReport(CheckerContext &C, const Expr *E) const;
+
 public:
   void checkLocation(SVal location, bool isLoad, const Stmt* S,
  CheckerContext &C) const;
@@ -49,6 +52,8 @@ class DereferenceChecker
  const Expr *Ex, const ProgramState *state,
  const LocationContext *LCtx,
  bool loadedFrom = false);
+
+  bool SuppressAddressSpaces = false;
 };
 } // end anonymous namespace
 
@@ -109,9 +114,35 @@ static const Expr *getDereferenceExpr(const Stmt *S, bool 
IsBind=false){
   return E;
 }
 
-static bool suppressReport(const Expr *E) {
-  // Do not report dereferences on memory in non-default address spaces.
-  return E->getType().hasAddressSpace();
+bool DereferenceChecker::suppressReport(CheckerContext &C,
+const Expr *E) const {
+  // Do not report dereference

[PATCH] D122841: [analyzer] Add option for AddrSpace in core.NullDereference check

2022-04-24 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3566bbe62f2e: [analyzer] Add option for AddrSpace in 
core.NullDereference check (authored by vabridgers, committed by einvbri 
).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122841

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/cast-value-notes.cpp

Index: clang/test/Analysis/cast-value-notes.cpp
===
--- clang/test/Analysis/cast-value-notes.cpp
+++ clang/test/Analysis/cast-value-notes.cpp
@@ -1,10 +1,44 @@
-// RUN: %clang_analyze_cc1 -std=c++14 \
-// RUN:  -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
-// RUN:  -analyzer-output=text -verify -DDEFAULT_TRIPLE %s 2>&1 | FileCheck %s -check-prefix=DEFAULT-CHECK
+// RUN: %clang_analyze_cc1 -std=c++14 -triple amdgcn-unknown-unknown \
+// RUN: -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
+// RUN: -analyzer-output=text -verify -DX86 -DSUPPRESSED %s 2>&1 | FileCheck %s -check-prefix=X86-CHECK
+//
+// RUN: %clang_analyze_cc1 -std=c++14 -triple amdgcn-unknown-unknown \
+// RUN: -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
+// RUN:  -analyzer-config core.NullDereference:SuppressAddressSpaces=false\
+// RUN:  -analyzer-output=text -verify -DX86 -DNOT_SUPPRESSED %s 2>&1 | FileCheck %s -check-prefix=X86-CHECK
 //
 // RUN: %clang_analyze_cc1 -std=c++14 -triple amdgcn-unknown-unknown \
 // RUN: -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
-// RUN: -analyzer-output=text -verify -DAMDGCN_TRIPLE %s 2>&1 | FileCheck %s -check-prefix=AMDGCN-CHECK
+// RUN:  -analyzer-config core.NullDereference:SuppressAddressSpaces=true\
+// RUN:  -analyzer-output=text -verify -DX86 -DSUPPRESSED %s 2>&1 | FileCheck %s -check-prefix=X86-CHECK
+//
+// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-unknown-unknown \
+// RUN:  -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
+// RUN:  -analyzer-output=text -verify -DX86 -DSUPPRESSED %s 2>&1 | FileCheck %s --check-prefix=X86-CHECK
+//
+// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-unknown-unknown \
+// RUN:  -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
+// RUN:  -analyzer-config core.NullDereference:SuppressAddressSpaces=true\
+// RUN:  -analyzer-output=text -verify -DX86 -DSUPPRESSED %s 2>&1 | FileCheck %s --check-prefix=X86-CHECK-SUPPRESSED
+//
+// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-unknown-unknown \
+// RUN:  -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
+// RUN:  -analyzer-config core.NullDereference:SuppressAddressSpaces=false\
+// RUN:  -analyzer-output=text -verify -DX86 -DNOT_SUPPRESSED %s 2>&1 | FileCheck %s --check-prefix=X86-CHECK
+//
+// RUN: %clang_analyze_cc1 -std=c++14 -triple mips-unknown-unknown \
+// RUN: -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
+// RUN: -analyzer-output=text -verify -DMIPS %s 2>&1
+//
+// RUN: %clang_analyze_cc1 -std=c++14 -triple mips-unknown-unknown \
+// RUN: -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
+// RUN: -analyzer-config core.NullDereference:SuppressAddressSpaces=false\
+// RUN: -analyzer-output=text -verify -DMIPS %s 2>&1
+//
+// RUN: %clang_analyze_cc1 -std=c++14 -triple mips-unknown-unknown \
+// RUN: -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
+// RUN: -analyzer-config core.NullDereference:SuppressAddressSpaces=true\
+// RUN: -analyzer-output=text -verify -DMIPS_SUPPRESSED %s
 
 #include "Inputs/llvm.h"
 
@@ -36,27 +70,51 @@
 
 void clang_analyzer_printState();
 
-#if defined(DEFAULT_TRIPLE)
+#if defined(X86)
 void evalReferences(const Shape &S) {
   const auto &C = dyn_cast(S);
   // expected-note@-1 {{Assuming 'S' is not a 'Circle'}}
   // expected-note@-2 {{Dereference of null pointer}}
   // expected-warning@-3 {{Dereference of null pointer}}
   clang_analyzer_printState();
-  // DEFAULT-CHECK: "dynamic_types": [
-  // DEFAULT-CHECK-NEXT: { "region": "SymRegion{reg_$0}", "dyn_type": "const class clang::Circle &", "sub_classable": true }
+  // XX86-CHECK:  "dynamic_types": [
+  // XX86-CHECK-NEXT:   { "region": "SymRegion{reg_$0}", "dyn_type": "const class clang::Circle &", "sub_classable": true }
   (void)C;
 }
-#elif defined(AMDGCN_TRIPLE)
-void evalReferences(const Shape &S) {
+#if defined(SUPPRESSED)
+void evalReferences_addrspace(const Shape &S) {
   const auto &C = dyn_cast(S);
   clang_analyzer_printState();
-  // AMDGCN-CHECK: "dynamic_types": [
-  // AMDGCN-CHECK-NEXT: { "region": "SymRegion{reg_$0}", "dyn_type": "const __attribute__((address_space(3)

[libunwind] b3df14b - [runtimes] [CMake] Unify variable names

2022-04-24 Thread Martin Storsjö via cfe-commits

Author: Petr Hosek
Date: 2022-04-24T13:06:36+03:00
New Revision: b3df14b6c98702ce50401fd039852787373e4676

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

LOG: [runtimes] [CMake] Unify variable names

Avoid repeating CMake checks across runtimes by unifying names of
variables used for results to leverage CMake caching.

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

Added: 


Modified: 
compiler-rt/CMakeLists.txt
compiler-rt/cmake/config-ix.cmake
libcxx/CMakeLists.txt
libcxx/cmake/Modules/HandleLibcxxFlags.cmake
libcxx/cmake/config-ix.cmake
libcxxabi/CMakeLists.txt
libcxxabi/cmake/Modules/HandleLibcxxabiFlags.cmake
libcxxabi/cmake/config-ix.cmake
libcxxabi/src/CMakeLists.txt
libunwind/CMakeLists.txt
libunwind/cmake/Modules/HandleLibunwindFlags.cmake
libunwind/cmake/config-ix.cmake
libunwind/src/CMakeLists.txt
runtimes/CMakeLists.txt

Removed: 




diff  --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 3a41aa43e4066..84575b49079c1 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -457,7 +457,7 @@ append_list_if(COMPILER_RT_HAS_WD4800_FLAG /wd4800 
SANITIZER_COMMON_CFLAGS)
 append_list_if(MINGW -fms-extensions SANITIZER_COMMON_CFLAGS)
 
 # Set common link flags.
-append_list_if(COMPILER_RT_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs 
SANITIZER_COMMON_LINK_FLAGS)
+append_list_if(C_SUPPORTS_NODEFAULTLIBS_FLAG -nodefaultlibs 
SANITIZER_COMMON_LINK_FLAGS)
 append_list_if(COMPILER_RT_HAS_Z_TEXT -Wl,-z,text SANITIZER_COMMON_LINK_FLAGS)
 
 if (COMPILER_RT_USE_BUILTINS_LIBRARY)

diff  --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index ba84f0bfb53df..17e515684048b 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -23,8 +23,8 @@ else()
   endif()
 endif()
 
-check_c_compiler_flag(-nodefaultlibs COMPILER_RT_HAS_NODEFAULTLIBS_FLAG)
-if (COMPILER_RT_HAS_NODEFAULTLIBS_FLAG)
+check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG)
+if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
   set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
   if (COMPILER_RT_HAS_LIBC)
 list(APPEND CMAKE_REQUIRED_LIBRARIES c)

diff  --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 2948fdc308842..9ad93a39b43f3 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -593,7 +593,7 @@ function(cxx_add_basic_build_flags target)
 target_compile_definitions(${target} PRIVATE 
-D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS)
   endif()
 
-  if (LIBCXX_HAS_COMMENT_LIB_PRAGMA)
+  if (C_SUPPORTS_COMMENT_LIB_PRAGMA)
 if (LIBCXX_HAS_PTHREAD_LIB)
   target_compile_definitions(${target} PRIVATE -D_LIBCPP_LINK_PTHREAD_LIB)
 endif()
@@ -774,7 +774,7 @@ function(cxx_link_system_libraries target)
 # Unfortunately this cannot be used universally because for example g++ 
supports
 # only -nodefaultlibs in which case all libraries will be removed and
 # all libraries but c++ have to be added in manually.
-  if (LIBCXX_SUPPORTS_NOSTDLIBXX_FLAG)
+  if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
 target_add_link_flags_if_supported(${target} PRIVATE "-nostdlib++")
   else()
 target_add_link_flags_if_supported(${target} PRIVATE "-nodefaultlibs")
@@ -782,7 +782,7 @@ function(cxx_link_system_libraries target)
 target_add_link_flags_if_supported(${target} PRIVATE "/nodefaultlib")
   endif()
 
-  if (LIBCXX_SUPPORTS_UNWINDLIB_NONE_FLAG AND LIBCXXABI_USE_LLVM_UNWINDER)
+  if (CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG AND LIBCXXABI_USE_LLVM_UNWINDER)
 # If we're linking directly against the libunwind that we're building
 # in the same invocation, don't try to link in the toolchain's
 # default libunwind (which may be missing still).

diff  --git a/libcxx/cmake/Modules/HandleLibcxxFlags.cmake 
b/libcxx/cmake/Modules/HandleLibcxxFlags.cmake
index 859cfc4a51559..72512544e6339 100644
--- a/libcxx/cmake/Modules/HandleLibcxxFlags.cmake
+++ b/libcxx/cmake/Modules/HandleLibcxxFlags.cmake
@@ -42,7 +42,7 @@ endmacro(remove_flags)
 
 macro(check_flag_supported flag)
 mangle_name("${flag}" flagname)
-check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG")
+check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
 endmacro()
 
 macro(append_flags DEST)
@@ -63,8 +63,8 @@ endmacro()
 macro(append_flags_if_supported DEST)
   foreach(flag ${ARGN})
 mangle_name("${flag}" flagname)
-check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG")
-append_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${DEST} ${flag})
+check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
+append_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${DEST} ${flag})
   endforeach()
 endmacro()
 
@@ -127,8 +1

[PATCH] D124260: [clang-format] ColumnLimit check for trailing comments alignment acts wrong for multi-byte UTF-8 #47624

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

There seem to be failing tests. Did you run the FormatTests?




Comment at: clang/unittests/Format/FormatTestComments.cpp:2861-2864
+  EXPECT_EQ("int ab; // utf8 🐉\n"
+"int a;  // line\n",
+format("int ab; // long 🐉\n"
+   "int a; // line\n",

Here is something wrong.


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

https://reviews.llvm.org/D124260

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


[PATCH] D124344: [clangd] Output inlay hints with `clangd --check`

2022-04-24 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj created this revision.
upsj added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
Herald added a project: All.
upsj requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

With the addition of inlay hints to clangd, it would be useful to output them 
during verbose `clangd --check`.
This patch adds an output step for inlay hints and unifies the way 
`--check-lines` are passed around


https://reviews.llvm.org/D124344

Files:
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -61,8 +61,7 @@
 namespace clangd {
 
 // Implemented in Check.cpp.
-bool check(const llvm::StringRef File,
-   llvm::function_ref ShouldCheckLine,
+bool check(const llvm::StringRef File, llvm::Optional LineRange,
const ThreadsafeFS &TFS, const ClangdLSPServer::Options &Opts,
bool EnableCodeCompletion);
 
@@ -955,8 +954,9 @@
   return 1;
 }
 log("Entering check mode (no LSP server)");
-uint32_t Begin = 0, End = std::numeric_limits::max();
+llvm::Optional CheckLineRange;
 if (!CheckFileLines.empty()) {
+  uint32_t Begin = 0, End = std::numeric_limits::max();
   StringRef RangeStr(CheckFileLines);
   bool ParseError = RangeStr.consumeInteger(0, Begin);
   if (RangeStr.empty()) {
@@ -965,19 +965,18 @@
 ParseError |= !RangeStr.consume_front("-");
 ParseError |= RangeStr.consumeInteger(0, End);
   }
-  if (ParseError || !RangeStr.empty()) {
-elog("Invalid --check-line specified. Use Begin-End format, e.g. 3-17");
+  if (ParseError || !RangeStr.empty() || Begin <= 0 || End < Begin) {
+elog(
+"Invalid --check-lines specified. Use Begin-End format, e.g. 3-17");
 return 1;
   }
+  CheckLineRange = Range{Position{static_cast(Begin - 1), 0},
+ Position{static_cast(End), 0}};
 }
-auto ShouldCheckLine = [&](const Position &Pos) {
-  uint32_t Line = Pos.line + 1; // Position::line is 0-based.
-  return Line >= Begin && Line <= End;
-};
 // For now code completion is enabled any time the range is limited via
 // --check-lines. If it turns out to be to slow, we can introduce a
 // dedicated flag for that instead.
-return check(Path, ShouldCheckLine, TFS, Opts,
+return check(Path, CheckLineRange, TFS, Opts,
  /*EnableCodeCompletion=*/!CheckFileLines.empty())
? 0
: static_cast(ErrorResultCode::CheckFailed);
Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -30,8 +30,10 @@
 #include "Config.h"
 #include "GlobalCompilationDatabase.h"
 #include "Hover.h"
+#include "InlayHints.h"
 #include "ParsedAST.h"
 #include "Preamble.h"
+#include "Protocol.h"
 #include "SourceCode.h"
 #include "XRefs.h"
 #include "index/CanonicalIncludes.h"
@@ -190,10 +192,20 @@
 return true;
   }
 
+  // Build Inlay Hints for the entire AST
+  bool buildInlayHints(llvm::Optional LineRange) {
+log("Building inlay hints");
+auto Hints = inlayHints(*AST, LineRange);
+
+for (const auto &Hint : Hints) {
+  vlog("  {0} {1}", Hint.position, Hint.label);
+}
+return true;
+  }
+
   // Run AST-based features at each token in the file.
-  void testLocationFeatures(
-  llvm::function_ref ShouldCheckLine,
-  const bool EnableCodeCompletion) {
+  void testLocationFeatures(llvm::Optional LineRange,
+const bool EnableCodeCompletion) {
 trace::Span Trace("testLocationFeatures");
 log("Testing features at each token (may be slow in large files)");
 auto &SM = AST->getSourceManager();
@@ -207,7 +219,7 @@
   unsigned End = Start + Tok.length();
   Position Pos = offsetToPosition(Inputs.Contents, Start);
 
-  if (!ShouldCheckLine(Pos))
+  if (LineRange && LineRange->contains(Pos))
 continue;
 
   trace::Span Trace("Token");
@@ -254,8 +266,7 @@
 
 } // namespace
 
-bool check(llvm::StringRef File,
-   llvm::function_ref ShouldCheckLine,
+bool check(llvm::StringRef File, llvm::Optional LineRange,
const ThreadsafeFS &TFS, const ClangdLSPServer::Options &Opts,
bool EnableCodeCompletion) {
   llvm::SmallString<0> FakeFile;
@@ -282,9 +293,9 @@
   : /*Don't turn on local configs for an arbitrary temp path.*/ ""));
   Checker C(File, Opts);
   if (!C.buildCommand(TFS) || !C.buildInvocation(TFS, Contents) ||
-  !C.buildAST())
+  !C.buildAST() || !C.buildInlayHints(LineRange))
 

[clang-tools-extra] 3f0f203 - run-clang-tidy: Fix infinite loop on windows

2022-04-24 Thread Jonas Toth via cfe-commits

Author: Jonas Toth
Date: 2022-04-24T17:17:02+02:00
New Revision: 3f0f20366622ee5fd35a1d65d7db5226f5e5751f

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

LOG: run-clang-tidy: Fix infinite loop on windows

`find_compilation_database` checked only for "/" as exit point, but on Windows, 
this root is impossible.
Fixes #53642

Authored By: Febbe
Reviewed By: JonasToth
Differential Revision: https://reviews.llvm.org/D119481

Added: 


Modified: 
clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py 
b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
index afe2bfd28554d..9497e0b9f52d3 100755
--- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -73,13 +73,14 @@ def strtobool(val):
 
 def find_compilation_database(path):
   """Adjusts the directory until a compilation database is found."""
-  result = './'
+  result = os.path.realpath('./')
   while not os.path.isfile(os.path.join(result, path)):
-if os.path.realpath(result) == '/':
+parent = os.path.dirname(result)
+if result == parent:
   print('Error: could not find compilation database.')
   sys.exit(1)
-result += '../'
-  return os.path.realpath(result)
+result = parent
+  return result
 
 
 def make_absolute(f, directory):



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


[PATCH] D119481: run-clang-tidy: Fix infinite loop on windows

2022-04-24 Thread Jonas Toth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3f0f20366622: run-clang-tidy: Fix infinite loop on windows 
(authored by JonasToth).
Herald added a project: All.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119481

Files:
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -73,13 +73,14 @@
 
 def find_compilation_database(path):
   """Adjusts the directory until a compilation database is found."""
-  result = './'
+  result = os.path.realpath('./')
   while not os.path.isfile(os.path.join(result, path)):
-if os.path.realpath(result) == '/':
+parent = os.path.dirname(result)
+if result == parent:
   print('Error: could not find compilation database.')
   sys.exit(1)
-result += '../'
-  return os.path.realpath(result)
+result = parent
+  return result
 
 
 def make_absolute(f, directory):


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -73,13 +73,14 @@
 
 def find_compilation_database(path):
   """Adjusts the directory until a compilation database is found."""
-  result = './'
+  result = os.path.realpath('./')
   while not os.path.isfile(os.path.join(result, path)):
-if os.path.realpath(result) == '/':
+parent = os.path.dirname(result)
+if result == parent:
   print('Error: could not find compilation database.')
   sys.exit(1)
-result += '../'
-  return os.path.realpath(result)
+result = parent
+  return result
 
 
 def make_absolute(f, directory):
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119481: run-clang-tidy: Fix infinite loop on windows

2022-04-24 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Sorry for the long delay, i simply forgot.
The patch is commited! :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119481

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


[PATCH] D121838: Generalize "check-all" umbrella targets, use for check-clang-tools

2022-04-24 Thread Louis Dionne via Phabricator via cfe-commits
ldionne resigned from this revision.
ldionne added a comment.

I think @phosek is the right person to look at this. I looked at it and it 
seems fine, but I don't know how the runtimes tests are setup well enough to 
spot an issue if there were one.

Nit: I'd suggest rebasing and re-uploading the patch so that the runtimes CI 
can run again (and hopefully pass -- there was a flake last time).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121838

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


[PATCH] D54943: [clang-tidy] implement const-transformation for cppcoreguidelines-const-correctness

2022-04-24 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 424787.
JonasToth added a comment.

- refactor: rename check to 'misc-const-correctness' and adjust the tests 
accordingly
- docs: adjust release notes and adjust check docs slightly


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
  clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.h
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-const-correctness.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-cxx17.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-templates.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-transform-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-transform-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-unaligned.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-values.cpp
  clang/lib/Analysis/ExprMutationAnalyzer.cpp
  clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -1251,13 +1251,13 @@
   AST =
   buildASTFromCode("void f() { int* x[2]; for (int* e : x) e = nullptr; }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_TRUE(isMutated(Results, AST.get()));
 
   AST = buildASTFromCode(
   "typedef int* IntPtr;"
   "void f() { int* x[2]; for (IntPtr e : x) e = nullptr; }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_TRUE(isMutated(Results, AST.get()));
 }
 
 TEST(ExprMutationAnalyzerTest, RangeForArrayByConstRef) {
Index: clang/lib/Analysis/ExprMutationAnalyzer.cpp
===
--- clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -445,14 +445,16 @@
   // array is considered modified if the loop-variable is a non-const reference.
   const auto DeclStmtToNonRefToArray = declStmt(hasSingleDecl(varDecl(hasType(
   hasUnqualifiedDesugaredType(referenceType(pointee(arrayType(;
-  const auto RefToArrayRefToElements = match(
-  findAll(stmt(cxxForRangeStmt(
-   hasLoopVariable(varDecl(hasType(nonConstReferenceType()))
-   .bind(NodeID::value)),
-   hasRangeStmt(DeclStmtToNonRefToArray),
-   hasRangeInit(canResolveToExpr(equalsNode(Exp)
-  .bind("stmt")),
-  Stm, Context);
+  const auto RefToArrayRefToElements =
+  match(findAll(stmt(cxxForRangeStmt(
+ hasLoopVariable(
+ varDecl(anyOf(hasType(nonConstReferenceType()),
+   hasType(nonConstPointerType(
+ .bind(NodeID::value)),
+ hasRangeStmt(DeclStmtToNonRefToArray),
+ hasRangeInit(canResolveToExpr(equalsNode(Exp)
+.bind("stmt")),
+Stm, Context);
 
   if (const auto *BadRangeInitFromArray =
   selectFirst("stmt", RefToArrayRefToElements))
Index: clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-values.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-values.cpp
@@ -0,0 +1,958 @@
+// RUN: %check_clang_tidy %s misc-const-correctness %t -- \
+// RUN:   -config="{CheckOptions: [\
+// RUN:   {key: 'misc-const-correctness.TransformValues', value: true}, \
+// RUN:   {key: 'misc-const-correctness.WarnPointersAsValues', value: false}, \
+// RUN:   {key: 'misc-const-correctness.TransformPointersAsValues', value: false}, \
+// RUN:   ]}" -- -fno-delayed-template-parsing
+
+// --- Provide test samples for primitive builtins -
+// - every 'p_*' variable is a 'potential_const_*' variable
+// - every 'np_*' variable is a 'non_potential_const_*' variable
+
+bool global;
+char np_global = 0; // globals can't be known to be const
+
+// FIXME: 'static' globals are not matched right now. They 

[PATCH] D54943: [clang-tidy] implement const-transformation for misc-const-correctness

2022-04-24 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 424788.
JonasToth added a comment.

- fix: remove clangAnalysis link in cppcoreguidelines and add it in misc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
  clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.h
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-const-correctness.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-cxx17.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-templates.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-transform-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-transform-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-unaligned.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-values.cpp
  clang/lib/Analysis/ExprMutationAnalyzer.cpp
  clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -1251,13 +1251,13 @@
   AST =
   buildASTFromCode("void f() { int* x[2]; for (int* e : x) e = nullptr; }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_TRUE(isMutated(Results, AST.get()));
 
   AST = buildASTFromCode(
   "typedef int* IntPtr;"
   "void f() { int* x[2]; for (IntPtr e : x) e = nullptr; }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_TRUE(isMutated(Results, AST.get()));
 }
 
 TEST(ExprMutationAnalyzerTest, RangeForArrayByConstRef) {
Index: clang/lib/Analysis/ExprMutationAnalyzer.cpp
===
--- clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -445,14 +445,16 @@
   // array is considered modified if the loop-variable is a non-const reference.
   const auto DeclStmtToNonRefToArray = declStmt(hasSingleDecl(varDecl(hasType(
   hasUnqualifiedDesugaredType(referenceType(pointee(arrayType(;
-  const auto RefToArrayRefToElements = match(
-  findAll(stmt(cxxForRangeStmt(
-   hasLoopVariable(varDecl(hasType(nonConstReferenceType()))
-   .bind(NodeID::value)),
-   hasRangeStmt(DeclStmtToNonRefToArray),
-   hasRangeInit(canResolveToExpr(equalsNode(Exp)
-  .bind("stmt")),
-  Stm, Context);
+  const auto RefToArrayRefToElements =
+  match(findAll(stmt(cxxForRangeStmt(
+ hasLoopVariable(
+ varDecl(anyOf(hasType(nonConstReferenceType()),
+   hasType(nonConstPointerType(
+ .bind(NodeID::value)),
+ hasRangeStmt(DeclStmtToNonRefToArray),
+ hasRangeInit(canResolveToExpr(equalsNode(Exp)
+.bind("stmt")),
+Stm, Context);
 
   if (const auto *BadRangeInitFromArray =
   selectFirst("stmt", RefToArrayRefToElements))
Index: clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-values.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-values.cpp
@@ -0,0 +1,958 @@
+// RUN: %check_clang_tidy %s misc-const-correctness %t -- \
+// RUN:   -config="{CheckOptions: [\
+// RUN:   {key: 'misc-const-correctness.TransformValues', value: true}, \
+// RUN:   {key: 'misc-const-correctness.WarnPointersAsValues', value: false}, \
+// RUN:   {key: 'misc-const-correctness.TransformPointersAsValues', value: false}, \
+// RUN:   ]}" -- -fno-delayed-template-parsing
+
+// --- Provide test samples for primitive builtins -
+// - every 'p_*' variable is a 'potential_const_*' variable
+// - every 'np_*' variable is a 'non_potential_const_*' variable
+
+bool global;
+char np_global = 0; // globals can't be known to be const
+
+// FIXME: 'static' globals are not matched right now. They could be analyzed but aren't right now.
+static int p_static_global = 42;
+
+namespace foo {
+int scoped;
+float np_scoped = 1; // namespa

[PATCH] D124348: [1/2][RISCV]Add Intrinsics for B extension in Clang

2022-04-24 Thread Chang Hu via Phabricator via cfe-commits
joker881 created this revision.
Herald added subscribers: sunshaoce, VincentWu, luke957, vkmr, frasercrmck, 
evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, 
jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, 
zzheng, jrtc27, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
joker881 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, eopXD, 
MaskRay.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124348

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/CodeGen/CGBuiltin.cpp
  llvm/include/llvm/IR/IntrinsicsRISCV.td

Index: llvm/include/llvm/IR/IntrinsicsRISCV.td
===
--- llvm/include/llvm/IR/IntrinsicsRISCV.td
+++ llvm/include/llvm/IR/IntrinsicsRISCV.td
@@ -87,6 +87,14 @@
 
   // Zbb
   def int_riscv_orc_b : BitManipGPRIntrinsics;
+  def int_riscv_andn : BitManipGPRGPRGRIntrinsics;
+  def int_riscv_clzw : BitManipGPRIntrinsics;
+  def int_riscv_cpop : BitManipGPRIntrinsics;
+  def int_riscv_cpopw : BitManipGPRIntrinsics;
+  def int_riscv_ctz : BitManipGPRIntrinsics;
+  def int_riscv_max : BitManipGPRGPRIntrinsics;
+  def int_riscv_maxu : BitManipGPRGPRIntrinsics;
+  def int_riscv_orn : BitManipGPRGPRIntrinsics;
 
   // Zbc or Zbkc
   def int_riscv_clmul  : BitManipGPRGPRIntrinsics;
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -18994,6 +18994,20 @@
   case RISCV::BI__builtin_riscv_orc_b_64:
   case RISCV::BI__builtin_riscv_clz_32:
   case RISCV::BI__builtin_riscv_clz_64:
+  case RISCV::BI__builtin_riscv_andn_32:
+  case RISCV::BI__builtin_riscv_andn_64:
+  case RISCV::BI__builtin_riscv_clzw_64:
+  case RISCV::BI__builtin_riscv_cpop_32:
+  case RISCV::BI__builtin_riscv_cpop_64:
+  case RISCV::BI__builtin_riscv_cpopw_64:
+  case RISCV::BI__builtin_riscv_ctz_32:
+  case RISCV::BI__builtin_riscv_ctz_64:
+  case RISCV::BI__builtin_riscv_max_32:
+  case RISCV::BI__builtin_riscv_max_64:
+  case RISCV::BI__builtin_riscv_maxu_32:
+  case RISCV::BI__builtin_riscv_maxu_64:
+  case RISCV::BI__builtin_riscv_orn_32:
+  case RISCV::BI__builtin_riscv_orn_64:
   case RISCV::BI__builtin_riscv_clmul:
   case RISCV::BI__builtin_riscv_clmulh:
   case RISCV::BI__builtin_riscv_clmulr:
@@ -19044,6 +19058,36 @@
   Function *F = CGM.getIntrinsic(Intrinsic::ctlz, Ops[0]->getType());
   return Builder.CreateCall(F, {Ops[0], Builder.getInt1(false)});
 }
+case RISCV::BI__builtin_riscv_andn_32:
+case RISCV::BI__builtin_riscv_andn_64:
+  ID = Intrinsic::riscv_andn;
+  break;
+case RISCV::BI__builtin_riscv_clzw_64:
+  ID = Intrinsic::riscv_clzw;
+  break;
+case RISCV::BI__builtin_riscv_cpop_32:
+case RISCV::BI__builtin_riscv_cpop_64:
+  ID = Intrinsic::riscv_cpop;
+  break;
+case RISCV::BI__builtin_riscv_cpopw_64:
+  ID = Intrinsic::riscv_cpopw;
+  break;
+case RISCV::BI__builtin_riscv_ctz_32:
+case RISCV::BI__builtin_riscv_ctz_64:
+  ID = Intrinsic::riscv_ctz;
+  break;
+case RISCV::BI__builtin_riscv_max_32:
+case RISCV::BI__builtin_riscv_max_64:
+  ID = Intrinsic::riscv_max;
+  break;
+case RISCV::BI__builtin_riscv_maxu_32:
+case RISCV::BI__builtin_riscv_maxu_64:
+  ID = Intrinsic::riscv_maxu;
+  break;
+case RISCV::BI__builtin_riscv_orn_32:
+case RISCV::BI__builtin_riscv_orn_64:
+  ID = Intrinsic::riscv_orn;
+  break;
 
 // Zbc
 case RISCV::BI__builtin_riscv_clmul:
Index: clang/include/clang/Basic/BuiltinsRISCV.def
===
--- clang/include/clang/Basic/BuiltinsRISCV.def
+++ clang/include/clang/Basic/BuiltinsRISCV.def
@@ -20,6 +20,21 @@
 TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "zbb,64bit")
 TARGET_BUILTIN(__builtin_riscv_clz_32, "ZiZi", "nc", "zbb")
 TARGET_BUILTIN(__builtin_riscv_clz_64, "WiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_andn_32, "ZiZiZi", "nc", "zbb")
+TARGET_BUILTIN(__builtin_riscv_andn_64, "WiWiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_clzw_64, "WiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_cpop_32, "ZiZi", "nc", "zbb")
+TARGET_BUILTIN(__builtin_riscv_cpop_64, "WiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_cpopw_64, "WiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_ctz_32, "ZiZi", "nc", "zbb")
+TARGET_BUILTIN(__builtin_riscv_ctz_64, "WiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_ctzw_64, "WiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_max_32, "ZiZiZi", "nc", "zbb")
+TARGET_BUILTIN(__builtin_riscv_max_64, "WiWiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_maxu_32, "ZiZiZi", "nc", "zbb")
+TARGET_BUILT

[PATCH] D124221: Add new builtin __builtin_reflect_struct.

2022-04-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D124221#3469251 , @rsmith wrote:

> In D124221#3468706 , @aaron.ballman 
> wrote:
>
>> Thank you for looking into this! I've also thought that the 
>> `__builtin_dump_struct` implementation hasn't been quite as robust as it 
>> could be. However, the primary use case for that builtin has been for kernel 
>> folks to debug when they have no access to an actual debugger -- it being a 
>> super limited interface is actually a feature rather than a bug, in some 
>> ways.
>
> I'm more concerned about the design of `__builtin_dump_struct` than the 
> implementation -- we can always fix the implementation. Right now the design 
> is hostile to any use other than the very simplest one where the function you 
> give it is essentially `printf`. You can't even dump to a log file or to a 
> string without having to fight the design of the builtin. And if you want 
> anything other than the exact recursion and formatting choices that we've 
> arbitrarily made, you're out of luck. And of course, if you're in C++, you'll 
> want to be able to print out `std::string` and `std::optional` and 
> similar types too, which are not supported by the current design at all. 
> Perhaps this is precisely what a specific set of kernel folks want for a 
> specific use case, but if the only purpose is to address that one use case, 
> then I don't really see how we can justify keeping this builtin in-tree. So I 
> think we should either expand the scope beyond the specific kernel folks or 
> we should remove it.

Yes, I agree that the current builtin is limited and not particularly well 
designed for general use. I would be fine removing support for it. I'd be 
happier augmenting it so it works for more use cases. However, I don't think 
what you've got here so far "expands the scope" so much as "moves the 
goalposts" -- if the replacement can't be used by the kernel folks, then we're 
losing the primary use case we have for that builtin. However, it sounds like 
you may have some ideas on that so we can make it more usable in C.

>> I think what you're designing here is straight-up reflection, which is a 
>> different use case. If we're going to get something that's basically only 
>> usable in C++, I'm not certain there's much value in adding builtins for 
>> reflection until WG21 decides what reflection looks like, and then we can 
>> design around that. (Personally, I think designing usable reflection 
>> interfaces for C would be considerably harder but would provide considerably 
>> more benefit to users given the lack of reflection capabilities. There's 
>> almost no chance WG14 and WG21 would come up with the same interfaces for 
>> reflection, so I think we've got some opportunity for exploration here.)
>
> What I set out to build is something that lets you implement struct dumping 
> without all the shortcomings I see in `__builtin_dump_struct`. I think it's 
> inevitable that that ends up being substantially a struct reflection system, 
> and indeed `__builtin_dump_struct` is a reflection system, too, just a really 
> awkward one -- people have already started parsing its format strings to 
> extract struct field names, for example. (The usage I've seen actually *is* 
> struct dumping, but that usage can't use `__builtin_dump_struct` directly 
> because of its limitations, so `__builtin_dump_struct` is just used to 
> extract the field names, and the field values and types are extracted via 
> structured bindings instead.)

Agreed that the current builtin is effectively (really bad) reflection as well, 
and I'm sad to hear people are trying to parse its output to get structure 
field names (we have a JSON AST dump for exactly that kind of situation, so I'm 
not super sympathetic to people using builtin dump struct in that way unless 
they also need the runtime value information of the fields).

> I do agree that we shouldn't be providing a full reflection mechanism here, 
> given both that one is coming anyway, and that whatever we design, people 
> will inevitably ask for more, and we don't want to be maintaining our own 
> reflection technology.

Agreed.

> So, I think we should either roll back `__builtin_dump_struct` or fix 
> forward. This patch attempted to do the latter, but maybe it's gone too far 
> in the direction of reflection. I think we can address most of my concerns 
> with `__builtin_dump_struct` without a new builtin, by incorporating things 
> from this implementation as follows:
>
> - Desugar it in Sema rather than in CodeGen -- this is necessary to enable 
> following things as well as for constant evaluation

+1

> - Take any callable as the printing function and pass it the fields with 
> their correct types, so that a C++ implementation can dispatch based on the 
> type and print the values of types that we don't hard-code (eg, we'd generate 
> calls like `user_dump_function("%s = %p",

[PATCH] D114837: format: Remove redundant calls to guessIsObjC to speed up clang-format on unknown file types

2022-04-24 Thread David Van Cleve via Phabricator via cfe-commits
davidvc1 added a comment.
Herald added a project: All.

@curdeius , the PR description mentions the reason: when you pipe input from 
stdin, clang-format has to run through the "is it objective C?" codepath, and 
this is the codepath with the bug.

On the other hand, when you pass a .cpp file as a file path input, it doesn't 
need to figure out whether the code is objective C.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114837

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


[PATCH] D124349: [analyzer] Get direct binding for specific punned case

2022-04-24 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers created this revision.
vabridgers added reviewers: NoQ, steakhal.
Herald added subscribers: manas, ASDenysPetrov, martong, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: All.
vabridgers requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Region store was not able to see through this case to the actual
initialized value of STRUCT ff. This change addresses this case by
getting the direct binding. This was found and debugged in a downstream
compiler, with debug guidance from @steakhal. A positive and negative
test case is added.

The specific case where this issue was exposed.

  typedef struct {
int a:1;
int b[2];
  } STRUCT;
  
  int main() {
STRUCT ff = {0};
STRUCT* pff = &ff;
int a = ((int)pff + 1);
return a;
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124349

Files:
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/array-struct-region.c


Index: clang/test/Analysis/array-struct-region.c
===
--- clang/test/Analysis/array-struct-region.c
+++ clang/test/Analysis/array-struct-region.c
@@ -353,3 +353,21 @@
   // FIXME: Should be TRUE.
   clang_analyzer_eval(vals[index].a[0].x == 42); // expected-warning{{UNKNOWN}}
 }
+
+typedef struct {
+  int a:1;
+  int b[2];
+} BITFIELD_CAST;
+
+int array_struct_bitfield_1() {
+  BITFIELD_CAST ff = {0};
+  BITFIELD_CAST* pff = &ff;
+  return *((int*)pff + 1);
+}
+
+int array_struct_bitfield_2() {
+  BITFIELD_CAST ff = {0};
+  BITFIELD_CAST* pff = &ff;
+  int a = *((int*)pff + 2); // expected-warning{{Assigned value is garbage or 
undefined [core.uninitialized.Assign]}}
+  return a;
+}
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2153,8 +2153,13 @@
   return UnknownVal();
 
 // Additionally allow introspection of a block's internal layout.
-if (!hasPartialLazyBinding && !isa(R->getBaseRegion()))
+// Try to get direct binding if all other attempts failed thus far.
+// Else, return UndefinedVal()
+if (!hasPartialLazyBinding && !isa(R->getBaseRegion())) {
+  if (const Optional &V = B.getDefaultBinding(R))
+return *V;
   return UndefinedVal();
+}
   }
 
   // All other values are symbolic.


Index: clang/test/Analysis/array-struct-region.c
===
--- clang/test/Analysis/array-struct-region.c
+++ clang/test/Analysis/array-struct-region.c
@@ -353,3 +353,21 @@
   // FIXME: Should be TRUE.
   clang_analyzer_eval(vals[index].a[0].x == 42); // expected-warning{{UNKNOWN}}
 }
+
+typedef struct {
+  int a:1;
+  int b[2];
+} BITFIELD_CAST;
+
+int array_struct_bitfield_1() {
+  BITFIELD_CAST ff = {0};
+  BITFIELD_CAST* pff = &ff;
+  return *((int*)pff + 1);
+}
+
+int array_struct_bitfield_2() {
+  BITFIELD_CAST ff = {0};
+  BITFIELD_CAST* pff = &ff;
+  int a = *((int*)pff + 2); // expected-warning{{Assigned value is garbage or undefined [core.uninitialized.Assign]}}
+  return a;
+}
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2153,8 +2153,13 @@
   return UnknownVal();
 
 // Additionally allow introspection of a block's internal layout.
-if (!hasPartialLazyBinding && !isa(R->getBaseRegion()))
+// Try to get direct binding if all other attempts failed thus far.
+// Else, return UndefinedVal()
+if (!hasPartialLazyBinding && !isa(R->getBaseRegion())) {
+  if (const Optional &V = B.getDefaultBinding(R))
+return *V;
   return UndefinedVal();
+}
   }
 
   // All other values are symbolic.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124349: [analyzer] Get direct binding for specific punned case

2022-04-24 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 424796.
vabridgers added a comment.

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124349

Files:
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/array-struct-region.c


Index: clang/test/Analysis/array-struct-region.c
===
--- clang/test/Analysis/array-struct-region.c
+++ clang/test/Analysis/array-struct-region.c
@@ -353,3 +353,21 @@
   // FIXME: Should be TRUE.
   clang_analyzer_eval(vals[index].a[0].x == 42); // expected-warning{{UNKNOWN}}
 }
+
+typedef struct {
+  int a : 1;
+  int b[2];
+} BITFIELD_CAST;
+
+int array_struct_bitfield_1() {
+  BITFIELD_CAST ff = {0};
+  BITFIELD_CAST *pff = &ff;
+  return *((int *)pff + 1);
+}
+
+int array_struct_bitfield_2() {
+  BITFIELD_CAST ff = {0};
+  BITFIELD_CAST *pff = &ff;
+  int a = *((int *)pff + 2); // expected-warning{{Assigned value is garbage or 
undefined [core.uninitialized.Assign]}}
+  return a;
+}
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2153,8 +2153,13 @@
   return UnknownVal();
 
 // Additionally allow introspection of a block's internal layout.
-if (!hasPartialLazyBinding && !isa(R->getBaseRegion()))
+// Try to get direct binding if all other attempts failed thus far.
+// Else, return UndefinedVal()
+if (!hasPartialLazyBinding && !isa(R->getBaseRegion())) {
+  if (const Optional &V = B.getDefaultBinding(R))
+return *V;
   return UndefinedVal();
+}
   }
 
   // All other values are symbolic.


Index: clang/test/Analysis/array-struct-region.c
===
--- clang/test/Analysis/array-struct-region.c
+++ clang/test/Analysis/array-struct-region.c
@@ -353,3 +353,21 @@
   // FIXME: Should be TRUE.
   clang_analyzer_eval(vals[index].a[0].x == 42); // expected-warning{{UNKNOWN}}
 }
+
+typedef struct {
+  int a : 1;
+  int b[2];
+} BITFIELD_CAST;
+
+int array_struct_bitfield_1() {
+  BITFIELD_CAST ff = {0};
+  BITFIELD_CAST *pff = &ff;
+  return *((int *)pff + 1);
+}
+
+int array_struct_bitfield_2() {
+  BITFIELD_CAST ff = {0};
+  BITFIELD_CAST *pff = &ff;
+  int a = *((int *)pff + 2); // expected-warning{{Assigned value is garbage or undefined [core.uninitialized.Assign]}}
+  return a;
+}
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2153,8 +2153,13 @@
   return UnknownVal();
 
 // Additionally allow introspection of a block's internal layout.
-if (!hasPartialLazyBinding && !isa(R->getBaseRegion()))
+// Try to get direct binding if all other attempts failed thus far.
+// Else, return UndefinedVal()
+if (!hasPartialLazyBinding && !isa(R->getBaseRegion())) {
+  if (const Optional &V = B.getDefaultBinding(R))
+return *V;
   return UndefinedVal();
+}
   }
 
   // All other values are symbolic.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124348: [1/2][RISCV]Add Intrinsics for B extension in Clang

2022-04-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

The "B extension" terminology no longer exists.




Comment at: clang/include/clang/Basic/BuiltinsRISCV.def:29
+TARGET_BUILTIN(__builtin_riscv_cpopw_64, "WiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_ctz_32, "ZiZi", "nc", "zbb")
+TARGET_BUILTIN(__builtin_riscv_ctz_64, "WiWi", "nc", "zbb,64bit")

The only ones of these we need is ctz_32 and ctz_64 and they should be 
implemented the same as clz_32/clz_64.

I guess we might also need 
max_32/max_64/maxu_32/maxu_64/min_32/min_64/minu_32/minu_64 for -O0. For -O1 
and above `(x > y) ? x : y` already works. They can use the existing 
llvm.smax/smin/umax/umin intrinsics. 

andn can be represented directly in C with X & ~Y
orn is X | ~Y
cpop_32 is __builtin_popcount
cpop_64 is __builtin_popcountll
clzw_32 is __builtin_riscv_clz_32 sign extended to 64 bits. Similar for ctzw_64.



Comment at: llvm/include/llvm/IR/IntrinsicsRISCV.td:90
   def int_riscv_orc_b : BitManipGPRIntrinsics;
+  def int_riscv_andn : BitManipGPRGPRGRIntrinsics;
+  def int_riscv_clzw : BitManipGPRIntrinsics;

We don't need any of these intrinsics.

Max already has llvm.smax and llvm.umax.
clzw is (signext (llvm.cltz))
cpop is llvm.ctpop
cpopw is (signext (llvm.ctpop))
andn is (and X, (not Y))
orn is (or X, (not Y))
ctz is llvm.ctlz 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124348

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


[PATCH] D97625: fix check-clang-tools tests that fail due to Windows CRLF line endings

2022-04-24 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D97625#3337018 , @dmgreen wrote:

> I'm not sure it will do much where it is.

It won't, to quote **gitattributes**(5):

> When deciding what attributes are assigned to a path, Git consults 
> `$GIT_DIR/info/attributes` file (which has the highest precedence), 
> `.gitattributes` file in the same directory as the path in question, and its 
> parent directories up to the toplevel of the work tree (the further the 
> directory that contains `.gitattributes` is from the path in question, the 
> lower its precedence).

Obviously `test/` is not a parent directory of `clang-tools-extra/test`.

In D97625#3394751 , @bcain wrote:

> If it makes sense, it could be re-applied to `clang-tools-extra/test/`.

I thought that maybe `lit` would try to run it as a test then, but `llvm-lit 
--show-tests clang-tools-extra/test/` doesn't list it if I move it there. 
Specifically `llvm-lit --show-tests clang-tools-extra/test/.gitattributes` 
prints:

  llvm-lit: [...]/llvm/utils/lit/lit/discovery.py:176: error: 'Clang Tools :: 
.gitattributes' would not be run indirectly: change name or LIT config(e.g. 
suffixes or standalone_tests variables)
  1 errors, exiting.

Indeed, in `llvm/utils/lit/lit/formats/base.py`:

  class FileBasedTest(TestFormat):
  def getTestsInDirectory(self, testSuite, path_in_suite,
  litConfig, localConfig):
  source_path = testSuite.getSourcePath(path_in_suite)
  for filename in os.listdir(source_path):
  # Ignore dot files and excluded tests.
  if (filename.startswith('.') or
  filename in localConfig.excludes):
  continue

It also applies the attributes correctly:

  > git check-attr -a 
clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
  clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp: text: 
set
  clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp: eol: 
crlf

Previously that printed nothing.

So I went ahead and just fixed this in ac5f7be6a8688955a282becf00eebc542238a86b 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97625

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


[PATCH] D124351: [Clang][WIP] Implement Change scope of lambda trailing-return-type

2022-04-24 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision.
Herald added a project: All.
cor3ntin requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This implements P2036R3 with the changes proposed by D2579R0 applied.
That is, explicit, int, and implicit capture become visible
at the start of the parameter head.

This approach is meant to address breakages observed in

https://reviews.llvm.org/D119136.

It is based on D119136  and D124012 
.

Most of the code is similar, except that Clang
will do a tentative parse action to try to find a mutable keyword
after the parameter list, and inject the explicit captures in the call
operator context before parsing the template parameter list.

If the code is not-well balanced, there is no degadation in diagnostics,
as we simply fallback to assuming the lambda is not mutable.

In lambda template parameters, naming a capture is still ill-formed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124351

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Scope.h
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/Scope.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp
  clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1356,7 +1356,7 @@
 
   Change scope of lambda trailing-return-type
   https://wg21.link/P2036R3";>P2036R3
-  No
+  Clang 15
 
 
   Multidimensional subscript operator
Index: clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
+++ clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -95,7 +95,7 @@
 #ifdef AVOID
   auto l4 = [var = param] (int param) { ; }; // no warning
 #else
-  auto l4 = [var = param] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  auto l4 = [var = param](int param) { ; }; // expected-warning 2{{declaration shadows a local variable}}
 #endif
 
   // Make sure that inner lambdas work as well.
Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -0,0 +1,248 @@
+// RUN: %clang_cc1 -std=c++2b -verify -fsyntax-only %s
+
+template 
+constexpr bool is_same = false;
+
+template 
+constexpr bool is_same = true;
+
+void f() {
+
+  int y;
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  auto ref = [&x = y](
+ decltype([&](decltype(x)) { return 0; }) y) {
+return x;
+  };
+}
+
+void test_noexcept() {
+
+  int y;
+
+  static_assert(noexcept([x = 1] noexcept(is_same) {}()));
+  static_assert(noexcept([x = 1] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([y] noexcept(is_same) {}()));
+  static_assert(noexcept([y] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([=] noexcept(is_same) {}()));
+  static_assert(noexcept([=] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([&] noexcept(is_same) {}()));
+  static_assert(noexcept([&] mutable noexcept(is_same) {}()));
+
+  static_assert(noexcept([&] mutable noexcept(!is_same) {}())); // expected-error {{static_assert failed due}}
+}
+
+void test_requires() {
+
+  int x;
+
+  [x = 1]() requires is_same {}
+  ();
+  [x = 1]() mutable requires is_same {}
+  ();
+  [x]() requires is_same {}
+  ();
+  [x]() mutable requires is_same {}
+  ();
+  [=]() requires is_same {}
+  ();
+  [=]() mutable requires is_same {}
+  ();
+  [&]() requires is_same {}
+  ();
+  [&]() mutable requires is_same {}
+  ();
+  [&x]() requires is_same {}
+  ();
+  [&x]() mutable requires is_same {}
+  ();
+
+  [x = 1]() requires is_same {} (); //expected-error {{no matching function for call to object of type}} \
+   // expected-note {{can

[PATCH] D124351: [Clang][WIP] Implement Change scope of lambda trailing-return-type - Take 2

2022-04-24 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Hey folks.
I do not intend this to be merge but if there is anyway this can be battle 
tested against internal codebases, i think it could be helpful to help guide 
how WG21 proceed with this feature.
Here is a paper listing the failures encountered when we merged the previous 
attempt, and offers a more holistic mitigation - by looking a head for the 
mutable keyword https://isocpp.org/files/papers/D2579R0.pdf

Sorry again for the troubles the previous attempt caused but I'm glad we caught 
this problem sooner rather than later...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124351

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


[clang] c261f78 - [clang-format] Refactor determineStarAmpUsage NFC

2022-04-24 Thread via cfe-commits

Author: sstwcw
Date: 2022-04-24T22:30:22Z
New Revision: c261f78d05deee305166e5f8c91e347b8401dfa4

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

LOG: [clang-format] Refactor determineStarAmpUsage NFC

There was some duplicate code in determineStarAmpUsage and
determinePlusMinusCaretUsage

Now a `-` or `+` following `;`, `sizeof`, `co_await`, or `delete` is
regarded as a unary operator.

Now a `*` or `&` following `case` is also a unary operator.

Reviewed By: curdeius, MyDeveloperDay, HazardyKnusperkeks

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index cb950f2b2198d..3714b9d3e0fc3 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2146,6 +2146,42 @@ class AnnotatingParser {
 return true;
   }
 
+  /// Returns true if the token is used as a unary operator.
+  bool determineUnaryOperatorByUsage(const FormatToken &Tok) {
+const FormatToken *PrevToken = Tok.getPreviousNonComment();
+if (!PrevToken)
+  return true;
+
+// These keywords are deliberately not included here because they may
+// precede only one of unary star/amp and plus/minus but not both.  They 
are
+// either included in determineStarAmpUsage or 
determinePlusMinusCaretUsage.
+//
+// @ - It may be followed by a unary `-` in Objective-C literals. We don't
+//   know how they can be followed by a star or amp.
+if (PrevToken->isOneOf(
+TT_ConditionalExpr, tok::l_paren, tok::comma, tok::colon, 
tok::semi,
+tok::equal, tok::question, tok::l_square, tok::l_brace,
+tok::kw_case, tok::kw_co_await, tok::kw_co_return, 
tok::kw_co_yield,
+tok::kw_delete, tok::kw_return, tok::kw_throw))
+  return true;
+
+// We put sizeof here instead of only in determineStarAmpUsage. In the 
cases
+// where the unary `+` operator is overloaded, it is reasonable to write
+// things like `sizeof +x`. Like commit 446d6ec996c6c3.
+if (PrevToken->is(tok::kw_sizeof))
+  return true;
+
+// A sequence of leading unary operators.
+if (PrevToken->isOneOf(TT_CastRParen, TT_UnaryOperator))
+  return true;
+
+// There can't be two consecutive binary operators.
+if (PrevToken->is(TT_BinaryOperator))
+  return true;
+
+return false;
+  }
+
   /// Return the type of the given token assuming it is * or &.
   TokenType determineStarAmpUsage(const FormatToken &Tok, bool IsExpression,
   bool InTemplateArgument) {
@@ -2177,12 +2213,7 @@ class AnnotatingParser {
 if (PrevToken->is(tok::r_paren) && PrevToken->is(TT_TypeDeclarationParen))
   return TT_PointerOrReference;
 
-if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
-   tok::comma, tok::semi, tok::kw_return, tok::colon,
-   tok::kw_co_return, tok::kw_co_await,
-   tok::kw_co_yield, tok::equal, tok::kw_delete,
-   tok::kw_sizeof, tok::kw_throw, TT_BinaryOperator,
-   TT_ConditionalExpr, TT_UnaryOperator, 
TT_CastRParen))
+if (determineUnaryOperatorByUsage(Tok))
   return TT_UnaryOperator;
 
 if (NextToken->is(tok::l_square) && NextToken->isNot(TT_LambdaLSquare))
@@ -2232,23 +2263,14 @@ class AnnotatingParser {
   }
 
   TokenType determinePlusMinusCaretUsage(const FormatToken &Tok) {
-const FormatToken *PrevToken = Tok.getPreviousNonComment();
-if (!PrevToken)
+if (determineUnaryOperatorByUsage(Tok))
   return TT_UnaryOperator;
 
-if (PrevToken->isOneOf(TT_CastRParen, TT_UnaryOperator))
-  // This must be a sequence of leading unary operators.
-  return TT_UnaryOperator;
-
-// Use heuristics to recognize unary operators.
-if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
-   tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw,
-   tok::kw_co_return, tok::kw_co_yield))
+const FormatToken *PrevToken = Tok.getPreviousNonComment();
+if (!PrevToken)
   return TT_UnaryOperator;
 
-// There can't be two consecutive binary operators.
-if (PrevToken->is(TT_BinaryOperator))
+if (PrevToken->is(tok::at))
   return TT_UnaryOperator;
 
 // Fall back to marking the token as binary operator.

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cp

[PATCH] D121754: [clang-format] Refactor determineStarAmpUsage NFC

2022-04-24 Thread sstwcw via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc261f78d05de: [clang-format] Refactor determineStarAmpUsage 
NFC (authored by sstwcw).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121754

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp

Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -78,6 +78,102 @@
   EXPECT_EQ(Tokens.size(), 21u) << Tokens;
   EXPECT_TOKEN(Tokens[10], tok::ampamp, TT_BinaryOperator);
   EXPECT_TOKEN(Tokens[11], tok::star, TT_UnaryOperator);
+
+  Tokens = annotate("case *x:");
+  EXPECT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::star, TT_UnaryOperator);
+  Tokens = annotate("case &x:");
+  EXPECT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::amp, TT_UnaryOperator);
+}
+
+TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {
+  auto Tokens = annotate("x - 0");
+  ASSERT_EQ(Tokens.size(), 4u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::minus, TT_BinaryOperator);
+  Tokens = annotate("0 + 0");
+  ASSERT_EQ(Tokens.size(), 4u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::plus, TT_BinaryOperator);
+  Tokens = annotate("x + +0");
+  ASSERT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[2], tok::plus, TT_UnaryOperator);
+  Tokens = annotate("x ? -0 : +0");
+  ASSERT_EQ(Tokens.size(), 8u) << Tokens;
+  EXPECT_TOKEN(Tokens[2], tok::minus, TT_UnaryOperator);
+  EXPECT_TOKEN(Tokens[5], tok::plus, TT_UnaryOperator);
+  Tokens = annotate("(-0)");
+  ASSERT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::minus, TT_UnaryOperator);
+  Tokens = annotate("0, -0");
+  ASSERT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[2], tok::minus, TT_UnaryOperator);
+  Tokens = annotate("for (; -1;) {\n}");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::minus, TT_UnaryOperator);
+  Tokens = annotate("x = -1;");
+  ASSERT_EQ(Tokens.size(), 6u) << Tokens;
+  EXPECT_TOKEN(Tokens[2], tok::minus, TT_UnaryOperator);
+  Tokens = annotate("x[-1]");
+  ASSERT_EQ(Tokens.size(), 6u) << Tokens;
+  EXPECT_TOKEN(Tokens[2], tok::minus, TT_UnaryOperator);
+  Tokens = annotate("x = {-1};");
+  ASSERT_EQ(Tokens.size(), 8u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::minus, TT_UnaryOperator);
+  Tokens = annotate("case -x:");
+  ASSERT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::minus, TT_UnaryOperator);
+  Tokens = annotate("co_await -x;");
+  ASSERT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::minus, TT_UnaryOperator);
+  Tokens = annotate("co_return -x;");
+  ASSERT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::minus, TT_UnaryOperator);
+  Tokens = annotate("co_yield -x;");
+  ASSERT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::minus, TT_UnaryOperator);
+  Tokens = annotate("delete -x;");
+  ASSERT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::minus, TT_UnaryOperator);
+  Tokens = annotate("return -x;");
+  ASSERT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::minus, TT_UnaryOperator);
+  Tokens = annotate("throw -x;");
+  ASSERT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::minus, TT_UnaryOperator);
+  Tokens = annotate("sizeof -x");
+  ASSERT_EQ(Tokens.size(), 4u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::minus, TT_UnaryOperator);
+  Tokens = annotate("co_await +x;");
+  ASSERT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::plus, TT_UnaryOperator);
+  Tokens = annotate("co_return +x;");
+  ASSERT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::plus, TT_UnaryOperator);
+  Tokens = annotate("co_yield +x;");
+  ASSERT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::plus, TT_UnaryOperator);
+  Tokens = annotate("delete +x;");
+  ASSERT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::plus, TT_UnaryOperator);
+  Tokens = annotate("return +x;");
+  ASSERT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::plus, TT_UnaryOperator);
+  Tokens = annotate("throw +x;");
+  ASSERT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::plus, TT_UnaryOperator);
+  Tokens = annotate("sizeof +x");
+  ASSERT_EQ(Tokens.size(), 4u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::plus, TT_UnaryOperator);
+  Tokens = annotate("(int)-x");
+  ASSERT_EQ(Tokens.size(), 6u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::minus, TT_UnaryOperator);
+  Tokens = annotate("(-x)");
+  ASSERT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::minus, TT_UnaryOperator);
+  Tokens = annotate("!+x");
+  ASSERT_EQ(Tokens.size(), 4u) << Tokens;
+  EXP

[PATCH] D122663: Mark identifier prefixes as substitutable

2022-04-24 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk added a comment.

In D122663#3457330 , @erichkeane 
wrote:

> LGTM!  I would like @rjmccall to take a pass if he ends up having time in the 
> next day or two (perhaps tack on an extra day or two because of Easter), else 
> I'll be willing to approve later in the week.

ping, I did get feedback from @rsmith (much appreciated) and applied his 
suggestions, but not from @rjmccall, would you be okay to approve it then?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122663

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


[PATCH] D123884: [HLSL][clang][Driver] Support target profile command line option.

2022-04-24 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 424810.
python3kgae marked an inline comment as done.
python3kgae added a comment.
Herald added a subscriber: Anastasia.

Use c_str instead of data to avoid test fail.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123884

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGHLSLRuntime.cpp
  clang/lib/CodeGen/CGHLSLRuntime.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/HLSL.cpp
  clang/lib/Driver/ToolChains/HLSL.h
  clang/test/CodeGenHLSL/validator_version.hlsl
  clang/unittests/Driver/ToolChainTest.cpp

Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -504,4 +504,97 @@
   DiagConsumer->clear();
 }
 
+TEST(DxcModeTest, ValidatorVersionValidation) {
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+  struct SimpleDiagnosticConsumer : public DiagnosticConsumer {
+void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
+  const Diagnostic &Info) override {
+  if (DiagLevel == DiagnosticsEngine::Level::Error) {
+Errors.emplace_back();
+Info.FormatDiagnostic(Errors.back());
+Errors.back().append({0});
+  } else {
+Msgs.emplace_back();
+Info.FormatDiagnostic(Msgs.back());
+Msgs.back().append({0});
+  }
+}
+void clear() override {
+  Msgs.clear();
+  Errors.clear();
+  DiagnosticConsumer::clear();
+}
+std::vector> Msgs;
+std::vector> Errors;
+  };
+
+  IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+
+  InMemoryFileSystem->addFile("foo.hlsl", 0,
+  llvm::MemoryBuffer::getMemBuffer("\n"));
+
+  auto *DiagConsumer = new SimpleDiagnosticConsumer;
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagConsumer);
+  Driver TheDriver("/bin/clang", "", Diags, "", InMemoryFileSystem);
+  std::unique_ptr C(
+  TheDriver.BuildCompilation({"clang", "--driver-mode=dxc", "foo.hlsl"}));
+  EXPECT_TRUE(C);
+  EXPECT_TRUE(!C->containsError());
+
+  auto &TC = C->getDefaultToolChain();
+  bool ContainsError = false;
+  auto Args = TheDriver.ParseArgStrings({"-validator-version", "1.1"}, false,
+ContainsError);
+  EXPECT_FALSE(ContainsError);
+  auto DAL = std::make_unique(Args);
+  for (auto *A : Args) {
+DAL->append(A);
+  }
+  auto *TranslatedArgs =
+  TC.TranslateArgs(*DAL, "0", Action::OffloadKind::OFK_None);
+  EXPECT_NE(TranslatedArgs, nullptr);
+  if (TranslatedArgs) {
+auto *A = TranslatedArgs->getLastArg(
+clang::driver::options::OPT_dxil_validator_version);
+EXPECT_NE(A, nullptr);
+if (A) {
+  EXPECT_STREQ(A->getValue(), "1.1");
+}
+  }
+  EXPECT_EQ(Diags.getNumErrors(), 0);
+
+  // Invalid tests.
+  Args = TheDriver.ParseArgStrings({"-validator-version", "0.1"}, false,
+   ContainsError);
+  EXPECT_FALSE(ContainsError);
+  DAL = std::make_unique(Args);
+  for (auto *A : Args) {
+DAL->append(A);
+  }
+  TranslatedArgs = TC.TranslateArgs(*DAL, "0", Action::OffloadKind::OFK_None);
+  EXPECT_EQ(Diags.getNumErrors(), 1);
+  EXPECT_STREQ(DiagConsumer->Errors.back().c_str(),
+   "invalid validator version : 0.1\nIf validator major version is "
+   "0, minor version must also be 0.");
+  Diags.Clear();
+  DiagConsumer->clear();
+
+  Args = TheDriver.ParseArgStrings({"-validator-version", "1"}, false,
+   ContainsError);
+  EXPECT_FALSE(ContainsError);
+  DAL = std::make_unique(Args);
+  for (auto *A : Args) {
+DAL->append(A);
+  }
+  TranslatedArgs = TC.TranslateArgs(*DAL, "0", Action::OffloadKind::OFK_None);
+  EXPECT_EQ(Diags.getNumErrors(), 2);
+  EXPECT_STREQ(DiagConsumer->Errors.back().c_str(),
+   "invalid validator version : 1\nFormat of validator version is "
+   "\".\" (ex:\"1.4\").");
+  Diags.Clear();
+  DiagConsumer->clear();
+}
+
 } // end anonymous namespace.
Index: clang/test/CodeGenHLSL/validator_version.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/validator_version.hlsl
@@ -0,0 +1,10 @@
+// RUN: %clang -cc1 -S -triple dxil-pc-shadermodel6.3-library -S -emit-llvm -xhlsl -validator-version 1.1 -o - %s | FileCheck %s
+
+// CHECK:!"dx.valver", ![[valver:[0-9]+]]}
+// CHECK:![[valver]] = !{i32 1, i32 1}
+
+float bar(float a, float b);
+
+float foo(float a, float b) {
+  return bar(a, b);

[PATCH] D124356: [Driver][Solaris] -r: imply -nostdlib like GCC

2022-04-24 Thread Brad Smith via Phabricator via cfe-commits
brad created this revision.
brad added reviewers: MaskRay, ro.
brad added a project: clang.
Herald added subscribers: StephenFan, fedor.sergeev.
Herald added a project: All.
brad requested review of this revision.

Similar to D116843  for Gnu.cpp


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124356

Files:
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/test/Driver/solaris-ld.c


Index: clang/test/Driver/solaris-ld.c
===
--- clang/test/Driver/solaris-ld.c
+++ clang/test/Driver/solaris-ld.c
@@ -108,3 +108,11 @@
 // CHECK-SPARC32-SHARED-SAME: "-lc"
 // CHECK-SPARC32-SHARED-NOT: "-lgcc"
 // CHECK-SPARC32-SHARED-NOT: "-lm"
+
+// -r suppresses default -l and crt*.o, values-*.o like -nostdlib.
+// RUN: %clang -### %s --target=sparc-sun-solaris2.11 -r \
+// RUN:   2>&1 | FileCheck %s --check-prefix=CHECK-RELOCATABLE
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "-l
+// CHECK-RELOCATABLE-NOT: {{.*}}crt{{[^.]+}}.o
+// CHECK-RELOCATABLE-NOT: {{.*}}values-{{[^.]+}}.o
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -84,7 +84,8 @@
 assert(Output.isNothing() && "Invalid output.");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 if (!Args.hasArg(options::OPT_shared))
   CmdArgs.push_back(
   Args.MakeArgString(getToolChain().GetFilePath("crt1.o")));
@@ -124,7 +125,8 @@
   bool NeedsSanitizerDeps = addSanitizerRuntimes(getToolChain(), Args, 
CmdArgs);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
+   options::OPT_r)) {
 if (getToolChain().ShouldLinkCXXStdlib(Args))
   getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
 if (Args.hasArg(options::OPT_fstack_protector) ||
@@ -161,11 +163,13 @@
 }
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crtend.o")));
+CmdArgs.push_back(
+Args.MakeArgString(getToolChain().GetFilePath("crtn.o")));
   }
-  CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath("crtn.o")));
 
   getToolChain().addProfileRTLibs(Args, CmdArgs);
 


Index: clang/test/Driver/solaris-ld.c
===
--- clang/test/Driver/solaris-ld.c
+++ clang/test/Driver/solaris-ld.c
@@ -108,3 +108,11 @@
 // CHECK-SPARC32-SHARED-SAME: "-lc"
 // CHECK-SPARC32-SHARED-NOT: "-lgcc"
 // CHECK-SPARC32-SHARED-NOT: "-lm"
+
+// -r suppresses default -l and crt*.o, values-*.o like -nostdlib.
+// RUN: %clang -### %s --target=sparc-sun-solaris2.11 -r \
+// RUN:   2>&1 | FileCheck %s --check-prefix=CHECK-RELOCATABLE
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "-l
+// CHECK-RELOCATABLE-NOT: {{.*}}crt{{[^.]+}}.o
+// CHECK-RELOCATABLE-NOT: {{.*}}values-{{[^.]+}}.o
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -84,7 +84,8 @@
 assert(Output.isNothing() && "Invalid output.");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 if (!Args.hasArg(options::OPT_shared))
   CmdArgs.push_back(
   Args.MakeArgString(getToolChain().GetFilePath("crt1.o")));
@@ -124,7 +125,8 @@
   bool NeedsSanitizerDeps = addSanitizerRuntimes(getToolChain(), Args, CmdArgs);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
+   options::OPT_r)) {
 if (getToolChain().ShouldLinkCXXStdlib(Args))
   getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
 if (Args.hasArg(options::OPT_fstack_protector) ||
@@ -161,11 +163,13 @@
 }
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crtend.o")));
+CmdArgs.push_back(
+Args.MakeArgString(getToolChain().GetFilePath("crtn.o")));
   }
-  CmdArgs.push_back(Args.MakeArgSt

[clang] e33867a - Fix an issue in comment. NFC

2022-04-24 Thread Jun Zhang via cfe-commits

Author: Jun Zhang
Date: 2022-04-25T12:45:39+08:00
New Revision: e33867a43410ea425c169cde9de7187f08264e59

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

LOG: Fix an issue in comment. NFC

I think the author renamed the function but forgot to update the
comment.
Signed-off-by: Jun Zhang 

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 250a553c414ea..3f095bc61ebe0 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5794,7 +5794,7 @@ static bool hasSimilarParameters(ASTContext &Context,
   return true;
 }
 
-/// NeedsRebuildingInCurrentInstantiation - Checks whether the given
+/// RebuildDeclaratorInCurrentInstantiation - Checks whether the given
 /// declarator needs to be rebuilt in the current instantiation.
 /// Any bits of declarator which appear before the name are valid for
 /// consideration here.  That's specifically the type in the decl spec



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


[PATCH] D124344: [clangd] Output inlay hints with `clangd --check`

2022-04-24 Thread Nathan Ridge via Phabricator via cfe-commits
nridge accepted this revision.
nridge added a comment.
This revision is now accepted and ready to land.

Thanks, this seems useful.




Comment at: clang-tools-extra/clangd/tool/Check.cpp:195
 
+  // Build Inlay Hints for the entire AST
+  bool buildInlayHints(llvm::Optional LineRange) {

The comment should probably say "... for the entire AST or the specified range"



Comment at: clang-tools-extra/clangd/tool/Check.cpp:201
+for (const auto &Hint : Hints) {
+  vlog("  {0} {1}", Hint.position, Hint.label);
+}

Might be useful for print the hint kind as well?


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

https://reviews.llvm.org/D124344

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


[PATCH] D124344: [clangd] Output inlay hints with `clangd --check`

2022-04-24 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj updated this revision to Diff 424816.
upsj added a comment.

Output InlayHintKind and improve comments


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

https://reviews.llvm.org/D124344

Files:
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/tool/Check.cpp


Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -192,7 +192,7 @@
 return true;
   }
 
-  // Build Inlay Hints for the entire AST
+  // Build Inlay Hints for the entire AST or the specified range
   bool buildInlayHints(llvm::Optional LineRange) {
 log("Building inlay hints");
 auto Hints = inlayHints(*AST, LineRange);
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -1576,6 +1576,7 @@
   /// naturally when placed inline with the code.
   std::string label;
 };
+const char* toString(InlayHintKind);
 llvm::json::Value toJSON(const InlayHint &);
 bool operator==(const InlayHint &, const InlayHint &);
 bool operator<(const InlayHint &, const InlayHint &);
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -1316,7 +1316,7 @@
   return O && O.map("textDocument", R.textDocument) && O.map("range", R.range);
 }
 
-llvm::json::Value toJSON(InlayHintKind K) {
+const char* toString(InlayHintKind K){
   switch (K) {
   case InlayHintKind::ParameterHint:
 return "parameter";
@@ -1328,6 +1328,10 @@
   llvm_unreachable("Unknown clang.clangd.InlayHintKind");
 }
 
+llvm::json::Value toJSON(InlayHintKind K) {
+  return toString(K);
+}
+
 llvm::json::Value toJSON(const InlayHint &H) {
   return llvm::json::Object{{"position", H.position},
 {"range", H.range},


Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -192,7 +192,7 @@
 return true;
   }
 
-  // Build Inlay Hints for the entire AST
+  // Build Inlay Hints for the entire AST or the specified range
   bool buildInlayHints(llvm::Optional LineRange) {
 log("Building inlay hints");
 auto Hints = inlayHints(*AST, LineRange);
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -1576,6 +1576,7 @@
   /// naturally when placed inline with the code.
   std::string label;
 };
+const char* toString(InlayHintKind);
 llvm::json::Value toJSON(const InlayHint &);
 bool operator==(const InlayHint &, const InlayHint &);
 bool operator<(const InlayHint &, const InlayHint &);
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -1316,7 +1316,7 @@
   return O && O.map("textDocument", R.textDocument) && O.map("range", R.range);
 }
 
-llvm::json::Value toJSON(InlayHintKind K) {
+const char* toString(InlayHintKind K){
   switch (K) {
   case InlayHintKind::ParameterHint:
 return "parameter";
@@ -1328,6 +1328,10 @@
   llvm_unreachable("Unknown clang.clangd.InlayHintKind");
 }
 
+llvm::json::Value toJSON(InlayHintKind K) {
+  return toString(K);
+}
+
 llvm::json::Value toJSON(const InlayHint &H) {
   return llvm::json::Object{{"position", H.position},
 {"range", H.range},
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124344: [clangd] Output inlay hints with `clangd --check`

2022-04-24 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj updated this revision to Diff 424817.
upsj added a comment.

forgot to include the old changes in the diff


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

https://reviews.llvm.org/D124344

Files:
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -61,8 +61,7 @@
 namespace clangd {
 
 // Implemented in Check.cpp.
-bool check(const llvm::StringRef File,
-   llvm::function_ref ShouldCheckLine,
+bool check(const llvm::StringRef File, llvm::Optional LineRange,
const ThreadsafeFS &TFS, const ClangdLSPServer::Options &Opts,
bool EnableCodeCompletion);
 
@@ -955,8 +954,9 @@
   return 1;
 }
 log("Entering check mode (no LSP server)");
-uint32_t Begin = 0, End = std::numeric_limits::max();
+llvm::Optional CheckLineRange;
 if (!CheckFileLines.empty()) {
+  uint32_t Begin = 0, End = std::numeric_limits::max();
   StringRef RangeStr(CheckFileLines);
   bool ParseError = RangeStr.consumeInteger(0, Begin);
   if (RangeStr.empty()) {
@@ -965,19 +965,18 @@
 ParseError |= !RangeStr.consume_front("-");
 ParseError |= RangeStr.consumeInteger(0, End);
   }
-  if (ParseError || !RangeStr.empty()) {
-elog("Invalid --check-line specified. Use Begin-End format, e.g. 3-17");
+  if (ParseError || !RangeStr.empty() || Begin <= 0 || End < Begin) {
+elog(
+"Invalid --check-lines specified. Use Begin-End format, e.g. 3-17");
 return 1;
   }
+  CheckLineRange = Range{Position{static_cast(Begin - 1), 0},
+ Position{static_cast(End), 0}};
 }
-auto ShouldCheckLine = [&](const Position &Pos) {
-  uint32_t Line = Pos.line + 1; // Position::line is 0-based.
-  return Line >= Begin && Line <= End;
-};
 // For now code completion is enabled any time the range is limited via
 // --check-lines. If it turns out to be to slow, we can introduce a
 // dedicated flag for that instead.
-return check(Path, ShouldCheckLine, TFS, Opts,
+return check(Path, CheckLineRange, TFS, Opts,
  /*EnableCodeCompletion=*/!CheckFileLines.empty())
? 0
: static_cast(ErrorResultCode::CheckFailed);
Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -30,8 +30,10 @@
 #include "Config.h"
 #include "GlobalCompilationDatabase.h"
 #include "Hover.h"
+#include "InlayHints.h"
 #include "ParsedAST.h"
 #include "Preamble.h"
+#include "Protocol.h"
 #include "SourceCode.h"
 #include "XRefs.h"
 #include "index/CanonicalIncludes.h"
@@ -190,10 +192,20 @@
 return true;
   }
 
+  // Build Inlay Hints for the entire AST or the specified range
+  bool buildInlayHints(llvm::Optional LineRange) {
+log("Building inlay hints");
+auto Hints = inlayHints(*AST, LineRange);
+
+for (const auto &Hint : Hints) {
+  vlog("  {0} {1} {2}", toString(Hint.kind), Hint.position, Hint.label);
+}
+return true;
+  }
+
   // Run AST-based features at each token in the file.
-  void testLocationFeatures(
-  llvm::function_ref ShouldCheckLine,
-  const bool EnableCodeCompletion) {
+  void testLocationFeatures(llvm::Optional LineRange,
+const bool EnableCodeCompletion) {
 trace::Span Trace("testLocationFeatures");
 log("Testing features at each token (may be slow in large files)");
 auto &SM = AST->getSourceManager();
@@ -207,7 +219,7 @@
   unsigned End = Start + Tok.length();
   Position Pos = offsetToPosition(Inputs.Contents, Start);
 
-  if (!ShouldCheckLine(Pos))
+  if (LineRange && LineRange->contains(Pos))
 continue;
 
   trace::Span Trace("Token");
@@ -254,8 +266,7 @@
 
 } // namespace
 
-bool check(llvm::StringRef File,
-   llvm::function_ref ShouldCheckLine,
+bool check(llvm::StringRef File, llvm::Optional LineRange,
const ThreadsafeFS &TFS, const ClangdLSPServer::Options &Opts,
bool EnableCodeCompletion) {
   llvm::SmallString<0> FakeFile;
@@ -282,9 +293,9 @@
   : /*Don't turn on local configs for an arbitrary temp path.*/ ""));
   Checker C(File, Opts);
   if (!C.buildCommand(TFS) || !C.buildInvocation(TFS, Contents) ||
-  !C.buildAST())
+  !C.buildAST() || !C.buildInlayHints(LineRange))
 return false;
-  C.testLocationFeatures(ShouldCheckLine, EnableCodeCompletion);
+  C.testLocationFeatures(LineRange, EnableCodeCompletion);
 
   log("All checks completed, {0} errors", C.ErrCount);
   ret

[PATCH] D124344: [clangd] Output inlay hints with `clangd --check`

2022-04-24 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj marked 2 inline comments as done.
upsj added inline comments.



Comment at: clang-tools-extra/clangd/tool/Check.cpp:195
 
+  // Build Inlay Hints for the entire AST
+  bool buildInlayHints(llvm::Optional LineRange) {

nridge wrote:
> The comment should probably say "... for the entire AST or the specified 
> range"
done



Comment at: clang-tools-extra/clangd/tool/Check.cpp:201
+for (const auto &Hint : Hints) {
+  vlog("  {0} {1}", Hint.position, Hint.label);
+}

nridge wrote:
> Might be useful for print the hint kind as well?
right, is the current solution (adding a public toString) okay?


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

https://reviews.llvm.org/D124344

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


[PATCH] D124104: [clang][dataflow] Fix `Environment::join`'s handling of flow condition merging

2022-04-24 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev accepted this revision.
sgatev added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp:339-341
   // Move `LocToVal` so that `Environment::ValueModel::merge` can safely assign
   // values to storage locations while this code iterates over the current
   // assignments.

This comment is no longer relevant, right?



Comment at: 
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp:299
 
+// Models an analysis that uses the flow conditions.
+class SpecialBoolAnalysis





Comment at: 
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp:340-344
+if (!Type->isRecordType())
+  return false;
+const auto *Decl = Type->getAsCXXRecordDecl();
+if (Decl->getIdentifier() == nullptr || Decl->getName() != "SpecialBool")
+  return false;





Comment at: 
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp:356
+
+return V1 == V2 ||
+   Env1.flowConditionImplies(*V1) == Env2.flowConditionImplies(*V2);

That's guaranteed to be false in `compareEquivalent`.



Comment at: 
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp:364-368
+if (!Type->isRecordType())
+  return true;
+const auto *Decl = Type->getAsCXXRecordDecl();
+if (Decl->getIdentifier() == nullptr || Decl->getName() != "SpecialBool")
+  return true;





Comment at: 
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp:414
+  void set();
+};
+void target(bool Cond) {





Comment at: 
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp:422
+  } else {
+Foo.set();
+  }

Add `/*[[p3]]*/` after this statement and ensure that the value is implied in 
the "else" branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124104

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


[PATCH] D54943: [clang-tidy] implement new check 'misc-const-correctness' to add 'const' to unmodified variables

2022-04-24 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp:103
+
+#if 0
+  // FIXME: Remove this section if there are no crashes after the iterator-fix.

Hasn't this already been addressed, if so can this block just be removed.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:103
 - New :doc:`bugprone-shared-ptr-array-mismatch 
` check.
-
   Finds initializations of C++ shared pointers to non-array type that are 
initialized with an array.

Unrelated change.



Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:87
`bugprone-reserved-identifier `_, "Yes"
-   `bugprone-shared-ptr-array-mismatch 
`_, "Yes"
`bugprone-signal-handler `_,

This should be committed separately.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/misc-const-correctness-transform-values.cpp:27
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' 
can be declared 'const'
+  // CHECK-FIXES: const
+}

This check directive isn't going to be effective.
Try `CHECK-FIXES: const int p_local0 = 2;`
Same goes for all the ones below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

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