[PATCH] D118095: [clang][AVR] Reject non assembly source files for the avr1 family

2022-01-29 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 404344.

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

https://reviews.llvm.org/D118095

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/lib/Driver/ToolChains/AVR.h
  clang/test/Driver/avr-mmcu.S
  clang/test/Driver/avr-mmcu.c

Index: clang/test/Driver/avr-mmcu.c
===
--- clang/test/Driver/avr-mmcu.c
+++ clang/test/Driver/avr-mmcu.c
@@ -1,12 +1,15 @@
 // A test for the propagation of the -mmcu option to -cc1 and -cc1as
 
-// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny11 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK0 %s
-// CHECK0: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "attiny11"
-// CHECK0: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "attiny11"
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny11 %s -c 2>&1 | FileCheck -check-prefix=CHECKA %s
+// CHECKA: error: device 'attiny11' only supports assembly programming
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny11 -x assembler-with-cpp %s -c 2>&1 | FileCheck -check-prefix=CHECKB %s
+// CHECKB-NOT: error: device 'attiny11' only supports assembly programming
 
 // RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=at90s2313 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK1 %s
 // CHECK1: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "at90s2313"
 // CHECK1: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "at90s2313"
+// CHECK1-NOT: error: device 'at90s2313' only supports assembly programming
 
 // RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=at90s8515 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK2 %s
 // CHECK2: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "at90s8515"
Index: clang/test/Driver/avr-mmcu.S
===
--- /dev/null
+++ clang/test/Driver/avr-mmcu.S
@@ -0,0 +1,13 @@
+// A test for the supported language mode by different avr families.
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny11 %s -c 2>&1 | FileCheck -check-prefix=CHECKA %s
+// CHECKA-NOT: error: device 'attiny11' only supports assembly programming
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny11 -x c++ %s -c 2>&1 | FileCheck -check-prefix=CHECKB %s
+// CHECKB: error: device 'attiny11' only supports assembly programming
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=at90s8515 %s -c 2>&1 | FileCheck -check-prefix=CHECKC %s
+// CHECKC-NOT: error: device 'at90s8515' only supports assembly programming
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=at90s8515 %s -x c++ -c 2>&1 | FileCheck -check-prefix=CHECKD %s
+// CHECKD-NOT: error: device 'at90s8515' only supports assembly programming
Index: clang/lib/Driver/ToolChains/AVR.h
===
--- clang/lib/Driver/ToolChains/AVR.h
+++ clang/lib/Driver/ToolChains/AVR.h
@@ -35,6 +35,8 @@
   Tool *buildLinker() const override;
 
 private:
+  std::string AVRMcu;
+
   /// Whether libgcc, libct, and friends should be linked.
   ///
   /// This is not done if the user does not specify a
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -12,6 +12,7 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Options.h"
+#include "clang/Driver/Types.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
@@ -19,6 +20,7 @@
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::driver;
 using namespace clang::driver::toolchains;
@@ -311,24 +313,27 @@
 : Generic_ELF(D, Triple, Args), LinkStdlib(false) {
   GCCInstallation.init(Triple, Args);
 
+  // Save the CPU name for further checks.
+  AVRMcu = getCPUName(D, Args, Triple);
+
   // Only add default libraries if the user hasn't explicitly opted out.
   if (!Args.hasArg(options::OPT_nostdlib) &&
   !Args.hasArg(options::OPT_nodefaultlibs) &&
+  !Args.hasArg(options::OPT_S /* does not apply when not linking */) &&
   !Args.hasArg(options::OPT_c /* does not apply when not linking */)) {
-std::string CPU = getCPUName(D, Args, Triple);
 
-if (CPU.empty()) {
+if (AVRMcu.empty()) {
   // We cannot link any standard libraries without an MCU specified.
   D.Diag(diag::warn_drv_avr_mcu_not_specified);
 } else {
-  Optional FamilyName = GetMCUFamilyName(CPU);
+  Optional FamilyName = GetMCUFamilyName(AVRMcu);
   Optional AVRLibcRoot = findAVRLibcInstallation();
 
   if (!FamilyName.hasValue()) {
 // We do not have an entry for this CPU in the family
 // 

[PATCH] D109977: LLVM Driver Multicall tool

2022-01-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Hope that someone familiar with CMake can take a look.

> As currently implemented llvm-driver contains dsymutil, llvm-ar, 
> llvm-cxxfilt, llvm-objcopy, and clang (if clang is included in the build).

I think either (bundled clang+binary utilities) or (bundled lld+binary 
utilities) is fine.
Some folks are interested in PGO builds for clang and lld. Not bundling clang 
and lld together can make both optimized.
The performance of binary utilities likely does not matter that much, so 
bundling them with either clang or lld should be fine.

---

I have tried the latest diff but 
`-DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;flang;lldb;lld;compiler-rt;openmp;mlir;cross-project-tests'
 -DLLVM_TOOL_LLVM_DRIVER_BUILD=on` gives me:

  CMake Error at cmake/modules/LLVM-Config.cmake:110 (target_link_libraries):   
  
The keyword signature for target_link_libraries has already been used with  
  
the target "obj.dsymutil".  All uses of target_link_libraries with a target 
  
must be either all-keyword or all-plain.
  

  
The uses of the keyword signature are here: 


  
 * cmake/modules/AddLLVM.cmake:897 (target_link_libraries)  
  

  
  Call Stack (most recent call first):  
  
cmake/modules/LLVM-Config.cmake:95 (explicit_llvm_config)   
  
cmake/modules/AddLLVM.cmake:898 (llvm_config)   

cmake/modules/AddLLVM.cmake:1264 (add_llvm_executable)  

tools/dsymutil/CMakeLists.txt:21 (add_llvm_tool)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[PATCH] D117603: [clang] Don't typo-fix an expression in a SFINAE context

2022-01-29 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 404343.
Quuxplusone added a comment.

Move the regression test to clang/test/SemaTemplate/, alongside the one for 
D118552 . Also, make it test the error 
message wording.


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

https://reviews.llvm.org/D117603

Files:
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/test/SemaTemplate/pr52970.cpp

Index: clang/test/SemaTemplate/pr52970.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/pr52970.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify=cxx20 %s
+// expected-no-diagnostics
+
+struct Incomplete;
+template  struct Holder { T t; };
+
+namespace DotFollowingFunctionName {
+struct Good {
+  struct Nested {
+int b;
+  } a;
+};
+
+struct Bad {
+  Holder a();
+};
+
+template 
+constexpr auto f(T t) -> decltype((t.a.b, true)) { return true; }
+constexpr bool f(...) { return false; }
+
+static_assert(DotFollowingFunctionName::f(Good{}), "");
+static_assert(!DotFollowingFunctionName::f(Bad{}), "");
+
+#if __cplusplus >= 202002L
+template 
+concept C = requires(T t) { t.a.b; };
+  // cxx20-note@-1 {{because 't.a.b' would be invalid: reference to non-static member function must be called}}
+
+static_assert(C);
+static_assert(!C);
+static_assert(C); // cxx20-error {{static_assert failed}}
+  // cxx20-note@-1 {{because 'DotFollowingFunctionName::Bad' does not satisfy 'C'}}
+#endif
+} // namespace DotFollowingFunctionName
+
+namespace DotFollowingPointer {
+struct Good {
+  int begin();
+};
+using Bad = Holder *;
+
+template 
+constexpr auto f(T t) -> decltype((t.begin(), true)) { return true; }
+constexpr bool f(...) { return false; }
+
+static_assert(DotFollowingPointer::f(Good{}), "");
+static_assert(!DotFollowingPointer::f(Bad{}), "");
+
+#if __cplusplus >= 202002L
+template 
+concept C = requires(T t) { t.begin(); };
+  // cxx20-note@-1 {{because 't.begin()' would be invalid: member reference type 'Holder *' is a pointer}}
+
+static_assert(C);
+static_assert(!C);
+static_assert(C); // cxx20-error {{static_assert failed}}
+  // cxx20-note@-1 {{because 'DotFollowingPointer::Bad' (aka 'Holder *') does not satisfy 'C'}}
+#endif
+} // namespace DotFollowingPointer
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -1645,6 +1645,9 @@
   << BaseType << int(IsArrow) << BaseExpr.get()->getSourceRange()
   << FixItHint::CreateReplacement(OpLoc, "->");
 
+  if (S.isSFINAEContext())
+return ExprError();
+
   // Recurse as an -> access.
   IsArrow = true;
   return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS,
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -2556,32 +2556,35 @@
 bool (*IsPlausibleResult)(QualType)) {
   SourceLocation Loc = E.get()->getExprLoc();
   SourceRange Range = E.get()->getSourceRange();
-
-  QualType ZeroArgCallTy;
   UnresolvedSet<4> Overloads;
-  if (tryExprAsCall(*E.get(), ZeroArgCallTy, Overloads) &&
-  !ZeroArgCallTy.isNull() &&
-  (!IsPlausibleResult || IsPlausibleResult(ZeroArgCallTy))) {
-// At this point, we know E is potentially callable with 0
-// arguments and that it returns something of a reasonable type,
-// so we can emit a fixit and carry on pretending that E was
-// actually a CallExpr.
-SourceLocation ParenInsertionLoc = getLocForEndOfToken(Range.getEnd());
-bool IsMV = IsCPUDispatchCPUSpecificMultiVersion(E.get());
-Diag(Loc, PD) << /*zero-arg*/ 1 << IsMV << Range
-  << (IsCallableWithAppend(E.get())
-  ? FixItHint::CreateInsertion(ParenInsertionLoc, "()")
-  : FixItHint());
-if (!IsMV)
-  notePlausibleOverloads(*this, Loc, Overloads, IsPlausibleResult);
-
-// FIXME: Try this before emitting the fixit, and suppress diagnostics
-// while doing so.
-E = BuildCallExpr(nullptr, E.get(), Range.getEnd(), None,
-  Range.getEnd().getLocWithOffset(1));
-return true;
-  }
 
+  // If this is a SFINAE context, don't try anything that might trigger ADL
+  // prematurely.
+  if (!isSFINAEContext()) {
+QualType ZeroArgCallTy;
+if (tryExprAsCall(*E.get(), ZeroArgCallTy, Overloads) &&
+!ZeroArgCallTy.isNull() &&
+(!IsPlausibleResult || IsPlausibleResult(ZeroArgCallTy))) {
+  // At this point, we know E is potentially callable with 0
+  // arguments and that it returns something of a 

[PATCH] D118552: [clang] [concepts] Correctly(?) handle placeholder types in ExprRequirements.

2022-01-29 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

It's a type that the debugger integration uses when it doesn't know the type of 
a symbol.  If it's a data symbol, you make a `VarDecl` with `UnknownAny` type; 
if it's a function symbol, you make a `FunctionDecl` with `UnknownAny`.  In 
either case, if the user fails to cast it, it gets diagnosed as an error.

I can't think of any reason why we'd want to build a reference to `UnknownAny` 
type; generally it's bad if the type "escapes" into subordinate positions.  
Probably we should be diagnosing something before we try to propagate the 
`UnknownAny` type.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118552

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


[PATCH] D117603: [clang] Don't typo-fix an expression in a SFINAE context

2022-01-29 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 404341.
Quuxplusone added a comment.

It seems like we need `tryToRecoverWithCall` to always identify a diagnostic 
explaining the problem, so just short-circuit-returning `ExprError()` with no 
diagnostic is not acceptable. Let's try this version instead.
(This is also now based on top of D118552 .)


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

https://reviews.llvm.org/D117603

Files:
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/test/SemaCXX/PR52970.cpp

Index: clang/test/SemaCXX/PR52970.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/PR52970.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
+// expected-no-diagnostics
+
+struct Incomplete;
+template  struct Holder { T t; };
+
+namespace DotFollowingFunctionName {
+struct Good {
+  struct Nested {
+int b;
+  } a;
+};
+
+struct Bad {
+  Holder a();
+};
+
+template 
+constexpr auto f(T t) -> decltype((t.a.b, true)) { return true; }
+constexpr bool f(...) { return false; }
+
+static_assert(DotFollowingFunctionName::f(Good{}), "");
+static_assert(!DotFollowingFunctionName::f(Bad{}), "");
+
+#if __cplusplus >= 202002L
+template 
+concept C = requires(T t) { t.a.b; };
+
+static_assert(C);
+static_assert(!C);
+#endif
+} // namespace DotFollowingFunctionName
+
+namespace DotFollowingPointer {
+struct Good {
+  int begin();
+};
+using Bad = Holder *;
+
+template 
+constexpr auto f(T t) -> decltype((t.begin(), true)) { return true; }
+constexpr bool f(...) { return false; }
+
+static_assert(DotFollowingPointer::f(Good{}), "");
+static_assert(!DotFollowingPointer::f(Bad{}), "");
+
+#if __cplusplus >= 202002L
+template 
+concept C = requires(T t) { t.begin(); };
+
+static_assert(C);
+static_assert(!C);
+#endif
+} // namespace DotFollowingPointer
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -1645,6 +1645,9 @@
   << BaseType << int(IsArrow) << BaseExpr.get()->getSourceRange()
   << FixItHint::CreateReplacement(OpLoc, "->");
 
+  if (S.isSFINAEContext())
+return ExprError();
+
   // Recurse as an -> access.
   IsArrow = true;
   return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS,
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -2556,32 +2556,35 @@
 bool (*IsPlausibleResult)(QualType)) {
   SourceLocation Loc = E.get()->getExprLoc();
   SourceRange Range = E.get()->getSourceRange();
-
-  QualType ZeroArgCallTy;
   UnresolvedSet<4> Overloads;
-  if (tryExprAsCall(*E.get(), ZeroArgCallTy, Overloads) &&
-  !ZeroArgCallTy.isNull() &&
-  (!IsPlausibleResult || IsPlausibleResult(ZeroArgCallTy))) {
-// At this point, we know E is potentially callable with 0
-// arguments and that it returns something of a reasonable type,
-// so we can emit a fixit and carry on pretending that E was
-// actually a CallExpr.
-SourceLocation ParenInsertionLoc = getLocForEndOfToken(Range.getEnd());
-bool IsMV = IsCPUDispatchCPUSpecificMultiVersion(E.get());
-Diag(Loc, PD) << /*zero-arg*/ 1 << IsMV << Range
-  << (IsCallableWithAppend(E.get())
-  ? FixItHint::CreateInsertion(ParenInsertionLoc, "()")
-  : FixItHint());
-if (!IsMV)
-  notePlausibleOverloads(*this, Loc, Overloads, IsPlausibleResult);
-
-// FIXME: Try this before emitting the fixit, and suppress diagnostics
-// while doing so.
-E = BuildCallExpr(nullptr, E.get(), Range.getEnd(), None,
-  Range.getEnd().getLocWithOffset(1));
-return true;
-  }
 
+  // If this is a SFINAE context, don't try anything that might trigger ADL
+  // prematurely.
+  if (!isSFINAEContext()) {
+QualType ZeroArgCallTy;
+if (tryExprAsCall(*E.get(), ZeroArgCallTy, Overloads) &&
+!ZeroArgCallTy.isNull() &&
+(!IsPlausibleResult || IsPlausibleResult(ZeroArgCallTy))) {
+  // At this point, we know E is potentially callable with 0
+  // arguments and that it returns something of a reasonable type,
+  // so we can emit a fixit and carry on pretending that E was
+  // actually a CallExpr.
+  SourceLocation ParenInsertionLoc = getLocForEndOfToken(Range.getEnd());
+  bool IsMV = IsCPUDispatchCPUSpecificMultiVersion(E.get());
+  Diag(Loc, PD) << /*zero-arg*/ 1 << IsMV << Range
+<< (IsCallableWithAppend(E.get())
+? 

[PATCH] D117423: [AVR][clang] Reject non assembly source files for the avr1 family

2022-01-29 Thread Ben Shi via Phabricator via cfe-commits
benshi001 abandoned this revision.
benshi001 added a comment.

Re-implement in https://reviews.llvm.org/D118095


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

https://reviews.llvm.org/D117423

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


[PATCH] D118095: [clang][AVR] Reject non assembly source files for the avr1 family

2022-01-29 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

The other implementation (https://reviews.llvm.org/D117423) is abundoned, since 
we should not put AVR specified checks in the common code in Clang.cpp.


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

https://reviews.llvm.org/D118095

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


[PATCH] D118095: [clang][AVR] Reject non assembly source files for the avr1 family

2022-01-29 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 404340.
benshi001 retitled this revision from "[AVR][clang] Reject non assembly source 
files for the avr1 family" to "[clang][AVR] Reject non assembly source files 
for the avr1 family".

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

https://reviews.llvm.org/D118095

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/lib/Driver/ToolChains/AVR.h
  clang/test/Driver/avr-mmcu.S
  clang/test/Driver/avr-mmcu.c

Index: clang/test/Driver/avr-mmcu.c
===
--- clang/test/Driver/avr-mmcu.c
+++ clang/test/Driver/avr-mmcu.c
@@ -1,12 +1,15 @@
 // A test for the propagation of the -mmcu option to -cc1 and -cc1as
 
-// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny11 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK0 %s
-// CHECK0: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "attiny11"
-// CHECK0: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "attiny11"
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny11 %s -c 2>&1 | FileCheck -check-prefix=CHECKA %s
+// CHECKA: error: device 'attiny11' only supports assembly programming
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny11 -x assembler-with-cpp %s -c 2>&1 | FileCheck -check-prefix=CHECKB %s
+// CHECKB-NOT: error: device 'attiny11' only supports assembly programming
 
 // RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=at90s2313 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK1 %s
 // CHECK1: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "at90s2313"
 // CHECK1: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "at90s2313"
+// CHECK1-NOT: error: device 'at90s2313' only supports assembly programming
 
 // RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=at90s8515 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK2 %s
 // CHECK2: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "at90s8515"
Index: clang/test/Driver/avr-mmcu.S
===
--- /dev/null
+++ clang/test/Driver/avr-mmcu.S
@@ -0,0 +1,13 @@
+// A test for the supported language mode by different avr families.
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny11 %s -c 2>&1 | FileCheck -check-prefix=CHECKA %s
+// CHECKA-NOT: error: device 'attiny11' only supports assembly programming
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny11 -x c++ %s -c 2>&1 | FileCheck -check-prefix=CHECKB %s
+// CHECKB: error: device 'attiny11' only supports assembly programming
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=at90s8515 %s -c 2>&1 | FileCheck -check-prefix=CHECKC %s
+// CHECKC-NOT: error: device 'at90s8515' only supports assembly programming
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=at90s8515 %s -x c++ -c 2>&1 | FileCheck -check-prefix=CHECKD %s
+// CHECKD-NOT: error: device 'at90s8515' only supports assembly programming
Index: clang/lib/Driver/ToolChains/AVR.h
===
--- clang/lib/Driver/ToolChains/AVR.h
+++ clang/lib/Driver/ToolChains/AVR.h
@@ -19,6 +19,8 @@
 namespace toolchains {
 
 class LLVM_LIBRARY_VISIBILITY AVRToolChain : public Generic_ELF {
+  std::string AVRMcu;
+
 public:
   AVRToolChain(const Driver , const llvm::Triple ,
const llvm::opt::ArgList );
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -12,6 +12,7 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Options.h"
+#include "clang/Driver/Types.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
@@ -19,6 +20,7 @@
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::driver;
 using namespace clang::driver::toolchains;
@@ -311,24 +313,27 @@
 : Generic_ELF(D, Triple, Args), LinkStdlib(false) {
   GCCInstallation.init(Triple, Args);
 
+  // Save the CPU name for further checks.
+  AVRMcu = getCPUName(D, Args, Triple);
+
   // Only add default libraries if the user hasn't explicitly opted out.
   if (!Args.hasArg(options::OPT_nostdlib) &&
   !Args.hasArg(options::OPT_nodefaultlibs) &&
+  !Args.hasArg(options::OPT_S /* does not apply when not linking */) &&
   !Args.hasArg(options::OPT_c /* does not apply when not linking */)) {
-std::string CPU = getCPUName(D, Args, Triple);
 
-if (CPU.empty()) {
+if (AVRMcu.empty()) {
   // We cannot link any standard libraries without an MCU specified.
   D.Diag(diag::warn_drv_avr_mcu_not_specified);
 } else {
-  Optional FamilyName = GetMCUFamilyName(CPU);
+  Optional 

[PATCH] D118552: [clang] [concepts] Correctly(?) handle placeholder types in ExprRequirements.

2022-01-29 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a subscriber: rjmccall.
Quuxplusone added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:3375
+assert(T->isSpecificPlaceholderType(BuiltinType::UnknownAny) && 
"Unresolved placeholder type");
+  }
 

Btw, I strongly suspect that the presence of placeholder type `UnknownAny` all 
the way down in here is a bug (@rjmccall, thoughts?). But I found that the test 
suite didn't pass without this exception, and I'm not terribly interested in 
tracking down why; I don't have any idea what `UnknownAny` is, myself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118552

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


[PATCH] D110869: [X86] Implement -fzero-call-used-regs option

2022-01-29 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 404336.
void added a comment.

Make this only for x86.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110869

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/zero-call-used-regs.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/zero_call_used_regs.c
  llvm/include/llvm/CodeGen/MachineRegisterInfo.h
  llvm/include/llvm/CodeGen/TargetFrameLowering.h
  llvm/include/llvm/CodeGen/TargetRegisterInfo.h
  llvm/include/llvm/Support/CodeGen.h
  llvm/lib/CodeGen/MachineRegisterInfo.cpp
  llvm/lib/CodeGen/PrologEpilogInserter.cpp
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86FrameLowering.h
  llvm/lib/Target/X86/X86RegisterInfo.cpp
  llvm/lib/Target/X86/X86RegisterInfo.h
  llvm/test/CodeGen/X86/zero-call-used-regs-fmod.ll
  llvm/test/CodeGen/X86/zero-call-used-regs.ll

Index: llvm/test/CodeGen/X86/zero-call-used-regs.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/zero-call-used-regs.ll
@@ -0,0 +1,292 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i386-unknown-linux-gnu | FileCheck %s --check-prefix=I386
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefix=X86-64
+
+@result = dso_local global i32 0, align 4
+
+define dso_local i32 @skip(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="skip" {
+; I386-LABEL: skip:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:retl
+;
+; X86-64-LABEL: skip:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:retq
+
+entry:
+  ret i32 %x
+}
+
+define dso_local i32 @used_gpr_arg(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="used-gpr-arg" {
+; I386-LABEL: used_gpr_arg:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:retl
+;
+; X86-64-LABEL: used_gpr_arg:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:xorl %edi, %edi
+; X86-64-NEXT:retq
+
+entry:
+  ret i32 %x
+}
+
+define dso_local i32 @used_gpr(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="used-gpr" {
+; I386-LABEL: used_gpr:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:retl
+;
+; X86-64-LABEL: used_gpr:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:xorl %edi, %edi
+; X86-64-NEXT:retq
+
+entry:
+  ret i32 %x
+}
+
+define dso_local i32 @used_arg(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="used-arg" {
+; I386-LABEL: used_arg:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:retl
+;
+; X86-64-LABEL: used_arg:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:xorl %edi, %edi
+; X86-64-NEXT:retq
+
+entry:
+  ret i32 %x
+}
+
+define dso_local i32 @used(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="used" {
+; I386-LABEL: used:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:retl
+;
+; X86-64-LABEL: used:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:xorl %edi, %edi
+; X86-64-NEXT:retq
+
+entry:
+  ret i32 %x
+}
+
+define dso_local i32 @all_gpr_arg(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="all-gpr-arg" {
+; I386-LABEL: all_gpr_arg:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:xorl %ecx, %ecx
+; I386-NEXT:xorl %edx, %edx
+; I386-NEXT:retl
+;
+; X86-64-LABEL: all_gpr_arg:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:xorq %rcx, %rcx
+; X86-64-NEXT:xorq %rdi, %rdi
+; X86-64-NEXT:xorq %rdx, %rdx
+; X86-64-NEXT:xorq %rsi, %rsi
+; X86-64-NEXT:xorq %r8, %r8
+; X86-64-NEXT:xorq %r9, %r9
+; X86-64-NEXT:retq
+
+entry:
+  ret i32 %x
+}
+
+define dso_local i32 @all_gpr(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="all-gpr" {
+; I386-LABEL: all_gpr:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:xorl %ebp, %ebp
+; I386-NEXT:xorl %ebx, %ebx
+; I386-NEXT:xorl %ecx, %ecx
+; I386-NEXT:xorl %edi, %edi
+; I386-NEXT:xorl %edx, %edx
+; I386-NEXT:xorl %esi, %esi
+; I386-NEXT:retl
+;
+; X86-64-LABEL: all_gpr:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:xorq %rbp, %rbp
+; X86-64-NEXT:xorq %rbx, 

[PATCH] D118552: [clang] [concepts] Correctly(?) handle placeholder types in ExprRequirements.

2022-01-29 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone created this revision.
Quuxplusone added reviewers: ChuanqiXu, saar.raz, rsmith.
Quuxplusone added a project: clang.
Quuxplusone requested review of this revision.
Herald added a subscriber: cfe-commits.

PR52905 was originally papered over in a different way, but I believe this is 
the actually proper fix, or at least closer to it. We need to detect 
placeholder types as close to the front-end as possible, and cause them to fail 
constraints, rather than letting them persist into later stages.

  

Fixes https://llvm.org/PR52905
Fixes https://llvm.org/PR52909
Fixes https://llvm.org/PR53075


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118552

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaTemplate/constraints.cpp
  clang/test/SemaTemplate/pr52909.cpp

Index: clang/test/SemaTemplate/pr52909.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/pr52909.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+// RUN: %clang_cc1 -std=c++2b -verify %s
+
+namespace PR52905 {
+template  concept C = true;
+
+struct A {
+  int begin();
+  int begin() const;
+};
+
+template 
+concept Beginable = requires (T t) {
+  { t.begin } -> C;
+  // expected-note@-1 {{because 't.begin' would be invalid: reference to non-static member function must be called}}
+};
+
+static_assert(Beginable); // expected-error {{static_assert failed}}
+ // expected-note@-1 {{does not satisfy 'Beginable'}}
+} // namespace PR52905
+
+namespace PR52909a {
+
+template constexpr bool B = true;
+template concept True = B;
+
+template 
+int foo(T t) requires requires { // expected-note {{candidate template ignored: constraints not satisfied}}
+{t.begin} -> True; // expected-note {{because 't.begin' would be invalid: reference to non-static member function must be called}}
+}
+{}
+
+struct A { int begin(); };
+auto x = foo(A()); // expected-error {{no matching function for call to 'foo'}}
+
+} // namespace PR52909a
+
+namespace PR52909b {
+
+template concept True = true;
+
+template concept C = requires {
+{ T::begin } -> True; // expected-note {{because 'T::begin' would be invalid: reference to overloaded function could not be resolved}}
+};
+
+struct A {
+static void begin(int);
+static void begin(double);
+};
+
+static_assert(C); // expected-error {{static_assert failed}}
+  // expected-note@-1 {{because 'PR52909b::A' does not satisfy 'C'}}
+
+} // namespace PR52909b
+
+namespace PR53075 {
+template concept True = true;
+
+template concept C = requires {
+{ ::f } -> True; // expected-note {{because '::f' would be invalid: reference to overloaded function could not be resolved}}
+};
+
+struct S {
+int *f();
+int *f() const;
+};
+
+static_assert(C); // expected-error {{static_assert failed}}
+  // expected-note@-1 {{because 'PR53075::S' does not satisfy 'C'}}
+
+} // namespace PR53075
Index: clang/test/SemaTemplate/constraints.cpp
===
--- clang/test/SemaTemplate/constraints.cpp
+++ clang/test/SemaTemplate/constraints.cpp
@@ -24,35 +24,3 @@
   // FIXME: These diagnostics are excessive.
   static_assert(test == 1); // expected-note 2{{while}} expected-note 2{{during}}
 }
-
-namespace PR52905 {
-// A mock for std::convertible_to. Not complete support.
-template 
-concept convertible_to = __is_convertible_to(_From, _To); // expected-note {{evaluated to false}}
-
-template 
-class A {
-public:
-  using iterator = void **;
-
-  iterator begin();
-  const iterator begin() const;
-};
-
-template 
-concept Beginable1 = requires(T t) {
-  { t.begin }
-  ->convertible_to; // expected-note {{not satisfied}}
-};
-
-static_assert(Beginable1>); // expected-error {{static_assert failed}}
-   // expected-note@-1 {{does not satisfy 'Beginable1'}}
-
-template 
-concept Beginable2 = requires(T t) {
-  { t.begin() }
-  ->convertible_to;
-};
-
-static_assert(Beginable2>);
-} // namespace PR52905
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -12494,6 +12494,8 @@
 TransExpr = Req->getExprSubstitutionDiagnostic();
   else {
 ExprResult TransExprRes = getDerived().TransformExpr(Req->getExpr());
+if (TransExprRes.isUsable() && TransExprRes.get()->hasPlaceholderType())
+  TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.get());
 if (TransExprRes.isInvalid())
   return nullptr;
 TransExpr = TransExprRes.get();
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1943,6 +1943,11 @@
   

[PATCH] D110869: [X86] Implement -fzero-call-used-regs option

2022-01-29 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 404326.
void added a comment.

Don't zero out all sub and super registers that are callee-saved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110869

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/zero-call-used-regs.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/zero_call_used_regs.c
  llvm/include/llvm/CodeGen/MachineRegisterInfo.h
  llvm/include/llvm/CodeGen/TargetFrameLowering.h
  llvm/include/llvm/CodeGen/TargetRegisterInfo.h
  llvm/include/llvm/Support/CodeGen.h
  llvm/lib/CodeGen/MachineRegisterInfo.cpp
  llvm/lib/CodeGen/PrologEpilogInserter.cpp
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86FrameLowering.h
  llvm/lib/Target/X86/X86RegisterInfo.cpp
  llvm/lib/Target/X86/X86RegisterInfo.h
  llvm/test/CodeGen/X86/zero-call-used-regs-fmod.ll
  llvm/test/CodeGen/X86/zero-call-used-regs.ll

Index: llvm/test/CodeGen/X86/zero-call-used-regs.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/zero-call-used-regs.ll
@@ -0,0 +1,292 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i386-unknown-linux-gnu | FileCheck %s --check-prefix=I386
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefix=X86-64
+
+@result = dso_local global i32 0, align 4
+
+define dso_local i32 @skip(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="skip" {
+; I386-LABEL: skip:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:retl
+;
+; X86-64-LABEL: skip:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:retq
+
+entry:
+  ret i32 %x
+}
+
+define dso_local i32 @used_gpr_arg(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="used-gpr-arg" {
+; I386-LABEL: used_gpr_arg:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:retl
+;
+; X86-64-LABEL: used_gpr_arg:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:xorl %edi, %edi
+; X86-64-NEXT:retq
+
+entry:
+  ret i32 %x
+}
+
+define dso_local i32 @used_gpr(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="used-gpr" {
+; I386-LABEL: used_gpr:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:retl
+;
+; X86-64-LABEL: used_gpr:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:xorl %edi, %edi
+; X86-64-NEXT:retq
+
+entry:
+  ret i32 %x
+}
+
+define dso_local i32 @used_arg(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="used-arg" {
+; I386-LABEL: used_arg:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:retl
+;
+; X86-64-LABEL: used_arg:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:xorl %edi, %edi
+; X86-64-NEXT:retq
+
+entry:
+  ret i32 %x
+}
+
+define dso_local i32 @used(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="used" {
+; I386-LABEL: used:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:retl
+;
+; X86-64-LABEL: used:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:xorl %edi, %edi
+; X86-64-NEXT:retq
+
+entry:
+  ret i32 %x
+}
+
+define dso_local i32 @all_gpr_arg(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="all-gpr-arg" {
+; I386-LABEL: all_gpr_arg:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:xorl %ecx, %ecx
+; I386-NEXT:xorl %edx, %edx
+; I386-NEXT:retl
+;
+; X86-64-LABEL: all_gpr_arg:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:xorq %rcx, %rcx
+; X86-64-NEXT:xorq %rdi, %rdi
+; X86-64-NEXT:xorq %rdx, %rdx
+; X86-64-NEXT:xorq %rsi, %rsi
+; X86-64-NEXT:xorq %r8, %r8
+; X86-64-NEXT:xorq %r9, %r9
+; X86-64-NEXT:retq
+
+entry:
+  ret i32 %x
+}
+
+define dso_local i32 @all_gpr(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="all-gpr" {
+; I386-LABEL: all_gpr:
+; I386:   # %bb.0: # %entry
+; I386-NEXT:movl {{[0-9]+}}(%esp), %eax
+; I386-NEXT:xorl %ebp, %ebp
+; I386-NEXT:xorl %ebx, %ebx
+; I386-NEXT:xorl %ecx, %ecx
+; I386-NEXT:xorl %edi, %edi
+; I386-NEXT:xorl %edx, %edx
+; I386-NEXT:xorl %esi, %esi
+; I386-NEXT:retl
+;
+; X86-64-LABEL: all_gpr:
+; X86-64:   # %bb.0: # %entry
+; X86-64-NEXT:movl %edi, %eax
+; X86-64-NEXT:xorq 

[PATCH] D118519: [clang-tidy] Organize the release notes a little better

2022-01-29 Thread Richard via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
LegalizeAdulthood marked an inline comment as done.
Closed by commit rG994802068267: [clang-tidy] Organize the release notes a 
little better (authored by LegalizeAdulthood).

Changed prior to commit:
  https://reviews.llvm.org/D118519?vs=404200=404324#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118519

Files:
  clang-tools-extra/docs/ReleaseNotes.rst

Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -67,10 +67,6 @@
 Improvements to clang-tidy
 --
 
-- Make the `cppcoreguidelines-pro-bounds-array-to-pointer-decay` check accept
-  string literal to pointer decay in conditional operator even if operands are
-  of the same length.
-
 - Ignore warnings from macros defined in system headers, if not using the
   `-system-headers` flag.
 
@@ -80,23 +76,11 @@
 - Added support for `NOLINTBEGIN` ... `NOLINTEND` comments to suppress
   Clang-Tidy warnings over multiple lines.
 
-- Generalized the `modernize-use-default-member-init` check to handle non-default
-  constructors.
-
-- Eliminated false positives for `cppcoreguidelines-macro-usage` by restricting
-  the warning about using constants to only macros that expand to literals.
-
 - Added support for external plugin checks with `-load`.
 
 New checks
 ^^
 
-- New :doc:`bugprone-stringview-nullptr
-  ` check.
-
-  Checks for various ways that the ``const CharT*`` constructor of
-  ``std::basic_string_view`` can be passed a null argument.
-
 - New :doc:`abseil-cleanup-ctad
   ` check.
 
@@ -104,6 +88,12 @@
   instances from the factory function to class template argument
   deduction (CTAD), in C++17 and higher.
 
+- New :doc:`bugprone-stringview-nullptr
+  ` check.
+
+  Checks for various ways that the ``const CharT*`` constructor of
+  ``std::basic_string_view`` can be passed a null argument.
+
 - New :doc:`bugprone-suspicious-memory-comparison
   ` check.
 
@@ -116,6 +106,11 @@
   Finds virtual classes whose destructor is neither public and virtual nor
   protected and non-virtual.
 
+- New :doc:`misc-misleading-bidirectional ` check.
+
+  Inspects string literal and comments for unterminated bidirectional Unicode
+  characters.
+
 - New :doc:`misc-misleading-identifier ` check.
 
   Reports identifier with unicode right-to-left characters.
@@ -143,11 +138,6 @@
   Reports identifiers whose names are too short. Currently checks local
   variables and function parameters only.
 
-- New :doc:`misc-misleading-bidirectional ` check.
-
-  Inspects string literal and comments for unterminated bidirectional Unicode
-  characters.
-
 New check aliases
 ^
 
@@ -169,40 +159,66 @@
 Changes in existing checks
 ^^
 
-- :doc:`bugprone-assert-side-effect `
-  check now supports an ``IgnoredFunctions`` option to explicitly consider
-  the specified semicolon-separated functions list as not having any
-  side-effects. Regular expressions for the list items are also accepted.
+- :doc:`bugprone-assert-side-effect
+  ` check now supports an
+  ``IgnoredFunctions`` option to explicitly consider the specified
+  semicolon-separated functions list as not having any side-effects.
+  Regular expressions for the list items are also accepted.
+
+- Fixed a false positive in :doc:`bugprone-throw-keyword-missing
+  ` when creating an
+  exception object using placement new.
 
 - Removed default setting ``cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors = "true"``,
-  from :doc:`cppcoreguidelines-explicit-virtual-functions `
+  from :doc:`cppcoreguidelines-explicit-virtual-functions
+  `
   to match the current state of the C++ Core Guidelines.
 
-- Removed suggestion ``use gsl::at`` from warning message in the
-  ``cppcoreguidelines-pro-bounds-constant-array-index`` check, since that is not
-  a requirement from the C++ Core Guidelines. This allows people to choose
-  their own safe indexing strategy. The fix-it is kept for those who want to
-  use the GSL library.
+- Eliminated false positives for :doc:`cppcoreguidelines-macro-usage
+  ` by restricting
+  the warning about using constants to only macros that expand to literals.
 
-- Updated :doc:`google-readability-casting
-  ` to diagnose and fix functional
-  casts, to achieve feature parity with the corresponding ``cpplint.py`` check.
+- :doc:`cppcoreguidelines-narrowing-conversions
+  `
+  check now supports a ``WarnOnIntegerToFloatingPointNarrowingConversion``
+  option to control whether to warn on narrowing integer to floating-point
+  conversions.
+
+- Make the :doc:`cppcoreguidelines-pro-bounds-array-to-pointer-decay
+  `
+  check accept string literal to pointer decay in conditional operator even
+  if operands are of the same 

[clang-tools-extra] 9948020 - [clang-tidy] Organize the release notes a little better

2022-01-29 Thread via cfe-commits

Author: Richard
Date: 2022-01-29T20:32:25-07:00
New Revision: 9948020682679653dad81c6350d9900c22dc2951

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

LOG: [clang-tidy] Organize the release notes a little better

- Sort new checks by check name
- Sort changes to existing checks by check name
- Add docs for changes to readability-simplify-boolean-expr
- Move check changes from "Improvements to clang-tidy" to
  "Changes in existing checks" section

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

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index eceed8749c950..115855c759d68 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -67,10 +67,6 @@ The improvements are...
 Improvements to clang-tidy
 --
 
-- Make the `cppcoreguidelines-pro-bounds-array-to-pointer-decay` check accept
-  string literal to pointer decay in conditional operator even if operands are
-  of the same length.
-
 - Ignore warnings from macros defined in system headers, if not using the
   `-system-headers` flag.
 
@@ -80,23 +76,11 @@ Improvements to clang-tidy
 - Added support for `NOLINTBEGIN` ... `NOLINTEND` comments to suppress
   Clang-Tidy warnings over multiple lines.
 
-- Generalized the `modernize-use-default-member-init` check to handle 
non-default
-  constructors.
-
-- Eliminated false positives for `cppcoreguidelines-macro-usage` by restricting
-  the warning about using constants to only macros that expand to literals.
-
 - Added support for external plugin checks with `-load`.
 
 New checks
 ^^
 
-- New :doc:`bugprone-stringview-nullptr
-  ` check.
-
-  Checks for various ways that the ``const CharT*`` constructor of
-  ``std::basic_string_view`` can be passed a null argument.
-
 - New :doc:`abseil-cleanup-ctad
   ` check.
 
@@ -104,6 +88,12 @@ New checks
   instances from the factory function to class template argument
   deduction (CTAD), in C++17 and higher.
 
+- New :doc:`bugprone-stringview-nullptr
+  ` check.
+
+  Checks for various ways that the ``const CharT*`` constructor of
+  ``std::basic_string_view`` can be passed a null argument.
+
 - New :doc:`bugprone-suspicious-memory-comparison
   ` check.
 
@@ -116,6 +106,11 @@ New checks
   Finds virtual classes whose destructor is neither public and virtual nor
   protected and non-virtual.
 
+- New :doc:`misc-misleading-bidirectional 
` check.
+
+  Inspects string literal and comments for unterminated bidirectional Unicode
+  characters.
+
 - New :doc:`misc-misleading-identifier 
` check.
 
   Reports identifier with unicode right-to-left characters.
@@ -143,11 +138,6 @@ New checks
   Reports identifiers whose names are too short. Currently checks local
   variables and function parameters only.
 
-- New :doc:`misc-misleading-bidirectional 
` check.
-
-  Inspects string literal and comments for unterminated bidirectional Unicode
-  characters.
-
 New check aliases
 ^
 
@@ -169,40 +159,66 @@ New check aliases
 Changes in existing checks
 ^^
 
-- :doc:`bugprone-assert-side-effect 
`
-  check now supports an ``IgnoredFunctions`` option to explicitly consider
-  the specified semicolon-separated functions list as not having any
-  side-effects. Regular expressions for the list items are also accepted.
+- :doc:`bugprone-assert-side-effect
+  ` check now supports an
+  ``IgnoredFunctions`` option to explicitly consider the specified
+  semicolon-separated functions list as not having any side-effects.
+  Regular expressions for the list items are also accepted.
+
+- Fixed a false positive in :doc:`bugprone-throw-keyword-missing
+  ` when creating an
+  exception object using placement new.
 
 - Removed default setting 
``cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors = "true"``,
-  from :doc:`cppcoreguidelines-explicit-virtual-functions 
`
+  from :doc:`cppcoreguidelines-explicit-virtual-functions
+  `
   to match the current state of the C++ Core Guidelines.
 
-- Removed suggestion ``use gsl::at`` from warning message in the
-  ``cppcoreguidelines-pro-bounds-constant-array-index`` check, since that is 
not
-  a requirement from the C++ Core Guidelines. This allows people to choose
-  their own safe indexing strategy. The fix-it is kept for those who want to
-  use the GSL library.
+- Eliminated false positives for :doc:`cppcoreguidelines-macro-usage
+  ` by restricting
+  the warning about using constants to only macros that expand to literals.
 
-- Updated :doc:`google-readability-casting
-  ` to diagnose and fix 
functional
-  casts, to achieve feature parity with the 

[PATCH] D117416: [clang-format] Handle C variables with name that matches c++ access specifier

2022-01-29 Thread psigillito via Phabricator via cfe-commits
psigillito updated this revision to Diff 404323.
psigillito marked 2 inline comments as done.
psigillito added a comment.

- unnecessary whitespace


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117416

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3123,6 +3123,46 @@
"label:\n"
"  signals.baz();\n"
"}");
+  verifyFormat("private[1];");
+  verifyFormat("testArray[public] = 1;");
+  verifyFormat("public();");
+  verifyFormat("myFunc(public);");
+  verifyFormat("std::vector testVec = {private};");
+  verifyFormat("private.p = 1;");
+  verifyFormat("void function(private...){};");
+  verifyFormat("if (private && public)\n");
+  verifyFormat("private &= true;");
+  verifyFormat("int x = private * public;");
+  verifyFormat("public *= private;");
+  verifyFormat("int x = public + private;");
+  verifyFormat("private++;");
+  verifyFormat("++private;");
+  verifyFormat("public += private;");
+  verifyFormat("public = public - private;");
+  verifyFormat("public->foo();");
+  verifyFormat("private--;");
+  verifyFormat("--private;");
+  verifyFormat("public -= 1;");
+  verifyFormat("if (!private && !public)\n");
+  verifyFormat("public != private;");
+  verifyFormat("int x = public / private;");
+  verifyFormat("public /= 2;");
+  verifyFormat("public = public % 2;");
+  verifyFormat("public %= 2;");
+  verifyFormat("if (public < private)\n");
+  verifyFormat("public << private;");
+  verifyFormat("public <<= private;");
+  verifyFormat("if (public > private)\n");
+  verifyFormat("public >> private;");
+  verifyFormat("public >>= private;");
+  verifyFormat("public ^ private;");
+  verifyFormat("public ^= private;");
+  verifyFormat("public | private;");
+  verifyFormat("public |= private;");
+  verifyFormat("auto x = private ? 1 : 2;");
+  verifyFormat("if (public == private)\n");
+  verifyFormat("void foo(public, private)");
+  verifyFormat("public::foo();");
 }
 
 TEST_F(FormatTest, SeparatesLogicalBlocks) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2707,14 +2707,25 @@
 }
 
 void UnwrappedLineParser::parseAccessSpecifier() {
+  FormatToken *AccessSpecifierCandidate = FormatTok;
   nextToken();
   // Understand Qt's slots.
   if (FormatTok->isOneOf(Keywords.kw_slots, Keywords.kw_qslots))
 nextToken();
   // Otherwise, we don't know what it is, and we'd better keep the next token.
-  if (FormatTok->Tok.is(tok::colon))
+  if (FormatTok->Tok.is(tok::colon)) {
 nextToken();
-  addUnwrappedLine();
+addUnwrappedLine();
+  } else if (!FormatTok->Tok.is(tok::coloncolon) &&
+ !std::binary_search(COperatorsFollowingVar.begin(),
+ COperatorsFollowingVar.end(),
+ FormatTok->Tok.getKind())) {
+// Not a variable name nor namespace name.
+addUnwrappedLine();
+  } else if (AccessSpecifierCandidate) {
+// Consider the access specifier to be a C identifier.
+AccessSpecifierCandidate->Tok.setKind(tok::identifier);
+  }
 }
 
 void UnwrappedLineParser::parseConcept() {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -100,10 +100,27 @@
 if (Style.Language == FormatStyle::LK_Java || Style.isJavaScript() ||
 Style.isCSharp())
   return 0;
-if (RootToken.isAccessSpecifier(false) ||
-RootToken.isObjCAccessSpecifier() ||
-(RootToken.isOneOf(Keywords.kw_signals, Keywords.kw_qsignals) &&
- RootToken.Next && RootToken.Next->is(tok::colon))) {
+
+auto IsAccessModifier = [this, ]() {
+  if (RootToken.isAccessSpecifier(Style.isCpp()))
+return true;
+  else if (RootToken.isObjCAccessSpecifier())
+return true;
+  // Handle Qt signals.
+  else if ((RootToken.isOneOf(Keywords.kw_signals, Keywords.kw_qsignals) &&
+RootToken.Next && RootToken.Next->is(tok::colon)))
+return true;
+  else if (RootToken.Next &&
+   RootToken.Next->isOneOf(Keywords.kw_slots, Keywords.kw_qslots) &&
+   RootToken.Next->Next && RootToken.Next->Next->is(tok::colon))
+return true;
+  // Handle malformed access specifier e.g. 'private' without trailing ':'.
+  else if (!RootToken.Next && RootToken.isAccessSpecifier(false))
+return true;
+ 

[PATCH] D118519: [clang-tidy] Organize the release notes a little better

2022-01-29 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood marked an inline comment as done.
LegalizeAdulthood added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:221-227
 Removed checks
 ^^
 
 Improvements to include-fixer
 -
 
 The improvements are...

salman-javed-nz wrote:
> Small nit, not about this patch, but the documentation release process as a 
> whole.
> 
> Clang 13 got released with a lot of these placeholders still in the 
> documentation.
> https://releases.llvm.org/13.0.0/tools/clang/tools/extra/docs/ReleaseNotes.html
> They were never tidied up before release.
> 
> What could be done to ensure that this doesn't happen again? Perhaps keep the 
> placeholders in the file but in a commented-out state?
> 
> I'm aware of https://llvm.org/docs/HowToReleaseLLVM.html#update-documentation 
> but in this case I guess it wasn't enough to capture this?
I think it would be reasonable to have them as comment blocks.

I don't know if there's an automated process for generating/updating
release notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118519

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


[PATCH] D117416: [clang-format] Handle C variables with name that matches c++ access specifier

2022-01-29 Thread psigillito via Phabricator via cfe-commits
psigillito updated this revision to Diff 404322.
psigillito added a comment.

- wrap vector in function


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117416

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3123,6 +3123,46 @@
"label:\n"
"  signals.baz();\n"
"}");
+  verifyFormat("private[1];");
+  verifyFormat("testArray[public] = 1;");
+  verifyFormat("public();");
+  verifyFormat("myFunc(public);");
+  verifyFormat("std::vector testVec = {private};");
+  verifyFormat("private.p = 1;");
+  verifyFormat("void function(private...){};");
+  verifyFormat("if (private && public)\n");
+  verifyFormat("private &= true;");
+  verifyFormat("int x = private * public;");
+  verifyFormat("public *= private;");
+  verifyFormat("int x = public + private;");
+  verifyFormat("private++;");
+  verifyFormat("++private;");
+  verifyFormat("public += private;");
+  verifyFormat("public = public - private;");
+  verifyFormat("public->foo();");
+  verifyFormat("private--;");
+  verifyFormat("--private;");
+  verifyFormat("public -= 1;");
+  verifyFormat("if (!private && !public)\n");
+  verifyFormat("public != private;");
+  verifyFormat("int x = public / private;");
+  verifyFormat("public /= 2;");
+  verifyFormat("public = public % 2;");
+  verifyFormat("public %= 2;");
+  verifyFormat("if (public < private)\n");
+  verifyFormat("public << private;");
+  verifyFormat("public <<= private;");
+  verifyFormat("if (public > private)\n");
+  verifyFormat("public >> private;");
+  verifyFormat("public >>= private;");
+  verifyFormat("public ^ private;");
+  verifyFormat("public ^= private;");
+  verifyFormat("public | private;");
+  verifyFormat("public |= private;");
+  verifyFormat("auto x = private ? 1 : 2;");
+  verifyFormat("if (public == private)\n");
+  verifyFormat("void foo(public, private)");
+  verifyFormat("public::foo();");
 }
 
 TEST_F(FormatTest, SeparatesLogicalBlocks) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2707,14 +2707,26 @@
 }
 
 void UnwrappedLineParser::parseAccessSpecifier() {
+  FormatToken *AccessSpecifierCandidate = FormatTok;
   nextToken();
   // Understand Qt's slots.
   if (FormatTok->isOneOf(Keywords.kw_slots, Keywords.kw_qslots))
 nextToken();
+
   // Otherwise, we don't know what it is, and we'd better keep the next token.
-  if (FormatTok->Tok.is(tok::colon))
+  if (FormatTok->Tok.is(tok::colon)) {
 nextToken();
-  addUnwrappedLine();
+addUnwrappedLine();
+  } else if (!FormatTok->Tok.is(tok::coloncolon) &&
+ !std::binary_search(COperatorsFollowingVar.begin(),
+ COperatorsFollowingVar.end(),
+ FormatTok->Tok.getKind())) {
+// Not a variable name nor namespace name.
+addUnwrappedLine();
+  } else if (AccessSpecifierCandidate) {
+// Consider the access specifier to be a C identifier.
+AccessSpecifierCandidate->Tok.setKind(tok::identifier);
+  }
 }
 
 void UnwrappedLineParser::parseConcept() {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -100,10 +100,27 @@
 if (Style.Language == FormatStyle::LK_Java || Style.isJavaScript() ||
 Style.isCSharp())
   return 0;
-if (RootToken.isAccessSpecifier(false) ||
-RootToken.isObjCAccessSpecifier() ||
-(RootToken.isOneOf(Keywords.kw_signals, Keywords.kw_qsignals) &&
- RootToken.Next && RootToken.Next->is(tok::colon))) {
+
+auto IsAccessModifier = [this, ]() {
+  if (RootToken.isAccessSpecifier(Style.isCpp()))
+return true;
+  else if (RootToken.isObjCAccessSpecifier())
+return true;
+  // Handle Qt signals.
+  else if ((RootToken.isOneOf(Keywords.kw_signals, Keywords.kw_qsignals) &&
+RootToken.Next && RootToken.Next->is(tok::colon)))
+return true;
+  else if (RootToken.Next &&
+   RootToken.Next->isOneOf(Keywords.kw_slots, Keywords.kw_qslots) &&
+   RootToken.Next->Next && RootToken.Next->Next->is(tok::colon))
+return true;
+  // Handle malformed access specifier e.g. 'private' without trailing ':'.
+  else if (!RootToken.Next && RootToken.isAccessSpecifier(false))
+return true;
+  return false;
+};
+
+if 

[PATCH] D118445: [clang][AVR] Set '-fno-use-cxa-atexit' to default

2022-01-29 Thread Ben Shi via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG653836251ac4: [clang][AVR] Set 
-fno-use-cxa-atexit to default (authored by benshi001).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118445

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/test/Driver/avr-toolchain.c


Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -25,7 +25,12 @@
 // CHECK3-SAME: {{^}} "[[SYSROOT]]/usr/avr/include"
 
 // RUN: %clang %s -### -target avr 2>&1 | FileCheck -check-prefix=CC1 %s
-// CC1: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-fno-use-init-array"
+// CC1: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-fno-use-init-array" 
"-fno-use-cxa-atexit"
+
+// RUN: %clang %s -### -target avr -fuse-init-array -fuse-cxa-atexit 2>&1 | 
FileCheck -check-prefix=CHECK4 %s
+// CHECK4: clang{{.*}} "-cc1" "-triple" "avr"
+// CHECK4-NOT: "-fno-use-init-array"
+// CHECK4-NOT: "-fno-use-cxa-atexit"
 
 // RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 
-nostdinc | FileCheck --check-prefix=NOSTDINC %s
 // RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 
-nostdlibinc | FileCheck --check-prefix=NOSTDINC %s
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -379,6 +379,11 @@
   if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
   options::OPT_fno_use_init_array, false))
 CC1Args.push_back("-fno-use-init-array");
+  // Use `-fno-use-cxa-atexit` as default, since avr-libc does not support
+  // `__cxa_atexit()`.
+  if (!DriverArgs.hasFlag(options::OPT_fuse_cxa_atexit,
+  options::OPT_fno_use_cxa_atexit, false))
+CC1Args.push_back("-fno-use-cxa-atexit");
 }
 
 Tool *AVRToolChain::buildLinker() const {
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8304,12 +8304,14 @@
 // Check if global/static variable is defined in address space
 // 1~6 (__flash, __flash1, __flash2, __flash3, __flash4, __flash5)
 // but not constant.
-LangAS AS = D->getType().getAddressSpace();
-if (isTargetAddressSpace(AS) && 1 <= toTargetAddressSpace(AS) &&
-toTargetAddressSpace(AS) <= 6 && !D->getType().isConstQualified())
-  CGM.getDiags().Report(D->getLocation(),
-diag::err_verify_nonconst_addrspace)
-  << "__flash*";
+if (D) {
+  LangAS AS = D->getType().getAddressSpace();
+  if (isTargetAddressSpace(AS) && 1 <= toTargetAddressSpace(AS) &&
+  toTargetAddressSpace(AS) <= 6 && !D->getType().isConstQualified())
+CGM.getDiags().Report(D->getLocation(),
+  diag::err_verify_nonconst_addrspace)
+<< "__flash*";
+}
 return TargetCodeGenInfo::getGlobalVarAddressSpace(CGM, D);
   }
 


Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -25,7 +25,12 @@
 // CHECK3-SAME: {{^}} "[[SYSROOT]]/usr/avr/include"
 
 // RUN: %clang %s -### -target avr 2>&1 | FileCheck -check-prefix=CC1 %s
-// CC1: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-fno-use-init-array"
+// CC1: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-fno-use-init-array" "-fno-use-cxa-atexit"
+
+// RUN: %clang %s -### -target avr -fuse-init-array -fuse-cxa-atexit 2>&1 | FileCheck -check-prefix=CHECK4 %s
+// CHECK4: clang{{.*}} "-cc1" "-triple" "avr"
+// CHECK4-NOT: "-fno-use-init-array"
+// CHECK4-NOT: "-fno-use-cxa-atexit"
 
 // RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdinc | FileCheck --check-prefix=NOSTDINC %s
 // RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdlibinc | FileCheck --check-prefix=NOSTDINC %s
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -379,6 +379,11 @@
   if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
   options::OPT_fno_use_init_array, false))
 CC1Args.push_back("-fno-use-init-array");
+  // Use `-fno-use-cxa-atexit` as default, since avr-libc does not support
+  // `__cxa_atexit()`.
+  if (!DriverArgs.hasFlag(options::OPT_fuse_cxa_atexit,
+  options::OPT_fno_use_cxa_atexit, false))
+CC1Args.push_back("-fno-use-cxa-atexit");
 }
 
 

[clang] 6538362 - [clang][AVR] Set '-fno-use-cxa-atexit' to default

2022-01-29 Thread Ben Shi via cfe-commits

Author: Ben Shi
Date: 2022-01-30T02:26:19Z
New Revision: 653836251ac41775e3d376e9ee28efd2ea0232b2

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

LOG: [clang][AVR] Set '-fno-use-cxa-atexit' to default

AVR is baremetal environment, so the avr-libc does not support
'__cxa_atexit()'.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Driver/ToolChains/AVR.cpp
clang/test/Driver/avr-toolchain.c

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 3b5389ee3670..8a0150218a7a 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -8304,12 +8304,14 @@ class AVRTargetCodeGenInfo : public TargetCodeGenInfo {
 // Check if global/static variable is defined in address space
 // 1~6 (__flash, __flash1, __flash2, __flash3, __flash4, __flash5)
 // but not constant.
-LangAS AS = D->getType().getAddressSpace();
-if (isTargetAddressSpace(AS) && 1 <= toTargetAddressSpace(AS) &&
-toTargetAddressSpace(AS) <= 6 && !D->getType().isConstQualified())
-  CGM.getDiags().Report(D->getLocation(),
-diag::err_verify_nonconst_addrspace)
-  << "__flash*";
+if (D) {
+  LangAS AS = D->getType().getAddressSpace();
+  if (isTargetAddressSpace(AS) && 1 <= toTargetAddressSpace(AS) &&
+  toTargetAddressSpace(AS) <= 6 && !D->getType().isConstQualified())
+CGM.getDiags().Report(D->getLocation(),
+  diag::err_verify_nonconst_addrspace)
+<< "__flash*";
+}
 return TargetCodeGenInfo::getGlobalVarAddressSpace(CGM, D);
   }
 

diff  --git a/clang/lib/Driver/ToolChains/AVR.cpp 
b/clang/lib/Driver/ToolChains/AVR.cpp
index a66cae8b4d6b..2cf16cf9fdb4 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -379,6 +379,11 @@ void AVRToolChain::addClangTargetOptions(
   if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
   options::OPT_fno_use_init_array, false))
 CC1Args.push_back("-fno-use-init-array");
+  // Use `-fno-use-cxa-atexit` as default, since avr-libc does not support
+  // `__cxa_atexit()`.
+  if (!DriverArgs.hasFlag(options::OPT_fuse_cxa_atexit,
+  options::OPT_fno_use_cxa_atexit, false))
+CC1Args.push_back("-fno-use-cxa-atexit");
 }
 
 Tool *AVRToolChain::buildLinker() const {

diff  --git a/clang/test/Driver/avr-toolchain.c 
b/clang/test/Driver/avr-toolchain.c
index 6bb7a00b6a3b..50f62c34ff9e 100644
--- a/clang/test/Driver/avr-toolchain.c
+++ b/clang/test/Driver/avr-toolchain.c
@@ -25,7 +25,12 @@
 // CHECK3-SAME: {{^}} "[[SYSROOT]]/usr/avr/include"
 
 // RUN: %clang %s -### -target avr 2>&1 | FileCheck -check-prefix=CC1 %s
-// CC1: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-fno-use-init-array"
+// CC1: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-fno-use-init-array" 
"-fno-use-cxa-atexit"
+
+// RUN: %clang %s -### -target avr -fuse-init-array -fuse-cxa-atexit 2>&1 | 
FileCheck -check-prefix=CHECK4 %s
+// CHECK4: clang{{.*}} "-cc1" "-triple" "avr"
+// CHECK4-NOT: "-fno-use-init-array"
+// CHECK4-NOT: "-fno-use-cxa-atexit"
 
 // RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 
-nostdinc | FileCheck --check-prefix=NOSTDINC %s
 // RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 
-nostdlibinc | FileCheck --check-prefix=NOSTDINC %s



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


[PATCH] D118535: [clang] Move XCore specific options from Clang.cpp to XCore.cpp

2022-01-29 Thread Ben Shi via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGac3894cf1e09: [Clang] Move XCore specific options from 
Clang.cpp to XCore.cpp (authored by benshi001).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118535

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/XCore.cpp
  clang/test/Driver/xcore-opts.c


Index: clang/test/Driver/xcore-opts.c
===
--- clang/test/Driver/xcore-opts.c
+++ clang/test/Driver/xcore-opts.c
@@ -4,9 +4,8 @@
 // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck 
-check-prefix CHECK-G0 %s
 
 // CHECK: "-mframe-pointer=none"
-// CHECK: "-nostdsysteminc"
+// CHECK: "-nostdsysteminc" "-fno-use-cxa-atexit"
 // CHECK: "-fno-signed-char"
-// CHECK: "-fno-use-cxa-atexit"
 // CHECK-NOT: "-fcxx-exceptions"
 // CHECK-NOT: "-fexceptions"
 // CHECK-NOT: "-fcommon"
@@ -30,4 +29,3 @@
 // CHECK-G0: xcc"
 // CHECK-G0-NOT: "-g"
 // CHECK-G0: xcc"
-
Index: clang/lib/Driver/ToolChains/XCore.cpp
===
--- clang/lib/Driver/ToolChains/XCore.cpp
+++ clang/lib/Driver/ToolChains/XCore.cpp
@@ -130,6 +130,10 @@
ArgStringList ,
Action::OffloadKind) const {
   CC1Args.push_back("-nostdsysteminc");
+  // Set `-fno-use-cxa-atexit` to default.
+  if (!DriverArgs.hasFlag(options::OPT_fuse_cxa_atexit,
+  options::OPT_fno_use_cxa_atexit, false))
+CC1Args.push_back("-fno-use-cxa-atexit");
 }
 
 void XCoreToolChain::AddClangCXXStdlibIncludeArgs(
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6266,7 +6266,6 @@
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
   !RawTriple.isOSAIX() && !RawTriple.isOSWindows() &&
-  TC.getArch() != llvm::Triple::xcore &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)


Index: clang/test/Driver/xcore-opts.c
===
--- clang/test/Driver/xcore-opts.c
+++ clang/test/Driver/xcore-opts.c
@@ -4,9 +4,8 @@
 // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-G0 %s
 
 // CHECK: "-mframe-pointer=none"
-// CHECK: "-nostdsysteminc"
+// CHECK: "-nostdsysteminc" "-fno-use-cxa-atexit"
 // CHECK: "-fno-signed-char"
-// CHECK: "-fno-use-cxa-atexit"
 // CHECK-NOT: "-fcxx-exceptions"
 // CHECK-NOT: "-fexceptions"
 // CHECK-NOT: "-fcommon"
@@ -30,4 +29,3 @@
 // CHECK-G0: xcc"
 // CHECK-G0-NOT: "-g"
 // CHECK-G0: xcc"
-
Index: clang/lib/Driver/ToolChains/XCore.cpp
===
--- clang/lib/Driver/ToolChains/XCore.cpp
+++ clang/lib/Driver/ToolChains/XCore.cpp
@@ -130,6 +130,10 @@
ArgStringList ,
Action::OffloadKind) const {
   CC1Args.push_back("-nostdsysteminc");
+  // Set `-fno-use-cxa-atexit` to default.
+  if (!DriverArgs.hasFlag(options::OPT_fuse_cxa_atexit,
+  options::OPT_fno_use_cxa_atexit, false))
+CC1Args.push_back("-fno-use-cxa-atexit");
 }
 
 void XCoreToolChain::AddClangCXXStdlibIncludeArgs(
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6266,7 +6266,6 @@
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
   !RawTriple.isOSAIX() && !RawTriple.isOSWindows() &&
-  TC.getArch() != llvm::Triple::xcore &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ac3894c - [Clang] Move XCore specific options from Clang.cpp to XCore.cpp

2022-01-29 Thread Ben Shi via cfe-commits

Author: Ben Shi
Date: 2022-01-30T02:24:35Z
New Revision: ac3894cf1e093baff747d63bd37844b9176bcbe0

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

LOG: [Clang] Move XCore specific options from Clang.cpp to XCore.cpp

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/XCore.cpp
clang/test/Driver/xcore-opts.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 7acb70e0a396..6e0040150bfd 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6266,7 +6266,6 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
   !RawTriple.isOSAIX() && !RawTriple.isOSWindows() &&
-  TC.getArch() != llvm::Triple::xcore &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

diff  --git a/clang/lib/Driver/ToolChains/XCore.cpp 
b/clang/lib/Driver/ToolChains/XCore.cpp
index 7e74f6374050..29fa82aec0a9 100644
--- a/clang/lib/Driver/ToolChains/XCore.cpp
+++ b/clang/lib/Driver/ToolChains/XCore.cpp
@@ -130,6 +130,10 @@ void XCoreToolChain::addClangTargetOptions(const ArgList 
,
ArgStringList ,
Action::OffloadKind) const {
   CC1Args.push_back("-nostdsysteminc");
+  // Set `-fno-use-cxa-atexit` to default.
+  if (!DriverArgs.hasFlag(options::OPT_fuse_cxa_atexit,
+  options::OPT_fno_use_cxa_atexit, false))
+CC1Args.push_back("-fno-use-cxa-atexit");
 }
 
 void XCoreToolChain::AddClangCXXStdlibIncludeArgs(

diff  --git a/clang/test/Driver/xcore-opts.c b/clang/test/Driver/xcore-opts.c
index 8885974ec84a..d4b400cbe933 100644
--- a/clang/test/Driver/xcore-opts.c
+++ b/clang/test/Driver/xcore-opts.c
@@ -4,9 +4,8 @@
 // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck 
-check-prefix CHECK-G0 %s
 
 // CHECK: "-mframe-pointer=none"
-// CHECK: "-nostdsysteminc"
+// CHECK: "-nostdsysteminc" "-fno-use-cxa-atexit"
 // CHECK: "-fno-signed-char"
-// CHECK: "-fno-use-cxa-atexit"
 // CHECK-NOT: "-fcxx-exceptions"
 // CHECK-NOT: "-fexceptions"
 // CHECK-NOT: "-fcommon"
@@ -30,4 +29,3 @@
 // CHECK-G0: xcc"
 // CHECK-G0-NOT: "-g"
 // CHECK-G0: xcc"
-



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


[PATCH] D118095: [AVR][clang] Reject non assembly source files for the avr1 family

2022-01-29 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

In D118095#3282039 , @MaskRay wrote:

> I do not know whether the complexity is justified. Rejecting some -mmcu= for 
> C source files looks quite dubious. Does it really help users?
>
> Bear in mind that all these complexity translates to clang executable size 
> increase for other users (most people don't use AVR).

Actually I would like to make clang+llvm+lld fully compatible with gcc+binutils 
(functionality, ABI, quality, ...), and finally replace avr-gcc as Arduino's 
default toolchain. (https://www.arduino.cc/en/software, Arduino is a popular 
MCU platform for hardware prototype development & verification)

Even many avr-libc (https://www.nongnu.org/avr-libc/) developers are trying 
build it with clang.

If you think it is complex, we can remove the extreme check of `-x  
assembler-with-cpp`, which is rarely in a real world.


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

https://reviews.llvm.org/D118095

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


[PATCH] D111100: enable plugins for clang-tidy

2022-01-29 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

We started seeing CMake error after this change landed:

  CMake Error at cmake/modules/AddLLVM.cmake:683 (add_dependencies):
The dependency target "clang-tidy-headers" of target "CTTestTidyModule"
does not exist.
  Call Stack (most recent call first):
/b/s/w/ir/x/w/llvm-llvm-project/clang-tools-extra/test/CMakeLists.txt:82 
(llvm_add_library)

Would it be possible to revert it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D00

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


[PATCH] D118519: [clang-tidy] Organize the release notes a little better

2022-01-29 Thread Salman Javed via Phabricator via cfe-commits
salman-javed-nz added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:221-227
 Removed checks
 ^^
 
 Improvements to include-fixer
 -
 
 The improvements are...

Small nit, not about this patch, but the documentation release process as a 
whole.

Clang 13 got released with a lot of these placeholders still in the 
documentation.
https://releases.llvm.org/13.0.0/tools/clang/tools/extra/docs/ReleaseNotes.html
They were never tidied up before release.

What could be done to ensure that this doesn't happen again? Perhaps keep the 
placeholders in the file but in a commented-out state?

I'm aware of https://llvm.org/docs/HowToReleaseLLVM.html#update-documentation 
but in this case I guess it wasn't enough to capture this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118519

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


[PATCH] D118428: [clang-cl] Support the /JMC flag

2022-01-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 404307.
ychen added a comment.

- address Alexandre's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118428

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-options.c
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/CodeGen/Passes.h
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/LinkAllPasses.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/CodeGen.cpp
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/CodeGen/JMCInstrumenter.cpp
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/test/CodeGen/X86/jmc-instrument-32bit.ll
  llvm/test/CodeGen/X86/jmc-instrument.ll
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -498,7 +498,8 @@
   "generic-to-nvvm",  "expandmemcmp",
   "loop-reduce",  "lower-amx-type",
   "pre-amx-config",   "lower-amx-intrinsics",
-  "polyhedral-info",  "replace-with-veclib"};
+  "polyhedral-info",  "replace-with-veclib",
+  "jmc-instrument"};
   for (const auto  : PassNamePrefix)
 if (Pass.startswith(P))
   return true;
@@ -572,6 +573,7 @@
   initializeHardwareLoopsPass(Registry);
   initializeTypePromotionPass(Registry);
   initializeReplaceWithVeclibLegacyPass(Registry);
+  initializeJMCInstrumenterPass(Registry);
 
 #ifdef BUILD_EXAMPLES
   initializeExampleIRTransforms(Registry);
Index: llvm/test/CodeGen/X86/jmc-instrument.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/jmc-instrument.ll
@@ -0,0 +1,148 @@
+; RUN: opt -jmc-instrument -S < %s | FileCheck %s
+; RUN: llc < %s -enable-jmc-instrument | FileCheck %s -check-prefix CODEGEN
+
+; CHECK: $__JustMyCode_Default = comdat any
+
+; CHECK: @"__7DF23CF5_x@c" = internal unnamed_addr global i8 1, section ".msvcjmc", align 1, !dbg !0
+; CHECK: @"__A85D9D03_x@c" = internal unnamed_addr global i8 1, section ".msvcjmc", align 1, !dbg !5
+; CHECK: @llvm.used = appending global [3 x i8*] [i8* @"__7DF23CF5_x@c", i8* @"__A85D9D03_x@c", i8* bitcast (void (i8*)* @__JustMyCode_Default to i8*)], section "llvm.metadata"
+
+; CHECK: define void @l1() #0 !dbg !13 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__7DF23CF5_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @l2() #0 !dbg !17 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__7DF23CF5_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @w1() #0 !dbg !19 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @w2() #0 !dbg !20 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @w3() #0 !dbg !22 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @w4() #0 !dbg !24 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: declare void @__CheckForDebuggerJustMyCode(i8* noundef) unnamed_addr
+
+; CHECK: define void @__JustMyCode_Default(i8* noundef %0) unnamed_addr comdat {
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: attributes {{.*}} "jmc-instrumented"
+
+; CHECK: !llvm.linker.options = !{!12}
+
+; CHECK: !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+; CHECK: !1 = distinct !DIGlobalVariable(name: "__7DF23CF5_x@c", scope: !2, file: !3, type: !8, isLocal: true, isDefinition: true)
+; CHECK: !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
+; CHECK: !3 = !DIFile(filename: "a/x.c", directory: "/tmp")
+; CHECK: !4 = !{!0, !5}
+; CHECK: !5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
+; CHECK: !6 = distinct !DIGlobalVariable(name: "__A85D9D03_x@c", scope: !2, file: !7, type: !8, isLocal: true, isDefinition: true)
+; CHECK: !7 = !DIFile(filename: "./x.c", directory: "C:ab")
+; CHECK: !8 = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char, flags: DIFlagArtificial)
+; CHECK: !9 = !{i32 2, !"CodeView", i32 1}
+; CHECK: !10 = !{i32 2, !"Debug Info Version", i32 3}
+; CHECK: !11 = !{!"clang"}
+; CHECK: !12 = 

[PATCH] D118428: [clang-cl] Support the /JMC flag

2022-01-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen marked 2 inline comments as done.
ychen added a comment.

Thanks a lot for reviewing the patch!

In D118428#3281721 , @aganea wrote:

> Cool! :) Seems good generally.
> Sounds like an expensive flag for the runtime perf :-D But I guess it makes 
> the debugging experience a bit nicer.

Exactly. I had the same thoughts. For MSVC it is what it is. For ELF, the other 
choice from using the same scheme as MSVC is that we could inline the 
`__CheckForDebuggerJustMyCode` call (its definition is here: 
https://github.com/ojdkbuild/tools_toolchain_vs2017bt_1416/blob/master/VC/Tools/MSVC/14.16.27023/crt/src/vcruntime/debugger_jmc.c)
 before the function ABI prologue. For example, to instrument a function `_foo`:

andb r11l, _jmc_global_flag, _jmc_enable_per_thread_step
andb r11l, r11, _jmc_per_module_flag
andb r11l, r11, _jmc_per_file_flag
cmpb r11l, 0
jne _foo 
int 3
  _foo:

The parameter of `__CheckForDebuggerJustMyCode` is `_jmc_per_file_flag` above. 
`int 3` is basically a per-function flag. `_jmc_per_module_flag` and 
`_jmc_global_flag` control the JMC behavior at module-level or program-level 
for better performance. Otherwise, the debugger needs the gather this 
information using debuginfo. This scheme is target-dependent and increases the 
.text slightly. But it eliminates the call and the flag modification at 
different granularity is fast. With that being said, experts working on ELF 
debuggers have ideas about which scheme is better. I'll send an RFC for ELF 
after this patch goes in.




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:7457
+   /*Default=*/false)) {
+if (EnabledZ7)
+  CmdArgs.push_back("-fjmc");

aganea wrote:
> Can we do here `if (*EmitCodeView && *DebugInfoKind >= 
> codegenoptions::DebugInfoConstructor)`? Is it worth introducing a new 
> variable?
Yeah, I think that works better. No need for a new variable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118428

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


LLVM build master will be restarted soon

2022-01-29 Thread Galina Kistanova via cfe-commits
 Hello,

LLVM build master will be restarted at 3 PM PST.

Thanks

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


[PATCH] D114413: [OpenMPIRBuilder] Implement static-chunked workshare-loop schedules.

2022-01-29 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

@peixin Thanks for testing edge cases. You hit multiple issues:

1. Chunksize was i32, combining it with a i64 induction variable caused an 
error. Fixed the latest update of this patch.
2. OpenMPIRBuilder currently doesn't work really with exceptions. See D115216 
 for a start of a discussion with `#pragma 
omp parallel`. Support for irregular exits (exceptions, cancellation, 
destructors) out of CanonicalLoopInfo is what I was working on recently. Use 
`-fno-exceptions` to work around.
3. There is an off-by-one error that I already fixed in my development branch. 
Upstream patch here: D118542 

Result with these fixes for me is:

  lb: 18446744073709551615
  ub: 1844674407370955161
  step: 1844674407370955161
  18446744073709551615
  16602069666338596454
  14757395258967641293
  12912720851596686132
  11068046444225730971
  9223372036854775810
  7378697629483820649
  5534023222112865488
  3689348814741910327
  1844674407370955166

Note that this does involve `__kmpc_doacross_init` code in libomp you 
pointed-to in D116292 . This uses 
`__kmpc_for_static_init` calls of which there are 4 variants for 
(signed/unsigned x 32/64 bits). To do `__kmpc_doacross_init` correctly, it 
would also need at least have variants for signed/unsigned (or one working 
internally with signed 128 bits).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114413

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


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

2022-01-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Ping @phosek


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D118095: [AVR][clang] Reject non assembly source files for the avr1 family

2022-01-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I do not know whether the complexity is justified. Rejecting some -mmcu= for C 
source files looks quite dubious. Does it really help users?


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

https://reviews.llvm.org/D118095

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


[PATCH] D117416: [clang-format] Handle C variables with name that matches c++ access specifier

2022-01-29 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.
This revision is now accepted and ready to land.

+1 for assert




Comment at: clang/lib/Format/FormatToken.h:126
+/// Sorted operators that can follow a C variable.
+static const std::vector COperatorsFollowingVar = {
+tok::l_square, tok::r_square,

curdeius wrote:
> Is there a place anywhere that you verify it's sorted?
> If no, please add an assert.
Could initialize from a lambda in which the assert is located, thus it is only 
executed once.
```
static const std::vector COperatorsFollowingVar = []{
  std::vector Ret...;
  assert(...);
  return Ret;
}();
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117416

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


[PATCH] D118445: [clang][AVR] Set '-fno-use-cxa-atexit' to default

2022-01-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D118445

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


[PATCH] D118535: [clang] Move XCore specific options from Clang.cpp to XCore.cpp

2022-01-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118535

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


[PATCH] D118542: [Clang][OpenMPIRBuilder] Fix off-by-one error when dividing by stepsize.

2022-01-29 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur created this revision.
Meinersbur added reviewers: kiranchandramohan, ftynse, peixin, jdoerfert, 
clementval, Leporacanthicus, kiranktp, arnamoy10, bryanpkc, Chuanfeng, 
AMDChirag, anchu-rajendran, SouraVX, fghanim, jdenny, MatsPetersson, ABataev.
Herald added subscribers: zzheng, guansong, yaxunl.
Meinersbur requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

When the stepsize does not evenly divide the range's end, round-up to ensure 
that that last multiple of the stepsize before the reaching the upper boud is 
reached. For instance, the trip count of

  for (int i = 0; i < 7; i+=5)

is two (i=0 and i=5), not (7-0)/5 == 1.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118542

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/irbuilder_for_unsigned.c
  clang/test/OpenMP/irbuilder_for_unsigned_down.c
  clang/test/OpenMP/irbuilder_unroll_full.c
  clang/test/OpenMP/irbuilder_unroll_heuristic.c
  clang/test/OpenMP/irbuilder_unroll_partial_factor.c
  clang/test/OpenMP/irbuilder_unroll_partial_factor_for.c
  clang/test/OpenMP/irbuilder_unroll_partial_heuristic.c
  clang/test/OpenMP/irbuilder_unroll_partial_heuristic_constant_for.c
  clang/test/OpenMP/irbuilder_unroll_partial_heuristic_runtime_for.c
  clang/test/OpenMP/irbuilder_unroll_unroll_partial_factor.c
  clang/test/OpenMP/irbuilder_unroll_unroll_partial_heuristic.c

Index: clang/test/OpenMP/irbuilder_unroll_unroll_partial_heuristic.c
===
--- clang/test/OpenMP/irbuilder_unroll_unroll_partial_heuristic.c
+++ clang/test/OpenMP/irbuilder_unroll_unroll_partial_heuristic.c
@@ -154,7 +154,10 @@
 // CHECK-NEXT:%[[TMP7:.+]] = load i32, i32* %[[DOTSTART]], align 4
 // CHECK-NEXT:%[[SUB:.+]] = sub nsw i32 %[[TMP6]], %[[TMP7]]
 // CHECK-NEXT:%[[TMP8:.+]] = load i32, i32* %[[DOTSTEP]], align 4
-// CHECK-NEXT:%[[DIV:.+]] = udiv i32 %[[SUB]], %[[TMP8]]
+// CHECK-NEXT:%[[SUB1:.+]] = sub i32 %[[TMP8]], 1
+// CHECK-NEXT:%[[ADD:.+]] = add i32 %[[SUB]], %[[SUB1]]
+// CHECK-NEXT:%[[TMP9:.+]] = load i32, i32* %[[DOTSTEP]], align 4
+// CHECK-NEXT:%[[DIV:.+]] = udiv i32 %[[ADD]], %[[TMP9]]
 // CHECK-NEXT:br label %[[COND_END:.+]]
 // CHECK-EMPTY:
 // CHECK-NEXT:  [[COND_FALSE]]:
@@ -162,8 +165,8 @@
 // CHECK-EMPTY:
 // CHECK-NEXT:  [[COND_END]]:
 // CHECK-NEXT:%[[COND:.+]] = phi i32 [ %[[DIV]], %[[COND_TRUE]] ], [ 0, %[[COND_FALSE]] ]
-// CHECK-NEXT:%[[TMP9:.+]] = load i32*, i32** %[[DISTANCE_ADDR]], align 8
-// CHECK-NEXT:store i32 %[[COND]], i32* %[[TMP9]], align 4
+// CHECK-NEXT:%[[TMP10:.+]] = load i32*, i32** %[[DISTANCE_ADDR]], align 8
+// CHECK-NEXT:store i32 %[[COND]], i32* %[[TMP10]], align 4
 // CHECK-NEXT:ret void
 // CHECK-NEXT:  }
 
Index: clang/test/OpenMP/irbuilder_unroll_unroll_partial_factor.c
===
--- clang/test/OpenMP/irbuilder_unroll_unroll_partial_factor.c
+++ clang/test/OpenMP/irbuilder_unroll_unroll_partial_factor.c
@@ -173,7 +173,10 @@
 // CHECK-NEXT:%[[TMP7:.+]] = load i32, i32* %[[DOTSTART]], align 4
 // CHECK-NEXT:%[[SUB:.+]] = sub nsw i32 %[[TMP6]], %[[TMP7]]
 // CHECK-NEXT:%[[TMP8:.+]] = load i32, i32* %[[DOTSTEP]], align 4
-// CHECK-NEXT:%[[DIV:.+]] = udiv i32 %[[SUB]], %[[TMP8]]
+// CHECK-NEXT:%[[SUB1:.+]] = sub i32 %[[TMP8]], 1
+// CHECK-NEXT:%[[ADD:.+]] = add i32 %[[SUB]], %[[SUB1]]
+// CHECK-NEXT:%[[TMP9:.+]] = load i32, i32* %[[DOTSTEP]], align 4
+// CHECK-NEXT:%[[DIV:.+]] = udiv i32 %[[ADD]], %[[TMP9]]
 // CHECK-NEXT:br label %[[COND_END:.+]]
 // CHECK-EMPTY:
 // CHECK-NEXT:  [[COND_FALSE]]:
@@ -181,8 +184,8 @@
 // CHECK-EMPTY:
 // CHECK-NEXT:  [[COND_END]]:
 // CHECK-NEXT:%[[COND:.+]] = phi i32 [ %[[DIV]], %[[COND_TRUE]] ], [ 0, %[[COND_FALSE]] ]
-// CHECK-NEXT:%[[TMP9:.+]] = load i32*, i32** %[[DISTANCE_ADDR]], align 8
-// CHECK-NEXT:store i32 %[[COND]], i32* %[[TMP9]], align 4
+// CHECK-NEXT:%[[TMP10:.+]] = load i32*, i32** %[[DISTANCE_ADDR]], align 8
+// CHECK-NEXT:store i32 %[[COND]], i32* %[[TMP10]], align 4
 // CHECK-NEXT:ret void
 // CHECK-NEXT:  }
 
Index: clang/test/OpenMP/irbuilder_unroll_partial_heuristic_runtime_for.c
===
--- clang/test/OpenMP/irbuilder_unroll_partial_heuristic_runtime_for.c
+++ clang/test/OpenMP/irbuilder_unroll_partial_heuristic_runtime_for.c
@@ -206,7 +206,10 @@
 // CHECK-NEXT:%[[TMP10:.+]] = load i32, i32* %[[DOTSTART]], align 4
 // CHECK-NEXT:%[[SUB:.+]] = sub nsw i32 %[[TMP9]], %[[TMP10]]
 // CHECK-NEXT:%[[TMP11:.+]] = load i32, i32* %[[DOTSTEP]], align 4
-// CHECK-NEXT:%[[DIV:.+]] = udiv i32 %[[SUB]], %[[TMP11]]
+// CHECK-NEXT:%[[SUB1:.+]] = sub i32 %[[TMP11]], 1
+// CHECK-NEXT:%[[ADD:.+]] = add i32 %[[SUB]], %[[SUB1]]
+// CHECK-NEXT:%[[TMP12:.+]] = load i32, i32* %[[DOTSTEP]], 

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

2022-01-29 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth marked an inline comment as done.
JonasToth added a comment.

ping @aaron.ballman just in case the patch is now down on the list, I am sorry 
for my high latency :(




Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h:29
+  : ClangTidyCheck(Name, Context),
+AnalyzeValues(Options.get("AnalyzeValues", 1)),
+AnalyzeReferences(Options.get("AnalyzeReferences", 1)),

njames93 wrote:
> Can all these options be defaulted to Boolean values, as the options parser 
> has special parsing logic for bool
you are right. I updated it.


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


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

2022-01-29 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 404297.
JonasToth added a comment.

- use boolean for options
- fix snafoo on `arc` usage


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/cppcoreguidelines/ConstCorrectnessCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-const-correctness.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-cxx17.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-templates.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-unaligned.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-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/cppcoreguidelines-const-correctness-values.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-values.cpp
@@ -0,0 +1,958 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-const-correctness %t -- \
+// RUN:   -config="{CheckOptions: [\
+// RUN:   {key: 'cppcoreguidelines-const-correctness.TransformValues', value: 1}, \
+// RUN:   {key: 'cppcoreguidelines-const-correctness.WarnPointersAsValues', value: 0}, \
+// RUN:   {key: 'cppcoreguidelines-const-correctness.TransformPointersAsValues', value: 0}, \
+// 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 

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

2022-01-29 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 404296.
JonasToth added a comment.

- use boolean for option parsing


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/ConstCorrectnessCheck.h


Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
@@ -26,13 +26,13 @@
 public:
   ConstCorrectnessCheck(StringRef Name, ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context),
-AnalyzeValues(Options.get("AnalyzeValues", 1)),
-AnalyzeReferences(Options.get("AnalyzeReferences", 1)),
-WarnPointersAsValues(Options.get("WarnPointersAsValues", 0)),
-TransformValues(Options.get("TransformValues", 1)),
-TransformReferences(Options.get("TransformReferences", 1)),
-TransformPointersAsValues(Options.get("TransformPointersAsValues", 0)) 
{
-  }
+AnalyzeValues(Options.get("AnalyzeValues", true)),
+AnalyzeReferences(Options.get("AnalyzeReferences", true)),
+WarnPointersAsValues(Options.get("WarnPointersAsValues", false)),
+TransformValues(Options.get("TransformValues", true)),
+TransformReferences(Options.get("TransformReferences", true)),
+TransformPointersAsValues(
+Options.get("TransformPointersAsValues", false)) {}
 
   // The rules for C and 'const' are different and incompatible for this check.
   bool isLanguageVersionSupported(const LangOptions ) const override {


Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
@@ -26,13 +26,13 @@
 public:
   ConstCorrectnessCheck(StringRef Name, ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context),
-AnalyzeValues(Options.get("AnalyzeValues", 1)),
-AnalyzeReferences(Options.get("AnalyzeReferences", 1)),
-WarnPointersAsValues(Options.get("WarnPointersAsValues", 0)),
-TransformValues(Options.get("TransformValues", 1)),
-TransformReferences(Options.get("TransformReferences", 1)),
-TransformPointersAsValues(Options.get("TransformPointersAsValues", 0)) {
-  }
+AnalyzeValues(Options.get("AnalyzeValues", true)),
+AnalyzeReferences(Options.get("AnalyzeReferences", true)),
+WarnPointersAsValues(Options.get("WarnPointersAsValues", false)),
+TransformValues(Options.get("TransformValues", true)),
+TransformReferences(Options.get("TransformReferences", true)),
+TransformPointersAsValues(
+Options.get("TransformPointersAsValues", false)) {}
 
   // The rules for C and 'const' are different and incompatible for this check.
   bool isLanguageVersionSupported(const LangOptions ) const override {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111100: enable plugins for clang-tidy

2022-01-29 Thread Jameson Nash via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG36892727e4f1: enable plugins for clang-tidy (authored by 
vtjnash).

Changed prior to commit:
  https://reviews.llvm.org/D00?vs=401997=404294#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D00

Files:
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,9 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
+
+# Plugins (loadable modules)
+if config.has_plugins and config.llvm_plugin_ext:
+config.available_features.add('plugins')
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,66 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest*' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext -load %llvmshlibdir/LLVMHello%pluginext | FileCheck --check-prefix=CHECK-LIST %s
+// CHECK-LIST: Enabled checks:
+// CHECK-LIST-NEXT:mytest1
+// CHECK-LIST-NEXT:mytest2
+// RUN: clang-tidy -checks='-*,mytest*,misc-definitions-in-headers' -load %llvmshlibdir/CTTestTidyModule%pluginext /dev/null -- -xc 2>&1 | FileCheck %s
+// CHECK: 3 warnings generated.
+// CHECK-NEXT: warning: mytest success [misc-definitions-in-headers,mytest1,mytest2]
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override {
+Finder->addMatcher(translationUnitDecl().bind("tu"), this);
+  }
+
+  void check(const ast_matchers::MatchFinder::MatchResult ) override {
+auto S = Result.Nodes.getNodeAs("tu");
+if (S)
+  diag("mytest success");
+  }
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck("mytest1");
+CheckFactories.registerCheck("mytest2");
+// intentionally collide with an existing test name, overriding it
+CheckFactories.registerCheck("misc-definitions-in-headers");
+  }
+};
+} // namespace
+
+namespace tidy1 {
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+} // namespace tidy1
+
+namespace tidy2 {
+// intentionally collide with an existing test group name, merging with it
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("misc-module", "Adds miscellaneous lint checks.");
+} // namespace tidy2
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTestModuleAnchorSource = 0;
Index: 

[clang-tools-extra] 3689272 - enable plugins for clang-tidy

2022-01-29 Thread Jameson Nash via cfe-commits

Author: Jameson Nash
Date: 2022-01-29T14:21:19-05:00
New Revision: 36892727e4f19a60778e371d78f8fb09d8122c85

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

LOG: enable plugins for clang-tidy

Fixes #32739

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

Added: 
clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp

Modified: 
clang-tools-extra/clang-tidy/tool/CMakeLists.txt
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/Contributing.rst
clang-tools-extra/docs/clang-tidy/index.rst
clang-tools-extra/test/CMakeLists.txt
clang-tools-extra/test/lit.cfg.py
clang-tools-extra/test/lit.site.cfg.py.in

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/tool/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/tool/CMakeLists.txt
index 4b8c93801501a..3ce552872015e 100644
--- a/clang-tools-extra/clang-tidy/tool/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/tool/CMakeLists.txt
@@ -29,11 +29,17 @@ clang_target_link_libraries(clangTidyMain
   clangToolingCore
   )
 
+# Support plugins.
+if(CLANG_PLUGIN_SUPPORT)
+  set(support_plugins SUPPORT_PLUGINS)
+endif()
+
 add_clang_tool(clang-tidy
   ClangTidyToolMain.cpp
-  )
-add_dependencies(clang-tidy
+
+  DEPENDS
   clang-resource-headers
+  ${support_plugins}
   )
 clang_target_link_libraries(clang-tidy
   PRIVATE
@@ -50,6 +56,9 @@ target_link_libraries(clang-tidy
   ${ALL_CLANG_TIDY_CHECKS}
   )
 
+if(CLANG_PLUGIN_SUPPORT)
+  export_executable_symbols_for_plugins(clang-tidy)
+endif()
 
 install(PROGRAMS clang-tidy-
diff .py
   DESTINATION "${CMAKE_INSTALL_DATADIR}/clang"

diff  --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp 
b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index 6147d90eb10b9..1b0010bdd62a2 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -20,6 +20,7 @@
 #include "../GlobList.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/PluginLoader.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
@@ -386,6 +387,11 @@ getVfsFromFile(const std::string ,
 
 int clangTidyMain(int argc, const char **argv) {
   llvm::InitLLVM X(argc, argv);
+
+  // Enable help for -load option, if plugins are enabled.
+  if (cl::Option *LoadOpt = cl::getRegisteredOptions().lookup("load"))
+LoadOpt->addCategory(ClangTidyCategory);
+
   llvm::Expected OptionsParser =
   CommonOptionsParser::create(argc, argv, ClangTidyCategory,
   cl::ZeroOrMore);

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 0e9491eab9f6a..eceed8749c950 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -86,6 +86,8 @@ Improvements to clang-tidy
 - Eliminated false positives for `cppcoreguidelines-macro-usage` by restricting
   the warning about using constants to only macros that expand to literals.
 
+- Added support for external plugin checks with `-load`.
+
 New checks
 ^^
 

diff  --git a/clang-tools-extra/docs/clang-tidy/Contributing.rst 
b/clang-tools-extra/docs/clang-tidy/Contributing.rst
index b9eb0e7627cc1..b1771574950a8 100644
--- a/clang-tools-extra/docs/clang-tidy/Contributing.rst
+++ b/clang-tools-extra/docs/clang-tidy/Contributing.rst
@@ -634,6 +634,26 @@ This keeps the test directory from getting cluttered.
 .. _FileCheck: https://llvm.org/docs/CommandGuide/FileCheck.html
 .. _test/clang-tidy/google-readability-casting.cpp: https://reviews.llvm.org/
diff 
usion/L/browse/clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp
 
+Out-of-tree check plugins
+-
+
+Developing an out-of-tree check as a plugin largely follows the steps
+outlined above. The plugin is a shared library whose code lives outside
+the clang-tidy build system. Build and link this shared library against
+LLVM as done for other kinds of Clang plugins.
+
+The plugin can be loaded by passing `-load` to `clang-tidy` in addition to the
+names of the checks to enable.
+
+.. code-block:: console
+
+  $ clang-tidy --checks=-*,my-explicit-constructor -list-checks -load 
myplugin.so
+
+There is no expectations regarding ABI and API stability, so the plugin must be
+compiled against the version of clang-tidy that will be loading the plugin.
+
+The plugins can use threads, TLS, or any other facilities available to in-tree
+code which is accessible from the external headers.
 
 Running clang-tidy on LLVM
 --

diff  --git a/clang-tools-extra/docs/clang-tidy/index.rst 

[PATCH] D117416: [clang-format] Handle C variables with name that matches c++ access specifier

2022-01-29 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.

LGTM but please add an assert(is_sorted).




Comment at: clang/lib/Format/FormatToken.h:126
+/// Sorted operators that can follow a C variable.
+static const std::vector COperatorsFollowingVar = {
+tok::l_square, tok::r_square,

Is there a place anywhere that you verify it's sorted?
If no, please add an assert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117416

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


[PATCH] D117416: [clang-format] Handle C variables with name that matches c++ access specifier

2022-01-29 Thread psigillito via Phabricator via cfe-commits
psigillito updated this revision to Diff 404288.
psigillito marked an inline comment as done.
psigillito added a comment.

- review changes, lower_bound to binary_search


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117416

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3123,6 +3123,46 @@
"label:\n"
"  signals.baz();\n"
"}");
+  verifyFormat("private[1];");
+  verifyFormat("testArray[public] = 1;");
+  verifyFormat("public();");
+  verifyFormat("myFunc(public);");
+  verifyFormat("std::vector testVec = {private};");
+  verifyFormat("private.p = 1;");
+  verifyFormat("void function(private...){};");
+  verifyFormat("if (private && public)\n");
+  verifyFormat("private &= true;");
+  verifyFormat("int x = private * public;");
+  verifyFormat("public *= private;");
+  verifyFormat("int x = public + private;");
+  verifyFormat("private++;");
+  verifyFormat("++private;");
+  verifyFormat("public += private;");
+  verifyFormat("public = public - private;");
+  verifyFormat("public->foo();");
+  verifyFormat("private--;");
+  verifyFormat("--private;");
+  verifyFormat("public -= 1;");
+  verifyFormat("if (!private && !public)\n");
+  verifyFormat("public != private;");
+  verifyFormat("int x = public / private;");
+  verifyFormat("public /= 2;");
+  verifyFormat("public = public % 2;");
+  verifyFormat("public %= 2;");
+  verifyFormat("if (public < private)\n");
+  verifyFormat("public << private;");
+  verifyFormat("public <<= private;");
+  verifyFormat("if (public > private)\n");
+  verifyFormat("public >> private;");
+  verifyFormat("public >>= private;");
+  verifyFormat("public ^ private;");
+  verifyFormat("public ^= private;");
+  verifyFormat("public | private;");
+  verifyFormat("public |= private;");
+  verifyFormat("auto x = private ? 1 : 2;");
+  verifyFormat("if (public == private)\n");
+  verifyFormat("void foo(public, private)");
+  verifyFormat("public::foo();");
 }
 
 TEST_F(FormatTest, SeparatesLogicalBlocks) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2707,14 +2707,26 @@
 }
 
 void UnwrappedLineParser::parseAccessSpecifier() {
+  FormatToken *AccessSpecifierCandidate = FormatTok;
   nextToken();
   // Understand Qt's slots.
   if (FormatTok->isOneOf(Keywords.kw_slots, Keywords.kw_qslots))
 nextToken();
+
   // Otherwise, we don't know what it is, and we'd better keep the next token.
-  if (FormatTok->Tok.is(tok::colon))
+  if (FormatTok->Tok.is(tok::colon)) {
 nextToken();
-  addUnwrappedLine();
+addUnwrappedLine();
+  } else if (!FormatTok->Tok.is(tok::coloncolon) &&
+ !std::binary_search(COperatorsFollowingVar.begin(),
+ COperatorsFollowingVar.end(),
+ FormatTok->Tok.getKind())) {
+// Not a variable name nor namespace name.
+addUnwrappedLine();
+  } else if (AccessSpecifierCandidate) {
+// Consider the access specifier to be a C identifier.
+AccessSpecifierCandidate->Tok.setKind(tok::identifier);
+  }
 }
 
 void UnwrappedLineParser::parseConcept() {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -100,10 +100,27 @@
 if (Style.Language == FormatStyle::LK_Java || Style.isJavaScript() ||
 Style.isCSharp())
   return 0;
-if (RootToken.isAccessSpecifier(false) ||
-RootToken.isObjCAccessSpecifier() ||
-(RootToken.isOneOf(Keywords.kw_signals, Keywords.kw_qsignals) &&
- RootToken.Next && RootToken.Next->is(tok::colon))) {
+
+auto IsAccessModifier = [this, ]() {
+  if (RootToken.isAccessSpecifier(Style.isCpp()))
+return true;
+  else if (RootToken.isObjCAccessSpecifier())
+return true;
+  // Handle Qt signals.
+  else if ((RootToken.isOneOf(Keywords.kw_signals, Keywords.kw_qsignals) &&
+RootToken.Next && RootToken.Next->is(tok::colon)))
+return true;
+  else if (RootToken.Next &&
+   RootToken.Next->isOneOf(Keywords.kw_slots, Keywords.kw_qslots) &&
+   RootToken.Next->Next && RootToken.Next->Next->is(tok::colon))
+return true;
+  // Handle malformed access specifier e.g. 'private' without trailing ':'.
+  else if (!RootToken.Next && RootToken.isAccessSpecifier(false))

[PATCH] D117416: [clang-format] Handle C variables with name that matches c++ access specifier

2022-01-29 Thread psigillito via Phabricator via cfe-commits
psigillito marked 7 inline comments as done.
psigillito added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2716-2718
+  auto COperatorMatch =
+  std::lower_bound(COperatorsFollowingVar.begin(),
+   COperatorsFollowingVar.end(), FormatTok->Tok.getKind());

curdeius wrote:
> Please use `binary_search` and put it inside the `else` branch to avoid it if 
> the first condition is satisfied.
> Something like:
> ```
> if (FormatTok->Tok.is(tok::colon)) {
> ...
> } else if (!binary_search(...) {
> } else if (...) {
> }
> ```
> 
> Also, this code and the code in `UnwrappedLineFormatter` are pretty much 
> similar.
> Can we remove this duplication by e.g. setting the token kind here and 
> checking it in the formatter?
Yes, since we now set the kind to 'identifier' here, the binary_search check in 
the formatter is unnecessary. Updated the formatter to no longer do the check. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117416

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


[clang] 56cc697 - [clang][dataflow] Merge distinct pointer values in Environment::join

2022-01-29 Thread Stanislav Gatev via cfe-commits

Author: Stanislav Gatev
Date: 2022-01-29T16:33:15Z
New Revision: 56cc697323445337134cc2bbe8ce8b1f60131574

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

LOG: [clang][dataflow] Merge distinct pointer values in Environment::join

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Reviewed-by: ymandel, xazax.hun

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

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 938f7338b6403..8392f959d798e 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -89,8 +89,12 @@ LatticeJoinEffect Environment::join(const Environment ,
   if (ExprToLocSizeBefore != ExprToLoc.size())
 Effect = LatticeJoinEffect::Changed;
 
-  llvm::DenseMap MergedLocToVal;
-  for (auto  : LocToVal) {
+  // Move `LocToVal` so that `Environment::Merger::merge` can safely assign
+  // values to storage locations while this code iterates over the current
+  // assignments.
+  llvm::DenseMap OldLocToVal =
+  std::move(LocToVal);
+  for (auto  : OldLocToVal) {
 const StorageLocation *Loc = Entry.first;
 assert(Loc != nullptr);
 
@@ -103,19 +107,25 @@ LatticeJoinEffect Environment::join(const Environment 
,
 assert(It->second != nullptr);
 
 if (It->second == Val) {
-  MergedLocToVal.insert({Loc, Val});
+  LocToVal.insert({Loc, Val});
   continue;
 }
 
+if (auto *FirstVal = dyn_cast(Val)) {
+  auto *SecondVal = cast(It->second);
+  if (>getPointeeLoc() == >getPointeeLoc()) {
+LocToVal.insert({Loc, FirstVal});
+continue;
+  }
+}
+
 // FIXME: Consider destroying `MergedValue` immediately if `Merger::merge`
 // returns false to avoid storing unneeded values in `DACtx`.
 if (Value *MergedVal = createValue(Loc->getType()))
   if (Merger.merge(Loc->getType(), *Val, *It->second, *MergedVal, *this))
-MergedLocToVal.insert({Loc, MergedVal});
+LocToVal.insert({Loc, MergedVal});
   }
-  const unsigned LocToValSizeBefore = LocToVal.size();
-  LocToVal = std::move(MergedLocToVal);
-  if (LocToValSizeBefore != LocToVal.size())
+  if (OldLocToVal.size() != LocToVal.size())
 Effect = LatticeJoinEffect::Changed;
 
   return Effect;

diff  --git 
a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
index ee0bc3ed5e251..e9d5e129e32d6 100644
--- a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -494,4 +494,37 @@ TEST_F(WideningTest, JoinDistinctValuesWithSameProperties) 
{
   });
 }
 
+TEST_F(WideningTest, DistinctPointersToTheSameLocation) {
+  std::string Code = R"(
+void target(int Foo, bool Cond) {
+  int *Bar = 
+  while (Cond) {
+Bar = 
+  }
+  (void)0;
+  // [[p]]
+}
+  )";
+  runDataflow(Code,
+  [](llvm::ArrayRef<
+ std::pair>>
+ Results,
+ ASTContext ) {
+ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+const Environment  = Results[0].second.Env;
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+
+const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
+ASSERT_THAT(BarDecl, NotNull());
+
+const auto *FooLoc = cast(
+Env.getStorageLocation(*FooDecl, SkipPast::None));
+const auto *BarVal =
+cast(Env.getValue(*BarDecl, SkipPast::None));
+EXPECT_EQ(>getPointeeLoc(), FooLoc);
+  });
+}
+
 } // namespace



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


[PATCH] D118480: [clang][dataflow] Merge distinct pointer values in Environment::join

2022-01-29 Thread Stanislav Gatev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG56cc69732344: [clang][dataflow] Merge distinct pointer 
values in Environment::join (authored by sgatev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118480

Files:
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp


Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -494,4 +494,37 @@
   });
 }
 
+TEST_F(WideningTest, DistinctPointersToTheSameLocation) {
+  std::string Code = R"(
+void target(int Foo, bool Cond) {
+  int *Bar = 
+  while (Cond) {
+Bar = 
+  }
+  (void)0;
+  // [[p]]
+}
+  )";
+  runDataflow(Code,
+  [](llvm::ArrayRef<
+ std::pair>>
+ Results,
+ ASTContext ) {
+ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+const Environment  = Results[0].second.Env;
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+
+const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
+ASSERT_THAT(BarDecl, NotNull());
+
+const auto *FooLoc = cast(
+Env.getStorageLocation(*FooDecl, SkipPast::None));
+const auto *BarVal =
+cast(Env.getValue(*BarDecl, SkipPast::None));
+EXPECT_EQ(>getPointeeLoc(), FooLoc);
+  });
+}
+
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -89,8 +89,12 @@
   if (ExprToLocSizeBefore != ExprToLoc.size())
 Effect = LatticeJoinEffect::Changed;
 
-  llvm::DenseMap MergedLocToVal;
-  for (auto  : LocToVal) {
+  // Move `LocToVal` so that `Environment::Merger::merge` can safely assign
+  // values to storage locations while this code iterates over the current
+  // assignments.
+  llvm::DenseMap OldLocToVal =
+  std::move(LocToVal);
+  for (auto  : OldLocToVal) {
 const StorageLocation *Loc = Entry.first;
 assert(Loc != nullptr);
 
@@ -103,19 +107,25 @@
 assert(It->second != nullptr);
 
 if (It->second == Val) {
-  MergedLocToVal.insert({Loc, Val});
+  LocToVal.insert({Loc, Val});
   continue;
 }
 
+if (auto *FirstVal = dyn_cast(Val)) {
+  auto *SecondVal = cast(It->second);
+  if (>getPointeeLoc() == >getPointeeLoc()) {
+LocToVal.insert({Loc, FirstVal});
+continue;
+  }
+}
+
 // FIXME: Consider destroying `MergedValue` immediately if `Merger::merge`
 // returns false to avoid storing unneeded values in `DACtx`.
 if (Value *MergedVal = createValue(Loc->getType()))
   if (Merger.merge(Loc->getType(), *Val, *It->second, *MergedVal, *this))
-MergedLocToVal.insert({Loc, MergedVal});
+LocToVal.insert({Loc, MergedVal});
   }
-  const unsigned LocToValSizeBefore = LocToVal.size();
-  LocToVal = std::move(MergedLocToVal);
-  if (LocToValSizeBefore != LocToVal.size())
+  if (OldLocToVal.size() != LocToVal.size())
 Effect = LatticeJoinEffect::Changed;
 
   return Effect;


Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -494,4 +494,37 @@
   });
 }
 
+TEST_F(WideningTest, DistinctPointersToTheSameLocation) {
+  std::string Code = R"(
+void target(int Foo, bool Cond) {
+  int *Bar = 
+  while (Cond) {
+Bar = 
+  }
+  (void)0;
+  // [[p]]
+}
+  )";
+  runDataflow(Code,
+  [](llvm::ArrayRef<
+ std::pair>>
+ Results,
+ ASTContext ) {
+ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+const Environment  = Results[0].second.Env;
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+
+const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
+ASSERT_THAT(BarDecl, NotNull());
+
+const auto *FooLoc = cast(
+Env.getStorageLocation(*FooDecl, 

[PATCH] D107290: [RISCV] Add support for the vscale_range attribute

2022-01-29 Thread Zakk Chen via Phabricator via cfe-commits
khchen added inline comments.



Comment at: llvm/test/CodeGen/RISCV/rvv/fixed-vectors-vscale-range.ll:162
+
+attributes #0 = { vscale_range(2,1024) }
+attributes #1 = { vscale_range(4,1024) }

frasercrmck wrote:
> khchen wrote:
> > frasercrmck wrote:
> > > khchen wrote:
> > > > frasercrmck wrote:
> > > > > khchen wrote:
> > > > > > I'm thinking do we need to test zvl and vscale_range in the same 
> > > > > > attribute?
> > > > > > ex. `attributes #0 = { vscale_range(2,1024) 
> > > > > > "target-features"="+zvl512b" }`
> > > > > Perhaps yeah. Just to check - what exactly for? Because we need `zvl` 
> > > > > in the attributes for correctness, or in order to test the 
> > > > > combination of `zvl` architecture and `vscale_range` to test what 
> > > > > happens when they disagree?
> > > > Just test for they disagree.
> > > > Do you know what's expected value for different `vscale_range` value in 
> > > > two function after function inlining? If they are always have the same 
> > > > minimum value for VLEN, I think we don't need a check.
> > > Good idea.
> > > 
> > > As for inlining, I can't see anything that would //prevent// inlining of 
> > > functions with different `vscale_range` attributes, per se. However, I 
> > > was looking at `TTI::areInlineCompatible` and the default implementation 
> > > checks whether CPU/Feature Strings are equivalent. The frontend should 
> > > ensure that `vscale_range` attributes match up 1:1 with our `+zvl` 
> > > feature strings so I think in practice we won't inline functions with 
> > > different `zvl` values in clang-generated C/C++ code. But users could 
> > > write IR with different `vscale_range` attributes and we'd happily inline 
> > > them, which sounds fishy. What do you think?
> > Thanks for investigation!!! 
> > I think we can postpone this inline issue until we really need to fix it. 
> > at least the function would keep the feature string, which may include 
> > zvl*b, right?
> > 
> > BTW, could you please try the C code in https://godbolt.org/z/6hfTaxTj5 to 
> > see what's `vscale_range` value for function `vadd256` and `vadd512`? Are 
> > they expected value?
> > 
> > 
> Yeah the feature string looks to contain `zvl*b` as we expect -- in simple 
> cases (see below). I've updated this test to check for them too.
> 
> Thanks for the example! I tried it. We have a couple of issues.
> 
> Firstly, the `vscale_range` is not correctly set for the functions. It is 
> taken from whichever `zvl*b` we set on the command line. If I do 
> `-target-feature +zvl128b` all functions have `vscale_range(2,1024)`, if I do 
> `-target-feature +zvl256b` all functions have `(4,1024)`, etc. So something's 
> not being communicated properly.
> 
> The second issue is that, because of this (I think) when using the non-CC1 
> driver, the subtarget initialization crashes if I compile with 
> `-march=rv64gcv` or any `zvl*b` up to `-march=rv64gcv_zvl512b1p0` because the 
> `-march` we specify there determines the `vscale_range` which in turn 
> determines `RVVBitsMin`, but that's "lower than the Zvl*b limitation" so an 
> assert triggers.
Sorry, I have no idea about what's good way to fix them, or maybe RISC-V has 
not already supported ifunc then we could ignore this example, I'm not sure.

BTW, I'm wondering why we want to support `vscale_range` attribute in RISC-V V.
Could we get any benefit after supporting it? 
It seems like SVE does not have a way to encode vector length information, so 
it must introduce a new function attribute `vscale_range` in IR.
But in RISC-V V, we already have zvl*b target-feature to get the minimum vlen 
information, and the maximum vlen is always 65536. In addition, we also have 
default implication rule for zvl*b depend on V/Zve*.

It seem like we are trying to support users's manually IRs which have 
`vscale_range` without zvl*b target-feature, is it?  
Or am I misunderstanding the intention?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107290

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


[PATCH] D118518: [clang][NFC] Change some ->getType()->isPlaceholderType() to just ->hasPlaceholderType()

2022-01-29 Thread Arthur O'Dwyer via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG424400da2db8: [clang][NFC] Change some 
-getType()-isPlaceholderType() to just… (authored by arthur.j.odwyer).

Changed prior to commit:
  https://reviews.llvm.org/D118518?vs=404198=404265#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118518

Files:
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp

Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -564,7 +564,7 @@
 SourceLocation RParenLoc) {
   bool WasEvaluated = false;
   if (E && !E->isTypeDependent()) {
-if (E->getType()->isPlaceholderType()) {
+if (E->hasPlaceholderType()) {
   ExprResult result = CheckPlaceholderExpr(E);
   if (result.isInvalid()) return ExprError();
   E = result.get();
@@ -5704,7 +5704,7 @@
   SourceLocation RParen) {
   if (Queried->isTypeDependent()) {
 // Delay type-checking for type-dependent expressions.
-  } else if (Queried->getType()->isPlaceholderType()) {
+  } else if (Queried->hasPlaceholderType()) {
 ExprResult PE = CheckPlaceholderExpr(Queried);
 if (PE.isInvalid()) return ExprError();
 return BuildExpressionTrait(ET, KWLoc, PE.get(), RParen);
@@ -5720,8 +5720,7 @@
 ExprValueKind ,
 SourceLocation Loc,
 bool isIndirect) {
-  assert(!LHS.get()->getType()->isPlaceholderType() &&
- !RHS.get()->getType()->isPlaceholderType() &&
+  assert(!LHS.get()->hasPlaceholderType() && !RHS.get()->hasPlaceholderType() &&
  "placeholders should have been weeded out by now");
 
   // The LHS undergoes lvalue conversions if this is ->*, and undergoes the
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -497,7 +497,7 @@
 /// DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
 ExprResult Sema::DefaultFunctionArrayConversion(Expr *E, bool Diagnose) {
   // Handle any placeholder expressions which made it here.
-  if (E->getType()->isPlaceholderType()) {
+  if (E->hasPlaceholderType()) {
 ExprResult result = CheckPlaceholderExpr(E);
 if (result.isInvalid()) return ExprError();
 E = result.get();
@@ -621,7 +621,7 @@
 
 ExprResult Sema::DefaultLvalueConversion(Expr *E) {
   // Handle any placeholder expressions which made it here.
-  if (E->getType()->isPlaceholderType()) {
+  if (E->hasPlaceholderType()) {
 ExprResult result = CheckPlaceholderExpr(E);
 if (result.isInvalid()) return ExprError();
 E = result.get();
@@ -4685,7 +4685,7 @@
 Sema::ActOnArraySubscriptExpr(Scope *S, Expr *base, SourceLocation lbLoc,
   Expr *idx, SourceLocation rbLoc) {
   if (base && !base->getType().isNull() &&
-  base->getType()->isSpecificPlaceholderType(BuiltinType::OMPArraySection))
+  base->hasPlaceholderType(BuiltinType::OMPArraySection))
 return ActOnOMPArraySectionExpr(base, lbLoc, idx, SourceLocation(),
 SourceLocation(), /*Length*/ nullptr,
 /*Stride=*/nullptr, rbLoc);
@@ -4711,8 +4711,7 @@
   };
   // The matrix subscript operator ([][])is considered a single operator.
   // Separating the index expressions by parenthesis is not allowed.
-  if (base->getType()->isSpecificPlaceholderType(
-  BuiltinType::IncompleteMatrixIdx) &&
+  if (base->hasPlaceholderType(BuiltinType::IncompleteMatrixIdx) &&
   !isa(base)) {
 Diag(base->getExprLoc(), diag::err_matrix_separate_incomplete_index)
 << SourceRange(base->getBeginLoc(), rbLoc);
@@ -4944,9 +4943,8 @@
   SourceLocation ColonLocSecond,
   Expr *Length, Expr *Stride,
   SourceLocation RBLoc) {
-  if (Base->getType()->isPlaceholderType() &&
-  !Base->getType()->isSpecificPlaceholderType(
-  BuiltinType::OMPArraySection)) {
+  if (Base->hasPlaceholderType() &&
+  !Base->hasPlaceholderType(BuiltinType::OMPArraySection)) {
 ExprResult Result = CheckPlaceholderExpr(Base);
 if (Result.isInvalid())
   return ExprError();
@@ -5114,8 +5112,7 @@
 }
   }
 
-  if (!Base->getType()->isSpecificPlaceholderType(
-  BuiltinType::OMPArraySection)) {
+  if (!Base->hasPlaceholderType(BuiltinType::OMPArraySection)) {
 ExprResult Result = DefaultFunctionArrayLvalueConversion(Base);
 if (Result.isInvalid())
   return 

[clang] 424400d - [clang][NFC] Change some ->getType()->isPlaceholderType() to just ->hasPlaceholderType()

2022-01-29 Thread Arthur O'Dwyer via cfe-commits

Author: Arthur O'Dwyer
Date: 2022-01-29T10:20:22-05:00
New Revision: 424400da2db86558917e6da19a821e160acc48d1

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

LOG: [clang][NFC] Change some ->getType()->isPlaceholderType() to just 
->hasPlaceholderType()

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

Added: 


Modified: 
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCoroutine.cpp 
b/clang/lib/Sema/SemaCoroutine.cpp
index e7e60b7e7daf..cd3ae62ebbe2 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -810,7 +810,7 @@ ExprResult Sema::ActOnCoawaitExpr(Scope *S, SourceLocation 
Loc, Expr *E) {
 
   checkSuspensionContext(*this, Loc, "co_await");
 
-  if (E->getType()->isPlaceholderType()) {
+  if (E->hasPlaceholderType()) {
 ExprResult R = CheckPlaceholderExpr(E);
 if (R.isInvalid()) return ExprError();
 E = R.get();
@@ -828,7 +828,7 @@ ExprResult Sema::BuildUnresolvedCoawaitExpr(SourceLocation 
Loc, Expr *E,
   if (!FSI)
 return ExprError();
 
-  if (E->getType()->isPlaceholderType()) {
+  if (E->hasPlaceholderType()) {
 ExprResult R = CheckPlaceholderExpr(E);
 if (R.isInvalid())
   return ExprError();
@@ -866,7 +866,7 @@ ExprResult Sema::BuildResolvedCoawaitExpr(SourceLocation 
Loc, Expr *E,
   if (!Coroutine)
 return ExprError();
 
-  if (E->getType()->isPlaceholderType()) {
+  if (E->hasPlaceholderType()) {
 ExprResult R = CheckPlaceholderExpr(E);
 if (R.isInvalid()) return ExprError();
 E = R.get();
@@ -927,7 +927,7 @@ ExprResult Sema::BuildCoyieldExpr(SourceLocation Loc, Expr 
*E) {
   if (!Coroutine)
 return ExprError();
 
-  if (E->getType()->isPlaceholderType()) {
+  if (E->hasPlaceholderType()) {
 ExprResult R = CheckPlaceholderExpr(E);
 if (R.isInvalid()) return ExprError();
 E = R.get();
@@ -970,8 +970,8 @@ StmtResult Sema::BuildCoreturnStmt(SourceLocation Loc, Expr 
*E,
   if (!FSI)
 return StmtError();
 
-  if (E && E->getType()->isPlaceholderType() &&
-  !E->getType()->isSpecificPlaceholderType(BuiltinType::Overload)) {
+  if (E && E->hasPlaceholderType() &&
+  !E->hasPlaceholderType(BuiltinType::Overload)) {
 ExprResult R = CheckPlaceholderExpr(E);
 if (R.isInvalid()) return StmtError();
 E = R.get();

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 7de43705c2b1..85553eccde83 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -497,7 +497,7 @@ SourceRange Sema::getExprRange(Expr *E) const {
 /// DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
 ExprResult Sema::DefaultFunctionArrayConversion(Expr *E, bool Diagnose) {
   // Handle any placeholder expressions which made it here.
-  if (E->getType()->isPlaceholderType()) {
+  if (E->hasPlaceholderType()) {
 ExprResult result = CheckPlaceholderExpr(E);
 if (result.isInvalid()) return ExprError();
 E = result.get();
@@ -621,7 +621,7 @@ static void DiagnoseDirectIsaAccess(Sema , const 
ObjCIvarRefExpr *OIRE,
 
 ExprResult Sema::DefaultLvalueConversion(Expr *E) {
   // Handle any placeholder expressions which made it here.
-  if (E->getType()->isPlaceholderType()) {
+  if (E->hasPlaceholderType()) {
 ExprResult result = CheckPlaceholderExpr(E);
 if (result.isInvalid()) return ExprError();
 E = result.get();
@@ -4685,7 +4685,7 @@ ExprResult
 Sema::ActOnArraySubscriptExpr(Scope *S, Expr *base, SourceLocation lbLoc,
   Expr *idx, SourceLocation rbLoc) {
   if (base && !base->getType().isNull() &&
-  base->getType()->isSpecificPlaceholderType(BuiltinType::OMPArraySection))
+  base->hasPlaceholderType(BuiltinType::OMPArraySection))
 return ActOnOMPArraySectionExpr(base, lbLoc, idx, SourceLocation(),
 SourceLocation(), /*Length*/ nullptr,
 /*Stride=*/nullptr, rbLoc);
@@ -4711,8 +4711,7 @@ Sema::ActOnArraySubscriptExpr(Scope *S, Expr *base, 
SourceLocation lbLoc,
   };
   // The matrix subscript operator ([][])is considered a single operator.
   // Separating the index expressions by parenthesis is not allowed.
-  if (base->getType()->isSpecificPlaceholderType(
-  BuiltinType::IncompleteMatrixIdx) &&
+  if (base->hasPlaceholderType(BuiltinType::IncompleteMatrixIdx) &&
   !isa(base)) {
 Diag(base->getExprLoc(), diag::err_matrix_separate_incomplete_index)
 << SourceRange(base->getBeginLoc(), rbLoc);
@@ -4944,9 +4943,8 @@ ExprResult Sema::ActOnOMPArraySectionExpr(Expr *Base, 
SourceLocation LBLoc,
   SourceLocation ColonLocSecond,

Re: [EXTERNAL] [PATCH] D114639: Raise the minimum Visual Studio version to VS2019

2022-01-29 Thread Stella Stamenova via cfe-commits
I will take care of it today. The bot does have vs2019 installed and it should 
be picking up latest VS (and it was when I updated it), so there is an easy fix 
(remove 2017) and then I can investigate why it stopped picking up latest.

Get Outlook for iOS

From: Simon Pilgrim via Phabricator 
Sent: Saturday, January 29, 2022 3:12:52 AM
To: llvm-...@redking.me.uk ; Reid Kleckner 
; aaron.ball...@gmail.com ; 
ztur...@roblox.com ; jh7...@my.bristol.ac.uk 
; l...@meinersbur.de ; 
jan_svob...@apple.com ; greg_bedw...@sn.scee.net 
; Stella Stamenova 
Cc: jo...@devlieghere.com ; lldb-comm...@lists.llvm.org 
; h.vetin...@gmx.com ; 
vitalyb...@google.com ; jrhen...@gmail.com 
; reviews.llvm@jfbastien.com 
; erich.ke...@intel.com 
; joker@gmail.com ; Saleem 
Abdulrasool ; russell.gal...@sony.com 
; cfe-commits@lists.llvm.org 
; mgo...@gentoo.org ; 
mar...@martin.st ; llvm-comm...@lists.llvm.org 
; h.imai@nitech.jp ; 
bhuvanendra.kum...@amd.com ; gandhi21...@gmail.com 
; yanliang...@intel.com ; 
liburd1...@outlook.com ; serhiy.re...@gmail.com 
; quic_soura...@quicinc.com 
; dougp...@gmail.com ; 
david.spick...@linaro.org ; mlek...@skidmore.edu 
; blitzrak...@gmail.com ; 
shen...@google.com ; michael.hl...@gmail.com 
; bruce.mitche...@gmail.com 
; yuanfang.c...@sony.com 
Subject: [EXTERNAL] [PATCH] D114639: Raise the minimum Visual Studio version to 
VS2019

RKSimon added a comment.

@stella.stamenova It looks like the mlir-windows buildbot is still using VS2017:

  CMake Error at cmake/modules/CheckCompilerVersion.cmake:39 (message):
Host Visual Studio version must be at least 19.20, your version is
19.16.27045.0.

Are you able to make the fix or would you prefer I revert for now?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD114639%2Fnew%2Fdata=04%7C01%7Cstilis%40microsoft.com%7C1299827a2cee41cb745b08d9e3184ba9%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637790515814400729%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=WccQ1%2B3T0IE2c%2BrjkWNmZIFZFsQaaGq6NIM8gpduOpY%3Dreserved=0

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD114639data=04%7C01%7Cstilis%40microsoft.com%7C1299827a2cee41cb745b08d9e3184ba9%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637790515814400729%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=eymjF3kMlfwwx8%2Bf0B10dxYWaW%2BYkSuvmoWCCBuR2YE%3Dreserved=0

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


[PATCH] D114483: [SYCL] Add support for sycl_special_class attribute

2022-01-29 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

In D114483#3281731 , @aaron.ballman 
wrote:

> In D114483#3281718 , @aaron.ballman 
> wrote:
>
>> In D114483#3281714 , @zahiraam 
>> wrote:
>>
>>> In D114483#3280905 , @MaskRay 
>>> wrote:
>>>
 Closed by 8ba9c794feb30cd969b9776c39873def10c51bff 
 .

 If the commit message contained `Differential Revision:`, the differential 
 would be closely automatically when you pushed it to the git repo.
 Please ensure the tag is contained next time. `arc diff` adds this tag 
 automatically.

 `clang/include/clang/Basic/AttrDocs.td` had some formatting issues and 
 caused (`-DLLVM_ENABLE_SPHINX=ON`) `ninja docs-clang-html` to fail.
 I fixed it. Please test this build target for `.rst` and `AttrDocs.td` 
 changes.
>>>
>>> @MaskRay OK thanks. I see other clang-format issues. Should those be fixed 
>>> too?
>>
>> The issues aren't from clang-format, they're from the RST file contents not 
>> building in sphinx due to formatting issues in AttrDocs.td.
>>
>> https://lab.llvm.org/buildbot/#/builders/92/builds/20791/steps/5/logs/stdio
>> https://lab.llvm.org/buildbot/#/builders/92/builds/21098/steps/5/logs/stdio
>>
>> are two such examples that stem from your patch. Basically, you have to 
>> build the attribute documentation (converting AttrDocs.td into 
>> AttributeReference.rst) and then build the sphinx documents locally to 
>> ensure you're not introducing new issues. Or, you can try to speculatively 
>> fix based on the errors the bot gives you, but sometimes those errors are 
>> super cryptic and take multiple tries to fix (like the "can't lex as C++" 
>> one above), which is why trying to reproduce locally is a good first step.
>
> I've pushed a fix for it in a10ff373ddfa82a67c580a87f6258aa6ab8dd595 
>  and the 
> sphinx builder is happy again.

Thanks @aaron.ballman !


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

https://reviews.llvm.org/D114483

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


[PATCH] D114483: [SYCL] Add support for sycl_special_class attribute

2022-01-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D114483#3281718 , @aaron.ballman 
wrote:

> In D114483#3281714 , @zahiraam 
> wrote:
>
>> In D114483#3280905 , @MaskRay 
>> wrote:
>>
>>> Closed by 8ba9c794feb30cd969b9776c39873def10c51bff 
>>> .
>>>
>>> If the commit message contained `Differential Revision:`, the differential 
>>> would be closely automatically when you pushed it to the git repo.
>>> Please ensure the tag is contained next time. `arc diff` adds this tag 
>>> automatically.
>>>
>>> `clang/include/clang/Basic/AttrDocs.td` had some formatting issues and 
>>> caused (`-DLLVM_ENABLE_SPHINX=ON`) `ninja docs-clang-html` to fail.
>>> I fixed it. Please test this build target for `.rst` and `AttrDocs.td` 
>>> changes.
>>
>> @MaskRay OK thanks. I see other clang-format issues. Should those be fixed 
>> too?
>
> The issues aren't from clang-format, they're from the RST file contents not 
> building in sphinx due to formatting issues in AttrDocs.td.
>
> https://lab.llvm.org/buildbot/#/builders/92/builds/20791/steps/5/logs/stdio
> https://lab.llvm.org/buildbot/#/builders/92/builds/21098/steps/5/logs/stdio
>
> are two such examples that stem from your patch. Basically, you have to build 
> the attribute documentation (converting AttrDocs.td into 
> AttributeReference.rst) and then build the sphinx documents locally to ensure 
> you're not introducing new issues. Or, you can try to speculatively fix based 
> on the errors the bot gives you, but sometimes those errors are super cryptic 
> and take multiple tries to fix (like the "can't lex as C++" one above), which 
> is why trying to reproduce locally is a good first step.

I've pushed a fix for it in a10ff373ddfa82a67c580a87f6258aa6ab8dd595 
 and the 
sphinx builder is happy again.


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

https://reviews.llvm.org/D114483

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


[clang] a10ff37 - Speculatively fix the sphinx build for Clang's attribute reference

2022-01-29 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-01-29T09:39:26-05:00
New Revision: a10ff373ddfa82a67c580a87f6258aa6ab8dd595

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

LOG: Speculatively fix the sphinx build for Clang's attribute reference

Added: 


Modified: 
clang/include/clang/Basic/AttrDocs.td

Removed: 




diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 67a69bc9fd59e..efd2af1ab1df3 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -432,7 +432,7 @@ implementation detail and not intended to be used by 
external users.
 
 The syntax of the attribute is as follows:
 
-.. code-block:: c++
+.. code-block:: text
 
   class __attribute__((sycl_special_class)) accessor {};
   class [[clang::sycl_special_class]] accessor {};



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


[PATCH] D118445: [clang][AVR] Set '-fno-use-cxa-atexit' to default

2022-01-29 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

fixes https://github.com/llvm/llvm-project/issues/50631


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

https://reviews.llvm.org/D118445

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


[PATCH] D118428: [clang-cl] Support the /JMC flag

2022-01-29 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a reviewer: mstorsjo.
aganea added a subscriber: belkiss.
aganea added a comment.

Cool! :) Seems good generally.
Sounds like an expensive flag for the runtime perf :-D But I guess it makes the 
debugging experience a bit nicer.




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:7457
+   /*Default=*/false)) {
+if (EnabledZ7)
+  CmdArgs.push_back("-fjmc");

Can we do here `if (*EmitCodeView && *DebugInfoKind >= 
codegenoptions::DebugInfoConstructor)`? Is it worth introducing a new variable?



Comment at: clang/test/Driver/cl-options.c:782
+// JMCZ7: -fjmc
+
 void f() { }

Perhaps add a test `%clang_cl /JMC /JMC-`



Comment at: llvm/lib/CodeGen/JMCInstrumenter.cpp:131
+
+  // Add a linker options /alternatename to set the default implementation for
+  // the check function.

s/options/option/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118428

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


[PATCH] D114483: [SYCL] Add support for sycl_special_class attribute

2022-01-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D114483#3281714 , @zahiraam wrote:

> In D114483#3280905 , @MaskRay wrote:
>
>> Closed by 8ba9c794feb30cd969b9776c39873def10c51bff 
>> .
>>
>> If the commit message contained `Differential Revision:`, the differential 
>> would be closely automatically when you pushed it to the git repo.
>> Please ensure the tag is contained next time. `arc diff` adds this tag 
>> automatically.
>>
>> `clang/include/clang/Basic/AttrDocs.td` had some formatting issues and 
>> caused (`-DLLVM_ENABLE_SPHINX=ON`) `ninja docs-clang-html` to fail.
>> I fixed it. Please test this build target for `.rst` and `AttrDocs.td` 
>> changes.
>
> @MaskRay OK thanks. I see other clang-format issues. Should those be fixed 
> too?

The issues aren't from clang-format, they're from the RST file contents not 
building in sphinx due to formatting issues in AttrDocs.td.

https://lab.llvm.org/buildbot/#/builders/92/builds/20791/steps/5/logs/stdio
https://lab.llvm.org/buildbot/#/builders/92/builds/21098/steps/5/logs/stdio

are two such examples that stem from your patch. Basically, you have to build 
the attribute documentation (converting AttrDocs.td into 
AttributeReference.rst) and then build the sphinx documents locally to ensure 
you're not introducing new issues. Or, you can try to speculatively fix based 
on the errors the bot gives you, but sometimes those errors are super cryptic 
and take multiple tries to fix (like the "can't lex as C++" one above), which 
is why trying to reproduce locally is a good first step.


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

https://reviews.llvm.org/D114483

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


[PATCH] D114483: [SYCL] Add support for sycl_special_class attribute

2022-01-29 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

In D114483#3280905 , @MaskRay wrote:

> Closed by 8ba9c794feb30cd969b9776c39873def10c51bff 
> .
>
> If the commit message contained `Differential Revision:`, the differential 
> would be closely automatically when you pushed it to the git repo.
> Please ensure the tag is contained next time. `arc diff` adds this tag 
> automatically.
>
> `clang/include/clang/Basic/AttrDocs.td` had some formatting issues and caused 
> (`-DLLVM_ENABLE_SPHINX=ON`) `ninja docs-clang-html` to fail.
> I fixed it. Please test this build target for `.rst` and `AttrDocs.td` 
> changes.

@MaskRay OK thanks. I see other clang-format issues. Should those be fixed too?


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

https://reviews.llvm.org/D114483

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


[PATCH] D118050: [analyzer] Different address spaces cannot overlap

2022-01-29 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers marked an inline comment as done.
vabridgers added a comment.

Thanks for the comments, I'll address. Best


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118050

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


[PATCH] D118532: Fix -Wreserved-identifier in presence of system macro

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

LGTM with a minor nit




Comment at: clang/lib/Sema/SemaDecl.cpp:5720
   if (Status != ReservedIdentifierStatus::NotReserved &&
-  !Context.getSourceManager().isInSystemHeader(D->getLocation()))
+  !(isFromSystemHeader(Context.getSourceManager(), D))) {
 Diag(D->getLocation(), diag::warn_reserved_extern_symbol)




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118532

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


[PATCH] D118519: [clang-tidy] Organize the release notes a little better

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118519

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


[PATCH] D117238: [C2x] Add BITINT_MAXWIDTH support

2022-01-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D117238#3281010 , @jkorous wrote:

> I verified locally that reverting this patch fixes the build.
> Reverted in fad7e491a0770ac4336934030ac67d77e7af5520 
>  to 
> unblock Green Dragon, etc.
> @aaron.ballman Please take a look when you get a chance.

Thank you for the revert and sorry for not noticing the breakage sooner! I've 
corrected the issue in a6cabd98021fe357d14601eca2031bf775de 
 and 
re-committed. I'll keep an eye on the bots this morning to see if there's any 
further fallout.


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

https://reviews.llvm.org/D117238

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


[clang] a6cabd9 - Revert fad7e491a0770ac4336934030ac67d77e7af5520 with fixes applied

2022-01-29 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-01-29T08:12:16-05:00
New Revision: a6cabd98021fe357d14601eca2031bf775de

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

LOG: Revert fad7e491a0770ac4336934030ac67d77e7af5520 with fixes applied

fad7e491a0770ac4336934030ac67d77e7af5520 was a revert of
86797fdb6f51d32f285e48b6d3e0fc5b8b852734 due to build failures. This
hopefully fixes them.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/TargetInfo.h
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Headers/limits.h
clang/lib/Sema/SemaType.cpp
clang/test/CodeGen/ext-int-cc.c
clang/test/CodeGen/ext-int.c
clang/test/CodeGenCXX/ext-int.cpp
clang/test/Headers/limits.cpp
clang/test/Preprocessor/init-aarch64.c
clang/test/Preprocessor/init.c
clang/test/Sema/builtins-overflow.c
clang/test/SemaCXX/ext-int.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f081ff0313e0a..4b444bece68a7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -174,7 +174,12 @@ C Language Changes in Clang
   ``_BitInt(N)`` is supported as an extension in older C modes and in all C++
   modes. Note: the ABI for ``_BitInt(N)`` is still in the process of being
   stabilized, so this type should not yet be used in interfaces that require
-  ABI stability.
+  ABI stability. The maximum width supported by Clang can be obtained from the
+  ``BITINT_MAXWIDTH`` macro in . Currently, Clang supports bit
+  widths <= 128 because backends are not yet able to cope with some math
+  operations (like division) on wider integer types. See
+  `PR44994 `_ for more
+  information.
 - When using ``asm goto`` with outputs whose constraint modifier is ``"+"``, we
   now change the numbering of the labels to occur after hidden tied inputs for
   better compatibility with GCC.  For better portability between 
diff erent

diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 642c8500364bb..a49342a34f3e8 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -590,6 +590,17 @@ class TargetInfo : public virtual TransferrableTargetInfo,
 return false;
   }
 
+  // Different targets may support a 
diff erent maximum width for the _BitInt
+  // type, depending on what operations are supported.
+  virtual size_t getMaxBitIntWidth() const {
+// FIXME: this value should be llvm::IntegerType::MAX_INT_BITS, which is
+// maximum bit width that LLVM claims its IR can support. However, most
+// backends currently have a bug where they only support division
+// operations on types that are <= 128 bits and crash otherwise. We're
+// setting the max supported value to 128 to be conservative.
+return 128;
+  }
+
   /// Determine whether _Float16 is supported on this target.
   virtual bool hasLegalHalfType() const { return HasLegalHalfType; }
 

diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index a9023a7a1171e..e259ab47c5589 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -25,6 +25,7 @@
 #include "clang/Serialization/ASTReader.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/IR/DataLayout.h"
+#include "llvm/IR/DerivedTypes.h"
 using namespace clang;
 
 static bool MacroBodyEndsInBackslash(StringRef MacroBody) {
@@ -914,6 +915,13 @@ static void InitializePredefinedMacros(const TargetInfo 
,
   Builder.defineMacro("__LONG_WIDTH__", Twine(TI.getLongWidth()));
   Builder.defineMacro("__LLONG_WIDTH__", Twine(TI.getLongLongWidth()));
 
+  size_t BitIntMaxWidth = TI.getMaxBitIntWidth();
+  assert(BitIntMaxWidth <= llvm::IntegerType::MAX_INT_BITS &&
+ "Target defined a max bit width larger than LLVM can support!");
+  assert(BitIntMaxWidth >= TI.getLongLongWidth() &&
+ "Target defined a max bit width smaller than the C standard allows!");
+  Builder.defineMacro("__BITINT_MAXWIDTH__", Twine(BitIntMaxWidth));
+
   DefineTypeSize("__SCHAR_MAX__", TargetInfo::SignedChar, TI, Builder);
   DefineTypeSize("__SHRT_MAX__", TargetInfo::SignedShort, TI, Builder);
   DefineTypeSize("__INT_MAX__", TargetInfo::SignedInt, TI, Builder);

diff  --git a/clang/lib/Headers/limits.h b/clang/lib/Headers/limits.h
index c2d3a7cf43539..cfd23a219ee55 100644
--- a/clang/lib/Headers/limits.h
+++ b/clang/lib/Headers/limits.h
@@ -78,6 +78,8 @@
 #define LONG_WIDTH   __LONG_WIDTH__
 #define ULLONG_WIDTH __LLONG_WIDTH__
 #define LLONG_WIDTH  __LLONG_WIDTH__
+
+#define BITINT_MAXWIDTH __BITINT_MAXWIDTH__
 #endif
 
 #ifdef __CHAR_UNSIGNED__  /* -funsigned-char */

diff  

[PATCH] D118535: [clang] Move XCore specific options from Clang.cpp to XCore.cpp

2022-01-29 Thread Ben Shi via Phabricator via cfe-commits
benshi001 created this revision.
benshi001 added reviewers: MaskRay, rsmith.
benshi001 requested review of this revision.
Herald added subscribers: cfe-commits, jacquesguan.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118535

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/XCore.cpp
  clang/test/Driver/xcore-opts.c


Index: clang/test/Driver/xcore-opts.c
===
--- clang/test/Driver/xcore-opts.c
+++ clang/test/Driver/xcore-opts.c
@@ -4,9 +4,8 @@
 // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck 
-check-prefix CHECK-G0 %s
 
 // CHECK: "-mframe-pointer=none"
-// CHECK: "-nostdsysteminc"
+// CHECK: "-nostdsysteminc" "-fno-use-cxa-atexit"
 // CHECK: "-fno-signed-char"
-// CHECK: "-fno-use-cxa-atexit"
 // CHECK-NOT: "-fcxx-exceptions"
 // CHECK-NOT: "-fexceptions"
 // CHECK-NOT: "-fcommon"
@@ -30,4 +29,3 @@
 // CHECK-G0: xcc"
 // CHECK-G0-NOT: "-g"
 // CHECK-G0: xcc"
-
Index: clang/lib/Driver/ToolChains/XCore.cpp
===
--- clang/lib/Driver/ToolChains/XCore.cpp
+++ clang/lib/Driver/ToolChains/XCore.cpp
@@ -130,6 +130,10 @@
ArgStringList ,
Action::OffloadKind) const {
   CC1Args.push_back("-nostdsysteminc");
+  // Set `-fno-use-cxa-atexit` to default.
+  if (!DriverArgs.hasFlag(options::OPT_fuse_cxa_atexit,
+  options::OPT_fno_use_cxa_atexit, false))
+CC1Args.push_back("-fno-use-cxa-atexit");
 }
 
 void XCoreToolChain::AddClangCXXStdlibIncludeArgs(
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6266,7 +6266,6 @@
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
   !RawTriple.isOSAIX() && !RawTriple.isOSWindows() &&
-  TC.getArch() != llvm::Triple::xcore &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)


Index: clang/test/Driver/xcore-opts.c
===
--- clang/test/Driver/xcore-opts.c
+++ clang/test/Driver/xcore-opts.c
@@ -4,9 +4,8 @@
 // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-G0 %s
 
 // CHECK: "-mframe-pointer=none"
-// CHECK: "-nostdsysteminc"
+// CHECK: "-nostdsysteminc" "-fno-use-cxa-atexit"
 // CHECK: "-fno-signed-char"
-// CHECK: "-fno-use-cxa-atexit"
 // CHECK-NOT: "-fcxx-exceptions"
 // CHECK-NOT: "-fexceptions"
 // CHECK-NOT: "-fcommon"
@@ -30,4 +29,3 @@
 // CHECK-G0: xcc"
 // CHECK-G0-NOT: "-g"
 // CHECK-G0: xcc"
-
Index: clang/lib/Driver/ToolChains/XCore.cpp
===
--- clang/lib/Driver/ToolChains/XCore.cpp
+++ clang/lib/Driver/ToolChains/XCore.cpp
@@ -130,6 +130,10 @@
ArgStringList ,
Action::OffloadKind) const {
   CC1Args.push_back("-nostdsysteminc");
+  // Set `-fno-use-cxa-atexit` to default.
+  if (!DriverArgs.hasFlag(options::OPT_fuse_cxa_atexit,
+  options::OPT_fno_use_cxa_atexit, false))
+CC1Args.push_back("-fno-use-cxa-atexit");
 }
 
 void XCoreToolChain::AddClangCXXStdlibIncludeArgs(
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6266,7 +6266,6 @@
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
   !RawTriple.isOSAIX() && !RawTriple.isOSWindows() &&
-  TC.getArch() != llvm::Triple::xcore &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118385: [NFC] Optimize FoldingSet usage where it matters

2022-01-29 Thread Dawid Jurczak via Phabricator via cfe-commits
yurai007 added a comment.

In D118385#3281620 , @nikic wrote:

> It might make sense to split this into individual changes, so it's clearer 
> what impact each of them has.
>
> I tested just moving the `AddXYZ` methods into the header, which had a large 
> positive impact: 
> https://llvm-compile-time-tracker.com/compare.php?from=784e01abca65722df8969b56d2d240cf9ced9c85=179ee195b8ce9f483827f843fc063388aed7f0d1=instructions
>
> Moving hashing into the header has smaller impact: 
> https://llvm-compile-time-tracker.com/compare.php?from=179ee195b8ce9f483827f843fc063388aed7f0d1=5735a8981d5cf00281490989d02d7771b95cda51=instructions

Thanks for extra measurements. Yes, splitting it make sense. I will do it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118385

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


[PATCH] D118527: [X86] Promote default mtune from generic to sandybridge

2022-01-29 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei abandoned this revision.
pengfei added a comment.

New approch D118534 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118527

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


[PATCH] D118385: [NFC] Optimize FoldingSet usage where it matters

2022-01-29 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

It might make sense to split this into individual changes, so it's clearer what 
impact each of them has.

I tested just moving the `AddXYZ` methods into the header, which had a large 
positive impact: 
https://llvm-compile-time-tracker.com/compare.php?from=784e01abca65722df8969b56d2d240cf9ced9c85=179ee195b8ce9f483827f843fc063388aed7f0d1=instructions

Moving hashing into the header has smaller impact: 
https://llvm-compile-time-tracker.com/compare.php?from=179ee195b8ce9f483827f843fc063388aed7f0d1=5735a8981d5cf00281490989d02d7771b95cda51=instructions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118385

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


[PATCH] D114639: Raise the minimum Visual Studio version to VS2019

2022-01-29 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

@stella.stamenova It looks like the mlir-windows buildbot is still using VS2017:

  CMake Error at cmake/modules/CheckCompilerVersion.cmake:39 (message):
Host Visual Studio version must be at least 19.20, your version is
19.16.27045.0.

Are you able to make the fix or would you prefer I revert for now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114639

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


[PATCH] D118480: [clang][dataflow] Merge distinct pointer values in Environment::join

2022-01-29 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp:114
 
+if (auto *FirstVal = dyn_cast(Val)) {
+  auto *SecondVal = cast(It->second);

sgatev wrote:
> xazax.hun wrote:
> > xazax.hun wrote:
> > > xazax.hun wrote:
> > > > Shouldn't we ensure that `operator==` return true when we have two 
> > > > `PointerValue`s with the same pointee above? That would make this piece 
> > > > of code redundant.
> > > Never mind, just realized the above is comparing pointers. But I still 
> > > think we might want to have a separate `operator==` for `Value`s as we 
> > > might want to compare values in many separate places.
> > Or alternatively, Values could be internalized, and all `PointerValue`s 
> > with the same pointee could have the same address.
> Right. Currently, all tests that assign values in loops (including the test 
> introduced in this patch) are hitting the maximum iterations limit because we 
> don't have a way to tell the framework how to compare distinct values (e.g. 
> there's no need to continue iterating if the `has_value` properties of 
> distinct optional values are the same). This will be the focus of my next 
> patch.
Oh, I see. In this case let's merge this and looking forward to the next one :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118480

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


[PATCH] D118480: [clang][dataflow] Merge distinct pointer values in Environment::join

2022-01-29 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev marked 2 inline comments as done.
sgatev added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp:114
 
+if (auto *FirstVal = dyn_cast(Val)) {
+  auto *SecondVal = cast(It->second);

xazax.hun wrote:
> xazax.hun wrote:
> > xazax.hun wrote:
> > > Shouldn't we ensure that `operator==` return true when we have two 
> > > `PointerValue`s with the same pointee above? That would make this piece 
> > > of code redundant.
> > Never mind, just realized the above is comparing pointers. But I still 
> > think we might want to have a separate `operator==` for `Value`s as we 
> > might want to compare values in many separate places.
> Or alternatively, Values could be internalized, and all `PointerValue`s with 
> the same pointee could have the same address.
Right. Currently, all tests that assign values in loops (including the test 
introduced in this patch) are hitting the maximum iterations limit because we 
don't have a way to tell the framework how to compare distinct values (e.g. 
there's no need to continue iterating if the `has_value` properties of distinct 
optional values are the same). This will be the focus of my next patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118480

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


[PATCH] D114639: Raise the minimum Visual Studio version to VS2019

2022-01-29 Thread Simon Pilgrim via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG058c5dfc78cd: Raise the minimum Visual Studio version to 
VS2019 (authored by RKSimon).

Changed prior to commit:
  https://reviews.llvm.org/D114639?vs=404076=404249#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114639

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/UsersManual.rst
  lldb/docs/resources/build.rst
  lldb/docs/resources/test.rst
  llvm/cmake/modules/CheckCompilerVersion.cmake
  llvm/docs/CMake.rst
  llvm/docs/GettingStarted.rst
  llvm/docs/GettingStartedVS.rst
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Support/Compiler.h

Index: llvm/include/llvm/Support/Compiler.h
===
--- llvm/include/llvm/Support/Compiler.h
+++ llvm/include/llvm/Support/Compiler.h
@@ -77,12 +77,21 @@
 /// * 1916: VS2017, version 15.9
 /// * 1920: VS2019, version 16.0
 /// * 1921: VS2019, version 16.1
+/// * 1922: VS2019, version 16.2
+/// * 1923: VS2019, version 16.3
+/// * 1924: VS2019, version 16.4
+/// * 1925: VS2019, version 16.5
+/// * 1926: VS2019, version 16.6
+/// * 1927: VS2019, version 16.7
+/// * 1928: VS2019, version 16.8 + 16.9
+/// * 1929: VS2019, version 16.10 + 16.11
+/// * 1930: VS2022, version 17.0
 #ifdef _MSC_VER
 #define LLVM_MSC_PREREQ(version) (_MSC_VER >= (version))
 
-// We require at least MSVC 2017.
-#if !LLVM_MSC_PREREQ(1910)
-#error LLVM requires at least MSVC 2017.
+// We require at least VS 2019.
+#if !LLVM_MSC_PREREQ(1920)
+#error LLVM requires at least VS 2019.
 #endif
 
 #else
@@ -94,12 +103,8 @@
 /// Sadly, this is separate from just rvalue reference support because GCC
 /// and MSVC implemented this later than everything else. This appears to be
 /// corrected in MSVC 2019 but not MSVC 2017.
-#if __has_feature(cxx_rvalue_references) || defined(__GNUC__) ||   \
-LLVM_MSC_PREREQ(1920)
+/// FIXME: Remove LLVM_HAS_RVALUE_REFERENCE_THIS macro
 #define LLVM_HAS_RVALUE_REFERENCE_THIS 1
-#else
-#define LLVM_HAS_RVALUE_REFERENCE_THIS 0
-#endif
 
 /// Expands to '&' if ref-qualifiers for *this are supported.
 ///
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -65,7 +65,7 @@
 Changes to building LLVM
 
 
-* ...
+* Building LLVM with Visual Studio now requires version 2019 or later.
 
 Changes to TableGen
 ---
Index: llvm/docs/GettingStartedVS.rst
===
--- llvm/docs/GettingStartedVS.rst
+++ llvm/docs/GettingStartedVS.rst
@@ -36,7 +36,7 @@
 
 Hardware
 
-Any system that can adequately run Visual Studio 2017 is fine. The LLVM
+Any system that can adequately run Visual Studio 2019 is fine. The LLVM
 source tree including the git index consumes approximately 3GB.
 Object files, libraries and executables consume approximately 5GB in
 Release mode and much more in Debug mode. SSD drive and >16GB RAM are
@@ -45,13 +45,14 @@
 
 Software
 
-You will need `Visual Studio `_ 2017 or
-higher, with the latest Update installed. Visual Studio Community Edition
+You will need `Visual Studio `_ 2019 or
+later, with the latest Update installed. Visual Studio Community Edition
 suffices.
 
 You will also need the `CMake `_ build system since it
 generates the project files you will use to build with. CMake is bundled with
-Visual Studio 2019 so separate installation is not required.
+Visual Studio 2019 so separate installation is not required. If you do install
+CMake separately, Visual Studio 2022 will require CMake Version 3.21 or later.
 
 If you would like to run the LLVM tests you will need `Python
 `_. Version 3.6 and newer are known to work. You can
Index: llvm/docs/GettingStarted.rst
===
--- llvm/docs/GettingStarted.rst
+++ llvm/docs/GettingStarted.rst
@@ -238,7 +238,7 @@
 * Clang 3.5
 * Apple Clang 6.0
 * GCC 5.1
-* Visual Studio 2017
+* Visual Studio 2019
 
 Anything older than these toolchains *may* work, but will require forcing the
 build system with a special option and is not really a supported host platform.
@@ -273,8 +273,8 @@
 This section mostly applies to Linux and older BSDs. On macOS, you should
 have a sufficiently modern Xcode, or you will likely need to upgrade until you
 do. Windows does not have a "system compiler", so you must install either Visual
-Studio 2017 or a recent version of mingw64. FreeBSD 10.0 and newer have a modern
-Clang as the system compiler.
+Studio 2019 (or later), or a recent version of mingw64. FreeBSD 10.0 and newer

[clang] 058c5df - Raise the minimum Visual Studio version to VS2019

2022-01-29 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-01-29T10:56:41Z
New Revision: 058c5dfc78cd1a1a6075bba9799e63f3ec871c0d

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

LOG: Raise the minimum Visual Studio version to VS2019

As raised here: 
https://lists.llvm.org/pipermail/llvm-dev/2021-November/153881.html

Now that VS2022 is on general release, LLVM is expected to build on VS2017, 
VS2019 and VS2022, which is proving hazardous to maintain due to changes in 
behaviour including preprocessor and constexpr changes. Plus of the few 
developers that work with VS, many have already moved to VS2019/22.

This patch proposes to raise the minimum supported version to VS2019 (16.x) - 
I've made the hard limit 16.0 or later, with the soft limit VS2019 16.7 - older 
versions of VS2019 are "allowed" (at your own risk) via the 
LLVM_FORCE_USE_OLD_TOOLCHAIN cmake flag.

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/UsersManual.rst
lldb/docs/resources/build.rst
lldb/docs/resources/test.rst
llvm/cmake/modules/CheckCompilerVersion.cmake
llvm/docs/CMake.rst
llvm/docs/GettingStarted.rst
llvm/docs/GettingStartedVS.rst
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/Support/Compiler.h

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 76318e91cb203..bc1c2944c3961 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -162,7 +162,7 @@ the configuration (without a prefix: ``Auto``).
 `_
   * ``Microsoft``
 A style complying with `Microsoft's style guide
-
`_
+
`_
   * ``GNU``
 A style complying with the `GNU coding standards
 `_

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 227884f6aad6a..1df96296cb8ac 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3657,7 +3657,7 @@ When using CMake and the Visual Studio generators, the 
toolset can be set with t
 
   ::
 
-cmake -G"Visual Studio 15 2017" -T LLVM ..
+cmake -G"Visual Studio 16 2019" -T LLVM ..
 
 When using CMake with the Ninja generator, set the ``CMAKE_C_COMPILER`` and
 ``CMAKE_CXX_COMPILER`` variables to clang-cl:

diff  --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index c333134408f1d..5e67955c9c104 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -86,7 +86,7 @@ LLDB must use debug python as well.
 Windows
 ***
 
-* Visual Studio 2017.
+* Visual Studio 2019.
 * The latest Windows SDK.
 * The Active Template Library (ATL).
 * `GnuWin32 `_ for CoreUtils and Make.
@@ -121,8 +121,8 @@ process. They only need to be performed once.
 
 ::
 
-> regsvr32 "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\DIA 
SDK\bin\msdia140.dll"
-> regsvr32 "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\DIA 
SDK\bin\amd64\msdia140.dll"
+> regsvr32 "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\DIA 
SDK\bin\msdia140.dll"
+> regsvr32 "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\DIA 
SDK\bin\amd64\msdia140.dll"
 
 Any command prompt from which you build LLDB should have a valid Visual Studio
 environment setup. This means you should open an appropriate `Developer Command
@@ -300,7 +300,7 @@ project in another directory.
 
 ::
 
-  $ cmake -G "Visual Studio 15 2017 Win64" -Thost=x64  
+  $ cmake -G "Visual Studio 16 2019" -A x64 -T host=x64  

 
 Then you can open the .sln file in Visual Studio, set lldb as the startup
 project, and use F5 to run it. You need only edit the project settings to set

diff  --git a/lldb/docs/resources/test.rst b/lldb/docs/resources/test.rst
index fd4a24450ece9..f76800b88f808 100644
--- a/lldb/docs/resources/test.rst
+++ b/lldb/docs/resources/test.rst
@@ -599,7 +599,7 @@ A quick guide to getting started with PTVS is as follows:
 #. Right click the Project node in Solution Explorer.
 #. In the General tab, Make sure Python 3.5 Debug is the selected 
Interpreter.
 #. In Debug/Search Paths, enter the path to your ninja/lib/site-packages 
directory.
-#. In Debug/Environment Variables, enter ``VCINSTALLDIR=C:\Program Files 
(x86)\Microsoft Visual Studio 14.0\VC\``.
+#. In Debug/Environment Variables, enter ``VCINSTALLDIR=C:\Program Files 
(x86)\Microsoft Visual 

[PATCH] D118480: [clang][dataflow] Merge distinct pointer values in Environment::join

2022-01-29 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp:114
 
+if (auto *FirstVal = dyn_cast(Val)) {
+  auto *SecondVal = cast(It->second);

xazax.hun wrote:
> xazax.hun wrote:
> > Shouldn't we ensure that `operator==` return true when we have two 
> > `PointerValue`s with the same pointee above? That would make this piece of 
> > code redundant.
> Never mind, just realized the above is comparing pointers. But I still think 
> we might want to have a separate `operator==` for `Value`s as we might want 
> to compare values in many separate places.
Or alternatively, Values could be internalized, and all `PointerValue`s with 
the same pointee could have the same address.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118480

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


[PATCH] D118480: [clang][dataflow] Merge distinct pointer values in Environment::join

2022-01-29 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp:114
 
+if (auto *FirstVal = dyn_cast(Val)) {
+  auto *SecondVal = cast(It->second);

xazax.hun wrote:
> Shouldn't we ensure that `operator==` return true when we have two 
> `PointerValue`s with the same pointee above? That would make this piece of 
> code redundant.
Never mind, just realized the above is comparing pointers. But I still think we 
might want to have a separate `operator==` for `Value`s as we might want to 
compare values in many separate places.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118480

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


[PATCH] D118480: [clang][dataflow] Merge distinct pointer values in Environment::join

2022-01-29 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp:114
 
+if (auto *FirstVal = dyn_cast(Val)) {
+  auto *SecondVal = cast(It->second);

Shouldn't we ensure that `operator==` return true when we have two 
`PointerValue`s with the same pointee above? That would make this piece of code 
redundant.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118480

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


[PATCH] D118385: [NFC] Optimize FoldingSet usage where it matters

2022-01-29 Thread Dawid Jurczak via Phabricator via cfe-commits
yurai007 added inline comments.



Comment at: llvm/include/llvm/ADT/FoldingSet.h:328
   /// Add* - Add various data types to Bit data.
-  void AddPointer(const void *Ptr);
-  void AddInteger(signed I);
-  void AddInteger(unsigned I);
-  void AddInteger(long I);
-  void AddInteger(unsigned long I);
-  void AddInteger(long long I);
-  void AddInteger(unsigned long long I);
+  void AddPointer(const void *Ptr) {
+// Note: this adds pointers to the hash using sizes and endianness that

serge-sans-paille wrote:
> xbolva00 wrote:
> > yurai007 wrote:
> > > serge-sans-paille wrote:
> > > > Concerning that inlined part, I expect LTO to close the gap instead of 
> > > > moving everything to headers. Do we have a policy on that topic?
> > > I'm not aware of any LLVM Coding Guidlines policy, probably most related 
> > > is just general rule: 
> > > https://llvm.org/docs/CodingStandards.html#include-as-little-as-possible 
> > > I agree LTO is great when enabled. I just tried to move only small part 
> > > which matters.
> > > Could you please elaborate what are you concerning about?
> > > 
> > > The only potential risks which come to my mind right now are:
> > > * increased binary size, however I noticed Clang binary grows only below 
> > > +0.1% which is acceptable I think.
> > > * moving to header part of implementation which is often changed, however 
> > > AddPointer/AddInteger/ComputeHash were touched last time in 2012.
> > > * compile time impact on Clang build time. I confess I didn't compare 
> > > Clang build times before and after change, but if you like I can.
> > > * reduced I-cache hit rate. This is something also I didn't check under 
> > > perf but I can if you like (not sure how important it is given that we 
> > > get drops of other metrics). 
> > Is LLVM / Clang in distro releases even built with LTO / LTO + PGO? 
> In fedora, LLVM is compiled with LTO. But I agree that's not an assumption we 
> should make, and thus moving some functions to the header looks ok.
Yep, recently there is growing interest in using LTO among distros. I heard 
about at least Fedora, Ubuntu, Red Hat, Debian and Arch interested in enabling 
it by default. Except Fedora not sure how it looks like with Clang package, 
though. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118385

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


[PATCH] D118445: [clang][AVR] Set '-fno-use-cxa-atexit' to default

2022-01-29 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

AVR is baremetal environment, it does not support __cxa_atexit().


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

https://reviews.llvm.org/D118445

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


[PATCH] D118445: [clang][AVR] Set '-fno-use-cxa-atexit' to default

2022-01-29 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

AVR is baremetal environment, it does not support __cxa_atexit()


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

https://reviews.llvm.org/D118445

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


[PATCH] D118445: [clang][AVR] Set '-fno-use-cxa-atexit' to default

2022-01-29 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

This patch fixes

https://github.com/llvm/llvm-project/issues/43443
https://github.com/llvm/llvm-project/issues/50631


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

https://reviews.llvm.org/D118445

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


[PATCH] D118445: [clang][AVR] Set '-fno-use-cxa-atexit' to default

2022-01-29 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 404244.
benshi001 retitled this revision from "[clang][AVR] Fix a crash in 
AVRTargetCodeGenInfo::getGlobalVarAddressSpace" to "[clang][AVR] Set 
'-fno-use-cxa-atexit' to default".
benshi001 edited the summary of this revision.

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

https://reviews.llvm.org/D118445

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/test/Driver/avr-toolchain.c


Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -25,7 +25,12 @@
 // CHECK3-SAME: {{^}} "[[SYSROOT]]/usr/avr/include"
 
 // RUN: %clang %s -### -target avr 2>&1 | FileCheck -check-prefix=CC1 %s
-// CC1: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-fno-use-init-array"
+// CC1: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-fno-use-init-array" 
"-fno-use-cxa-atexit"
+
+// RUN: %clang %s -### -target avr -fuse-init-array -fuse-cxa-atexit 2>&1 | 
FileCheck -check-prefix=CHECK4 %s
+// CHECK4: clang{{.*}} "-cc1" "-triple" "avr"
+// CHECK4-NOT: "-fno-use-init-array"
+// CHECK4-NOT: "-fno-use-cxa-atexit"
 
 // RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 
-nostdinc | FileCheck --check-prefix=NOSTDINC %s
 // RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 
-nostdlibinc | FileCheck --check-prefix=NOSTDINC %s
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -379,6 +379,11 @@
   if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
   options::OPT_fno_use_init_array, false))
 CC1Args.push_back("-fno-use-init-array");
+  // Use `-fno-use-cxa-atexit` as default, since avr-libc does not support
+  // `__cxa_atexit()`.
+  if (!DriverArgs.hasFlag(options::OPT_fuse_cxa_atexit,
+  options::OPT_fno_use_cxa_atexit, false))
+CC1Args.push_back("-fno-use-cxa-atexit");
 }
 
 Tool *AVRToolChain::buildLinker() const {
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8285,12 +8285,14 @@
 // Check if global/static variable is defined in address space
 // 1~6 (__flash, __flash1, __flash2, __flash3, __flash4, __flash5)
 // but not constant.
-LangAS AS = D->getType().getAddressSpace();
-if (isTargetAddressSpace(AS) && 1 <= toTargetAddressSpace(AS) &&
-toTargetAddressSpace(AS) <= 6 && !D->getType().isConstQualified())
-  CGM.getDiags().Report(D->getLocation(),
-diag::err_verify_nonconst_addrspace)
-  << "__flash*";
+if (D) {
+  LangAS AS = D->getType().getAddressSpace();
+  if (isTargetAddressSpace(AS) && 1 <= toTargetAddressSpace(AS) &&
+  toTargetAddressSpace(AS) <= 6 && !D->getType().isConstQualified())
+CGM.getDiags().Report(D->getLocation(),
+  diag::err_verify_nonconst_addrspace)
+<< "__flash*";
+}
 return TargetCodeGenInfo::getGlobalVarAddressSpace(CGM, D);
   }
 


Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -25,7 +25,12 @@
 // CHECK3-SAME: {{^}} "[[SYSROOT]]/usr/avr/include"
 
 // RUN: %clang %s -### -target avr 2>&1 | FileCheck -check-prefix=CC1 %s
-// CC1: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-fno-use-init-array"
+// CC1: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-fno-use-init-array" "-fno-use-cxa-atexit"
+
+// RUN: %clang %s -### -target avr -fuse-init-array -fuse-cxa-atexit 2>&1 | FileCheck -check-prefix=CHECK4 %s
+// CHECK4: clang{{.*}} "-cc1" "-triple" "avr"
+// CHECK4-NOT: "-fno-use-init-array"
+// CHECK4-NOT: "-fno-use-cxa-atexit"
 
 // RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdinc | FileCheck --check-prefix=NOSTDINC %s
 // RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdlibinc | FileCheck --check-prefix=NOSTDINC %s
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -379,6 +379,11 @@
   if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
   options::OPT_fno_use_init_array, false))
 CC1Args.push_back("-fno-use-init-array");
+  // Use `-fno-use-cxa-atexit` as default, since avr-libc does not support
+  // `__cxa_atexit()`.
+  if (!DriverArgs.hasFlag(options::OPT_fuse_cxa_atexit,
+  options::OPT_fno_use_cxa_atexit, false))
+CC1Args.push_back("-fno-use-cxa-atexit");
 }
 
 Tool 

[PATCH] D118532: Fix -Wreserved-identifier in presence of system macro

2022-01-29 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added reviewers: lebedev.ri, aaron.ballman, rsmith.
serge-sans-paille requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Do not warn on reserved identifiers resulting from expansion of system macros.
Also properly test -Wreserved-identifier wrt. system headers.

Should fix #49592


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118532

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/Inputs/reserved-identifier.h
  clang/test/Sema/reserved-identifier.c


Index: clang/test/Sema/reserved-identifier.c
===
--- clang/test/Sema/reserved-identifier.c
+++ clang/test/Sema/reserved-identifier.c
@@ -1,4 +1,12 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wreserved-identifier -Wno-visibility 
%s
+// RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -verify 
-Wreserved-identifier -Wno-visibility %s
+
+#include 
+
+__I_AM_A_SYSTEM_MACRO() // no-warning
+
+void test_system_macro_expansion() {
+  SOME_SYSTEM_MACRO(); // no-warning
+}
 
 #define __oof foo__ // expected-warning {{macro name is a reserved identifier}}
 
@@ -58,7 +66,7 @@
 
 extern char *_strdup(const char *); // expected-warning {{identifier '_strdup' 
is reserved because it starts with '_' at global scope}}
 
-// Don't warn on redecleration
+// Don't warn on redeclaration
 extern char *_strdup(const char *); // no-warning
 
 void ok() {
Index: clang/test/Sema/Inputs/reserved-identifier.h
===
--- /dev/null
+++ clang/test/Sema/Inputs/reserved-identifier.h
@@ -0,0 +1,4 @@
+int __i_come_from_a_system_header; // no-warning
+#define __I_AM_A_SYSTEM_MACRO()// no-warning
+
+#define SOME_SYSTEM_MACRO() int __i_come_from_a_system_macro
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -5703,6 +5703,13 @@
   return false;
 }
 
+/// Returns true if the declaration is declared in a system header or from a
+/// system macro.
+static bool isFromSystemHeader(SourceManager , const Decl *D) {
+  return SM.isInSystemHeader(D->getLocation()) ||
+ SM.isInSystemMacro(D->getLocation());
+}
+
 void Sema::warnOnReservedIdentifier(const NamedDecl *D) {
   // Avoid warning twice on the same identifier, and don't warn on 
redeclaration
   // of system decl.
@@ -5710,9 +5717,10 @@
 return;
   ReservedIdentifierStatus Status = D->isReserved(getLangOpts());
   if (Status != ReservedIdentifierStatus::NotReserved &&
-  !Context.getSourceManager().isInSystemHeader(D->getLocation()))
+  !(isFromSystemHeader(Context.getSourceManager(), D))) {
 Diag(D->getLocation(), diag::warn_reserved_extern_symbol)
 << D << static_cast(Status);
+  }
 }
 
 Decl *Sema::ActOnDeclarator(Scope *S, Declarator ) {


Index: clang/test/Sema/reserved-identifier.c
===
--- clang/test/Sema/reserved-identifier.c
+++ clang/test/Sema/reserved-identifier.c
@@ -1,4 +1,12 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wreserved-identifier -Wno-visibility %s
+// RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -verify -Wreserved-identifier -Wno-visibility %s
+
+#include 
+
+__I_AM_A_SYSTEM_MACRO() // no-warning
+
+void test_system_macro_expansion() {
+  SOME_SYSTEM_MACRO(); // no-warning
+}
 
 #define __oof foo__ // expected-warning {{macro name is a reserved identifier}}
 
@@ -58,7 +66,7 @@
 
 extern char *_strdup(const char *); // expected-warning {{identifier '_strdup' is reserved because it starts with '_' at global scope}}
 
-// Don't warn on redecleration
+// Don't warn on redeclaration
 extern char *_strdup(const char *); // no-warning
 
 void ok() {
Index: clang/test/Sema/Inputs/reserved-identifier.h
===
--- /dev/null
+++ clang/test/Sema/Inputs/reserved-identifier.h
@@ -0,0 +1,4 @@
+int __i_come_from_a_system_header; // no-warning
+#define __I_AM_A_SYSTEM_MACRO()// no-warning
+
+#define SOME_SYSTEM_MACRO() int __i_come_from_a_system_macro
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -5703,6 +5703,13 @@
   return false;
 }
 
+/// Returns true if the declaration is declared in a system header or from a
+/// system macro.
+static bool isFromSystemHeader(SourceManager , const Decl *D) {
+  return SM.isInSystemHeader(D->getLocation()) ||
+ SM.isInSystemMacro(D->getLocation());
+}
+
 void Sema::warnOnReservedIdentifier(const NamedDecl *D) {
   // Avoid warning twice on the same identifier, and don't warn on redeclaration
   // of system decl.
@@ -5710,9 +5717,10 @@
 return;
   ReservedIdentifierStatus Status = D->isReserved(getLangOpts());
   if