[PATCH] D125709: [analyzer][Casting] Support isa, cast, dyn_cast of SVals

2022-05-17 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 429947.
steakhal added a comment.

Use `cast` and `dyn_cast` in `castAs` and `getAs` respecitvely.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125709

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h


Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -98,19 +98,12 @@
 
   /// Convert to the specified SVal type, asserting that this SVal is of
   /// the desired type.
-  template
-  T castAs() const {
-assert(T::classof(*this));
-return *static_cast(this);
-  }
+  template  T castAs() const { return llvm::cast(*this); }
 
   /// Convert to the specified SVal type, returning None if this SVal is
   /// not of the desired type.
-  template
-  Optional getAs() const {
-if (!T::classof(*this))
-  return None;
-return *static_cast(this);
+  template  Optional getAs() const {
+return llvm::dyn_cast(*this);
   }
 
   unsigned getRawKind() const { return Kind; }
@@ -571,4 +564,28 @@
 } // namespace ento
 } // namespace clang
 
+namespace llvm {
+template 
+struct CastInfo<
+To, From,
+std::enable_if_t::value>>
+: public CastIsPossible {
+  using Self = CastInfo<
+  To, From,
+  std::enable_if_t::value>>;
+  static bool isPossible(const From &V) {
+return To::classof(*static_cast(&V));
+  }
+  static Optional castFailed() { return Optional{}; }
+  static To doCast(const From &f) {
+return *static_cast(cast<::clang::ento::SVal>(&f));
+  }
+  static Optional doCastIfPossible(const From &f) {
+if (!Self::isPossible(f))
+  return Self::castFailed();
+return doCast(f);
+  }
+};
+} // namespace llvm
+
 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALS_H


Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -98,19 +98,12 @@
 
   /// Convert to the specified SVal type, asserting that this SVal is of
   /// the desired type.
-  template
-  T castAs() const {
-assert(T::classof(*this));
-return *static_cast(this);
-  }
+  template  T castAs() const { return llvm::cast(*this); }
 
   /// Convert to the specified SVal type, returning None if this SVal is
   /// not of the desired type.
-  template
-  Optional getAs() const {
-if (!T::classof(*this))
-  return None;
-return *static_cast(this);
+  template  Optional getAs() const {
+return llvm::dyn_cast(*this);
   }
 
   unsigned getRawKind() const { return Kind; }
@@ -571,4 +564,28 @@
 } // namespace ento
 } // namespace clang
 
+namespace llvm {
+template 
+struct CastInfo<
+To, From,
+std::enable_if_t::value>>
+: public CastIsPossible {
+  using Self = CastInfo<
+  To, From,
+  std::enable_if_t::value>>;
+  static bool isPossible(const From &V) {
+return To::classof(*static_cast(&V));
+  }
+  static Optional castFailed() { return Optional{}; }
+  static To doCast(const From &f) {
+return *static_cast(cast<::clang::ento::SVal>(&f));
+  }
+  static Optional doCastIfPossible(const From &f) {
+if (!Self::isPossible(f))
+  return Self::castFailed();
+return doCast(f);
+  }
+};
+} // namespace llvm
+
 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALS_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125709: [analyzer][Casting] Support isa, cast, dyn_cast of SVals

2022-05-17 Thread Balázs Benics via Phabricator via cfe-commits
steakhal marked an inline comment as done.
steakhal added a comment.

I had to fix the `doIt` to return `To` instead of `Optional` to make it 
work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125709

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


[PATCH] D124382: [Clang] Recognize target address space in superset calculation

2022-05-17 Thread Jakub Chlanda via Phabricator via cfe-commits
jchlanda updated this revision to Diff 429956.
jchlanda edited the summary of this revision.
jchlanda added a reviewer: Anastasia.
jchlanda added a comment.
Herald added a subscriber: kosarev.

Use helper functions when handling address space values.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124382

Files:
  clang/include/clang/AST/Type.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/address_space_type_casts_amdgpu.cl
  clang/test/Sema/address_space_type_casts_default.cl
  clang/test/SemaOpenCL/atomic-ops.cl
  clang/test/SemaOpenCL/numbered-address-space.cl
  clang/test/SemaOpenCL/predefined-expr.cl
  clang/test/SemaOpenCL/vector-conv.cl

Index: clang/test/SemaOpenCL/vector-conv.cl
===
--- clang/test/SemaOpenCL/vector-conv.cl
+++ clang/test/SemaOpenCL/vector-conv.cl
@@ -16,7 +16,8 @@
   e = (constant int4)i;
   e = (private int4)i;
 
-  private int4 *private_ptr = (const private int4 *)const_global_ptr; // expected-error{{casting 'const __global int4 *' to type 'const __private int4 *' changes address space of pointer}}
-  global int4 *global_ptr = const_global_ptr; // expected-warning {{initializing '__global int4 *__private' with an expression of type 'const __global int4 *__private' discards qualifiers}}
+private
+  int4 *private_ptr = (const private int4 *)const_global_ptr; // expected-error{{casting 'const __global int4 *' to type 'const __private int4 *' changes address space of pointer}}
+  global int4 *global_ptr = const_global_ptr;
   global_ptr = (global int4 *)const_global_ptr;
 }
Index: clang/test/SemaOpenCL/predefined-expr.cl
===
--- clang/test/SemaOpenCL/predefined-expr.cl
+++ clang/test/SemaOpenCL/predefined-expr.cl
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 %s -verify -cl-std=CL2.0
 
 void f() {
-  char *f1 = __func__;  //expected-error-re{{initializing '{{__generic|__private}} char *__private' with an expression of type 'const __constant char *' changes address space of pointer}}
-  constant char *f2 = __func__; //expected-warning{{initializing '__constant char *__private' with an expression of type 'const __constant char[2]' discards qualifiers}}
+  char *f1 = __func__; // expected-error-re{{initializing '{{__generic|__private}} char *__private' with an expression of type 'const __constant char *' changes address space of pointer}}
+  constant char *f2 = __func__;
   constant const char *f3 = __func__;
 }
Index: clang/test/SemaOpenCL/numbered-address-space.cl
===
--- clang/test/SemaOpenCL/numbered-address-space.cl
+++ clang/test/SemaOpenCL/numbered-address-space.cl
@@ -2,11 +2,16 @@
 // RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -verify -pedantic -fsyntax-only %s
 
 void test_numeric_as_to_generic_implicit_cast(__attribute__((address_space(3))) int *as3_ptr, float src) {
-  generic int* generic_ptr = as3_ptr; // FIXME: This should error
+  generic int *generic_ptr = as3_ptr;
+}
+
+// AS 4 is constant on AMDGPU, casting it to generic is illegal.
+void test_numeric_as_const_to_generic_implicit_cast(__attribute__((address_space(4))) int *as4_ptr, float src) {
+  generic int *generic_ptr = as4_ptr; // expected-error{{initializing '__generic int *__private' with an expression of type '__attribute__((address_space(4))) int *__private' changes address space of pointer}}
 }
 
 void test_numeric_as_to_generic_explicit_cast(__attribute__((address_space(3))) int *as3_ptr, float src) {
-  generic int* generic_ptr = (generic int*) as3_ptr; // Should maybe be valid?
+  generic int *generic_ptr = (generic int *)as3_ptr;
 }
 
 void test_generic_to_numeric_as_implicit_cast(void) {
@@ -20,12 +25,12 @@
 }
 
 void test_generic_as_to_builtin_parameter_explicit_cast_numeric(__attribute__((address_space(3))) int *as3_ptr, float src) {
-  generic int* generic_ptr = as3_ptr; // FIXME: This should error
-  volatile float result = __builtin_amdgcn_ds_fmaxf((__attribute__((address_space(3))) float*) generic_ptr, src, 0, 0, false); // expected-error {{passing '__attribute__((address_space(3))) float *' to parameter of type '__local float *' changes address space of pointer}}
+  generic int *generic_ptr = as3_ptr;
+  // This is legal, as address_space(3) corresponds to local on amdgpu.
+  volatile float result = __builtin_amdgcn_ds_fmaxf((__attribute__((address_space(3))) float *)generic_ptr, src, 0, 0, false);
 }
 
 void test_generic_as_to_builtin_parameterimplicit_cast_numeric(__attribute__((address_space(3))) int *as3_ptr, float src) {
-  generic int* generic_ptr = as3_ptr;
+  generic int *generic_ptr = as3_ptr;
   volatile float result = __builtin_amdgcn_ds_fmaxf(generic_ptr, src, 0, 0, false); // expected-error {{passing '__generic int *__private' to parameter of type '__lo

[PATCH] D125749: [analyzer][NFC] Introduce SVal::isa

2022-05-17 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: NoQ, martong, Szelethus, balazske, ASDenysPetrov, 
bzcheeseman, xazax.hun.
Herald added subscribers: manas, dkrupp, donat.nagy, mikhail.ramalho, 
a.sidorin, rnkovacs, szepet, baloghadamsoftware.
Herald added a project: All.
steakhal requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This cleans up the uses of `getAs` at quite a few places leading to more 
readable code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125749

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
  clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  
clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
  clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/CheckerContext.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/lib/StaticAnalyzer/Core/ProgramState.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/SVals.cpp
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp

Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -459,10 +459,10 @@
   // FIXME: For absolute pointer addresses, we just return that value back as
   //  well, although in reality we should return the offset added to that
   //  value. See also the similar FIXME in getLValueFieldOrIvar().
-  if (Base.isUnknownOrUndef() || Base.getAs())
+  if (Base.isUnknownOrUndef() || Base.isa())
 return Base;
 
-  if (Base.getAs())
+  if (Base.isa())
 return UnknownVal();
 
   const SubRegion *BaseRegion =
@@ -488,7 +488,7 @@
 
   SVal BaseIdx = ElemR->getIndex();
 
-  if (!BaseIdx.getAs())
+  if (!BaseIdx.isa())
 return UnknownVal();
 
   const llvm::APSInt &BaseIdxI =
@@ -497,7 +497,7 @@
   // Only allow non-integer offsets if the base region has no offset itself.
   // FIXME: This is a somewhat arbitrary restriction. We should be using
   // SValBuilder here to add the two offsets without checking their types.
-  if (!Offset.getAs()) {
+  if (!Offset.isa()) {
 if (isa(BaseRegion->StripCasts()))
   return UnknownVal();
 
Index: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -865,7 +865,7 @@
   if (Optional Result = ResultVal.getAs())
 return evalCast(*Result, resultTy, QualType{});
 
-  assert(!ResultVal.getAs() && "Loc-Loc ops should not produce Locs");
+  assert(!ResultVal.isa() && "Loc-Loc ops should not produce Locs");
   return UnknownVal();
 }
 
@@ -873,7 +873,7 @@
 // This must come after the test if the RHS is a symbol, which is used to
 // build constraints. The address of any non-symbolic region is guaranteed
 // to be non-NULL, as is any label.
-assert(rhs.getAs() || rhs.getAs());
+assert((rhs.isa()));
 if (lhs.isZeroConstant()) {
   switch (op) {
   default:
Index: clang/lib/StaticAnalyzer/Core/SVals.cpp
===
--- clang/lib/StaticAnalyzer/Core/SVals.cpp
+++ clang/lib/StaticAnalyzer/Core/SVals.cpp
@@ -46,7 +46,7 @@
 bool SVal::hasConjuredSymbol() const {
   if (Optional SV = getAs()) {
 SymbolRef sym = SV->getSymbol();
-if (isa(sym))
+if (llvm::isa(sym))
   return true;
   }
 
@@ -54,7 +54,7 @@
 const 

[PATCH] D125749: [analyzer][NFC] Introduce SVal::isa

2022-05-17 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h:99-100
 
+  template  bool isa() const { return llvm::isa(*this); 
}
+
   /// Convert to the specified SVal type, asserting that this SVal is of

This is the core of this change :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125749

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


[PATCH] D125400: [clang][Analyzer] Add errno state to standard functions modeling.

2022-05-17 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D125400#3508955 , @balazske wrote:

> Function `mkdir` is modeled incorrectly by the checker. According to the man 
> page it can return 0 or -1 only (-1 is error) but the checker allows 
> non-negative value at success. So the shown bug report is incorrect (it can 
> be only -1 if not 0 and then check of `errno` is allowed). Anyway the note 
> tags should be added to every function.

Okay, could you please correct the summary then?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125400

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


[PATCH] D124382: [Clang] Recognize target address space in superset calculation

2022-05-17 Thread Jakub Chlanda via Phabricator via cfe-commits
jchlanda added inline comments.



Comment at: clang/include/clang/AST/Type.h:486
+   bool IsSYCLOrOpenCL = false) {
+if (ASMap) {
+  bool IsATargetAS = false;

jchlanda wrote:
> tra wrote:
> > If A and B are both target AS, we fall through to the code which is dealing 
> > with language AS, which would not do us any good. If that's not expected to 
> > happen, we should have an assert to ensure it.
> > 
> > Next, I'm not particularly fond of `IsSYCLOrOpenCL`. Do we need it at all. 
> > If we do know that AS maps to OpenCL `Constant` or `Generic`, I would 
> > assume that those AS would follow the same semantics. Besides, will we ever 
> > see OpenCL language AS in non-OpenCL code?
> > 
> > Next, the function *is* OpenCL specific and would not work for CUDA or HIP. 
> > I think it needs to be generalized to provide language-specific AS mapping 
> > rules.
> I would only like to handle the mixed AS case, it feels like trying to walk 
> back from both HW AS and potentially do the logic of global and constant 
> would be against the intention of users. Asserting on only one HW AS could 
> backfire, as I think it should be allowed to assign between different HW AS.
> 
> The reason I added `IsSYCLOrOpenCL` is because this code is also exercised by 
> `checkPointerTypesForAssignment` which is not OpenCL specific, so I had to 
> have a way of conditionally enabling the conversion to generic AS.
> 
> I agree, it is too restrictive now, especially that the AS map provides 
> values for SYCL, OpenCL and CUDA, so perhaps I should extend `IsSYCLOrOpenCL` 
> to be an enum specifying which language the function deals with and act 
> accordingly?
> 
> Next, I'm not particularly fond of `IsSYCLOrOpenCL`. Do we need it at all. If 
> we do know that AS maps to OpenCL `Constant` or `Generic`, I would assume 
> that those AS would follow the same semantics. Besides, will we ever see 
> OpenCL language AS in non-OpenCL code?
> 
> Next, the function *is* OpenCL specific and would not work for CUDA or HIP. I 
> think it needs to be generalized to provide language-specific AS mapping 
> rules.

I've changed that bool flag to be an enum specifying OpenCL/SYCL/None. The 
rational here is that the handling of AS values differs slightly (SYCL 
introduces `globa device` and `global host`). It would appear that CUDA follows 
completely different code-path and by the time `isAddressSpaceSuperset` called 
all of the language AS values are stripped and set to `0`, which is why (along 
the fact that we don't have a valid use case for CUDA) I left it out, and only 
return true for an exact match.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124382

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


[PATCH] D125400: [clang][Analyzer] Add errno state to standard functions modeling.

2022-05-17 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D125400#3516164 , @balazske wrote:

> @martong Do you mean that a "describe" function is needed for the return 
> value constraint of the function and for the errno constraint type? Then a 
> note tag can contain what the function is assumed to return on success and 
> what is allowed (or not) to do with `errno`. For example: "Assuming that 
> 'mkdir' is successful, it returns zero in this case and value of 'errno' is 
> unspecified after the call".

Yes, that sounds good. We have the virtual `describe` function in the base 
constraint class that could be used to explain what values we expect.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125400

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


[PATCH] D125400: [clang][Analyzer] Add errno state to standard functions modeling.

2022-05-17 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:435
+  assert(Cond);
+  State = State->assume(*Cond, true);
+  return errno_modeling::setErrnoValue(State, C.getLocationContext(),

balazske wrote:
> martong wrote:
> > Please check if `State` can be nullptr.
> I think here it is never null. A relation is created between a new conjured 
> symbol and zero, this can never fail, or not? (The `ErrnoSVal` should be here 
> a newly created symbol. If the `Tag` is not used it may be the same symbol 
> that was previously bound to the expression if `EvalCallAsPure` is used.)
Okay, I see your reasoning. However, we might never know how the constraint 
solver reasons about it, thus we should not rely on that. As a contrived 
example, it might check recursively that the LHS of the BinOp you just conjured 
and it might recognize that the State is infeasible.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:603
 
-Summary &Case(ConstraintSet &&CS, StringRef Note = "") {
-  Cases.push_back(SummaryCase(std::move(CS), Note));
+Summary &Case(ConstraintSet &&CS, const ErrnoConstraintKind &ErrnoC,
+  StringRef Note = "") {

balazske wrote:
> martong wrote:
> > Would it make sense to have a `ErrnoIrrelevant` as the default value for 
> > `ErrnoC`?
> It would be a bit more convenient but in the current design it is not 
> possible to pass the member variable as default value. `ErrnoIrrelevant` is 
> really used in less than half of the cases.
Ok.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125400

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


[PATCH] D125749: [analyzer][NFC] Introduce SVal::isa

2022-05-17 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 429960.
steakhal added a comment.

Refactor in the `getAs` uses of `clang/include/StaticAnalyzer` directory as 
well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125749

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
  clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  
clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
  clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/CheckerContext.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/lib/StaticAnalyzer/Core/ProgramState.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/SVals.cpp
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp

Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -459,10 +459,10 @@
   // FIXME: For absolute pointer addresses, we just return that value back as
   //  well, although in reality we should return the offset added to that
   //  value. See also the similar FIXME in getLValueFieldOrIvar().
-  if (Base.isUnknownOrUndef() || Base.getAs())
+  if (Base.isUnknownOrUndef() || Base.isa())
 return Base;
 
-  if (Base.getAs())
+  if (Base.isa())
 return UnknownVal();
 
   const SubRegion *BaseRegion =
@@ -488,7 +488,7 @@
 
   SVal BaseIdx = ElemR->getIndex();
 
-  if (!BaseIdx.getAs())
+  if (!BaseIdx.isa())
 return UnknownVal();
 
   const llvm::APSInt &BaseIdxI =
@@ -497,7 +497,7 @@
   // Only allow non-integer offsets if the base region has no offset itself.
   // FIXME: This is a somewhat arbitrary restriction. We should be using
   // SValBuilder here to add the two offsets without checking their types.
-  if (!Offset.getAs()) {
+  if (!Offset.isa()) {
 if (isa(BaseRegion->StripCasts()))
   return UnknownVal();
 
Index: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -865,7 +865,7 @@
   if (Optional Result = ResultVal.getAs())
 return evalCast(*Result, resultTy, QualType{});
 
-  assert(!ResultVal.getAs() && "Loc-Loc ops should not produce Locs");
+  assert(!ResultVal.isa() && "Loc-Loc ops should not produce Locs");
   return UnknownVal();
 }
 
@@ -873,7 +873,7 @@
 // This must come after the test if the RHS is a symbol, which is used to
 // build constraints. The address of any non-symbolic region is guaranteed
 // to be non-NULL, as is any label.
-assert(rhs.getAs() || rhs.getAs());
+assert((rhs.isa()));
 if (lhs.isZeroConstant()) {
   switch (op) {
   default:
Index: clang/lib/StaticAnalyzer/Core/SVals.cpp
===
--- clang/lib/StaticAnalyzer/Core/SVals.cpp
+++ clang/lib/StaticAnalyzer/Core/SVals.cpp
@@ -46,7 +46,7 @@
 bool SVal::hasConjuredSymbol() const {
   if (Optional SV = getAs()) {
 SymbolRef sym = SV->getSymbol();
-if (isa(sym))
+if (llvm::isa(sym))
   return true;
   }
 
@@ -54,7 +54,7 @@
 const MemRegion *R = RV->getRegion();
 if (const auto *SR = dyn_cast(R)) {
   SymbolRef sym = SR->getSymbol();
- 

[PATCH] D125709: [analyzer][Casting] Support isa, cast, dyn_cast of SVals

2022-05-17 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

> I'm not sure, shall I add tests?

Yes, please. Unit tests for `dyn_cast` and `isa` should be easy. However, I am 
not sure how to test `cast` for the failure cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125709

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


[PATCH] D125706: [analyzer][NFC] Use idiomatic classof instead of isKind

2022-05-17 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong 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/D125706/new/

https://reviews.llvm.org/D125706

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


[PATCH] D125707: [analyzer][NFC] Remove unused friend SVal declarations

2022-05-17 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong 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/D125707/new/

https://reviews.llvm.org/D125707

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


[PATCH] D125708: [analyzer][NFC] Remove unused default SVal constructors

2022-05-17 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong 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/D125708/new/

https://reviews.llvm.org/D125708

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


[clang] b250cca - [OpenCL] Do not guard vload/store_half builtins

2022-05-17 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-05-17T10:57:23+01:00
New Revision: b250cca11d5996ed01d72cb1f933867da0e8d5e0

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

LOG: [OpenCL] Do not guard vload/store_half builtins

The vload*_half* and vstore*_half* builtins do not require the
cl_khr_fp16 extension: pointers to `half` can be declared without the
extension and the _half variants of vload and vstore should be
available without the extension.

This aligns the guards for these builtins for
`-fdeclare-opencl-builtins` with `opencl-c.h`.

Fixes https://github.com/llvm/llvm-project/issues/55275

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

Added: 


Modified: 
clang/lib/Headers/opencl-c-base.h
clang/lib/Sema/OpenCLBuiltins.td
clang/test/SemaOpenCL/half.cl

Removed: 




diff  --git a/clang/lib/Headers/opencl-c-base.h 
b/clang/lib/Headers/opencl-c-base.h
index d0a0d5bdbf4f5..4e87afad84bf7 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -202,6 +202,9 @@ typedef double double8 __attribute__((ext_vector_type(8)));
 typedef double double16 __attribute__((ext_vector_type(16)));
 #endif
 
+// An internal alias for half, for use by OpenCLBuiltins.td.
+#define __half half
+
 #if defined(__OPENCL_CPP_VERSION__)
 #define NULL nullptr
 #elif defined(__OPENCL_C_VERSION__)

diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index ece0b8866d942..220daf05acf94 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -352,9 +352,22 @@ def Float : Type<"float", 
QualType<"Context.FloatTy">>;
 let Extension = Fp64TypeExt in {
   def Double: Type<"double",QualType<"Context.DoubleTy">>;
 }
+
+// The half type for builtins that require the cl_khr_fp16 extension.
 let Extension = Fp16TypeExt in {
   def Half  : Type<"half",  QualType<"Context.HalfTy">>;
 }
+
+// Without the cl_khr_fp16 extension, the half type can only be used to declare
+// a pointer.  Define const and non-const pointer types in all address spaces.
+// Use the "__half" alias to allow the TableGen emitter to distinguish the
+// (extensionless) pointee type of these pointer-to-half types from the "half"
+// type defined above that already carries the cl_khr_fp16 extension.
+foreach AS = [PrivateAS, GlobalAS, ConstantAS, LocalAS, GenericAS] in {
+  def "HalfPtr" # AS  : PointerType>, AS>;
+  def "HalfPtrConst" # AS : PointerType>>, AS>;
+}
+
 def Size  : Type<"size_t",QualType<"Context.getSizeType()">>;
 def PtrDiff   : Type<"ptr
diff _t", QualType<"Context.getPointerDiffType()">>;
 def IntPtr: Type<"intptr_t",  QualType<"Context.getIntPtrType()">>;
@@ -877,22 +890,22 @@ defm : VloadVstore<[ConstantAS], 0>;
 
 multiclass VloadVstoreHalf addrspaces, bit defStores> {
   foreach AS = addrspaces in {
-def : Builtin<"vload_half", [Float, Size, PointerType, 
AS>], Attr.Pure>;
+def : Builtin<"vload_half", [Float, Size, !cast("HalfPtrConst" # 
AS)], Attr.Pure>;
 foreach VSize = [2, 3, 4, 8, 16] in {
   foreach name = ["vload_half" # VSize, "vloada_half" # VSize] in {
-def : Builtin, Size, 
PointerType, AS>], Attr.Pure>;
+def : Builtin, Size, 
!cast("HalfPtrConst" # AS)], Attr.Pure>;
   }
 }
 if defStores then {
   foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
 foreach name = ["vstore_half" # rnd] in {
-  def : Builtin]>;
-  def : Builtin]>;
+  def : Builtin("HalfPtr" # 
AS)]>;
+  def : Builtin("HalfPtr" # 
AS)]>;
 }
 foreach VSize = [2, 3, 4, 8, 16] in {
   foreach name = ["vstore_half" # VSize # rnd, "vstorea_half" # VSize 
# rnd] in {
-def : Builtin, Size, 
PointerType]>;
-def : Builtin, Size, 
PointerType]>;
+def : Builtin, Size, 
!cast("HalfPtr" # AS)]>;
+def : Builtin, Size, 
!cast("HalfPtr" # AS)]>;
   }
 }
   }

diff  --git a/clang/test/SemaOpenCL/half.cl b/clang/test/SemaOpenCL/half.cl
index e3e558995b21c..d0cd529a8f9af 100644
--- a/clang/test/SemaOpenCL/half.cl
+++ b/clang/test/SemaOpenCL/half.cl
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value 
-triple spir-unknown-unknown
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value 
-triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value 
-triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header 
-DHAVE_BUILTINS
 
 constant float f = 1.0h; // expected-error{{half precision constant requires 
cl_khr_fp16}}
 
@@ -22,6 +22,11 @@ half half_disabled(half *p, // expected-error

[PATCH] D125401: [OpenCL] Do not guard vload/store_half builtins

2022-05-17 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb250cca11d59: [OpenCL] Do not guard vload/store_half 
builtins (authored by svenvh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125401

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Sema/OpenCLBuiltins.td
  clang/test/SemaOpenCL/half.cl

Index: clang/test/SemaOpenCL/half.cl
===
--- clang/test/SemaOpenCL/half.cl
+++ clang/test/SemaOpenCL/half.cl
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value -triple spir-unknown-unknown
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value -triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value -triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header -DHAVE_BUILTINS
 
 constant float f = 1.0h; // expected-error{{half precision constant requires cl_khr_fp16}}
 
@@ -22,6 +22,11 @@
   half *allowed2 = &*p;
   half *allowed3 = p + 1;
 
+#ifdef HAVE_BUILTINS
+  (void)ilogb(*p); // expected-error{{loading directly from pointer to type '__private half' requires cl_khr_fp16. Use vector data load builtin functions instead}}
+  vstore_half(42.0f, 0, p);
+#endif
+
   return h;
 }
 
@@ -49,6 +54,11 @@
   half *allowed2 = &*p;
   half *allowed3 = p + 1;
 
+#ifdef HAVE_BUILTINS
+  (void)ilogb(*p);
+  vstore_half(42.0f, 0, p);
+#endif
+
   return h;
 }
 
Index: clang/lib/Sema/OpenCLBuiltins.td
===
--- clang/lib/Sema/OpenCLBuiltins.td
+++ clang/lib/Sema/OpenCLBuiltins.td
@@ -352,9 +352,22 @@
 let Extension = Fp64TypeExt in {
   def Double: Type<"double",QualType<"Context.DoubleTy">>;
 }
+
+// The half type for builtins that require the cl_khr_fp16 extension.
 let Extension = Fp16TypeExt in {
   def Half  : Type<"half",  QualType<"Context.HalfTy">>;
 }
+
+// Without the cl_khr_fp16 extension, the half type can only be used to declare
+// a pointer.  Define const and non-const pointer types in all address spaces.
+// Use the "__half" alias to allow the TableGen emitter to distinguish the
+// (extensionless) pointee type of these pointer-to-half types from the "half"
+// type defined above that already carries the cl_khr_fp16 extension.
+foreach AS = [PrivateAS, GlobalAS, ConstantAS, LocalAS, GenericAS] in {
+  def "HalfPtr" # AS  : PointerType>, AS>;
+  def "HalfPtrConst" # AS : PointerType>>, AS>;
+}
+
 def Size  : Type<"size_t",QualType<"Context.getSizeType()">>;
 def PtrDiff   : Type<"ptrdiff_t", QualType<"Context.getPointerDiffType()">>;
 def IntPtr: Type<"intptr_t",  QualType<"Context.getIntPtrType()">>;
@@ -877,22 +890,22 @@
 
 multiclass VloadVstoreHalf addrspaces, bit defStores> {
   foreach AS = addrspaces in {
-def : Builtin<"vload_half", [Float, Size, PointerType, AS>], Attr.Pure>;
+def : Builtin<"vload_half", [Float, Size, !cast("HalfPtrConst" # AS)], Attr.Pure>;
 foreach VSize = [2, 3, 4, 8, 16] in {
   foreach name = ["vload_half" # VSize, "vloada_half" # VSize] in {
-def : Builtin, Size, PointerType, AS>], Attr.Pure>;
+def : Builtin, Size, !cast("HalfPtrConst" # AS)], Attr.Pure>;
   }
 }
 if defStores then {
   foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
 foreach name = ["vstore_half" # rnd] in {
-  def : Builtin]>;
-  def : Builtin]>;
+  def : Builtin("HalfPtr" # AS)]>;
+  def : Builtin("HalfPtr" # AS)]>;
 }
 foreach VSize = [2, 3, 4, 8, 16] in {
   foreach name = ["vstore_half" # VSize # rnd, "vstorea_half" # VSize # rnd] in {
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
+def : Builtin, Size, !cast("HalfPtr" # AS)]>;
+def : Builtin, Size, !cast("HalfPtr" # AS)]>;
   }
 }
   }
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -202,6 +202,9 @@
 typedef double double16 __attribute__((ext_vector_type(16)));
 #endif
 
+// An internal alias for half, for use by OpenCLBuiltins.td.
+#define __half half
+
 #if defined(__OPENCL_CPP_VERSION__)
 #define NULL nullptr
 #elif defined(__OPENCL_C_VERSION__)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125679: [Clang] Added options for integrated backend only used for SPIR-V for now

2022-05-17 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki added a comment.

From my point of view this patch LGTM.




Comment at: clang/include/clang/Driver/Options.td:4164-4169
+def fintegrated_objemitter : Flag<["-"], "fintegrated-objemitter">,
+  Flags<[CoreOption, NoXarchOption]>, Group,
+  HelpText<"Use internal machine object code emitter.">;
+def fno_integrated_objemitter : Flag<["-"], "fno-integrated-objemitter">,
+ Flags<[CoreOption, NoXarchOption]>, Group,
+ HelpText<"Use external machine object code emitter.">;

Adjust indentation?


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

https://reviews.llvm.org/D125679

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


[PATCH] D124982: [clang][OpenMP][DebugInfo] Debug support for variables in containing scope of OMP constructs

2022-05-17 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb added inline comments.



Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:689
   auto ScopeDIE = DIE::get(DIEValueAllocator, dwarf::DW_TAG_lexical_block);
+  insertDIE(Scope->getScopeNode(), ScopeDIE);
   if (Scope->isAbstractScope())

In case of compiling optimized code with inlining enabled, the `Scope` may be 
either a scope of an inlined instance (which may appear multiple times), an 
abstract scope or a concrete out-of-line scope. All of them will match a single 
ScopeNode, so this will override the map's value multiple times and `getDIE()` 
will likely return something that one may not expect.
I've been working on patches that make possible for local types, imports and 
static variables to be scoped in a lexical block, see D125693 for 
backend-related changes. May be you could find something useful there (see 
`DwarfCompileUnit::getOrCreateLexicalBlockDIE()` and 
`DwarfCompileUnit::getOrCreateContextDIE()`) or could help to review the 
patches.


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

https://reviews.llvm.org/D124982

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


[PATCH] D125604: [FileCheck] Catch missspelled directives.

2022-05-17 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev added inline comments.



Comment at: llvm/lib/FileCheck/FileCheck.cpp:1774-1781
+static std::pair
+FindCheckType(const FileCheckRequest &Req, StringRef Buffer, StringRef Prefix) 
{
+  bool Misspelled = false;
+  auto Res = FindCheckType(Req, Buffer, Prefix, Misspelled);
+  if (Res.first != Check::CheckNone && Misspelled)
+return {Check::CheckMisspelled, Res.second};
+  return Res;

thopre wrote:
> Instead of introducing a new wrapper, why don't you change all the return to 
> call a constructor method (e.g. `make_check_type()`) that does what this 
> wrapper do? Then there would not be any FindCheckType that take a Misspelled 
> parameter.
> 
> I'm also not sure about Misspelled being a check kind. It feels conceptually 
> wrong but on the other hand I guess it makes the implementation simpler.
Tried that. Replacing the returned pair with a new `CheckLine` kind of object 
implementing the misspelled-related logic seems to add a lot of extra clutter 
such as the definition of the new structure itself, but especially all the 
repetitive mentions of `Misspelled` on every `return`. Feels like having it as 
a reference parameter works better, as we only need to alter the flag 
occasionally.

Regarding `CheckMisspelled`, now that we have `CheckBadNot` and 
`CheckBadCount`, this looks the usual way of propagating the information about 
our spelling-related concerns. Might be not the best design and may be worth 
looking into at some point, but at least doesn' seem to be specific to this 
patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125604

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


[PATCH] D74765: [compiler-rt] Addd FreeBSD arm64 sanitizer support

2022-05-17 Thread Andrew Turner via Phabricator via cfe-commits
andrew abandoned this revision.
andrew added a comment.
Herald added a project: All.

Replaced with D125756  D125757 
 D125758 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74765

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


[PATCH] D125084: [test, x86] Fix spurious x86-target-features.c failure

2022-05-17 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre added a comment.

Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125084

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


[PATCH] D124446: [clang-tidy] Add the misc-discarded-return-value check

2022-05-17 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/DiscardedReturnValueCheck.cpp:181
+
+  static const auto Decltype = decltypeType(hasUnderlyingExpr(Call));
+  static const auto TemplateArg =

whisperity wrote:
> whisperity wrote:
> > aaron.ballman wrote:
> > > So, I'm not super keen on this approach of having to try to identify 
> > > every single place in which an expression is considered to be "used" -- 
> > > this is going to be fragile because we'll miss places and it's going to 
> > > be a maintenance burden because new places will be added as the languages 
> > > evolve.
> > > 
> > > For example, if we're handling `decltype` as a use, why not `noexcept`? 
> > > Or conditional `explicit`? What about a `co_return` statement?
> > > 
> > > I'm not certain what we can do to improve this, but I think it's worth 
> > > trying to explore options to see if we can generalize what constitutes a 
> > > use so that we can write a few custom matchers to do the heavy lifting 
> > > instead of trying to play whack-a-mole.
> > I've been having other thoughts about this `decltype` here... Actually, 
> > neither `decltype` nor `noexcept` should be handled as a //"use"// at all, 
> > while `co_return` should be the same as a `return` -- however, I think it 
> > was due to lack of projects where such could be meaningfully measured as a 
> > missed case was why implementing that failed.
> > 
> > For `decltype`, `typedef`, and `noexcept` (and perhaps several others), the 
> > good solution would be having a third route: calls that //should not be 
> > counted//. Neither as a "consumed call", nor as a "bare call". Ignored, 
> > from both calculations. Maybe even for template arguments below.
> As for better matching... Unfortunately, types in the AST are so varied and 
> `hasDescendant` is too generic to express something like 
> `stmt(anyOf(ifStmt(), forStmt(), switchStmt()), hasDescendant(Call))` to 
> express in a single expression matching uses... The conditions are not always 
> direct children of the outer node, while `hasDescendant` will match not just 
> the condition but the entire tree... resulting in things like //both// 
> functions in
> 
> ```lang=cpp
> if (foo())
>   bar()
> ```
> 
> matching.
> 
> Well... generalisation... I can throw in a formal fluke:
> 
> > A **use** is a //context// for a specific `CallExpr C` in which we can 
> > reasonably assume that the value produced by evaluating `C` is loaded by 
> > another expression.
> 
> Now what I found is `-Wunused-result`, aka 
> `SemaDiagnostics::warn_unused_expr`, which is triggered in the function 
> `ExprResult Sema::ActOnFinishFullExpr(Expr* FE, SourceLocation CC, bool 
> DiscardedValue, bool IsConstexpr);`. Now this function itself does //some// 
> heuristics inside (with a **lot** of `FIXME`s as of 
> rGdab5e10ea5dbc2e6314e0e7ce54a9c51fbcb44bd), but notably, `DiscardedValue` is 
> a parameter. According to a quick search, this function (and its overloads) 
> have **82** callsites within `Sema`, with many of them just tougher to 
> decipher than others. Some of the other ways this function is called, e.g. 
> `ActOnStmtExprResult`, have codes like this:
> 
> ```lang=cpp
> IsStmtExprResult = GetLookAheadToken(LookAhead).is(tok::r_brace) && 
> GetLookAheadToken(LookAhead + 1).is(tok::r_paren);
> ```
> 
> So I would say most of the logic there is **very** parsing specific, and 
> requires information that is only available during the parsing descent, and 
> not later when someone tries to consume a `const AST`.
@aaron.ballman There is a `bugprone-unused-return-value` since mid 2018, in 
which the matched function set is configurable with a hardcoded default, and 
the matching logic is also... verbose.

[[ 
http://github.com/llvm/llvm-project/blob/c1a9d14982f887355da1959eba3a47b952fc6e7a/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp#L144-L165
 | Source ]]

```lang=cpp
auto UnusedInIfStmt =
  ifStmt(eachOf(hasThen(MatchedCallExpr), hasElse(MatchedCallExpr)));
  auto UnusedInWhileStmt = whileStmt(hasBody(MatchedCallExpr));
  auto UnusedInDoStmt = doStmt(hasBody(MatchedCallExpr));
```

Agreed, this is seemingly a subset of the inverse match.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124446

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


[PATCH] D125727: [clang] Avoid suggesting typoed directives in `.S` files

2022-05-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I know it's retroactive, but this also LGTM. Thank you for the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125727

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


[PATCH] D124977: [NFC][Clang] Modify expect of fail test or XFAIL because CSKY align is different

2022-05-17 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!


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

https://reviews.llvm.org/D124977

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


[PATCH] D124701: [clang] Honor __attribute__((no_builtin("foo"))) on functions

2022-05-17 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: clang/test/CodeGen/no-builtin-2.c:51
+// CHECK:   {{.*}}call {{.*}} @memmove
+void foo4(char *s, char *d, size_t n) __attribute__((no_builtin("*"))) {
+  bar(s);

In AttrDocs.td it says the wildcard case is spelled 
"__attribute__((no_builtin))".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124701

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


[PATCH] D125604: [FileCheck] Catch missspelled directives.

2022-05-17 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev updated this revision to Diff 429997.
kosarev added a comment.
Herald added subscribers: ThomasRaoux, sdasgup3, wenzhicui, wrengr, 
Chia-hungDuan, dcaballe, cota, mravishankar, teijeong, rdzhabarov, tatianashp, 
msifontes, jurahul, Kayjukh, grosul1, Joonsoo, stephenneuendorffer, liufengdb, 
aartbik, mgester, arpith-jacob, csigg, nicolasvasilache, antiagainst, shauheen, 
rriddle, mehdi_amini.
Herald added a reviewer: antiagainst.
Herald added a reviewer: nicolasvasilache.
Herald added a reviewer: aartbik.
Herald added a project: MLIR.

Added MLIR fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125604

Files:
  clang/test/CodeGen/cmse-clear-return.c
  clang/test/CodeGenCXX/attr-mustprogress.cpp
  clang/test/CodeGenCXX/eh-aggregate-copy-destroy.cpp
  clang/test/CodeGenCXX/inheriting-constructor.cpp
  clang/test/CodeGenObjC/non-runtime-protocol.m
  clang/test/OpenMP/master_taskloop_private_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_private_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_private_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_private_codegen.cpp
  clang/test/OpenMP/task_private_codegen.cpp
  clang/test/OpenMP/taskgroup_task_reduction_codegen.cpp
  clang/test/OpenMP/taskloop_private_codegen.cpp
  clang/test/OpenMP/taskloop_simd_private_codegen.cpp
  llvm/include/llvm/FileCheck/FileCheck.h
  llvm/lib/FileCheck/FileCheck.cpp
  llvm/test/Analysis/MemorySSA/phi-translation.ll
  llvm/test/Analysis/RegionInfo/infinite_loop_4.ll
  llvm/test/CodeGen/AArch64/fp16-v8-instructions.ll
  llvm/test/CodeGen/AArch64/neon-vmull-high-p64.ll
  llvm/test/CodeGen/AMDGPU/divergence-driven-bfe-isel.ll
  llvm/test/CodeGen/AMDGPU/hoist-cond.ll
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ps.live.ll
  llvm/test/CodeGen/AMDGPU/mode-register.mir
  llvm/test/CodeGen/AMDGPU/phi-vgpr-input-moveimm.mir
  llvm/test/CodeGen/AMDGPU/smrd.ll
  llvm/test/CodeGen/ARM/cmpxchg-O0-be.ll
  llvm/test/CodeGen/AVR/atomics/fence.ll
  llvm/test/CodeGen/BPF/CORE/offset-reloc-middle-chain.ll
  llvm/test/CodeGen/MIR/AMDGPU/extra-imm-operand.mir
  llvm/test/CodeGen/MIR/AMDGPU/extra-reg-operand.mir
  llvm/test/CodeGen/Thumb2/thumb2-execute-only-prologue.ll
  llvm/test/CodeGen/WebAssembly/libcalls.ll
  llvm/test/CodeGen/X86/GlobalISel/select-ext.mir
  llvm/test/CodeGen/X86/coalesce-dead-lanes.mir
  llvm/test/CodeGen/X86/copy-propagation.ll
  llvm/test/CodeGen/X86/lvi-hardening-indirectbr.ll
  llvm/test/CodeGen/X86/statepoint-vreg-details.ll
  llvm/test/DebugInfo/NVPTX/debug-info.ll
  llvm/test/DebugInfo/X86/debug-info-template-parameter.ll
  llvm/test/FileCheck/missspelled-directive.txt
  llvm/test/MC/AMDGPU/data.s
  llvm/test/MC/AsmParser/directive_file-g.s
  llvm/test/MC/PowerPC/ppc64-reloc-directive-pcrel.s
  llvm/test/MC/WebAssembly/unnamed-data.ll
  llvm/test/Transforms/Inline/inline-strictfp.ll
  llvm/test/Transforms/LoopVectorize/X86/gather-vs-interleave.ll
  llvm/test/Transforms/MergeFunc/alias.ll
  llvm/test/Transforms/PGOProfile/PR41279.ll
  llvm/test/Transforms/PGOProfile/memop_clone.ll
  llvm/test/Transforms/PGOProfile/memop_size_from_strlen.ll
  llvm/test/tools/llvm-dwp/X86/tu_units_v5.s
  llvm/test/tools/llvm-dwp/X86/type_dedup_v5.test
  llvm/test/tools/llvm-objdump/MachO/disassemble-all.test
  llvm/test/tools/llvm-readobj/COFF/unwind-arm64-windows.test
  mlir/test/Conversion/MemRefToSPIRV/alloc.mlir
  mlir/test/Dialect/Affine/loop-coalescing.mlir
  mlir/test/Dialect/Linalg/fuse-with-reshape-by-collapsing.mlir
  mlir/test/Dialect/Linalg/tile-and-fuse-no-fuse.mlir
  mlir/test/Dialect/MemRef/canonicalize.mlir
  mlir/test/Dialect/SPIRV/IR/memory-ops.mlir
  mlir/test/Dialect/Vector/vector-transfer-full-partial-split.mlir
  mlir/test/IR/dynamic.mlir
  mlir/test/mlir-tblgen/op-decl-and-defs.td

Index: mlir/test/mlir-tblgen/op-decl-and-defs.td
===
--- mlir/test/mlir-tblgen/op-decl-and-defs.td
+++ mlir/test/mlir-tblgen/op-decl-and-defs.td
@@ -199,7 +199,7 @@
   let results = (outs AnyType:$b);
 }
 
-// CHECK_LABEL: class HCollectiveParamsOp :
+// CHECK-LABEL: class HCollectiveParamsOp :
 // CHECK: static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type b, ::mlir::Value a);
 // CHECK: static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a);
 // CHECK: static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {})
@@ -212,7 +212,7 @@
   let results = (outs Variadic:$b);
 }
 
-// CHECK_LABEL: class HCollectiveParamsSuppress0Op :
+// CHECK-LABEL: class HCollectiveParamsSuppress0Op :
 // CHECK-NOT: static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange b, ::mlir::ValueRange a

[PATCH] D125557: [APInt] Remove all uses of zextOrSelf, sextOrSelf and truncOrSelf

2022-05-17 Thread Jay Foad via Phabricator via cfe-commits
foad added inline comments.



Comment at: llvm/lib/IR/ConstantRange.cpp:724
 auto BW = getBitWidth();
-APInt Min = APInt::getMinValue(BW).zextOrSelf(ResultBitWidth);
-APInt Max = APInt::getMaxValue(BW).zextOrSelf(ResultBitWidth);
+APInt Min = APInt::getMinValue(BW);
+APInt Max = APInt::getMaxValue(BW);

foad wrote:
> efriedma wrote:
> > efriedma wrote:
> > > Making the bitwidth of the result here not equal to ResultBitWidth seems 
> > > suspect.
> > > 
> > > I think there should just be an `if (ResultBitWidth < BW) return 
> > > getFull(ResultBitWidth);` here.  Then a simple conversion just works.
> > Actually, looking at D27294 again, maybe it is actually making the result 
> > bitwidth intentionally inflate like this.
> > 
> > This could use a comment explaining what it's doing, in any case.
> I agree it could use a comment but I don't feel qualified to write it - I am 
> just trying to preserve the current behaviour.
@efriedma do you have any objection to the patch as-is?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125557

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


[PATCH] D125765: [RISCV] Add type aliases float16_t, float32_t and float64_t

2022-05-17 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead created this revision.
pcwang-thead added reviewers: asb, luismarques, kito-cheng, craig.topper.
Herald added subscribers: sunshaoce, VincentWu, luke957, jeroen.dobbelaere, 
StephenFan, vkmr, frasercrmck, evandro, apazos, sameer.abuasal, s.egerton, Jim, 
benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, 
johnrusso, rbar, arichardson.
Herald added a project: All.
pcwang-thead requested review of this revision.
Herald added subscribers: cfe-commits, eopXD.
Herald added a project: clang.

We use them in RVV intrinsics doc but there is no definition
in riscv_vector.h, which is confusing for users. This matches
what GCC does too.

There are too many tests using the raw types, so we keep them
untouched.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125765

Files:
  clang/include/clang/Basic/riscv_vector.td


Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -1504,6 +1504,16 @@
 // and LMUL.
 let HeaderCode =
 [{
+#if defined(__riscv_zvfh)
+typedef _Float16 float16_t;
+#endif
+#if defined(__riscv_f)
+typedef float float32_t;
+#endif
+#if defined(__riscv_d)
+typedef double float64_t;
+#endif
+
 #define vsetvl_e8mf8(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 5)
 #define vsetvl_e8mf4(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 6)
 #define vsetvl_e8mf2(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 7)


Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -1504,6 +1504,16 @@
 // and LMUL.
 let HeaderCode =
 [{
+#if defined(__riscv_zvfh)
+typedef _Float16 float16_t;
+#endif
+#if defined(__riscv_f)
+typedef float float32_t;
+#endif
+#if defined(__riscv_d)
+typedef double float64_t;
+#endif
+
 #define vsetvl_e8mf8(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 5)
 #define vsetvl_e8mf4(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 6)
 #define vsetvl_e8mf2(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 7)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] df2a4ea - [clang] Expose CoawaitExpr's operand in the AST

2022-05-17 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2022-05-17T08:13:37-04:00
New Revision: df2a4eae6b190806c0b96ef3312975e1c97dbda0

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

LOG: [clang] Expose CoawaitExpr's operand in the AST

Previously the Expr returned by getOperand() was actually the
subexpression common to the "ready", "suspend", and "resume"
expressions, which often isn't just the operand but e.g.
await_transform() called on the operand.

It's important for the AST to expose the operand as written
in the source for traversals and tools like clangd to work
correctly.

Fixes https://github.com/clangd/clangd/issues/939

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

Added: 
clang/test/SemaCXX/co_await-ast.cpp

Modified: 
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang/include/clang/AST/ExprCXX.h
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/TreeTransform.h
clang/test/AST/coroutine-locals-cleanup-exp-namespace.cpp
clang/test/AST/coroutine-locals-cleanup.cpp
clang/test/AST/coroutine-source-location-crash-exp-namespace.cpp
clang/test/AST/coroutine-source-location-crash.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index c21114fa45b0..f7d547bd960c 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -548,6 +548,50 @@ TEST_F(TargetDeclTest, Concept) {
{"template  concept Fooable = true"});
 }
 
+TEST_F(TargetDeclTest, Coroutine) {
+  Flags.push_back("-std=c++20");
+
+  Code = R"cpp(
+namespace std::experimental {
+template  struct coroutine_traits;
+template  struct coroutine_handle {
+  template 
+  coroutine_handle(coroutine_handle&&) noexcept;
+  static coroutine_handle from_address(void* __addr) noexcept;
+};
+} // namespace std::experimental
+
+struct executor {};
+struct awaitable {};
+struct awaitable_frame {
+  awaitable get_return_object();
+  void return_void();
+  void unhandled_exception();
+  struct result_t {
+~result_t();
+bool await_ready() const noexcept;
+void await_suspend(std::experimental::coroutine_handle) noexcept;
+void await_resume() const noexcept;
+  };
+  result_t initial_suspend() noexcept;
+  result_t final_suspend() noexcept;
+  result_t await_transform(executor) noexcept;
+};
+
+namespace std::experimental {
+template <>
+struct coroutine_traits {
+  typedef awaitable_frame promise_type;
+};
+} // namespace std::experimental
+
+awaitable foo() {
+  co_await [[executor]]();
+}
+  )cpp";
+  EXPECT_DECLS("RecordTypeLoc", "struct executor");
+}
+
 TEST_F(TargetDeclTest, FunctionTemplate) {
   Code = R"cpp(
 // Implicit specialization.

diff  --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 3da9290c7dfb..967a74db916d 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -4698,18 +4698,19 @@ class CoroutineSuspendExpr : public Expr {
 
   SourceLocation KeywordLoc;
 
-  enum SubExpr { Common, Ready, Suspend, Resume, Count };
+  enum SubExpr { Operand, Common, Ready, Suspend, Resume, Count };
 
   Stmt *SubExprs[SubExpr::Count];
   OpaqueValueExpr *OpaqueValue = nullptr;
 
 public:
-  CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, Expr *Common,
-   Expr *Ready, Expr *Suspend, Expr *Resume,
+  CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, Expr *Operand,
+   Expr *Common, Expr *Ready, Expr *Suspend, Expr *Resume,
OpaqueValueExpr *OpaqueValue)
   : Expr(SC, Resume->getType(), Resume->getValueKind(),
  Resume->getObjectKind()),
 KeywordLoc(KeywordLoc), OpaqueValue(OpaqueValue) {
+SubExprs[SubExpr::Operand] = Operand;
 SubExprs[SubExpr::Common] = Common;
 SubExprs[SubExpr::Ready] = Ready;
 SubExprs[SubExpr::Suspend] = Suspend;
@@ -4718,10 +4719,11 @@ class CoroutineSuspendExpr : public Expr {
   }
 
   CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, QualType Ty,
-   Expr *Common)
+   Expr *Operand, Expr *Common)
   : Expr(SC, Ty, VK_PRValue, OK_Ordinary), KeywordLoc(KeywordLoc) {
 assert(Common->isTypeDependent() && Ty->isDependentType() &&
"wrong constructor for non-dependent co_await/co_yield expression");
+SubExprs[SubExpr::Operand] = Operand;
 SubExprs[SubExpr::Common] = Common;
 SubExprs[SubExpr::Ready] = nullptr;
 

[PATCH] D115187: [clangd] Expose CoawaitExpr's operand in the AST

2022-05-17 Thread Nathan Ridge 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 rGdf2a4eae6b19: [clang] Expose CoawaitExpr's operand in 
the AST (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115187

Files:
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/AST/coroutine-locals-cleanup-exp-namespace.cpp
  clang/test/AST/coroutine-locals-cleanup.cpp
  clang/test/AST/coroutine-source-location-crash-exp-namespace.cpp
  clang/test/AST/coroutine-source-location-crash.cpp
  clang/test/SemaCXX/co_await-ast.cpp

Index: clang/test/SemaCXX/co_await-ast.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/co_await-ast.cpp
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -ast-dump -ast-dump-filter=foo %s | FileCheck %s --strict-whitespace
+
+namespace std {
+template  struct coroutine_traits;
+template  struct coroutine_handle {
+  template 
+  coroutine_handle(coroutine_handle &&) noexcept;
+  static coroutine_handle from_address(void *__addr) noexcept;
+};
+} // namespace std
+
+struct executor {};
+struct awaitable {};
+struct awaitable_frame {
+  awaitable get_return_object();
+  void return_void();
+  void unhandled_exception();
+  struct result_t {
+~result_t();
+bool await_ready() const noexcept;
+void await_suspend(std::coroutine_handle) noexcept;
+void await_resume() const noexcept;
+  };
+  result_t initial_suspend() noexcept;
+  result_t final_suspend() noexcept;
+  result_t await_transform(executor) noexcept;
+};
+
+namespace std {
+template <>
+struct coroutine_traits {
+  typedef awaitable_frame promise_type;
+};
+} // namespace std
+
+awaitable foo() {
+  co_await executor();
+}
+
+// Check that CoawaitExpr contains the correct subexpressions, including
+// the operand expression as written in the source.
+
+// CHECK-LABEL: Dumping foo:
+// CHECK: FunctionDecl {{.*}} foo 'awaitable ()'
+// CHECK: `-CoroutineBodyStmt {{.*}}
+// CHECK:   |-CompoundStmt {{.*}}
+// CHECK:   | `-ExprWithCleanups {{.*}} 'void'
+// CHECK:   |   `-CoawaitExpr {{.*}} 'void'
+// CHECK:   | |-CXXTemporaryObjectExpr {{.*}} 'executor' 'void () noexcept' zeroing
+// CHECK:   | |-MaterializeTemporaryExpr {{.*}} 'awaitable_frame::result_t' lvalue
+// CHECK:   | | `-CXXBindTemporaryExpr {{.*}} 'awaitable_frame::result_t' (CXXTemporary {{.*}})
+// CHECK:   | |   `-CXXMemberCallExpr {{.*}} 'awaitable_frame::result_t'
+// CHECK:   | | |-MemberExpr {{.*}} '' .await_transform {{.*}}
+// CHECK:   | | | `-DeclRefExpr {{.*}} 'std::coroutine_traits::promise_type':'awaitable_frame' lvalue Var {{.*}} '__promise' 'std::coroutine_traits::promise_type':'awaitable_frame'
+// CHECK:   | | `-CXXTemporaryObjectExpr {{.*}} 'executor' 'void () noexcept' zeroing
+// CHECK:   | |-ExprWithCleanups {{.*}} 'bool'
+// CHECK:   | | `-CXXMemberCallExpr {{.*}} 'bool'
+// CHECK:   | |   `-MemberExpr {{.*}} '' .await_ready {{.*}}
+// CHECK:   | | `-ImplicitCastExpr {{.*}} 'const awaitable_frame::result_t' lvalue 
+// CHECK:   | |   `-OpaqueValueExpr {{.*}} 'awaitable_frame::result_t' lvalue
+// CHECK:   | | `-MaterializeTemporaryExpr {{.*}} 'awaitable_frame::result_t' lvalue
+// CHECK:   | |   `-CXXBindTemporaryExpr {{.*}} 'awaitable_frame::result_t' (CXXTemporary {{.*}})
+// CHECK:   | | `-CXXMemberCallExpr {{.*}} 'awaitable_frame::result_t'
+// CHECK:   | |   |-MemberExpr {{.*}} '' .await_transform {{.*}}
+// CHECK:   | |   | `-DeclRefExpr {{.*}} 'std::coroutine_traits::promise_type':'awaitable_frame' lvalue Var {{.*}} '__promise' 'std::coroutine_traits::promise_type':'awaitable_frame'
+// CHECK:   | |   `-CXXTemporaryObjectExpr {{.*}} 'executor' 'void () noexcept' zeroing
+// CHECK:   | |-ExprWithCleanups {{.*}} 'void'
+// CHECK:   | | `-CXXMemberCallExpr {{.*}} 'void'
+// CHECK:   | |   |-MemberExpr {{.*}} '' .await_suspend {{.*}}
+// CHECK:   | |   | `-OpaqueValueExpr {{.*}} 'awaitable_frame::result_t' lvalue
+// CHECK:   | |   |   `-MaterializeTemporaryExpr {{.*}} 'awaitable_frame::result_t' lvalue
+// CHECK:   | |   | `-CXXBindTemporaryExpr {{.*}} 'awaitable_frame::result_t' (CXXTemporary {{.*}})
+// CHECK:   | |   |   `-CXXMemberCallExpr {{.*}} 'awaitable_frame::result_t'
+// CHECK:   | |   | |-MemberExpr {{.*}} '' .await_transform {{.*}}
+// CHECK:   | |   | | `-DeclRefExpr {{.*}} 'std::coroutine_traits::promise_type':'awaitable_frame' lvalue Var {{.*}} '__promise' 'std::coroutine_traits::promise_type':'

[PATCH] D125513: [clang-cl] Add /Zc:wchar_t- option

2022-05-17 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: clang/test/Driver/cl-zc.cpp:50
 // RUN: %clang_cl /c -### /Zc:wchar_t- -- %s 2>&1 | FileCheck 
-check-prefix=WCHAR_T-OFF %s
-// WCHAR_T-OFF: argument unused during compilation
+// WCHAR_T-OFF: "-fno-wchar"
 

Should probably remove `/Zc:wchar_t` from the list of ignored options in 
clang/test/Driver/cl-options.c too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125513

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


[PATCH] D125711: [concepts] Implement dcl.decl.general p4: No constraints on non-template funcs

2022-05-17 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked an inline comment as done.
erichkeane added a comment.

In D125711#3517065 , @royjacobson 
wrote:

> Code and added/modified tests LGTM!
>
> Do you think we should add a release note, given that it could break existing 
> code? Its seems a bit unlikely, but the amount of broken tests have made me a 
> bit worried.
> Also, maybe mention the github issue 
> (https://github.com/llvm/llvm-project/issues/51173) in the commit message.

Thanks for the review!  I absolutely need a release note, I'll add one before 
committing.


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

https://reviews.llvm.org/D125711

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


[PATCH] D124446: [clang-tidy] Add the misc-discarded-return-value check

2022-05-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/misc/DiscardedReturnValueCheck.cpp:83-86
+void DiscardedReturnValueCheck::onStartOfTranslationUnit() {
+  ConsumedCalls.clear();
+  CallMap.clear();
+}

whisperity wrote:
> aaron.ballman wrote:
> > Is this code necessary?
> Yes, if you have checks that store TU-specific data, and you run `clang-tidy 
> a.cpp b.cpp` then if you do not clear the data structures, dangling pointers 
> into already destroyed ASTs will remain.
Ah, thank you!



Comment at: clang-tools-extra/clang-tidy/misc/DiscardedReturnValueCheck.cpp:181
+
+  static const auto Decltype = decltypeType(hasUnderlyingExpr(Call));
+  static const auto TemplateArg =

whisperity wrote:
> whisperity wrote:
> > whisperity wrote:
> > > aaron.ballman wrote:
> > > > So, I'm not super keen on this approach of having to try to identify 
> > > > every single place in which an expression is considered to be "used" -- 
> > > > this is going to be fragile because we'll miss places and it's going to 
> > > > be a maintenance burden because new places will be added as the 
> > > > languages evolve.
> > > > 
> > > > For example, if we're handling `decltype` as a use, why not `noexcept`? 
> > > > Or conditional `explicit`? What about a `co_return` statement?
> > > > 
> > > > I'm not certain what we can do to improve this, but I think it's worth 
> > > > trying to explore options to see if we can generalize what constitutes 
> > > > a use so that we can write a few custom matchers to do the heavy 
> > > > lifting instead of trying to play whack-a-mole.
> > > I've been having other thoughts about this `decltype` here... Actually, 
> > > neither `decltype` nor `noexcept` should be handled as a //"use"// at 
> > > all, while `co_return` should be the same as a `return` -- however, I 
> > > think it was due to lack of projects where such could be meaningfully 
> > > measured as a missed case was why implementing that failed.
> > > 
> > > For `decltype`, `typedef`, and `noexcept` (and perhaps several others), 
> > > the good solution would be having a third route: calls that //should not 
> > > be counted//. Neither as a "consumed call", nor as a "bare call". 
> > > Ignored, from both calculations. Maybe even for template arguments below.
> > As for better matching... Unfortunately, types in the AST are so varied and 
> > `hasDescendant` is too generic to express something like 
> > `stmt(anyOf(ifStmt(), forStmt(), switchStmt()), hasDescendant(Call))` to 
> > express in a single expression matching uses... The conditions are not 
> > always direct children of the outer node, while `hasDescendant` will match 
> > not just the condition but the entire tree... resulting in things like 
> > //both// functions in
> > 
> > ```lang=cpp
> > if (foo())
> >   bar()
> > ```
> > 
> > matching.
> > 
> > Well... generalisation... I can throw in a formal fluke:
> > 
> > > A **use** is a //context// for a specific `CallExpr C` in which we can 
> > > reasonably assume that the value produced by evaluating `C` is loaded by 
> > > another expression.
> > 
> > Now what I found is `-Wunused-result`, aka 
> > `SemaDiagnostics::warn_unused_expr`, which is triggered in the function 
> > `ExprResult Sema::ActOnFinishFullExpr(Expr* FE, SourceLocation CC, bool 
> > DiscardedValue, bool IsConstexpr);`. Now this function itself does //some// 
> > heuristics inside (with a **lot** of `FIXME`s as of 
> > rGdab5e10ea5dbc2e6314e0e7ce54a9c51fbcb44bd), but notably, `DiscardedValue` 
> > is a parameter. According to a quick search, this function (and its 
> > overloads) have **82** callsites within `Sema`, with many of them just 
> > tougher to decipher than others. Some of the other ways this function is 
> > called, e.g. `ActOnStmtExprResult`, have codes like this:
> > 
> > ```lang=cpp
> > IsStmtExprResult = GetLookAheadToken(LookAhead).is(tok::r_brace) && 
> > GetLookAheadToken(LookAhead + 1).is(tok::r_paren);
> > ```
> > 
> > So I would say most of the logic there is **very** parsing specific, and 
> > requires information that is only available during the parsing descent, and 
> > not later when someone tries to consume a `const AST`.
> @aaron.ballman There is a `bugprone-unused-return-value` since mid 2018, in 
> which the matched function set is configurable with a hardcoded default, and 
> the matching logic is also... verbose.
> 
> [[ 
> http://github.com/llvm/llvm-project/blob/c1a9d14982f887355da1959eba3a47b952fc6e7a/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp#L144-L165
>  | Source ]]
> 
> ```lang=cpp
> auto UnusedInIfStmt =
>   ifStmt(eachOf(hasThen(MatchedCallExpr), hasElse(MatchedCallExpr)));
>   auto UnusedInWhileStmt = whileStmt(hasBody(MatchedCallExpr));
>   auto UnusedInDoStmt = doStmt(hasBody(MatchedCallExpr));
> ```
> 
> Agreed, this is seemingly a subset of the inverse match.
> For decltype, typedef, and noexcept (and 

[PATCH] D124446: [clang-tidy] Add the misc-discarded-return-value check

2022-05-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Btw, I'm in C standards meetings all week this week, so my reviews are going to 
be delayed by a bit, just as an FYI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124446

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


[PATCH] D125209: [clang-tidy] modernize-deprecated-headers check should respect extern "C" blocks

2022-05-17 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 430012.
steakhal added a comment.
This revision is now accepted and ready to land.

- Copy the `mylib.h` under the build directory to have deterministic relative 
order to the LIT test file.
- Use `SourceManager::isBeforeInTranslationUnit` instead of the fancy 
decomposed decl logarithmic search.
- Add a test for including a system header containing a deprecated include.
- Add `REQUIRES: system-linux` clause to the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125209

Files:
  clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
  clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-deprecated-headers/mylib.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-deprecated-headers/mysystemlib.h
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
@@ -0,0 +1,66 @@
+
+// Copy the 'mylib.h' to a directory under the build directory. This is
+// required, since the relative order of the emitted diagnostics depends on the
+// absolute file paths which is sorted by clang-tidy prior emitting.
+//
+// RUN: mkdir -p %t/sys && mkdir -p %t/usr \
+// RUN:   && cp %S/Inputs/modernize-deprecated-headers/mysystemlib.h %t/sys/mysystemlib.h \
+// RUN:   && cp %S/Inputs/modernize-deprecated-headers/mylib.h   %t/usr/mylib.h
+
+// RUN: %check_clang_tidy -std=c++11 %s modernize-deprecated-headers %t \
+// RUN:   --header-filter='.*' --system-headers \
+// RUN:   -- -I %t/usr -isystem %t/sys -isystem %S/Inputs/modernize-deprecated-headers
+
+// REQUIRES: system-linux
+
+#define EXTERN_C extern "C"
+
+extern "C++" {
+// We should still have the warnings here.
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it [modernize-deprecated-headers]
+}
+
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
+
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it [modernize-deprecated-headers]
+
+#include  // FIXME: We should have no warning into system headers.
+// CHECK-MESSAGES: mysystemlib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
+
+#include 
+// CHECK-MESSAGES: mylib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
+
+namespace wrapping {
+extern "C" {
+#include   // no-warning
+#include// no-warning
+#include  // no-warning
+}
+} // namespace wrapping
+
+extern "C" {
+namespace wrapped {
+#include   // no-warning
+#include// no-warning
+#include  // no-warning
+} // namespace wrapped
+}
+
+namespace wrapping {
+extern "C" {
+namespace wrapped {
+#include   // no-warning
+#include// no-warning
+#include  // no-warning
+} // namespace wrapped
+}
+} // namespace wrapping
+
+EXTERN_C {
+#include   // no-warning
+#include// no-warning
+#include  // no-warning
+}
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-deprecated-headers/mysystemlib.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-deprecated-headers/mysystemlib.h
@@ -0,0 +1 @@
+#include 
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-deprecated-headers/mylib.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-deprecated-headers/mylib.h
@@ -0,0 +1 @@
+#include 
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -170,6 +170,11 @@
   ` involving assignments in
   conditions. This fixes `Issue 35853 `_.
 
+- Fixed a false positive in :doc:`modernize-deprecated-headers
+  ` involving including
+  C header files from C++ files wrapped by ``extern "C" { ... }`` blocks.
+  Such includes will be ignored by now.
+
 - Improved :doc:`performance-inefficient-vector-operation
   ` to work when
   the vector is a member of a structure.
Index: clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.h
===
--- 

[clang] 99639e5 - Enabling the detection of devtoolset-11 toolchain.

2022-05-17 Thread Kamau Bridgeman via cfe-commits

Author: Kamau Bridgeman
Date: 2022-05-17T07:57:45-05:00
New Revision: 99639e5a3e6e7f3f207128fc3bfd707596d5ba59

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

LOG: Enabling the detection of devtoolset-11 toolchain.

This patch allows systems to build the llvm-project with the devtoolset-11
toolchain.

Reviewed By: phosek

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 183828dcaa734..003a97e2c3ebb 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2150,7 +2150,9 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   // Non-Solaris is much simpler - most systems just go with "/usr".
   if (SysRoot.empty() && TargetTriple.getOS() == llvm::Triple::Linux) {
 // Yet, still look for RHEL/CentOS devtoolsets and gcc-toolsets.
+Prefixes.push_back("/opt/rh/gcc-toolset-11/root/usr");
 Prefixes.push_back("/opt/rh/gcc-toolset-10/root/usr");
+Prefixes.push_back("/opt/rh/devtoolset-11/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-10/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-9/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-8/root/usr");



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


[PATCH] D125499: Enabling the detection of devtoolset-11 toolchain.

2022-05-17 Thread Kamau Bridgeman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG99639e5a3e6e: Enabling the detection of devtoolset-11 
toolchain. (authored by kamaub).

Changed prior to commit:
  https://reviews.llvm.org/D125499?vs=429059&id=430013#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125499

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2150,7 +2150,9 @@
   // Non-Solaris is much simpler - most systems just go with "/usr".
   if (SysRoot.empty() && TargetTriple.getOS() == llvm::Triple::Linux) {
 // Yet, still look for RHEL/CentOS devtoolsets and gcc-toolsets.
+Prefixes.push_back("/opt/rh/gcc-toolset-11/root/usr");
 Prefixes.push_back("/opt/rh/gcc-toolset-10/root/usr");
+Prefixes.push_back("/opt/rh/devtoolset-11/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-10/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-9/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-8/root/usr");


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2150,7 +2150,9 @@
   // Non-Solaris is much simpler - most systems just go with "/usr".
   if (SysRoot.empty() && TargetTriple.getOS() == llvm::Triple::Linux) {
 // Yet, still look for RHEL/CentOS devtoolsets and gcc-toolsets.
+Prefixes.push_back("/opt/rh/gcc-toolset-11/root/usr");
 Prefixes.push_back("/opt/rh/gcc-toolset-10/root/usr");
+Prefixes.push_back("/opt/rh/devtoolset-11/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-10/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-9/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-8/root/usr");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125769: [clang-tidy] Introduce the WarnIntoHeaders option to modernize-deprecated-headers

2022-05-17 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: aaron.ballman, whisperity, LegalizeAdulthood, alexfh.
Herald added subscribers: carlosgalvezp, martong, rnkovacs, xazax.hun.
Herald added a project: All.
steakhal requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Unfortunately, we must restrict the checker to warn for deprecated headers
only if the header is included directly from a c++ source file.

For header files, we cannot know if the project has a C source file
that also directly/indirectly includes the offending header file
otherwise. Thus, it's better to be on the safe side and suppress those
reports.

One can opt-in the old behavior, emitting diagnostics into header files,
if one explicitly sets the `WarnIntoHeaders=true`, in which case nothing
will be changed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125769

Files:
  clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
  clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
@@ -8,6 +8,13 @@
 // RUN:   && cp %S/Inputs/modernize-deprecated-headers/mylib.h   %t/usr/mylib.h
 
 // RUN: %check_clang_tidy -std=c++11 %s modernize-deprecated-headers %t \
+// RUN:   -check-suffixes=DEFAULT \
+// RUN:   --header-filter='.*' --system-headers \
+// RUN:   -- -I %t/usr -isystem %t/sys -isystem %S/Inputs/modernize-deprecated-headers
+
+// RUN: %check_clang_tidy -std=c++11 %s modernize-deprecated-headers %t \
+// RUN:   -check-suffixes=DEFAULT,WARN-INTO-HEADERS \
+// RUN:   -config="{CheckOptions: [{key: modernize-deprecated-headers.WarnIntoHeaders, value: 'true'}]}" \
 // RUN:   --header-filter='.*' --system-headers \
 // RUN:   -- -I %t/usr -isystem %t/sys -isystem %S/Inputs/modernize-deprecated-headers
 
@@ -18,20 +25,20 @@
 extern "C++" {
 // We should still have the warnings here.
 #include 
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it [modernize-deprecated-headers]
+// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it [modernize-deprecated-headers]
 }
 
 #include 
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
+// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
 
 #include 
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it [modernize-deprecated-headers]
+// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it [modernize-deprecated-headers]
 
 #include  // FIXME: We should have no warning into system headers.
-// CHECK-MESSAGES: mysystemlib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
+// CHECK-MESSAGES-WARN-INTO-HEADERS: mysystemlib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
 
 #include 
-// CHECK-MESSAGES: mylib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
+// CHECK-MESSAGES-WARN-INTO-HEADERS: mylib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
 
 namespace wrapping {
 extern "C" {
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -174,6 +174,10 @@
   ` involving including
   C header files from C++ files wrapped by ``extern "C" { ... }`` blocks.
   Such includes will be ignored by now.
+  By default now it doesn't warn for including deprecated headers from header
+  files, since that header file might be used from C source files. By passing
+  the ``WarnIntoHeaders=true`` option if header files of the project only
+  included by c++ source files.
 
 - Improved :doc:`performance-inefficient-vector-operation
   ` to work when
Index: clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.h
===
--- clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersC

[PATCH] D125770: [clang-tidy] modernize-deprecated-headers should ignore system headers

2022-05-17 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: aaron.ballman, whisperity, LegalizeAdulthood, alexfh.
Herald added subscribers: carlosgalvezp, martong, rnkovacs, xazax.hun.
Herald added a project: All.
steakhal requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

The end-user has no way of 'fixing' bugs in the system library anyway.
Let's suppress these as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125770

Files:
  clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
@@ -34,8 +34,7 @@
 #include 
 // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:10: warning: including 'stdbool.h' has 
no effect in C++; consider removing it [modernize-deprecated-headers]
 
-#include  // FIXME: We should have no warning into system 
headers.
-// CHECK-MESSAGES-WARN-INTO-HEADERS: mysystemlib.h:1:10: warning: inclusion of 
deprecated C++ header 'assert.h'; consider using 'cassert' instead 
[modernize-deprecated-headers]
+#include  // no-warning: Don't warn into system headers.
 
 #include 
 // CHECK-MESSAGES-WARN-INTO-HEADERS: mylib.h:1:10: warning: inclusion of 
deprecated C++ header 'assert.h'; consider using 'cassert' instead 
[modernize-deprecated-headers]
Index: clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
@@ -182,6 +182,10 @@
   if (!Check.WarnIntoHeaders && !SM.isInMainFile(HashLoc))
 return;
 
+  // Ignore system headers.
+  if (SM.isInSystemHeader(HashLoc))
+return;
+
   // FIXME: Take care of library symbols from the global namespace.
   //
   // Reasonable options for the check:


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
@@ -34,8 +34,7 @@
 #include 
 // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it [modernize-deprecated-headers]
 
-#include  // FIXME: We should have no warning into system headers.
-// CHECK-MESSAGES-WARN-INTO-HEADERS: mysystemlib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
+#include  // no-warning: Don't warn into system headers.
 
 #include 
 // CHECK-MESSAGES-WARN-INTO-HEADERS: mylib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
Index: clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
@@ -182,6 +182,10 @@
   if (!Check.WarnIntoHeaders && !SM.isInMainFile(HashLoc))
 return;
 
+  // Ignore system headers.
+  if (SM.isInSystemHeader(HashLoc))
+return;
+
   // FIXME: Take care of library symbols from the global namespace.
   //
   // Reasonable options for the check:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125771: [clang-tidy] Add a useful note about -std=c++11-or-later

2022-05-17 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: aaron.ballman, whisperity, LegalizeAdulthood, alexfh.
Herald added subscribers: martong, rnkovacs, xazax.hun.
Herald added a project: All.
steakhal requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

I and @whisperity spent some time debugging a LIT test case using the
`-std=c++11-or-later` `check_clang_tidy.py` flag when the test had
fixits.

It turns out if the test wants to report a diagnostic into a header
file AND into the test file as well, one needs to first copy the header
somewhere under the build directory.
It needs to be copied since `clang-tidy` sorts the reports into
alphabetical order, thus to have a deterministic order relative to the
diagnostic in the header AND the diagnostic in the test cpp file.

There is more to this story.

The `-std=c++11-or-later` turns out executes the test with multiple
`-std=XX` version substitution and each execution will also have the
`-fix` tidy parameter. This means that the freshly copied header file I
stated in the previous paragraph gets fixed up and the very next tidy
execution will fail miserably.

Following @whisperity's advice, I'm leaving a reminder about such
//shared// state in the related doc comment.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125771

Files:
  clang-tools-extra/test/clang-tidy/check_clang_tidy.py


Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -19,11 +19,17 @@
 [-assume-filename=] \
 [-check-suffix=] \
 [-check-suffixes=] \
+[-std=(c++11-or-later|c++17)] \
\
 -- [optional clang-tidy arguments]
 
 Example:
   // RUN: %check_clang_tidy %s llvm-include-order %t -- -- -isystem %S/Inputs
+
+Notes:
+  -std=c++11-or-later:
+This flag will cause multiple runs withing the same check_clang_tidy
+execution. Make sure you don't have shared state across these runs.
 """
 
 import argparse


Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -19,11 +19,17 @@
 [-assume-filename=] \
 [-check-suffix=] \
 [-check-suffixes=] \
+[-std=(c++11-or-later|c++17)] \
\
 -- [optional clang-tidy arguments]
 
 Example:
   // RUN: %check_clang_tidy %s llvm-include-order %t -- -- -isystem %S/Inputs
+
+Notes:
+  -std=c++11-or-later:
+This flag will cause multiple runs withing the same check_clang_tidy
+execution. Make sure you don't have shared state across these runs.
 """
 
 import argparse
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D123773: [clang][analyzer][ctu] Make CTU a two phase analysis

2022-05-17 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp:446
+}
+const bool BState = State->contains(D);
+if (!BState) { // This is the first time we see this foreign function.

xazax.hun wrote:
> martong wrote:
> > xazax.hun wrote:
> > > xazax.hun wrote:
> > > > martong wrote:
> > > > > xazax.hun wrote:
> > > > > > So if we see the same foreign function called in multiple contexts, 
> > > > > > we will only queue one of the contexts for the CTU. Is this the 
> > > > > > intended design? 
> > > > > > 
> > > > > > So if I see:
> > > > > > ```
> > > > > > foreign(true);
> > > > > > foreign(false);
> > > > > > ```
> > > > > > 
> > > > > > The new CTU will only evaluate `foreign(true)` but not 
> > > > > > `foreign(false)`. 
> > > > > This is intentional.
> > > > > ```
> > > > > foreign(true);
> > > > > foreign(false);
> > > > > ```
> > > > > The new CTU will evaluate the following paths in the exploded graph:
> > > > > ```
> > > > > foreign(true); // conservative evaluated
> > > > > foreign(false); // conservative evaluated
> > > > > foreign(true); // inlined
> > > > > foreign(false); // inlined
> > > > > ```
> > > > > The point is to keep bifurcation to a minimum and avoid the 
> > > > > exponential blow up.
> > > > > So, we will never have a path like this:
> > > > > ```
> > > > > foreign(true); // conservative evaluated
> > > > > foreign(false); // inlined
> > > > > ```
> > > > > 
> > > > > Actually, this is the same strategy that we use during the dynamic 
> > > > > dispatch of C++ virtual calls. See `DynamicDispatchBifurcationMap`.
> > > > > 
> > > > > The conservative evaluation happens in the first phase, the inlining 
> > > > > in the second phase (assuming the phase1 inlining option is set to 
> > > > > none).
> > > > > The new CTU will evaluate the following paths in the exploded graph:
> > > > > ```
> > > > > foreign(true); // conservative evaluated
> > > > > foreign(false); // conservative evaluated
> > > > > foreign(true); // inlined
> > > > > foreign(false); // inlined
> > > > > ```
> > > > 
> > > > When we encounter `foreign(true)`, we would add the decl to 
> > > > `CTUDispatchBifurcationSet`. So the second time we see a call to the 
> > > > function `foreign(false);`, we will just do the conservative evaluation 
> > > > and will not add the call to the CTU worklist. So how will 
> > > > `foreign(false);` be inlined in the second pass? Do I miss something? 
> > > > 
> > > Oh, I think I now understand. Do you expect `foreign(false);` to be 
> > > inlined after we return from `foreign(true);` in the second pass? Sorry 
> > > for the confusion, in that case it looks good to me.
> > > Oh, I think I now understand. Do you expect `foreign(false);` to be 
> > > inlined after we return from `foreign(true);` in the second pass?
> > 
> > Yes, that's right.
> Actually, in this case I wonder whether we really need a set of declarations. 
> Wouldn't a boolean be sufficient for each path?
> 
> So in case of:
> ```
> foreign1(true);
> foreign2(false);
> ```
> 
> Why would we want to add `foreign2` to the CTU worklist? More specifically, 
> why is it important whether a foreign call is actually the same declaration 
> that we saw earlier on the path? Isn't being foreign the only important 
> information in this case?
Good point. 

By using the set of declarations we might have a path where `foreign1` is 
conservatively evaluated and then `foreign2` is inlined. I was having a hard 
time to find any use-cases where this would be useful, but could not find one. 

On the other hand, by using a `bool`, as you suggest, no such superfluous path 
would exist. Plus, the dependent child patch (D123784) is becoming unnecessary 
because the CTUWorklist will have at most one element during the first phase.

Besides, I've made measurements comparing the `bool` and the `set` 
implementation. The results are quite similar. Both have lost the same amount 
of bugreports compared to the single-tu analysis and the average length of the 
bugpaths are also similar. {F23090628}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123773

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


[clang-tools-extra] 86bc639 - [pseudo] Add the missing ; terminal for module-declaration rule.

2022-05-17 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-05-17T15:14:46+02:00
New Revision: 86bc6399a063439f2c58f9eed3ee6bf2d9276bf6

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

LOG: [pseudo] Add the missing ; terminal for module-declaration rule.

Added: 


Modified: 
clang-tools-extra/pseudo/lib/cxx.bnf

Removed: 




diff  --git a/clang-tools-extra/pseudo/lib/cxx.bnf 
b/clang-tools-extra/pseudo/lib/cxx.bnf
index c740f742436dc..3a4048f657570 100644
--- a/clang-tools-extra/pseudo/lib/cxx.bnf
+++ b/clang-tools-extra/pseudo/lib/cxx.bnf
@@ -512,7 +512,7 @@ linkage-specification := EXTERN string-literal { 
declaration-seq_opt }
 linkage-specification := EXTERN string-literal declaration
 
 # gram.module
-module-declaration := export-keyword_opt module-keyword module-name 
module-partition_opt
+module-declaration := export-keyword_opt module-keyword module-name 
module-partition_opt ;
 module-name := module-name-qualifier_opt IDENTIFIER
 module-partition := : module-name-qualifier_opt IDENTIFIER
 module-name-qualifier := IDENTIFIER .



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


[PATCH] D125084: [test, x86] Fix spurious x86-target-features.c failure

2022-05-17 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/test/Driver/x86-target-features.c:173
 // LVIHARDENING: "-target-feature" "+lvi-load-hardening" "-target-feature" 
"+lvi-cfi"
-// NO-LVIHARDENING-NOT: lvi
+// NO-LVIHARDENING-NOT: "-target-feature" "+lvi
 

How about just `// NO-LVIHARDENING-NOT: "+lvi-`? It should be distinct enough. 
We intentionally use less combination on a negative test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125084

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


[PATCH] D107082: [X86][RFC] Enable `_Float16` type support on X86 following the psABI

2022-05-17 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 430019.
pengfei added a comment.
Herald added subscribers: armkevincheng, eric-k256, javed.absar.
Herald added a reviewer: sjarus.

Rebased on the avx512fp16 implementation. Still WIP for optimizations and a 
fast RA issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107082

Files:
  llvm/docs/ReleaseNotes.rst
  llvm/lib/Target/X86/X86FastISel.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86InstrAVX512.td
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86InstrInfo.cpp
  llvm/lib/Target/X86/X86InstrSSE.td
  llvm/lib/Target/X86/X86InstrVecCompiler.td
  llvm/lib/Target/X86/X86InstructionSelector.cpp
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/test/Analysis/CostModel/X86/fptoi_sat.ll
  llvm/test/CodeGen/MIR/X86/inline-asm-registers.mir
  llvm/test/CodeGen/X86/atomic-non-integer.ll
  llvm/test/CodeGen/X86/avx512-insert-extract.ll
  llvm/test/CodeGen/X86/avx512-masked_memop-16-8.ll
  llvm/test/CodeGen/X86/callbr-asm-bb-exports.ll
  llvm/test/CodeGen/X86/cvt16-2.ll
  llvm/test/CodeGen/X86/cvt16.ll
  llvm/test/CodeGen/X86/fastmath-float-half-conversion.ll
  llvm/test/CodeGen/X86/fmf-flags.ll
  llvm/test/CodeGen/X86/fp-round.ll
  llvm/test/CodeGen/X86/fp-roundeven.ll
  llvm/test/CodeGen/X86/fp128-cast-strict.ll
  llvm/test/CodeGen/X86/fpclamptosat.ll
  llvm/test/CodeGen/X86/fpclamptosat_vec.ll
  llvm/test/CodeGen/X86/fptosi-sat-scalar.ll
  llvm/test/CodeGen/X86/fptosi-sat-vector-128.ll
  llvm/test/CodeGen/X86/fptoui-sat-scalar.ll
  llvm/test/CodeGen/X86/fptoui-sat-vector-128.ll
  llvm/test/CodeGen/X86/freeze.ll
  llvm/test/CodeGen/X86/half-constrained.ll
  llvm/test/CodeGen/X86/half.ll
  llvm/test/CodeGen/X86/pr31088.ll
  llvm/test/CodeGen/X86/pr38533.ll
  llvm/test/CodeGen/X86/pr47000.ll
  llvm/test/CodeGen/X86/scheduler-asm-moves.mir
  llvm/test/CodeGen/X86/shuffle-extract-subvector.ll
  llvm/test/CodeGen/X86/statepoint-invoke-ra-enter-at-end.mir
  llvm/test/CodeGen/X86/vec_fp_to_int.ll
  llvm/test/CodeGen/X86/vector-half-conversions.ll
  llvm/test/CodeGen/X86/vector-reduce-fmax-nnan.ll
  llvm/test/CodeGen/X86/vector-reduce-fmin-nnan.ll
  llvm/test/MC/X86/x86_64-asm-match.s

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


[clang] 6da3d66 - [concepts] Implement dcl.decl.general p4: No constraints on non-template funcs

2022-05-17 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2022-05-17T06:21:51-07:00
New Revision: 6da3d66f03f9162ef341cc67218be40e22fe9808

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

LOG: [concepts] Implement dcl.decl.general p4: No constraints on non-template 
funcs

The standard says:
The optional requires-clause ([temp.pre]) in an init-declarator or
member-declarator shall be present only if the declarator declares a
templated function ([dcl.fct]).

This implements that limitation, and updates the tests to the best of my
ability to capture the intent of the original checks.

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

Added: 
clang/test/CXX/dcl.decl/dcl.decl.general/p4-20.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDecl.cpp
clang/test/CXX/dcl/dcl.decl/p3.cpp
clang/test/CXX/expr/expr.prim/expr.prim.id/p4.cpp
clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
clang/test/CXX/over/over.match/over.match.viable/p3.cpp
clang/test/CXX/over/over.over/p4-2a.cpp
clang/test/Parser/cxx-concepts-requires-clause.cpp
clang/test/Parser/cxx2a-concepts-requires-expr.cpp
clang/test/SemaCXX/cxx20-check-fptr-constraints.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8058df16bc4c3..79e5a4622e8a6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -365,6 +365,8 @@ C++ Language Changes in Clang
   of clang; use the ``-fclang-abi-compat=14`` option to get the old mangling.
 - Preprocessor character literals with a ``u8`` prefix are now correctly 
treated as
   unsigned character literals. This fixes `Issue 54886 
`_.
+- Stopped allowing constriants on non-template functions to be compliant with
+  dcl.decl.general p4.
 
 C++20 Feature Support
 ^

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e03c583c63fe4..da44a0405b05c 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2853,6 +2853,8 @@ def err_constrained_virtual_method : Error<
   "virtual function cannot have a requires clause">;
 def err_trailing_requires_clause_on_deduction_guide : Error<
   "deduction guide cannot have a requires clause">;
+def err_constrained_non_templated_function
+: Error<"non-templated function cannot have a requires clause">;
 def err_reference_to_function_with_unsatisfied_constraints : Error<
   "invalid reference to function %0: constraints not satisfied">;
 def err_requires_expr_local_parameter_default_argument : Error<

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 426985fea64b0..d8ed252954969 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -11393,6 +11393,15 @@ bool Sema::CheckFunctionDeclaration(Scope *S, 
FunctionDecl *NewFD,
 checkThisInStaticMemberFunctionType(Method);
 }
 
+// C++20: dcl.decl.general p4:
+// The optional requires-clause ([temp.pre]) in an init-declarator or
+// member-declarator shall be present only if the declarator declares a
+// templated function ([dcl.fct]).
+if (Expr *TRC = NewFD->getTrailingRequiresClause()) {
+  if (!NewFD->isTemplated() && !NewFD->isTemplateInstantiation())
+Diag(TRC->getBeginLoc(), diag::err_constrained_non_templated_function);
+}
+
 if (CXXConversionDecl *Conversion = dyn_cast(NewFD))
   ActOnConversionDeclarator(Conversion);
 

diff  --git a/clang/test/CXX/dcl.decl/dcl.decl.general/p4-20.cpp 
b/clang/test/CXX/dcl.decl/dcl.decl.general/p4-20.cpp
new file mode 100644
index 0..3c012c8d57bbe
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.decl.general/p4-20.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+
+// expected-error@+2 {{non-templated function cannot have a requires clause}}
+void f1(int a)
+  requires true;
+template 
+auto f2(T a) -> bool
+  requires true; // OK
+
+// expected-error@+4 {{trailing return type must appear before trailing 
requires clause}}
+template 
+auto f3(T a)
+  requires true
+-> bool;
+
+// expected-error@+2{{trailing requires clause can only be used when declaring 
a function}}
+void (*pf)()
+  requires true;
+
+// expected-error@+1{{trailing requires clause can only be used when declaring 
a function}}
+void g(int (*)() requires true);
+
+// expected-error@+1{{expected expression}}
+auto *p = new void(*)(char)
+  requires true;

diff  --git a/clang/test/CXX/dcl/dcl.decl/p3.cpp 
b/clang/test/CXX/dcl/dcl.decl/p3.cpp
index 5bfec8a22da29..f141568ba6c22 100644
--- a/clang/test/CXX/dcl/dcl.decl/p3

[PATCH] D125711: [concepts] Implement dcl.decl.general p4: No constraints on non-template funcs

2022-05-17 Thread Erich Keane 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 rG6da3d66f03f9: [concepts] Implement dcl.decl.general p4: No 
constraints on non-template funcs (authored by erichkeane).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D125711?vs=429775&id=430020#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125711

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CXX/dcl.decl/dcl.decl.general/p4-20.cpp
  clang/test/CXX/dcl/dcl.decl/p3.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.id/p4.cpp
  clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
  clang/test/CXX/over/over.match/over.match.viable/p3.cpp
  clang/test/CXX/over/over.over/p4-2a.cpp
  clang/test/Parser/cxx-concepts-requires-clause.cpp
  clang/test/Parser/cxx2a-concepts-requires-expr.cpp
  clang/test/SemaCXX/cxx20-check-fptr-constraints.cpp

Index: clang/test/SemaCXX/cxx20-check-fptr-constraints.cpp
===
--- clang/test/SemaCXX/cxx20-check-fptr-constraints.cpp
+++ clang/test/SemaCXX/cxx20-check-fptr-constraints.cpp
@@ -1,12 +1,15 @@
 // RUN: %clang_cc1 -std=c++20 -verify %s
 
 namespace P1972 {
-void f(int) requires false; // expected-note 4{{because 'false' evaluated to false}} \
-// expected-note{{constraints not satisfied}}
+template 
+struct S {
+  static void f(int)
+requires false; // expected-note 4{{because 'false' evaluated to false}}
+};
 void g() {
-  f(0);  // expected-error{{no matching function for call to 'f'}}
-  void (*p1)(int) = f;   // expected-error{{invalid reference to function 'f': constraints not satisfied}}
-  void (*p21)(int) = &f; // expected-error{{invalid reference to function 'f': constraints not satisfied}}
-  decltype(f) *p2 = nullptr; // expected-error{{invalid reference to function 'f': constraints not satisfied}}
+  S::f(0);  // expected-error{{invalid reference to function 'f': constraints not satisfied}}
+  void (*p1)(int) = S::f;   // expected-error{{invalid reference to function 'f': constraints not satisfied}}
+  void (*p21)(int) = &S::f; // expected-error{{invalid reference to function 'f': constraints not satisfied}}
+  decltype(S::f) *p2 = nullptr; // expected-error{{invalid reference to function 'f': constraints not satisfied}}
 }
 }
Index: clang/test/Parser/cxx2a-concepts-requires-expr.cpp
===
--- clang/test/Parser/cxx2a-concepts-requires-expr.cpp
+++ clang/test/Parser/cxx2a-concepts-requires-expr.cpp
@@ -130,6 +130,7 @@
 
 bool r36 = requires (bool b) { requires sizeof(b) == 1; };
 
+template
 void r37(bool b) requires requires { 1 } {}
 // expected-error@-1 {{expected ';' at end of requirement}}
 
Index: clang/test/Parser/cxx-concepts-requires-clause.cpp
===
--- clang/test/Parser/cxx-concepts-requires-clause.cpp
+++ clang/test/Parser/cxx-concepts-requires-clause.cpp
@@ -139,8 +139,10 @@
 void bar() requires (sizeof(T)) == 0;
 // expected-error@-1{{parentheses are required around this expression in a requires clause}}
 
+template
 void bar(int x, int y) requires (x, y, true);
 
+template
 struct B {
   int x;
   void foo(int y) requires (x, this, this->x, y, true);
Index: clang/test/CXX/over/over.over/p4-2a.cpp
===
--- clang/test/CXX/over/over.over/p4-2a.cpp
+++ clang/test/CXX/over/over.over/p4-2a.cpp
@@ -12,50 +12,48 @@
 template
 concept AtMost8 = sizeof(T) <= 8;
 
-int foo() requires AtLeast2 && AtMost8 {
+template
+struct S {
+static int foo() requires AtLeast2 && AtMost8 {
   return 0;
 }
 
-double foo() requires AtLeast2 {
+static double foo() requires AtLeast2 {
   return 0.0;
 }
 
-char bar() requires AtLeast2 { // expected-note {{possible target for call}}
+static char bar() requires AtLeast2 {
   return 1.0;
 }
 
-short bar() requires AtLeast2 && AtMost8 {
-// expected-note@-1{{possible target for call}}
-// expected-note@-2{{candidate function}}
+static short bar() requires AtLeast2 && AtMost8 {
   return 0.0;
 }
 
-int bar() requires AtMost8 && AtLeast2 {
-// expected-note@-1{{possible target for call}}
-// expected-note@-2{{candidate function}}
+static int bar() requires AtMost8 && AtLeast2 {
   return 0.0;
 }
 
-char baz() requires AtLeast2 {
+static char baz() requires AtLeast2 {
   return 1.0;
 }
 
-short baz() requires AtLeast2 && AtMost8 {
+static short baz() requires AtLeast2 && AtMost8 {
   return 0.0;
 }
 
-int baz() requires AtMost8 && AtLeast2 {
+static int baz() requires AtMost8 && AtLeast2 {
   return 0.0;
 }
 
-long baz() requires AtMost8 && AtLeast2 &&

[PATCH] D123773: [clang][analyzer][ctu] Make CTU a two phase analysis

2022-05-17 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 430023.
martong marked an inline comment as done.
martong added a comment.

- Change ctuBifurcate to use bool in GDM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123773

Files:
  clang/include/clang/CrossTU/CrossTranslationUnit.h
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  clang/test/Analysis/Inputs/ctu-onego-existingdef-other.cpp
  
clang/test/Analysis/Inputs/ctu-onego-existingdef-other.cpp.externalDefMap.ast-dump.txt
  clang/test/Analysis/Inputs/ctu-onego-indirect-other.cpp
  
clang/test/Analysis/Inputs/ctu-onego-indirect-other.cpp.externalDefMap.ast-dump.txt
  clang/test/Analysis/Inputs/ctu-onego-small-other.cpp
  
clang/test/Analysis/Inputs/ctu-onego-small-other.cpp.externalDefMap.ast-dump.txt
  clang/test/Analysis/Inputs/ctu-onego-toplevel-other.cpp
  
clang/test/Analysis/Inputs/ctu-onego-toplevel-other.cpp.externalDefMap.ast-dump.txt
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/ctu-implicit.c
  clang/test/Analysis/ctu-main.c
  clang/test/Analysis/ctu-main.cpp
  clang/test/Analysis/ctu-on-demand-parsing.c
  clang/test/Analysis/ctu-on-demand-parsing.cpp
  clang/test/Analysis/ctu-onego-existingdef.cpp
  clang/test/Analysis/ctu-onego-indirect.cpp
  clang/test/Analysis/ctu-onego-small.cpp
  clang/test/Analysis/ctu-onego-toplevel.cpp

Index: clang/test/Analysis/ctu-onego-toplevel.cpp
===
--- /dev/null
+++ clang/test/Analysis/ctu-onego-toplevel.cpp
@@ -0,0 +1,54 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: mkdir -p %t/ctudir
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
+// RUN:   -emit-pch -o %t/ctudir/ctu-onego-toplevel-other.cpp.ast %S/Inputs/ctu-onego-toplevel-other.cpp
+// RUN: cp %S/Inputs/ctu-onego-toplevel-other.cpp.externalDefMap.ast-dump.txt %t/ctudir/externalDefMap.txt
+
+// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%t/ctudir \
+// RUN:   -analyzer-config ctu-phase1-inlining=none \
+// RUN:   -verify=ctu %s
+
+// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%t/ctudir \
+// RUN:   -analyzer-config ctu-phase1-inlining=none \
+// RUN:   -analyzer-config display-ctu-progress=true \
+// RUN:   -analyzer-display-progress \
+// RUN:   -verify=ctu %s 2>&1 | FileCheck %s
+
+// CallGraph: c->b
+// topological sort: c, b
+// Note that `other` calls into `b` but that is not visible in the CallGraph
+// because that happens in another TU.
+
+// During the onego CTU analysis, we start with c() as top level function.
+// Then we visit b() as non-toplevel during the processing of the FWList, thus
+// that would not be visited as toplevel without special care.
+
+// `c` is analyzed as toplevel and during that the other TU is loaded:
+// CHECK: ANALYZE (Path,  Inline_Regular): {{.*}} c(int){{.*}}CTU loaded AST file
+// next, `b` is analyzed as toplevel:
+// CHECK: ANALYZE (Path,  Inline_Regular): {{.*}} b(int)
+
+void b(int x);
+void other(int y);
+void c(int y) {
+  other(y);
+  return;
+  // The below call is here to form the proper CallGraph, but will not be
+  // analyzed.
+  b(1);
+}
+
+void b(int x) {
+  if (x == 0)
+(void)(1 / x);
+// ctu-warning@-1{{Division by zero}}
+// We receive the above warning only if `b` is analyzed as top-level.
+}
Index: clang/test/Analysis/ctu-onego-small.cpp
===
--- /dev/null
+++ clang/test/Analysis/ctu-onego-small.cpp
@@ -0,0 +1,51 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: mkdir -p %t/ctudir
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
+// RUN:   -emit-pch -o %t/ctudir/ctu-onego-small-other.cpp.ast %S/Inputs/ctu-onego-small-other.cpp
+// RUN: cp %S/Inputs/ctu-onego-small-other.cpp.externalDefMap.ast-dump.txt %t/ctudir/externalDefMap.txt
+
+// Small function defined in ano

[PATCH] D125773: [Driver] Do not auto-enable header modules with -std=c++20

2022-05-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added a project: All.
ilya-biryukov requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: clang.

This only shows up if one passes module maps to Clang in `-std=c++20`
modes, e.g. for layering checks.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125773

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Driver/cpp20-header-module.cpp
  clang/test/Modules/Inputs/cxx20-and-header-modules/a.h
  clang/test/Modules/Inputs/cxx20-and-header-modules/a.map
  clang/test/Modules/cxx20-and-header-modules.cpp

Index: clang/test/Modules/cxx20-and-header-modules.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-and-header-modules.cpp
@@ -0,0 +1,16 @@
+// RUN: rm -rf %t
+//
+// Check header modules are disabled by default in C++20 mode.
+// RUN: %clang -std=c++20 -fsyntax-only -fno-implicit-modules -fmodules-cache-path=%t -I%S/Inputs/cxx20-and-header-modules -fmodule-map-file=%S/Inputs/cxx20-and-header-modules/a.map %s
+// RUN: %clang -std=gnu++20 -fsyntax-only -fno-implicit-modules -fmodules-cache-path=%t -I%S/Inputs/cxx20-and-header-modules -fmodule-map-file=%S/Inputs/cxx20-and-header-modules/a.map %s
+//
+// Also run in the header modules mode.
+// RUN: %clang -std=c++20 -DBUILDING_MODULE -fmodules -fimplicit-modules -fmodules-cache-path=%t -I%S/Inputs/cxx20-and-header-modules -fmodule-map-file=%S/Inputs/cxx20-and-header-modules/a.map %s
+// RUN: %clang -std=gnu++20 -DBUILDING_MODULE -fmodules -fimplicit-modules -fmodules-cache-path=%t -I%S/Inputs/cxx20-and-header-modules -fmodule-map-file=%S/Inputs/cxx20-and-header-modules/a.map %s
+
+#define INCLUDING 1
+#include "a.h"
+
+int main() {
+  return X().foo();
+}
Index: clang/test/Modules/Inputs/cxx20-and-header-modules/a.map
===
--- /dev/null
+++ clang/test/Modules/Inputs/cxx20-and-header-modules/a.map
@@ -0,0 +1,4 @@
+module A {
+  header "a.h"
+  export *
+}
Index: clang/test/Modules/Inputs/cxx20-and-header-modules/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/cxx20-and-header-modules/a.h
@@ -0,0 +1,12 @@
+#ifndef A_HEADER
+#define A_HEADER
+
+#if INCLUDING && BUILDING_MODULE
+#error "invalid context"
+#endif
+
+struct X {
+  int foo() { return 10; }
+};
+
+#endif
Index: clang/test/Driver/cpp20-header-module.cpp
===
--- /dev/null
+++ clang/test/Driver/cpp20-header-module.cpp
@@ -0,0 +1,24 @@
+// Check header modules are not enabled with C++20 standard and -fmodules-ts.
+//
+// RUN: %clang -fmodules-ts -std=c++20 -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=NO_HEADER_MODULES
+// RUN: %clang -std=c++20 -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=NO_HEADER_MODULES
+// RUN: %clang -std=c++2a -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=NO_HEADER_MODULES
+// RUN: %clang -std=c++2b -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=NO_HEADER_MODULES
+// RUN: %clang_cl /std:c++latest /Zs -v %s 2>&1 | FileCheck %s --check-prefix=NO_HEADER_MODULES
+// RUN: %clang -std=gnu++20 -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=NO_HEADER_MODULES
+// RUN: %clang -std=gnu++2a -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=NO_HEADER_MODULES
+// RUN: %clang -std=gnu++2b -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=NO_HEADER_MODULES
+//
+// NO_HEADER_MODULES: -cc1
+// NO_HEADER_MODULES-SAME: -fno-header-modules
+//
+// RUN: %clang -fmodules -fmodules-ts -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=HAS_HEADER_MODULES
+// RUN: %clang -fmodules -fmodules-ts -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=HAS_HEADER_MODULES
+// RUN: %clang -fmodules -std=c++20 -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=HAS_HEADER_MODULES
+// RUN: %clang -fmodules -std=c++2a -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=HAS_HEADER_MODULES
+// RUN: %clang -fmodules -std=c++2b -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=HAS_HEADER_MODULES
+// RUN: %clang -fmodules -std=gnu++20 -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=HAS_HEADER_MODULES
+// RUN: %clang -fmodules -std=gnu++2a -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=HAS_HEADER_MODULES
+// RUN: %clang -fmodules -std=gnu++2b -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=HAS_HEADER_MODULES
+//
+// HAS_HEADER_MODULES-NOT: -fno-header-modules
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -2159,7 +2159,8 @@
   // Determine whether we should try to import the module f

[clang-tools-extra] 9c6a2f2 - Fix an unused variable warning in no-asserts build mode

2022-05-17 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2022-05-17T15:27:44+02:00
New Revision: 9c6a2f29660b886044a267bb4de662cd801079bc

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

LOG: Fix an unused variable warning in no-asserts build mode

Added: 


Modified: 
clang-tools-extra/pseudo/lib/GLR.cpp

Removed: 




diff  --git a/clang-tools-extra/pseudo/lib/GLR.cpp 
b/clang-tools-extra/pseudo/lib/GLR.cpp
index cf0a370820e1..10fa0d0568c0 100644
--- a/clang-tools-extra/pseudo/lib/GLR.cpp
+++ b/clang-tools-extra/pseudo/lib/GLR.cpp
@@ -40,6 +40,7 @@ const ForestNode &glrParse(const TokenStream &Tokens, const 
ParseParams &Params,
SymbolID StartSymbol) {
   llvm::ArrayRef Terminals = Params.Forest.createTerminals(Tokens);
   auto &G = Params.G;
+  (void)G;
   auto &GSS = Params.GSStack;
 
   // Lists of active shift, reduce, accept actions.



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


[PATCH] D123784: [clang][analyzer][ctu] Traverse the ctu CallEnter nodes in reverse order

2022-05-17 Thread Gabor Marton via Phabricator via cfe-commits
martong abandoned this revision.
martong marked an inline comment as done.
martong added a comment.

Abandoning because by using a `bool` in `ctuBifurcate`, the CTUWorklist will 
not have more than one elements during the first phase. Details: 
https://reviews.llvm.org/D123773?id=426037#inline-1206493


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123784

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


[PATCH] D125771: [clang-tidy] Add a useful note about -std=c++11-or-later

2022-05-17 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang-tools-extra/test/clang-tidy/check_clang_tidy.py:31
+  -std=c++11-or-later:
+This flag will cause multiple runs withing the same check_clang_tidy
+execution. Make sure you don't have shared state across these runs.

typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125771

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


[clang] 2def74b - Fix release note typo from 6da3d66f

2022-05-17 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2022-05-17T06:35:06-07:00
New Revision: 2def74bef15a867d940520ddf3808d09b7fff95b

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

LOG: Fix release note typo from 6da3d66f

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 79e5a4622e8a..2477a80d7938 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -365,7 +365,7 @@ C++ Language Changes in Clang
   of clang; use the ``-fclang-abi-compat=14`` option to get the old mangling.
 - Preprocessor character literals with a ``u8`` prefix are now correctly 
treated as
   unsigned character literals. This fixes `Issue 54886 
`_.
-- Stopped allowing constriants on non-template functions to be compliant with
+- Stopped allowing constraints on non-template functions to be compliant with
   dcl.decl.general p4.
 
 C++20 Feature Support



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


[PATCH] D125775: [ARM] Don't Enable AES Pass for Generic Cores

2022-05-17 Thread Sam Elliott via Phabricator via cfe-commits
lenary created this revision.
lenary added reviewers: john.brawn, dmgreen.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: All.
lenary requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

This brings clang/llvm into line with GCC. The Pass is still enabled for
the affected cores, but is now opt-in when using `-march=`.

I also took the opportunity to add release notes for this change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125775

Files:
  clang/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst
  llvm/lib/Target/ARM/ARM.td


Index: llvm/lib/Target/ARM/ARM.td
===
--- llvm/lib/Target/ARM/ARM.td
+++ llvm/lib/Target/ARM/ARM.td
@@ -1161,7 +1161,7 @@
 // ARM processors
 //
 // Dummy CPU, used to target architectures
-def : ProcessorModel<"generic", CortexA8Model,  
[FeatureFixCortexA57AES1742098]>;
+def : ProcessorModel<"generic", CortexA8Model,  []>;
 
 // FIXME: Several processors below are not using their own scheduler
 // model, but one of similar/previous processor. These should be fixed.
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -99,6 +99,8 @@
   warnings will be generated and -mrestrict-it is now always off by default.
   Previously it was on by default for Armv8 and off for all other architecture
   versions.
+* Added a pass to workaround Cortex-A57 Erratum 1742098 and Cortex-A72
+  Erratum 1655431. This is enabled by default when targeting either CPU.
 
 Changes to the AVR Backend
 --
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -265,6 +265,11 @@
   the parameter list were ``void``. There is no ``-fknr-functions`` or
   ``-fno-no-knr-functions`` flag; this feature cannot be disabled in language
   modes where it is required, such as C++ or C2x.
+- A new ARM pass to workaround Cortex-A57 Erratum 1742098 and Cortex-A72 
Erratum
+  1655431 can be enabled using ``-mfix-cortex-a57-aes-1742098`` or
+  ``-mfix-cortex-a72-aes-1655431``. The pass is enabled when using either of
+  these cpus with ``-mcpu=`` and can be disabled using
+  ``-mno-fix-cortex-a57-aes-1742098`` or ``-mno-fix-cortex-a72-aes-1655431``.
 
 Deprecated Compiler Flags
 -


Index: llvm/lib/Target/ARM/ARM.td
===
--- llvm/lib/Target/ARM/ARM.td
+++ llvm/lib/Target/ARM/ARM.td
@@ -1161,7 +1161,7 @@
 // ARM processors
 //
 // Dummy CPU, used to target architectures
-def : ProcessorModel<"generic", CortexA8Model,  [FeatureFixCortexA57AES1742098]>;
+def : ProcessorModel<"generic", CortexA8Model,  []>;
 
 // FIXME: Several processors below are not using their own scheduler
 // model, but one of similar/previous processor. These should be fixed.
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -99,6 +99,8 @@
   warnings will be generated and -mrestrict-it is now always off by default.
   Previously it was on by default for Armv8 and off for all other architecture
   versions.
+* Added a pass to workaround Cortex-A57 Erratum 1742098 and Cortex-A72
+  Erratum 1655431. This is enabled by default when targeting either CPU.
 
 Changes to the AVR Backend
 --
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -265,6 +265,11 @@
   the parameter list were ``void``. There is no ``-fknr-functions`` or
   ``-fno-no-knr-functions`` flag; this feature cannot be disabled in language
   modes where it is required, such as C++ or C2x.
+- A new ARM pass to workaround Cortex-A57 Erratum 1742098 and Cortex-A72 Erratum
+  1655431 can be enabled using ``-mfix-cortex-a57-aes-1742098`` or
+  ``-mfix-cortex-a72-aes-1655431``. The pass is enabled when using either of
+  these cpus with ``-mcpu=`` and can be disabled using
+  ``-mno-fix-cortex-a57-aes-1742098`` or ``-mno-fix-cortex-a72-aes-1655431``.
 
 Deprecated Compiler Flags
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125084: [test, x86] Fix spurious x86-target-features.c failure

2022-05-17 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre updated this revision to Diff 430029.
thopre marked an inline comment as done.
thopre added a comment.

Be more conservative in what we reject


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125084

Files:
  clang/test/Driver/x86-target-features.c


Index: clang/test/Driver/x86-target-features.c
===
--- clang/test/Driver/x86-target-features.c
+++ clang/test/Driver/x86-target-features.c
@@ -170,7 +170,7 @@
 // RUN: %clang -target i386-linux-gnu -mlvi-hardening %s -### -o %t.o 2>&1 | 
FileCheck -check-prefix=LVIHARDENING %s
 // RUN: %clang -target i386-linux-gnu -mno-lvi-hardening %s -### -o %t.o 2>&1 
| FileCheck -check-prefix=NO-LVIHARDENING %s
 // LVIHARDENING: "-target-feature" "+lvi-load-hardening" "-target-feature" 
"+lvi-cfi"
-// NO-LVIHARDENING-NOT: lvi
+// NO-LVIHARDENING-NOT: "+lvi-
 
 // RUN: %clang -target i386-linux-gnu -mlvi-hardening 
-mspeculative-load-hardening %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=LVIHARDENING-SLH %s
 // LVIHARDENING-SLH: error: invalid argument 'mspeculative-load-hardening' not 
allowed with 'mlvi-hardening'


Index: clang/test/Driver/x86-target-features.c
===
--- clang/test/Driver/x86-target-features.c
+++ clang/test/Driver/x86-target-features.c
@@ -170,7 +170,7 @@
 // RUN: %clang -target i386-linux-gnu -mlvi-hardening %s -### -o %t.o 2>&1 | FileCheck -check-prefix=LVIHARDENING %s
 // RUN: %clang -target i386-linux-gnu -mno-lvi-hardening %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-LVIHARDENING %s
 // LVIHARDENING: "-target-feature" "+lvi-load-hardening" "-target-feature" "+lvi-cfi"
-// NO-LVIHARDENING-NOT: lvi
+// NO-LVIHARDENING-NOT: "+lvi-
 
 // RUN: %clang -target i386-linux-gnu -mlvi-hardening -mspeculative-load-hardening %s -### -o %t.o 2>&1 | FileCheck -check-prefix=LVIHARDENING-SLH %s
 // LVIHARDENING-SLH: error: invalid argument 'mspeculative-load-hardening' not allowed with 'mlvi-hardening'
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124701: [clang] Honor __attribute__((no_builtin("foo"))) on functions

2022-05-17 Thread Stephen Long via Phabricator via cfe-commits
steplong added inline comments.



Comment at: clang/test/CodeGen/no-builtin-2.c:51
+// CHECK:   {{.*}}call {{.*}} @memmove
+void foo4(char *s, char *d, size_t n) __attribute__((no_builtin("*"))) {
+  bar(s);

hans wrote:
> In AttrDocs.td it says the wildcard case is spelled 
> "__attribute__((no_builtin))".
Ah whoops, missed that. I don't think I need the changes in SemaDeclAttr.cpp 
then. Thanks for catching this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124701

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


[PATCH] D125709: [analyzer][Casting] Support isa, cast, dyn_cast of SVals

2022-05-17 Thread Aman LaChapelle via Phabricator via cfe-commits
bzcheeseman added a comment.

In D125709#3518096 , @steakhal wrote:

> I had to fix the `doCast` to return `To` instead of `Optional` to make it 
> work.

That's fine (or it should be!) but you can also just dereference the optional, 
right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125709

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


[PATCH] D125773: [Driver] Do not auto-enable header modules with -std=c++20

2022-05-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

LG, but I think this is choosing a (new) public name for clang modules/header 
modules, so maybe Richard or others might want to weigh in?




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3631
+  // Unless '-fmodules' was specified explicitly.
+  if (!HaveClangModules && HaveModules) {
+CmdArgs.push_back("-fno-header-modules");

These interacting flags are complicated, and I think relying on how the default 
value is computed makes it harder to reason about.

Can we explicitly set -f{no}-header-modules whenever any version of modules is 
available?
i.e.
```
if (HaveModules) {
  if (HaveClangModules)
push("-fheader-modules")
  else
push ("-fno-header-modules")
}
```

(In the long run, it would be much clearer for -fheader-modules to default to 
false, and explicitly set it whenever it's needed, but this is a larger cleanup)



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6537
   // support by default, or just assume that all languages do.
-  bool HaveModules =
-  Std && (Std->containsValue("c++2a") || Std->containsValue("c++20") ||
-  Std->containsValue("c++latest"));
+  bool HaveModules = Std && llvm::any_of(Std->getValues(), [](const char *S) {
+   constexpr llvm::StringRef CPP_MODULES_STD[] = {

this change looks correct but unrelated, can we split into a separate change?
(Mostly because either change might break stuff downstream, and they could be 
reverted separately)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125773

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


[PATCH] D123773: [clang][analyzer][ctu] Make CTU a two phase analysis

2022-05-17 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 430047.
martong added a comment.

- Update ReleaseNotes.rst


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123773

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/CrossTU/CrossTranslationUnit.h
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  clang/test/Analysis/Inputs/ctu-onego-existingdef-other.cpp
  
clang/test/Analysis/Inputs/ctu-onego-existingdef-other.cpp.externalDefMap.ast-dump.txt
  clang/test/Analysis/Inputs/ctu-onego-indirect-other.cpp
  
clang/test/Analysis/Inputs/ctu-onego-indirect-other.cpp.externalDefMap.ast-dump.txt
  clang/test/Analysis/Inputs/ctu-onego-small-other.cpp
  
clang/test/Analysis/Inputs/ctu-onego-small-other.cpp.externalDefMap.ast-dump.txt
  clang/test/Analysis/Inputs/ctu-onego-toplevel-other.cpp
  
clang/test/Analysis/Inputs/ctu-onego-toplevel-other.cpp.externalDefMap.ast-dump.txt
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/ctu-implicit.c
  clang/test/Analysis/ctu-main.c
  clang/test/Analysis/ctu-main.cpp
  clang/test/Analysis/ctu-on-demand-parsing.c
  clang/test/Analysis/ctu-on-demand-parsing.cpp
  clang/test/Analysis/ctu-onego-existingdef.cpp
  clang/test/Analysis/ctu-onego-indirect.cpp
  clang/test/Analysis/ctu-onego-small.cpp
  clang/test/Analysis/ctu-onego-toplevel.cpp

Index: clang/test/Analysis/ctu-onego-toplevel.cpp
===
--- /dev/null
+++ clang/test/Analysis/ctu-onego-toplevel.cpp
@@ -0,0 +1,54 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: mkdir -p %t/ctudir
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
+// RUN:   -emit-pch -o %t/ctudir/ctu-onego-toplevel-other.cpp.ast %S/Inputs/ctu-onego-toplevel-other.cpp
+// RUN: cp %S/Inputs/ctu-onego-toplevel-other.cpp.externalDefMap.ast-dump.txt %t/ctudir/externalDefMap.txt
+
+// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%t/ctudir \
+// RUN:   -analyzer-config ctu-phase1-inlining=none \
+// RUN:   -verify=ctu %s
+
+// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%t/ctudir \
+// RUN:   -analyzer-config ctu-phase1-inlining=none \
+// RUN:   -analyzer-config display-ctu-progress=true \
+// RUN:   -analyzer-display-progress \
+// RUN:   -verify=ctu %s 2>&1 | FileCheck %s
+
+// CallGraph: c->b
+// topological sort: c, b
+// Note that `other` calls into `b` but that is not visible in the CallGraph
+// because that happens in another TU.
+
+// During the onego CTU analysis, we start with c() as top level function.
+// Then we visit b() as non-toplevel during the processing of the FWList, thus
+// that would not be visited as toplevel without special care.
+
+// `c` is analyzed as toplevel and during that the other TU is loaded:
+// CHECK: ANALYZE (Path,  Inline_Regular): {{.*}} c(int){{.*}}CTU loaded AST file
+// next, `b` is analyzed as toplevel:
+// CHECK: ANALYZE (Path,  Inline_Regular): {{.*}} b(int)
+
+void b(int x);
+void other(int y);
+void c(int y) {
+  other(y);
+  return;
+  // The below call is here to form the proper CallGraph, but will not be
+  // analyzed.
+  b(1);
+}
+
+void b(int x) {
+  if (x == 0)
+(void)(1 / x);
+// ctu-warning@-1{{Division by zero}}
+// We receive the above warning only if `b` is analyzed as top-level.
+}
Index: clang/test/Analysis/ctu-onego-small.cpp
===
--- /dev/null
+++ clang/test/Analysis/ctu-onego-small.cpp
@@ -0,0 +1,51 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: mkdir -p %t/ctudir
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
+// RUN:   -emit-pch -o %t/ctudir/ctu-onego-small-other.cpp.ast %S/Inputs/ctu-onego-small-other.cpp
+// RUN: cp %S/Inputs/ctu-onego-small-other.cpp.externalDefMap.ast-dump.txt %t/ctudir/externalDefMap.txt
+
+// Small function defined in another TU.
+int bar();
+
+// 

[PATCH] D125788: [flang][driver] Rename `flang-new` as `flang`

2022-05-17 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski created this revision.
awarzynski added reviewers: rovka, jeanPerier, peixin, kiranktp, 
Leporacanthicus, dpalermo, ekieri, schweitz, shraiysh, h-vetinari, rouson.
Herald added a subscriber: mgorny.
Herald added a reviewer: sscalpone.
Herald added a reviewer: clementval.
Herald added projects: Flang, All.
awarzynski requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, jdoerfert, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

Until now, `flang` has been reserved for the bash script that uses LLVM
Flang for parsing/unparsing and an external compiler (`gfortran` by
default) to generate machine code/assembly/executables. This patch
renames:

- `flang` as `flang-to-gfortran`
- `flang-new` as `flang`

These new names better reflect the functionality of both `flang` and
`flang-to-gfortran`. Tests and documentation are updated accordingly.

Similarly to Clang, Flang's driver executable will be called
`flang-` and `flang` will be a symlink to
`flang-`.  flang-new` becomes a symlink pointing to the
actual driver. We can delete it in the future once we get accustomed to
the new name.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125788

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/test/Driver/flang/flang.f90
  clang/test/Driver/flang/flang_ucase.F90
  clang/test/Driver/flang/multiple-inputs-mixed.f90
  clang/test/Driver/flang/multiple-inputs.f90
  flang/examples/FlangOmpReport/FlangOmpReport.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/CMakeLists.txt
  flang/test/Driver/disable-ext-name-interop.f90
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-version.f90
  flang/test/Driver/escaped-backslash.f90
  flang/test/Driver/fdefault.f90
  flang/test/Driver/flarge-sizes.f90
  flang/test/Driver/frontend-forwarding.f90
  flang/test/Driver/intrinsic-module-path.f90
  flang/test/Driver/macro-def-undef.F90
  flang/test/Driver/missing-input.f90
  flang/test/Driver/predefined-macros-compiler-version.F90
  flang/test/Driver/std2018-wrong.f90
  flang/test/Driver/std2018.f90
  flang/test/Driver/use-module-error.f90
  flang/test/Driver/use-module.f90
  flang/test/Frontend/multiple-input-files.f90
  flang/test/Lower/Intrinsics/command_argument_count.f90
  flang/test/Lower/Intrinsics/exit.f90
  flang/test/Lower/Intrinsics/get_command_argument.f90
  flang/test/Lower/Intrinsics/get_environment_variable.f90
  flang/test/Lower/OpenACC/Todo/acc-declare.f90
  flang/test/Lower/OpenACC/Todo/acc-routine.f90
  flang/test/Lower/OpenMP/Todo/omp-declarative-allocate.f90
  flang/test/Lower/OpenMP/Todo/omp-declare-reduction.f90
  flang/test/Lower/OpenMP/Todo/omp-declare-simd.f90
  flang/test/Lower/OpenMP/Todo/omp-declare-target.f90
  flang/test/Lower/OpenMP/Todo/omp-threadprivate.f90
  flang/test/lit.cfg.py
  flang/tools/f18/CMakeLists.txt
  flang/tools/f18/flang
  flang/tools/f18/flang-to-gfortran
  flang/tools/flang-driver/CMakeLists.txt
  flang/tools/flang-driver/driver.cpp

Index: flang/tools/flang-driver/driver.cpp
===
--- flang/tools/flang-driver/driver.cpp
+++ flang/tools/flang-driver/driver.cpp
@@ -80,7 +80,7 @@
   clang::driver::ParsedClangName targetandMode("flang", "--driver-mode=flang");
   std::string driverPath = getExecutablePath(args[0]);
 
-  // Check if flang-new is in the frontend mode
+  // Check if flang is in the frontend mode
   auto firstArg = std::find_if(
   args.begin() + 1, args.end(), [](const char *a) { return a != nullptr; });
   if (firstArg != args.end()) {
@@ -89,7 +89,7 @@
<< "Valid tools include '-fc1'.\n";
   return 1;
 }
-// Call flang-new frontend
+// Call flang frontend
 if (llvm::StringRef(args[1]).startswith("-fc1")) {
   return executeFC1Tool(args);
 }
Index: flang/tools/flang-driver/CMakeLists.txt
===
--- flang/tools/flang-driver/CMakeLists.txt
+++ flang/tools/flang-driver/CMakeLists.txt
@@ -10,7 +10,7 @@
   Support
 )
 
-add_flang_tool(flang-new
+add_flang_tool(flang
   driver.cpp
   fc1_main.cpp
 
@@ -23,23 +23,32 @@
   Fortran_main
 )
 
-target_link_libraries(flang-new
+target_link_libraries(flang
   PRIVATE
   flangFrontend
   flangFrontendTool
 )
 
-clang_target_link_libraries(flang-new
+clang_target_link_libraries(flang
   PRIVATE
   clangDriver
   clangBasic
 )
 
+if(WIN32 AND NOT CYGWIN)
+  # Prevent versioning if the buildhost is targeting for Win32.
+else()
+  set_target_properties(flang PROPERTIES VERSION ${FLANG_EXECUTABLE_VERSION})
+endif()
+
 option(FLANG_PLUGIN_SUPPORT "Build Flang with plugin support." ON)
 
-# Enable support for plugins, which need access to symbols from flang-new
+# Enable support for plugins, which need access to symbols from flang
 if(FLANG_PLUGIN_SUPPORT)
-  export_executable_symbols_for_plugins(flang-new)
+  export

[PATCH] D125683: [runtimes] Replace LIBCXX_ENABLE_STATIC_ABI_LIBRARY & friends by a new LIBCXX_CXX_ABI choice

2022-05-17 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In D125683#3516911 , @mstorsjo wrote:

> I guess that's better than silently (well, cmake warns, but it's easy to 
> miss) no longer doing what it used to, but it's not ideal IMO. I do my 
> continuous build testing with a build invocation that also works for the 
> latest release - but with the suggested transition, there's no single build 
> invocation that works for both the main branch and the 14.x release. I guess 
> I could manage though, but I'd prefer a smoother upgrade path.

Understood. I'll make sure it is backwards compatible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125683

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


[PATCH] D125683: [runtimes] Replace LIBCXX_ENABLE_STATIC_ABI_LIBRARY & friends by a new LIBCXX_CXX_ABI choice

2022-05-17 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 430051.
ldionne added a comment.

Don't remove the old options yet for backwards compatibility.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125683

Files:
  clang/cmake/caches/Android.cmake
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/cmake/caches/Fuchsia.cmake
  compiler-rt/cmake/Modules/AddCompilerRT.cmake
  libcxx/CMakeLists.txt
  libcxx/cmake/Modules/HandleLibCXXABI.cmake
  libcxx/cmake/caches/MinGW.cmake
  libcxx/docs/BuildingLibcxx.rst
  libcxx/docs/ReleaseNotes.rst
  libcxx/src/CMakeLists.txt
  libcxx/test/CMakeLists.txt
  libcxx/test/configs/legacy.cfg.in
  libcxxabi/CMakeLists.txt
  llvm/docs/HowToBuildWindowsItaniumPrograms.rst

Index: llvm/docs/HowToBuildWindowsItaniumPrograms.rst
===
--- llvm/docs/HowToBuildWindowsItaniumPrograms.rst
+++ llvm/docs/HowToBuildWindowsItaniumPrograms.rst
@@ -124,7 +124,6 @@
 * ``-DLIBCXXABI_ENABLE_SHARED=OFF``
 * ``-DLIBCXXABI_ENABLE_STATIC=ON``
 * ``-DLIBCXX_ENABLE_SHARED=ON'``
-* ``-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON``
 
 To break the symbol dependency between libc++abi and libc++ we
 build libc++abi as a static library and then statically link it
@@ -157,7 +156,6 @@
 
 Windows Itanium does not offer a POSIX-like layer over WIN32.
 
-* ``-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON``
 * ``-DLIBCXX_CXX_ABI=libcxxabi``
 * ``-DLIBCXX_CXX_ABI_INCLUDE_PATHS=/include``
 * ``-DLIBCXX_CXX_ABI_LIBRARY_PATH=/lib``
Index: libcxxabi/CMakeLists.txt
===
--- libcxxabi/CMakeLists.txt
+++ libcxxabi/CMakeLists.txt
@@ -251,7 +251,7 @@
 if (WIN32 AND LIBCXXABI_ENABLE_STATIC AND NOT LIBCXXABI_ENABLE_SHARED)
   # If LIBCXX_ENABLE_SHARED isn't set (by the user on the cmake command
   # line or via a cache file), use its expected default value (enabled).
-  if ((LIBCXX_ENABLE_SHARED OR NOT DEFINED LIBCXX_ENABLE_SHARED) AND LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
+  if ((LIBCXX_ENABLE_SHARED OR NOT DEFINED LIBCXX_ENABLE_SHARED) AND LIBCXX_CXX_ABI STREQUAL libcxxabi-objects)
 # Building libcxxabi statically, but intending for it to be statically
 # linked into a shared libcxx; keep dllexport enabled within libcxxabi,
 # as the symbols will need to be exported from libcxx.
Index: libcxx/test/configs/legacy.cfg.in
===
--- libcxx/test/configs/legacy.cfg.in
+++ libcxx/test/configs/legacy.cfg.in
@@ -14,7 +14,7 @@
 config.cxx_library_root = "@LIBCXX_LIBRARY_DIR@"
 config.abi_library_root = "@LIBCXX_CXX_ABI_LIBRARY_PATH@"
 config.enable_shared= @LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX@
-config.cxx_abi  = "@LIBCXX_CXXABI_FOR_TESTS@"
+config.cxx_abi  = "@LIBCXX_CXX_ABI@"
 config.configuration_variant= "@LIBCXX_LIT_VARIANT@"
 config.host_triple  = "@LLVM_HOST_TRIPLE@"
 config.sysroot  = "@CMAKE_SYSROOT@"
Index: libcxx/test/CMakeLists.txt
===
--- libcxx/test/CMakeLists.txt
+++ libcxx/test/CMakeLists.txt
@@ -14,14 +14,6 @@
 set(LIBCXX_TEST_COMPILER_FLAGS "" CACHE STRING
 "Additonal linker flags to pass when compiling the tests")
 
-# The tests shouldn't link to any ABI library when it has been linked into
-# libc++ statically or via a linker script.
-if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY OR LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
-  set(LIBCXX_CXXABI_FOR_TESTS "none")
-else()
-  set(LIBCXX_CXXABI_FOR_TESTS "${LIBCXX_CXX_ABI}")
-endif()
-
 # The tests shouldn't link to libunwind if we have a linker script which
 # already does so.
 if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
Index: libcxx/src/CMakeLists.txt
===
--- libcxx/src/CMakeLists.txt
+++ libcxx/src/CMakeLists.txt
@@ -204,7 +204,7 @@
 if (LIBCXX_ENABLE_SHARED)
   add_library(cxx_shared SHARED ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
   target_include_directories(cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
-  target_link_libraries(cxx_shared PUBLIC cxx-headers
+  target_link_libraries(cxx_shared PUBLIC cxx-headers libcxx-abi-shared
PRIVATE ${LIBCXX_LIBRARIES})
   set_target_properties(cxx_shared
 PROPERTIES
@@ -232,19 +232,9 @@
 endif()
   endif()
 
-  # Link against libc++abi
-  if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
-target_link_libraries(cxx_shared PRIVATE libcxx-abi-shared-objects)
-  else()
-target_link_libraries(cxx_shared PUBLIC libcxx-abi-shared)
-  endif()
-
   # Maybe re-export symbols from libc++abi
-  # In particular, we don't re-export the symbols if libc++abi is merged statically
-  # into libc++ because in that case there's no dylib to re-export from.
   if (APPLE AND LIBCXX_CXX_ABI STREQUAL "libcxxabi"
-AND NOT DEFI

[PATCH] D125709: [analyzer][Casting] Support isa, cast, dyn_cast of SVals

2022-05-17 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D125709#3518242 , @martong wrote:

>> I'm not sure, shall I add tests?
>
> Yes, please. Unit tests for `dyn_cast` and `isa` should be easy. However, I 
> am not sure how to test `cast` for the failure cases.

What if we were using the 'new' casting style at some places. If it compiles, 
it should be fine.
It feels weird to check stuff, only in `static_asserts`.

In D125709#3519033 , @bzcheeseman 
wrote:

> In D125709#3518096 , @steakhal 
> wrote:
>
>> I had to fix the `doCast` to return `To` instead of `Optional` to make 
>> it work.
>
> That's fine (or it should be!), you could dereference the optional if you 
> wanted to

Currently, we expect that casts result in regular SVal objects, instead of 
pointer-like objects , thus this code to compile:
`NonLoc N = llvm::cast(V)`, where `V` is of type `SVal`. I believe that 
is why I decided to make that change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125709

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


[PATCH] D125683: [runtimes] Replace LIBCXX_ENABLE_STATIC_ABI_LIBRARY & friends by a new LIBCXX_CXX_ABI choice

2022-05-17 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:124
 set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
-set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "")

Note that I am removing these options here because I don't think they are 
required -- since we specify `LIBCXXABI_ENABLE_SHARED=OFF`, there is no shared 
libc++abi to link against, so we should already be linking against 
`libc++abi.a` regardless of this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125683

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


[PATCH] D125402: [clang][diag] warn if function returns class type by-const-value

2022-05-17 Thread Namgoo Lee via Phabricator via cfe-commits
nlee added a comment.

Thank you for your reviews, and sorry for the mess in my last comment. I'm new 
to clang/Phabricator and trying to get used to it :)




Comment at: clang/lib/Sema/SemaType.cpp:5203
+  T.isConstQualified() &&
+  T->isStructureOrClassType()) {
+const SourceLocation ConstLoc = D.getDeclSpec().getConstSpecLoc();

nlee wrote:
> nlee wrote:
> > erichkeane wrote:
> > > I wonder if this is same concern applies to Unions?  Should this just be 
> > > `T->isRecordType()`?  Should we do more analysis to ensure that this is a 
> > > movable type? I THINK 
> > > `CXXRecordDecl::defaultedMoveConstructorIsDeleted()` should be enough to 
> > > test for t his.
> > How about adding `CXXRecordDecl::hasMoveConstructor()` to ensure the type 
> > is movable? I left out unions because they may alert false positives. An 
> > example of such a case is:
> > ```
> > union U { int i; std::string s; };
> > const U f() { return U{239}; }
> > ```
> > I wonder if this is same concern applies to Unions?  Should this just be 
> > `T->isRecordType()`?  Should we do more analysis to ensure that this is a 
> > movable type? I THINK `CXXRecordDecl::defaultedMoveConstructorIsDeleted()` 
> > should be enough to test for t his.
> 
> 
It seems it is not always possible to call 
`T->getAsCXXRecordDecl()->hasMoveConstructor()` here. 
`CXXRecordDecl::DefinitionData` is not populated if definition is not provided 
in the translation unit, such as in the following case:
```
extern struct no_def s;
const no_def f();
```
`assert` fails with message: `"queried property of class with no definition"`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125402

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


[PATCH] D125789: Fix release note typo from 6da3d66f

2022-05-17 Thread Changwei Zou via Phabricator via cfe-commits
sheisc created this revision.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
sheisc requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

The GNU assembler (used in gcc) complains about the syntactic correctness of
the assembly code (at line 9) generated by clang (with the option 
-no-integrated-as).

We need to delete the white space in "{%k1} {z}" (at line 9) to make both GCC 
and LLVM happy.

iron@CSE:demo$ cat -n main.s

   1.text
   2.file   "main.c"
   3.globl  main# -- Begin function main
   4.p2align4, 0x90
   5.type   main,@function
   6main:   # @main
   7.cfi_startproc
   8# %bb.0:# %entry
   9vmovdqu16 %zmm5 , %zmm5 {%k1} {z}
  10xorl%eax, %eax
  11retq
  12.Lfunc_end0:
  13.size   main, .Lfunc_end0-main
  14.cfi_endproc
  15# -- End function
  16
  17.ident  "clang"
  18.section".note.GNU-stack","",@progbits

iron@CSE:demo$ clang -c main.s -o main.o

iron@CSE:demo$ gcc -c main.s -o main.o

main.s: Assembler messages:
main.s:9: Error: unknown vector operation: ` {z}'


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125789

Files:
  clang/docs/ReleaseNotes.rst
  llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp
  llvm/lib/Target/X86/X86MCInstLower.cpp


Index: llvm/lib/Target/X86/X86MCInstLower.cpp
===
--- llvm/lib/Target/X86/X86MCInstLower.cpp
+++ llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -1877,7 +1877,7 @@
   CS << " {%" << GetRegisterName(WriteMaskOp.getReg()) << "}";
 
   if (SrcOp1Idx == 2) {
-CS << " {z}";
+CS << "{z}";
   }
 }
   }
Index: llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp
===
--- llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp
+++ llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp
@@ -278,7 +278,7 @@
 
   // MASKZ: zmmX {%kY} {z}
   if (MaskWithZero)
-OS << " {z}";
+OS << "{z}";
 }
 
 static bool printFMAComments(const MCInst *MI, raw_ostream &OS,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -365,7 +365,7 @@
   of clang; use the ``-fclang-abi-compat=14`` option to get the old mangling.
 - Preprocessor character literals with a ``u8`` prefix are now correctly 
treated as
   unsigned character literals. This fixes `Issue 54886 
`_.
-- Stopped allowing constriants on non-template functions to be compliant with
+- Stopped allowing constraints on non-template functions to be compliant with
   dcl.decl.general p4.
 
 C++20 Feature Support


Index: llvm/lib/Target/X86/X86MCInstLower.cpp
===
--- llvm/lib/Target/X86/X86MCInstLower.cpp
+++ llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -1877,7 +1877,7 @@
   CS << " {%" << GetRegisterName(WriteMaskOp.getReg()) << "}";
 
   if (SrcOp1Idx == 2) {
-CS << " {z}";
+CS << "{z}";
   }
 }
   }
Index: llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp
===
--- llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp
+++ llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp
@@ -278,7 +278,7 @@
 
   // MASKZ: zmmX {%kY} {z}
   if (MaskWithZero)
-OS << " {z}";
+OS << "{z}";
 }
 
 static bool printFMAComments(const MCInst *MI, raw_ostream &OS,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -365,7 +365,7 @@
   of clang; use the ``-fclang-abi-compat=14`` option to get the old mangling.
 - Preprocessor character literals with a ``u8`` prefix are now correctly treated as
   unsigned character literals. This fixes `Issue 54886 `_.
-- Stopped allowing constriants on non-template functions to be compliant with
+- Stopped allowing constraints on non-template functions to be compliant with
   dcl.decl.general p4.
 
 C++20 Feature Support
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125709: [analyzer][Casting] Support isa, cast, dyn_cast of SVals

2022-05-17 Thread Aman LaChapelle via Phabricator via cfe-commits
bzcheeseman accepted this revision.
bzcheeseman added a comment.
This revision is now accepted and ready to land.

> In D125709#3519033 , @bzcheeseman 
> wrote:
>
>> In D125709#3518096 , @steakhal 
>> wrote:
>>
>>> I had to fix the `doCast` to return `To` instead of `Optional` to make 
>>> it work.
>>
>> That's fine (or it should be!), you could dereference the optional if you 
>> wanted to
>
> Currently, we expect that casts result in regular SVal objects, instead of 
> pointer-like objects , thus this code to compile:
> `NonLoc N = llvm::cast(V)`, where `V` is of type `SVal`. I believe 
> that is why I decided to make that change.

Makes sense, LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125709

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


[PATCH] D125709: [analyzer][Casting] Support isa, cast, dyn_cast of SVals

2022-05-17 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Thanks for your help @bzcheeseman!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125709

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


[PATCH] D125773: [Driver] Do not auto-enable header modules with -std=c++20

2022-05-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 430056.
ilya-biryukov added a comment.

- Revert gnu++20 fix
- Always pass -fheader-modules/-fno-header-modules when modules are enabled


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125773

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Driver/cpp20-header-module.cpp
  clang/test/Modules/Inputs/cxx20-and-header-modules/a.h
  clang/test/Modules/Inputs/cxx20-and-header-modules/a.map
  clang/test/Modules/cxx20-and-header-modules.cpp

Index: clang/test/Modules/cxx20-and-header-modules.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-and-header-modules.cpp
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+//
+// Check header modules are disabled by default in C++20 mode.
+// RUN: %clang -std=c++20 -fsyntax-only -fno-implicit-modules -fmodules-cache-path=%t -I%S/Inputs/cxx20-and-header-modules -fmodule-map-file=%S/Inputs/cxx20-and-header-modules/a.map %s
+//
+// Also run in the header modules mode.
+// RUN: %clang -std=c++20 -DBUILDING_MODULE -fmodules -fimplicit-modules -fmodules-cache-path=%t -I%S/Inputs/cxx20-and-header-modules -fmodule-map-file=%S/Inputs/cxx20-and-header-modules/a.map %s
+
+#define INCLUDING 1
+#include "a.h"
+
+int main() {
+  return X().foo();
+}
Index: clang/test/Modules/Inputs/cxx20-and-header-modules/a.map
===
--- /dev/null
+++ clang/test/Modules/Inputs/cxx20-and-header-modules/a.map
@@ -0,0 +1,4 @@
+module A {
+  header "a.h"
+  export *
+}
Index: clang/test/Modules/Inputs/cxx20-and-header-modules/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/cxx20-and-header-modules/a.h
@@ -0,0 +1,12 @@
+#ifndef A_HEADER
+#define A_HEADER
+
+#if INCLUDING && BUILDING_MODULE
+#error "invalid context"
+#endif
+
+struct X {
+  int foo() { return 10; }
+};
+
+#endif
Index: clang/test/Driver/cpp20-header-module.cpp
===
--- /dev/null
+++ clang/test/Driver/cpp20-header-module.cpp
@@ -0,0 +1,19 @@
+// Check header modules are not enabled with C++20 standard and -fmodules-ts.
+//
+// RUN: %clang -fmodules-ts -std=c++20 -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=NO_HEADER_MODULES
+// RUN: %clang -std=c++20 -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=NO_HEADER_MODULES
+// RUN: %clang -std=c++2a -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=NO_HEADER_MODULES
+// RUN: %clang_cl /std:c++latest /Zs -v %s 2>&1 | FileCheck %s --check-prefix=NO_HEADER_MODULES
+//
+// NO_HEADER_MODULES-NOT: -fheader-modules
+// NO_HEADER_MODULES: -cc1
+// NO_HEADER_MODULES-SAME: -fno-header-modules
+//
+// RUN: %clang -fmodules -fmodules-ts -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=HAS_HEADER_MODULES
+// RUN: %clang -fmodules -fmodules-ts -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=HAS_HEADER_MODULES
+// RUN: %clang -fmodules -std=c++20 -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=HAS_HEADER_MODULES
+// RUN: %clang -fmodules -std=c++2a -fsyntax-only -v %s 2>&1 | FileCheck %s --check-prefix=HAS_HEADER_MODULES
+//
+// HAS_HEADER_MODULES-NOT: -fno-header-modules
+// HAS_HEADER_MODULES: -cc1
+// HAS_HEADER_MODULES: -fheader-modules
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -2159,7 +2159,8 @@
   // Determine whether we should try to import the module for this #include, if
   // there is one. Don't do so if precompiled module support is disabled or we
   // are processing this module textually (because we're building the module).
-  if (Action == Enter && File && SuggestedModule && getLangOpts().Modules &&
+  if (Action == Enter && File && SuggestedModule &&
+  getLangOpts().HeaderModules &&
   !isForModuleBuilding(SuggestedModule.getModule(),
getLangOpts().CurrentModule,
getLangOpts().ModuleName)) {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -38,6 +38,7 @@
 #include "clang/Driver/SanitizerArgs.h"
 #include "clang/Driver/Types.h"
 #include "clang/Driver/XRayArgs.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Option/ArgList.h"
@@ -3625,6 +3626,15 @@
 HaveModules = true;
   }
 
+  // Disable header modules in C++20 mode, they are not in the C++ standard.
+  // Unless '-fmodules' was specified explicitly.
+  if (HaveModules) {
+if (HaveClan

[PATCH] D125513: [clang-cl] Add /Zc:wchar_t- option

2022-05-17 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Looks good to me after addressing Hans's comment.

Do you have commit access?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125513

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


[PATCH] D125773: [Driver] Do not auto-enable header modules with -std=c++20

2022-05-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a reviewer: rsmith.
ilya-biryukov marked 2 inline comments as done.
ilya-biryukov added a comment.

In D125773#3519048 , @sammccall wrote:

> LG, but I think this is choosing a (new) public name for clang modules/header 
> modules, so maybe Richard or others might want to weigh in?

@rsmith could you confirm you are happy with the changes (and naming)?
And let us know if there are others we should loop in.




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3631
+  // Unless '-fmodules' was specified explicitly.
+  if (!HaveClangModules && HaveModules) {
+CmdArgs.push_back("-fno-header-modules");

sammccall wrote:
> These interacting flags are complicated, and I think relying on how the 
> default value is computed makes it harder to reason about.
> 
> Can we explicitly set -f{no}-header-modules whenever any version of modules 
> is available?
> i.e.
> ```
> if (HaveModules) {
>   if (HaveClangModules)
> push("-fheader-modules")
>   else
> push ("-fno-header-modules")
> }
> ```
> 
> (In the long run, it would be much clearer for -fheader-modules to default to 
> false, and explicitly set it whenever it's needed, but this is a larger 
> cleanup)
Makes sense, I think it's clearer.
As for using `false` as a default, the mentioned cleanup is that we need to 
update all tests to specify `-fheader-modules` explicitly.
I'm also not sure if there are any guarantees for `-cc1 ` that we have to 
adhere to. My assumption is that `-cc1` has no stability guarantees, but I'm 
not 100% certain.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6537
   // support by default, or just assume that all languages do.
-  bool HaveModules =
-  Std && (Std->containsValue("c++2a") || Std->containsValue("c++20") ||
-  Std->containsValue("c++latest"));
+  bool HaveModules = Std && llvm::any_of(Std->getValues(), [](const char *S) {
+   constexpr llvm::StringRef CPP_MODULES_STD[] = {

sammccall wrote:
> this change looks correct but unrelated, can we split into a separate change?
> (Mostly because either change might break stuff downstream, and they could be 
> reverted separately)
Good point, will send it as a separate review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125773

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


[PATCH] D124701: [clang] Honor __attribute__((no_builtin("foo"))) on functions

2022-05-17 Thread Stephen Long via Phabricator via cfe-commits
steplong updated this revision to Diff 430060.
steplong added a comment.

- Removed `__attribute__((no_builtin("*")))` from test
- Remove the logic that accepted `__attribute__((no_builtin("*")))`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124701

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/no-builtin-2.c

Index: clang/test/CodeGen/no-builtin-2.c
===
--- /dev/null
+++ clang/test/CodeGen/no-builtin-2.c
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+typedef typeof(sizeof(0)) size_t;
+
+void bar(char *s);
+void *memset(void *s, int c, size_t n);
+void *memcpy(void *d, const void *s, size_t n);
+void *memmove(void *d, const void *s, size_t n);
+
+// CHECK: define{{.*}} void @foo1({{.*}}) #[[NO_NOBUILTIN:[0-9]+]]
+// CHECK:   call void @bar
+// CHECK:   call void @llvm.memset
+// CHECK:   call void @llvm.memcpy
+// CHECK:   call void @llvm.memmove
+void foo1(char *s, char *d, size_t n) {
+  bar(s);
+  memset(s, 0, n);
+  memcpy(d, s, n);
+  memmove(d, s, n);
+}
+
+// CHECK: define{{.*}} void @foo2({{.*}}) #[[NOBUILTIN_MEMSET:[0-9]+]]
+// CHECK:   call void @bar
+// CHECK:   {{.*}}call {{.*}} @memset
+// CHECK:   call void @llvm.memcpy
+// CHECK:   call void @llvm.memmove
+void foo2(char *s, char *d, size_t n) __attribute__((no_builtin("memset"))) {
+  bar(s);
+  memset(s, 1, n);
+  memcpy(d, s, n);
+  memmove(d, s, n);
+}
+
+// CHECK: define{{.*}} void @foo3({{.*}}) #[[NOBUILTIN_MEMSET_MEMCPY:[0-9]+]]
+// CHECK:   call void @bar
+// CHECK:   {{.*}}call {{.*}} @memset
+// CHECK:   {{.*}}call {{.*}} @memcpy
+// CHECK:   call void @llvm.memmove
+void foo3(char *s, char *d, size_t n) __attribute__((no_builtin("memset", "memcpy"))) {
+  bar(s);
+  memset(s, 2, n);
+  memcpy(d, s, n);
+  memmove(d, s, n);
+}
+
+// CHECK: define{{.*}} void @foo4({{.*}}) #[[NOBUILTINS:[0-9]+]]
+// CHECK:   call void @bar
+// CHECK:   {{.*}}call {{.*}} @memset
+// CHECK:   {{.*}}call {{.*}} @memcpy
+// CHECK:   {{.*}}call {{.*}} @memmove
+void foo4(char *s, char *d, size_t n) __attribute__((no_builtin)) {
+  bar(s);
+  memset(s, 2, n);
+  memcpy(d, s, n);
+  memmove(s, d, n);
+}
+
+// CHECK-NOT: attributes #[[NO_NOBUILTIN]] = {{{.*}}"no-builtin-memset"{{.*}}}
+// CHECK-NOT: attributes #[[NO_NOBUILTIN]] = {{{.*}}"no-builtin-memcpy"{{.*}}"no-builtin-memset"{{.*}}}
+// CHECK-NOT: attributes #[[NO_NOBUILTIN]] = {{{.*}}"no-builtins"{{.*}}}
+// CHECK: attributes #[[NOBUILTIN_MEMSET]] = {{{.*}}"no-builtin-memset"{{.*}}}
+// CHECK: attributes #[[NOBUILTIN_MEMSET_MEMCPY]] = {{{.*}}"no-builtin-memcpy"{{.*}}"no-builtin-memset"{{.*}}}
+// CHECK: attributes #[[NOBUILTINS]] = {{{.*}}"no-builtins"{{.*}}}
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -5034,7 +5034,16 @@
   const FunctionDecl *FD = cast(GD.getDecl());
 
   if (auto builtinID = FD->getBuiltinID()) {
+std::string NoBuiltinFD = ("no-builtin-" + FD->getName()).str();
+std::string NoBuiltins = "no-builtins";
 std::string FDInlineName = (FD->getName() + ".inline").str();
+
+bool IsPredefinedLibFunction =
+CGF.getContext().BuiltinInfo.isPredefinedLibFunction(builtinID);
+bool HasAttributeNoBuiltin =
+CGF.CurFn->getAttributes().hasFnAttr(NoBuiltinFD) ||
+CGF.CurFn->getAttributes().hasFnAttr(NoBuiltins);
+
 // When directing calling an inline builtin, call it through it's mangled
 // name to make it clear it's not the actual builtin.
 if (CGF.CurFn->getName() != FDInlineName &&
@@ -5054,8 +5063,11 @@
 
 // Replaceable builtins provide their own implementation of a builtin. If we
 // are in an inline builtin implementation, avoid trivial infinite
-// recursion.
-else
+// recursion. Honor __attribute__((no_builtin("foo"))) or
+// __attribute((no_builtin("*"))) on the current function unless foo is
+// not a predefined library function which means we must generate the
+// builtin no matter what.
+else if (!IsPredefinedLibFunction || !HasAttributeNoBuiltin)
   return CGCallee::forBuiltin(builtinID, FD);
   }
 
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -6000,9 +6000,6 @@
 def NoBuiltinDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
-.. Note:: This attribute is not yet fully implemented, it is validated but has
-  no effect on the generated code.
-
 The ``__attribute__((no_builtin))`` is similar to the ``-fno-builtin`` flag
 except it is specific to the body of a function. The attribute may also be
 applied to a virtu

[PATCH] D125604: [FileCheck] Catch missspelled directives.

2022-05-17 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre added inline comments.



Comment at: llvm/lib/FileCheck/FileCheck.cpp:1774-1781
+static std::pair
+FindCheckType(const FileCheckRequest &Req, StringRef Buffer, StringRef Prefix) 
{
+  bool Misspelled = false;
+  auto Res = FindCheckType(Req, Buffer, Prefix, Misspelled);
+  if (Res.first != Check::CheckNone && Misspelled)
+return {Check::CheckMisspelled, Res.second};
+  return Res;

kosarev wrote:
> thopre wrote:
> > Instead of introducing a new wrapper, why don't you change all the return 
> > to call a constructor method (e.g. `make_check_type()`) that does what this 
> > wrapper do? Then there would not be any FindCheckType that take a 
> > Misspelled parameter.
> > 
> > I'm also not sure about Misspelled being a check kind. It feels 
> > conceptually wrong but on the other hand I guess it makes the 
> > implementation simpler.
> Tried that. Replacing the returned pair with a new `CheckLine` kind of object 
> implementing the misspelled-related logic seems to add a lot of extra clutter 
> such as the definition of the new structure itself, but especially all the 
> repetitive mentions of `Misspelled` on every `return`. Feels like having it 
> as a reference parameter works better, as we only need to alter the flag 
> occasionally.
> 
> Regarding `CheckMisspelled`, now that we have `CheckBadNot` and 
> `CheckBadCount`, this looks the usual way of propagating the information 
> about our spelling-related concerns. Might be not the best design and may be 
> worth looking into at some point, but at least doesn' seem to be specific to 
> this patch?
I was thinking something along the line of:

return getRealCheckType(CHECK::CheckBadCount, Rest, Misspelled); with:

```static std::pair
getRealCheckType(Check::FileCheckType CheckType, StringRef Rest, bool 
Misspelled) {
  if (CheckType != Check::CheckNone && Misspelled)
return {Check::CheckMisspelled, Rest};
  return {CheckType, Rest};
}```

Fair enough for CheckMisspelled, there is indeeed precedent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125604

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


[PATCH] D115232: [clangd] Indexing of standard library

2022-05-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 430062.
sammccall added a comment.

Address comments
Add end-to-end test
Move ownership of AsyncTaskRunner to allow blockUntilIdle() in test
Fix bugs caught by end-to-end-test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115232

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/index/StdLib.cpp
  clang-tools-extra/clangd/index/StdLib.h
  clang-tools-extra/clangd/index/SymbolOrigin.cpp
  clang-tools-extra/clangd/index/SymbolOrigin.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/StdLibTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -1123,7 +1123,8 @@
   public:
 BlockPreambleThread(llvm::StringRef BlockVersion, Notification &N)
 : BlockVersion(BlockVersion), N(N) {}
-void onPreambleAST(PathRef Path, llvm::StringRef Version, ASTContext &Ctx,
+void onPreambleAST(PathRef Path, llvm::StringRef Version,
+   const CompilerInvocation &, ASTContext &Ctx,
Preprocessor &, const CanonicalIncludes &) override {
   if (Version == BlockVersion)
 N.wait();
Index: clang-tools-extra/clangd/unittests/StdLibTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/StdLibTests.cpp
@@ -0,0 +1,162 @@
+//===-- StdLibTests.cpp -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Annotations.h"
+#include "ClangdServer.h"
+#include "CodeComplete.h"
+#include "Compiler.h"
+#include "Config.h"
+#include "SyncAPI.h"
+#include "TestFS.h"
+#include "index/StdLib.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceManager.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace testing;
+
+namespace clang {
+namespace clangd {
+namespace {
+
+// Check the generated header sources contains usual standard library headers.
+TEST(StdLibTests, getStdlibUmbrellaHeader) {
+  LangOptions LO;
+  LO.CPlusPlus = true;
+
+  auto CXX = getStdlibUmbrellaHeader(LO);
+  EXPECT_THAT(CXX, HasSubstr("#include "));
+  EXPECT_THAT(CXX, HasSubstr("#include "));
+  EXPECT_THAT(CXX, Not(HasSubstr("#include ")));
+
+  LO.CPlusPlus = false;
+  auto C = getStdlibUmbrellaHeader(LO);
+  EXPECT_THAT(C, Not(HasSubstr("#include ")));
+  EXPECT_THAT(C, Not(HasSubstr("#include ")));
+  EXPECT_THAT(C, HasSubstr("#include "));
+}
+
+MATCHER_P(Named, Name, "") { return arg.Name == Name; }
+
+// Build an index, and check if it contains the right symbols.
+TEST(StdLibTests, indexStandardLibrary) {
+  MockFS FS;
+  FS.Files["std/foo.h"] = R"cpp(
+  #include 
+  #if __cplusplus >= 201703L
+int foo17();
+  #elif __cplusplus >= 201402L
+int foo14();
+  #else
+bool foo98();
+  #endif
+  )cpp";
+  FS.Files["nonstd/platform_stuff.h"] = "int magic = 42;";
+
+  ParseInputs OriginalInputs;
+  OriginalInputs.TFS = &FS;
+  OriginalInputs.CompileCommand.Filename = testPath("main.cc");
+  OriginalInputs.CompileCommand.CommandLine = {"clang++", testPath("main.cc"),
+   "-isystemstd/",
+   "-isystemnonstd/", "-std=c++14"};
+  OriginalInputs.CompileCommand.Directory = testRoot();
+  IgnoreDiagnostics Diags;
+  auto CI = buildCompilerInvocation(OriginalInputs, Diags);
+  ASSERT_TRUE(CI);
+
+  StdLibLocation Loc;
+  Loc.Paths.push_back(testPath("std/"));
+
+  auto Symbols =
+  indexStandardLibrary("#include ", std::move(CI), Loc, FS);
+  EXPECT_THAT(Symbols, ElementsAre(Named("foo14")));
+}
+
+TEST(StdLibTests, StdLibSet) {
+  StdLibSet Set;
+  MockFS FS;
+  FS.Files["std/_"] = "";
+  FS.Files["libc/_"] = "";
+
+  auto Add = [&](const LangOptions &LO,
+ std::vector SearchPath) {
+SourceManagerForFile SM("scratch", "");
+SM.get().getFileManager().setVirtualFileSystem(FS.view(llvm::None));
+ 

[clang-tools-extra] ecaa4d9 - [clangd] Indexing of standard library

2022-05-17 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-05-17T16:50:41+02:00
New Revision: ecaa4d9662c9a6ac013ac40a8ad72a2c75e3fd3b

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

LOG: [clangd] Indexing of standard library

This provides a nice "warm start" with all headers indexed, not just
those included so far.

The standard library is indexed after a preamble is parsed, using that
file's configuration. The result is pushed into the dynamic index.
If we later see a higher language version, we reindex it.

It's configurable as Index.StandardLibrary, off by default for now.

Based on D105177 by @kuhnel

Fixes https://github.com/clangd/clangd/issues/618

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

Added: 
clang-tools-extra/clangd/index/StdLib.cpp
clang-tools-extra/clangd/index/StdLib.h
clang-tools-extra/clangd/unittests/StdLibTests.cpp

Modified: 
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/Config.h
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/ConfigFragment.h
clang-tools-extra/clangd/ConfigYAML.cpp
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/TUScheduler.h
clang-tools-extra/clangd/index/FileIndex.cpp
clang-tools-extra/clangd/index/FileIndex.h
clang-tools-extra/clangd/index/SymbolOrigin.cpp
clang-tools-extra/clangd/index/SymbolOrigin.h
clang-tools-extra/clangd/unittests/CMakeLists.txt
clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index 9c37cfe7b7001..7cfbd6f95750e 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -119,6 +119,7 @@ add_clang_library(clangDaemon
   index/Ref.cpp
   index/Relation.cpp
   index/Serialization.cpp
+  index/StdLib.cpp
   index/Symbol.cpp
   index/SymbolCollector.cpp
   index/SymbolID.cpp

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 80d7d5c5ece19..69a0f63972aae 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -26,6 +26,7 @@
 #include "index/CanonicalIncludes.h"
 #include "index/FileIndex.h"
 #include "index/Merge.h"
+#include "index/StdLib.h"
 #include "refactor/Rename.h"
 #include "refactor/Tweak.h"
 #include "support/Cancellation.h"
@@ -59,16 +60,39 @@ namespace {
 // Update the FileIndex with new ASTs and plumb the diagnostics responses.
 struct UpdateIndexCallbacks : public ParsingCallbacks {
   UpdateIndexCallbacks(FileIndex *FIndex,
-   ClangdServer::Callbacks *ServerCallbacks)
-  : FIndex(FIndex), ServerCallbacks(ServerCallbacks) {}
+   ClangdServer::Callbacks *ServerCallbacks,
+   const ThreadsafeFS &TFS, AsyncTaskRunner *Tasks)
+  : FIndex(FIndex), ServerCallbacks(ServerCallbacks), TFS(TFS),
+Tasks(Tasks) {}
 
-  void onPreambleAST(PathRef Path, llvm::StringRef Version, ASTContext &Ctx,
+  void onPreambleAST(PathRef Path, llvm::StringRef Version,
+ const CompilerInvocation &CI, ASTContext &Ctx,
  Preprocessor &PP,
  const CanonicalIncludes &CanonIncludes) override {
+// If this preamble uses a standard library we haven't seen yet, index it.
+if (FIndex)
+  if (auto Loc = Stdlib.add(*CI.getLangOpts(), PP.getHeaderSearchInfo()))
+indexStdlib(CI, std::move(*Loc));
+
 if (FIndex)
   FIndex->updatePreamble(Path, Version, Ctx, PP, CanonIncludes);
   }
 
+  void indexStdlib(const CompilerInvocation &CI, StdLibLocation Loc) {
+auto Task = [this, LO(*CI.getLangOpts()), Loc(std::move(Loc)),
+ CI(std::make_unique(CI))]() mutable {
+  IndexFileIn IF;
+  IF.Symbols = indexStandardLibrary(std::move(CI), Loc, TFS);
+  if (Stdlib.isBest(LO))
+FIndex->updatePreamble(std::move(IF));
+};
+if (Tasks)
+  // This doesn't have a semaphore to enforce -j, but it's rare.
+  Tasks->runAsync("IndexStdlib", std::move(Task));
+else
+  Task();
+  }
+
   void onMainAST(PathRef Path, ParsedAST &AST, PublishFn Publish) override {
 if (FIndex)
   FIndex->updateMain(Path, AST);
@@ -103,6 +127,9 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
 private:
   FileIndex *FIndex;
   ClangdServer::Callbacks *ServerCallbacks;
+  const ThreadsafeFS &TFS;
+  StdLibSet Stdlib;
+  AsyncTaskRunner *Tasks;
 };
 
 class DraftStoreFS : public ThreadsafeFS {
@@ -154,12 +181,15 @@ ClangdServer::ClangdServer(const 
GlobalCompilationDatabase &CDB,
   Transient(Opts.Impl

[PATCH] D115232: [clangd] Indexing of standard library

2022-05-17 Thread Sam McCall 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 rGecaa4d9662c9: [clangd] Indexing of standard library 
(authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115232

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/index/StdLib.cpp
  clang-tools-extra/clangd/index/StdLib.h
  clang-tools-extra/clangd/index/SymbolOrigin.cpp
  clang-tools-extra/clangd/index/SymbolOrigin.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/StdLibTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -1123,7 +1123,8 @@
   public:
 BlockPreambleThread(llvm::StringRef BlockVersion, Notification &N)
 : BlockVersion(BlockVersion), N(N) {}
-void onPreambleAST(PathRef Path, llvm::StringRef Version, ASTContext &Ctx,
+void onPreambleAST(PathRef Path, llvm::StringRef Version,
+   const CompilerInvocation &, ASTContext &Ctx,
Preprocessor &, const CanonicalIncludes &) override {
   if (Version == BlockVersion)
 N.wait();
Index: clang-tools-extra/clangd/unittests/StdLibTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/StdLibTests.cpp
@@ -0,0 +1,162 @@
+//===-- StdLibTests.cpp -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Annotations.h"
+#include "ClangdServer.h"
+#include "CodeComplete.h"
+#include "Compiler.h"
+#include "Config.h"
+#include "SyncAPI.h"
+#include "TestFS.h"
+#include "index/StdLib.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceManager.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace testing;
+
+namespace clang {
+namespace clangd {
+namespace {
+
+// Check the generated header sources contains usual standard library headers.
+TEST(StdLibTests, getStdlibUmbrellaHeader) {
+  LangOptions LO;
+  LO.CPlusPlus = true;
+
+  auto CXX = getStdlibUmbrellaHeader(LO);
+  EXPECT_THAT(CXX, HasSubstr("#include "));
+  EXPECT_THAT(CXX, HasSubstr("#include "));
+  EXPECT_THAT(CXX, Not(HasSubstr("#include ")));
+
+  LO.CPlusPlus = false;
+  auto C = getStdlibUmbrellaHeader(LO);
+  EXPECT_THAT(C, Not(HasSubstr("#include ")));
+  EXPECT_THAT(C, Not(HasSubstr("#include ")));
+  EXPECT_THAT(C, HasSubstr("#include "));
+}
+
+MATCHER_P(Named, Name, "") { return arg.Name == Name; }
+
+// Build an index, and check if it contains the right symbols.
+TEST(StdLibTests, indexStandardLibrary) {
+  MockFS FS;
+  FS.Files["std/foo.h"] = R"cpp(
+  #include 
+  #if __cplusplus >= 201703L
+int foo17();
+  #elif __cplusplus >= 201402L
+int foo14();
+  #else
+bool foo98();
+  #endif
+  )cpp";
+  FS.Files["nonstd/platform_stuff.h"] = "int magic = 42;";
+
+  ParseInputs OriginalInputs;
+  OriginalInputs.TFS = &FS;
+  OriginalInputs.CompileCommand.Filename = testPath("main.cc");
+  OriginalInputs.CompileCommand.CommandLine = {"clang++", testPath("main.cc"),
+   "-isystemstd/",
+   "-isystemnonstd/", "-std=c++14"};
+  OriginalInputs.CompileCommand.Directory = testRoot();
+  IgnoreDiagnostics Diags;
+  auto CI = buildCompilerInvocation(OriginalInputs, Diags);
+  ASSERT_TRUE(CI);
+
+  StdLibLocation Loc;
+  Loc.Paths.push_back(testPath("std/"));
+
+  auto Symbols =
+  indexStandardLibrary("#include ", std::move(CI), Loc, FS);
+  EXPECT_THAT(Symbols, ElementsAre(Named("foo14")));
+}
+
+TEST(StdLibTests, StdLibSet) {
+  StdLibSet Set;
+  MockFS FS;
+  FS.Files["std/_"] = "";
+  FS.Files["libc/_"] = "";
+
+  auto Add = [&](const LangOptions &LO,
+ std::vector SearchPath) {
+SourceManagerForFile SM("scratch", "");
+SM.get().getFileManager().setVirtualFileSystem(FS.view(llvm::

[PATCH] D125794: [pseudo] Remove unnecessary user-defined-string-literal rule.

2022-05-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: All.
hokein requested review of this revision.
Herald added a subscriber: alextsao1999.
Herald added a project: clang-tools-extra.

We accidently define two identical rules for user-defined-string-literal
(one left recursive and the other one is right recursive), it explodes
states when parsing a long long "" "" "" string literal.

TEST on a huge file which contains ~2.6w "" string literal:

before this patch: more than minutes
after this patch: < 1s


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125794

Files:
  clang-tools-extra/pseudo/lib/cxx.bnf


Index: clang-tools-extra/pseudo/lib/cxx.bnf
===
--- clang-tools-extra/pseudo/lib/cxx.bnf
+++ clang-tools-extra/pseudo/lib/cxx.bnf
@@ -713,7 +713,7 @@
 #! so it doesn't belong to the grammar. However, we extend the grammar to
 #! support it, to make the pseudoparser fully functional on practical code.
 string-literal := string-literal-chunk
-string-literal := string-literal string-literal-chunk
+string-literal := string-literal-chunk string-literal
 user-defined-literal := user-defined-integer-literal
 user-defined-literal := user-defined-floating-point-literal
 user-defined-literal := user-defined-string-literal
@@ -726,7 +726,6 @@
 user-defined-string-literal-chunk := UTF32_STRING_LITERAL
 user-defined-string-literal := user-defined-string-literal-chunk
 user-defined-string-literal := string-literal-chunk user-defined-string-literal
-user-defined-string-literal := user-defined-string-literal string-literal-chunk
 user-defined-floating-point-literal := NUMERIC_CONSTANT
 user-defined-character-literal := CHAR_CONSTANT
 user-defined-character-literal := WIDE_CHAR_CONSTANT


Index: clang-tools-extra/pseudo/lib/cxx.bnf
===
--- clang-tools-extra/pseudo/lib/cxx.bnf
+++ clang-tools-extra/pseudo/lib/cxx.bnf
@@ -713,7 +713,7 @@
 #! so it doesn't belong to the grammar. However, we extend the grammar to
 #! support it, to make the pseudoparser fully functional on practical code.
 string-literal := string-literal-chunk
-string-literal := string-literal string-literal-chunk
+string-literal := string-literal-chunk string-literal
 user-defined-literal := user-defined-integer-literal
 user-defined-literal := user-defined-floating-point-literal
 user-defined-literal := user-defined-string-literal
@@ -726,7 +726,6 @@
 user-defined-string-literal-chunk := UTF32_STRING_LITERAL
 user-defined-string-literal := user-defined-string-literal-chunk
 user-defined-string-literal := string-literal-chunk user-defined-string-literal
-user-defined-string-literal := user-defined-string-literal string-literal-chunk
 user-defined-floating-point-literal := NUMERIC_CONSTANT
 user-defined-character-literal := CHAR_CONSTANT
 user-defined-character-literal := WIDE_CHAR_CONSTANT
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125788: [flang][driver] Rename `flang-new` as `flang`

2022-05-17 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

Do you know how this will work with the llvm-testsuite runs that currrently use 
gfortran for codegen? Here is one we have: 
https://lab.llvm.org/buildbot/#/builders/179/builds/3694

Currently:

  2022-05-17 13:06:53 INFO: Execute: /usr/bin/cmake 
-DCMAKE_C_COMPILER:FILEPATH=/home/tcwg-buildbot/worker/clang-aarch64-full-2stage/stage2.install/bin/clang
 
-DCMAKE_CXX_COMPILER:FILEPATH=/home/tcwg-buildbot/worker/clang-aarch64-full-2stage/stage2.install/bin/clang++
 /home/tcwg-buildbot/worker/clang-aarch64-full-2stage/test/test-suite 
-DCMAKE_C_FLAGS=-mcpu=cortex-a57 -DCMAKE_C_FLAGS_DEBUG= 
-DCMAKE_C_FLAGS_MINSIZEREL= -DCMAKE_C_FLAGS_RELEASE= 
-DCMAKE_C_FLAGS_RELWITHDEBINFO= -DCMAKE_CXX_FLAGS=-mcpu=cortex-a57 
-DCMAKE_CXX_FLAGS_DEBUG= -DCMAKE_CXX_FLAGS_MINSIZEREL= 
-DCMAKE_CXX_FLAGS_RELEASE= -DCMAKE_CXX_FLAGS_RELWITHDEBINFO= 
-DTEST_SUITE_FORTRAN:STRING=ON 
-DCMAKE_Fortran_COMPILER=/home/tcwg-buildbot/worker/clang-aarch64-full-2stage/stage2.install/bin/flang
  <...>
  -- The Fortran compiler identification is unknown
  -- Check for working Fortran compiler: 
/home/tcwg-buildbot/worker/clang-aarch64-full-2stage/stage2.install/bin/flang
  -- Check for working Fortran compiler: 
/home/tcwg-buildbot/worker/clang-aarch64-full-2stage/stage2.install/bin/flang  
-- works
  -- Detecting Fortran compiler ABI info
  -- Detecting Fortran compiler ABI info - failed
  -- Checking whether 
/home/tcwg-buildbot/worker/clang-aarch64-full-2stage/stage2.install/bin/flang 
supports Fortran 90
  -- Checking whether 
/home/tcwg-buildbot/worker/clang-aarch64-full-2stage/stage2.install/bin/flang 
supports Fortran 90 -- yes

Can we expect the current `flang-new`, soon to be `flang` to also cope with 
these tests (I have no expectations myself here, fine if not) or should we move 
the bots to use `flang-to-gfortran`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125788

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


[PATCH] D125794: [pseudo] Remove unnecessary user-defined-string-literal rule.

2022-05-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/pseudo/lib/cxx.bnf:716
 string-literal := string-literal-chunk
-string-literal := string-literal string-literal-chunk
+string-literal := string-literal-chunk string-literal
 user-defined-literal := user-defined-integer-literal

I also wrote this as right recursive, it significantly reduces the states in 
the GSS (35% saving!) 

before:
```
Forest bytes: 1898128 nodes: 105456
GSS bytes: 3801192 nodes: 158029
```

after:
```
Forest bytes: 1898128 nodes: 105456
GSS bytes: 2539624 nodes: 105433
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125794

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


[PATCH] D125084: [test, x86] Fix spurious x86-target-features.c failure

2022-05-17 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125084

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


[PATCH] D125604: [FileCheck] Catch missspelled directives.

2022-05-17 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev added inline comments.



Comment at: llvm/lib/FileCheck/FileCheck.cpp:1774-1781
+static std::pair
+FindCheckType(const FileCheckRequest &Req, StringRef Buffer, StringRef Prefix) 
{
+  bool Misspelled = false;
+  auto Res = FindCheckType(Req, Buffer, Prefix, Misspelled);
+  if (Res.first != Check::CheckNone && Misspelled)
+return {Check::CheckMisspelled, Res.second};
+  return Res;

thopre wrote:
> kosarev wrote:
> > thopre wrote:
> > > Instead of introducing a new wrapper, why don't you change all the return 
> > > to call a constructor method (e.g. `make_check_type()`) that does what 
> > > this wrapper do? Then there would not be any FindCheckType that take a 
> > > Misspelled parameter.
> > > 
> > > I'm also not sure about Misspelled being a check kind. It feels 
> > > conceptually wrong but on the other hand I guess it makes the 
> > > implementation simpler.
> > Tried that. Replacing the returned pair with a new `CheckLine` kind of 
> > object implementing the misspelled-related logic seems to add a lot of 
> > extra clutter such as the definition of the new structure itself, but 
> > especially all the repetitive mentions of `Misspelled` on every `return`. 
> > Feels like having it as a reference parameter works better, as we only need 
> > to alter the flag occasionally.
> > 
> > Regarding `CheckMisspelled`, now that we have `CheckBadNot` and 
> > `CheckBadCount`, this looks the usual way of propagating the information 
> > about our spelling-related concerns. Might be not the best design and may 
> > be worth looking into at some point, but at least doesn' seem to be 
> > specific to this patch?
> I was thinking something along the line of:
> 
> return getRealCheckType(CHECK::CheckBadCount, Rest, Misspelled); with:
> 
> ```static std::pair
> getRealCheckType(Check::FileCheckType CheckType, StringRef Rest, bool 
> Misspelled) {
>   if (CheckType != Check::CheckNone && Misspelled)
> return {Check::CheckMisspelled, Rest};
>   return {CheckType, Rest};
> }```
> 
> Fair enough for CheckMisspelled, there is indeeed precedent.
That unfortunately wouldn't eliminate the repetitive `return 
getRealCheckType(..., Misspelled)` bits, thus adding a significant amount of 
clutter -- all for the sake of a single assignment where we raise the flag, 
while also making the code more fragile as the compiler wouldn't then be able 
to catch `return`s without calling `getRealCheckType()`. And if that's not 
enough, then the name of the function sounds like we introduce one of the most 
irritating kinds of concepts -- the 'real' ones. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125604

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


[PATCH] D125794: [pseudo] Remove unnecessary user-defined-string-literal rule.

2022-05-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

The intent here is that `user-defined-string-literal-chunk := STRING_LITERAL` 
only matches when there's a ud-suffix. And `string-literal-chunk := 
STRING_LITERAL` only matches when there isn't.
(e.g. with a rule guard, which we don't have implemented)
If this was happening, would we still have the explosion?

I believe (once the guards are added) this patch will lead to rejecting "foo" 
"bar"_ud "baz".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125794

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


[PATCH] D125765: [RISCV] Add type aliases float16_t, float32_t and float64_t

2022-05-17 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

Thanks for the patch - can you add test coverage for this please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125765

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


[PATCH] D125788: [flang][driver] Rename `flang-new` as `flang`

2022-05-17 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D125788#3519297 , @DavidSpickett 
wrote:

> Can we expect the current `flang-new`, soon to be `flang` to also cope with 
> these tests (I have no expectations myself here, fine if not) or should we 
> move the bots to use `flang-to-gfortran`?

Great point, thank for highlighting it! Moving the bots to `flang-to-gfortran` 
would make most sense. I can split this change into two patches so that there's 
no disruption from the buildbot perspective:

- patch 1: rename `flang` as `flang-to-gfortran`, but keep `flang` as an alias 
for `flang-to-gfortran`,
- patch 2: all the remaining changes from this patch.

Once "patch 1" is merged, we can update the buildbot config to use 
`flang-to-gfortran`. After that, we could land "patch 2".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125788

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


[PATCH] D123676: [clang-format] Fix WhitespaceSensitiveMacros not being honoured when macro closing parenthesis is followed by a newline.

2022-05-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

We found another regression with this in wrongly indenting/not putting on its 
own line ObjC `@interface`:

  % ./clang-format --version   
  clang-format version 15.0.0 (https://github.com/llvm/llvm-project.git 
50cd52d9357224cce66a9e00c9a0417c658a5655)
  % cat test.m
  NS_SWIFT_NAME(A)
  @interface B : C
  @property(readonly) D value;
  @end
  
  % ./clang-format test.m
  NS_SWIFT_NAME(A) @interface B : C
  @property(readonly) D value;
  @end
  %


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123676

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


[PATCH] D125789: Fix release note typo from 6da3d66f

2022-05-17 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

I guess a lot of lines of tests need to update

  $ grep -rn " {z}" llvm/test/CodeGen/X86/ | wc -l
  7797




Comment at: clang/docs/ReleaseNotes.rst:368
   unsigned character literals. This fixes `Issue 54886 
`_.
-- Stopped allowing constriants on non-template functions to be compliant with
+- Stopped allowing constraints on non-template functions to be compliant with
   dcl.decl.general p4.

I think this can be a sepreate patch. Or commit directly with a NFC label.



Comment at: llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp:279
 
   // MASKZ: zmmX {%kY} {z}
   if (MaskWithZero)

Fix the comment as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125789

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


[PATCH] D125499: Enabling the detection of devtoolset-11 toolchain.

2022-05-17 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added inline comments.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:2156
 Prefixes.push_back("/opt/rh/devtoolset-10/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-9/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-8/root/usr");

MaskRay wrote:
> The detection is wasted every Linux user (even if they don't use 
> RedHat/Fedora). Some may need to be refactored to detect `/opt/rh` first. 
> Some ancient devtoolset-* may be deleted now.
@kamaub Are you planning to address these comments in a follow up change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125499

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


[PATCH] D125771: [clang-tidy] Add a useful note about -std=c++11-or-later

2022-05-17 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 430069.
steakhal marked an inline comment as done.
steakhal added a comment.

fix typo `withing` -> `within`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125771

Files:
  clang-tools-extra/test/clang-tidy/check_clang_tidy.py


Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -19,11 +19,17 @@
 [-assume-filename=] \
 [-check-suffix=] \
 [-check-suffixes=] \
+[-std=(c++11-or-later|c++17)] \
\
 -- [optional clang-tidy arguments]
 
 Example:
   // RUN: %check_clang_tidy %s llvm-include-order %t -- -- -isystem %S/Inputs
+
+Notes:
+  -std=c++11-or-later:
+This flag will cause multiple runs within the same check_clang_tidy
+execution. Make sure you don't have shared state across these runs.
 """
 
 import argparse


Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -19,11 +19,17 @@
 [-assume-filename=] \
 [-check-suffix=] \
 [-check-suffixes=] \
+[-std=(c++11-or-later|c++17)] \
\
 -- [optional clang-tidy arguments]
 
 Example:
   // RUN: %check_clang_tidy %s llvm-include-order %t -- -- -isystem %S/Inputs
+
+Notes:
+  -std=c++11-or-later:
+This flag will cause multiple runs within the same check_clang_tidy
+execution. Make sure you don't have shared state across these runs.
 """
 
 import argparse
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125789: FIX the assembly format of the x86 backend to make both clang and gcc happy

2022-05-17 Thread Changwei Zou via Phabricator via cfe-commits
sheisc updated this revision to Diff 430067.
sheisc retitled this revision from "Fix release note typo from 6da3d66f" to 
"FIX the assembly format of the x86 backend to make both clang and gcc happy".
sheisc edited the summary of this revision.
sheisc added a project: libc-project.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125789

Files:
  llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp
  llvm/lib/Target/X86/X86MCInstLower.cpp


Index: llvm/lib/Target/X86/X86MCInstLower.cpp
===
--- llvm/lib/Target/X86/X86MCInstLower.cpp
+++ llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -1877,7 +1877,7 @@
   CS << " {%" << GetRegisterName(WriteMaskOp.getReg()) << "}";
 
   if (SrcOp1Idx == 2) {
-CS << " {z}";
+CS << "{z}";
   }
 }
   }
Index: llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp
===
--- llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp
+++ llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp
@@ -278,7 +278,7 @@
 
   // MASKZ: zmmX {%kY} {z}
   if (MaskWithZero)
-OS << " {z}";
+OS << "{z}";
 }
 
 static bool printFMAComments(const MCInst *MI, raw_ostream &OS,


Index: llvm/lib/Target/X86/X86MCInstLower.cpp
===
--- llvm/lib/Target/X86/X86MCInstLower.cpp
+++ llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -1877,7 +1877,7 @@
   CS << " {%" << GetRegisterName(WriteMaskOp.getReg()) << "}";
 
   if (SrcOp1Idx == 2) {
-CS << " {z}";
+CS << "{z}";
   }
 }
   }
Index: llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp
===
--- llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp
+++ llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp
@@ -278,7 +278,7 @@
 
   // MASKZ: zmmX {%kY} {z}
   if (MaskWithZero)
-OS << " {z}";
+OS << "{z}";
 }
 
 static bool printFMAComments(const MCInst *MI, raw_ostream &OS,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 76ddbb1 - Revert "[clangd] Indexing of standard library"

2022-05-17 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-05-17T17:17:27+02:00
New Revision: 76ddbb1ca747366417be64fdf79218df099a5973

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

LOG: Revert "[clangd] Indexing of standard library"

This reverts commit ecaa4d9662c9a6ac013ac40a8ad72a2c75e3fd3b.

Added: 


Modified: 
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/Config.h
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/ConfigFragment.h
clang-tools-extra/clangd/ConfigYAML.cpp
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/TUScheduler.h
clang-tools-extra/clangd/index/FileIndex.cpp
clang-tools-extra/clangd/index/FileIndex.h
clang-tools-extra/clangd/index/SymbolOrigin.cpp
clang-tools-extra/clangd/index/SymbolOrigin.h
clang-tools-extra/clangd/unittests/CMakeLists.txt
clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Removed: 
clang-tools-extra/clangd/index/StdLib.cpp
clang-tools-extra/clangd/index/StdLib.h
clang-tools-extra/clangd/unittests/StdLibTests.cpp



diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index 7cfbd6f95750e..9c37cfe7b7001 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -119,7 +119,6 @@ add_clang_library(clangDaemon
   index/Ref.cpp
   index/Relation.cpp
   index/Serialization.cpp
-  index/StdLib.cpp
   index/Symbol.cpp
   index/SymbolCollector.cpp
   index/SymbolID.cpp

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 69a0f63972aae..80d7d5c5ece19 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -26,7 +26,6 @@
 #include "index/CanonicalIncludes.h"
 #include "index/FileIndex.h"
 #include "index/Merge.h"
-#include "index/StdLib.h"
 #include "refactor/Rename.h"
 #include "refactor/Tweak.h"
 #include "support/Cancellation.h"
@@ -60,39 +59,16 @@ namespace {
 // Update the FileIndex with new ASTs and plumb the diagnostics responses.
 struct UpdateIndexCallbacks : public ParsingCallbacks {
   UpdateIndexCallbacks(FileIndex *FIndex,
-   ClangdServer::Callbacks *ServerCallbacks,
-   const ThreadsafeFS &TFS, AsyncTaskRunner *Tasks)
-  : FIndex(FIndex), ServerCallbacks(ServerCallbacks), TFS(TFS),
-Tasks(Tasks) {}
+   ClangdServer::Callbacks *ServerCallbacks)
+  : FIndex(FIndex), ServerCallbacks(ServerCallbacks) {}
 
-  void onPreambleAST(PathRef Path, llvm::StringRef Version,
- const CompilerInvocation &CI, ASTContext &Ctx,
+  void onPreambleAST(PathRef Path, llvm::StringRef Version, ASTContext &Ctx,
  Preprocessor &PP,
  const CanonicalIncludes &CanonIncludes) override {
-// If this preamble uses a standard library we haven't seen yet, index it.
-if (FIndex)
-  if (auto Loc = Stdlib.add(*CI.getLangOpts(), PP.getHeaderSearchInfo()))
-indexStdlib(CI, std::move(*Loc));
-
 if (FIndex)
   FIndex->updatePreamble(Path, Version, Ctx, PP, CanonIncludes);
   }
 
-  void indexStdlib(const CompilerInvocation &CI, StdLibLocation Loc) {
-auto Task = [this, LO(*CI.getLangOpts()), Loc(std::move(Loc)),
- CI(std::make_unique(CI))]() mutable {
-  IndexFileIn IF;
-  IF.Symbols = indexStandardLibrary(std::move(CI), Loc, TFS);
-  if (Stdlib.isBest(LO))
-FIndex->updatePreamble(std::move(IF));
-};
-if (Tasks)
-  // This doesn't have a semaphore to enforce -j, but it's rare.
-  Tasks->runAsync("IndexStdlib", std::move(Task));
-else
-  Task();
-  }
-
   void onMainAST(PathRef Path, ParsedAST &AST, PublishFn Publish) override {
 if (FIndex)
   FIndex->updateMain(Path, AST);
@@ -127,9 +103,6 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
 private:
   FileIndex *FIndex;
   ClangdServer::Callbacks *ServerCallbacks;
-  const ThreadsafeFS &TFS;
-  StdLibSet Stdlib;
-  AsyncTaskRunner *Tasks;
 };
 
 class DraftStoreFS : public ThreadsafeFS {
@@ -181,15 +154,12 @@ ClangdServer::ClangdServer(const 
GlobalCompilationDatabase &CDB,
   Transient(Opts.ImplicitCancellation ? TUScheduler::InvalidateOnUpdate
   : TUScheduler::NoInvalidation),
   DirtyFS(std::make_unique(TFS, DraftMgr)) {
-  if (Opts.AsyncThreadsCount != 0)
-IndexTasks.emplace();
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
   // parsed file and rebuild the file index synchronously each time an AST
   // is parsed.
-  WorkScheduler.

[PATCH] D125788: [flang][driver] Rename `flang-new` as `flang`

2022-05-17 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

Sounds good to me. https://reviews.llvm.org/D125796 for the bot side, let me 
know if/when the first half of the change goes in.

I'll leave it to others to approve the change overall. I do think being able to 
do `./bin/flang` and get the right flang will save a lot of confusion but I'm 
not a user of either of them myself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125788

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


[PATCH] D125789: FIX the assembly format of the x86 backend to make both clang and gcc happy

2022-05-17 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

I think another way is to report the issue to GCC. From the perspective of the 
user, GCC should support both `{%k1} {z}` and `{%k1}{z}`. Then we don't need 
the clange on LLVM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125789

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


[PATCH] D125789: FIX the assembly format of the x86 backend to make both clang and gcc happy

2022-05-17 Thread Changwei Zou via Phabricator via cfe-commits
sheisc abandoned this revision.
sheisc added a comment.

In D125789#3519361 , @pengfei wrote:

> I guess a lot of lines of tests need to update
>
>   $ grep -rn " {z}" llvm/test/CodeGen/X86/ | wc -l
>   7797

Thanks.
Yes. It seems to be a big revision, caused by only one white space :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125789

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


[PATCH] D121733: Clean pathnames in FileManager.

2022-05-17 Thread Paul Pluzhnikov via Phabricator via cfe-commits
ppluzhnikov added inline comments.



Comment at: clang-tools-extra/clangd/index/CanonicalIncludes.cpp:546
+  {"include/wordexp.h", ""},
+  {"include/x86intrin.h", ""},
+  {"include/xlocale.h", ""},

ilya-biryukov wrote:
> ppluzhnikov wrote:
> > ilya-biryukov wrote:
> > > Why do we change the order of elements here?
> > > Please revert, this increases the diff and is not relevant to the actual 
> > > change.
> > Note that the elements are inserted into a map
> > (after commit b3a991df3cd6a; used to be a vector before).
> > 
> > Also note that there are duplicates, e.g.
> > 
> > {"bits/typesizes.h", ""},
> > {"bits/typesizes.h", ""},
> > 
> > which can't work as intended / is already broken.
> > 
> > Sorting helps to find these duplicates.
> > 
> This refactoring makes sense, but please split this into a separate change.
https://reviews.llvm.org/D125742


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121733

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


[PATCH] D125789: FIX the assembly format of the x86 backend to make both clang and gcc happy

2022-05-17 Thread Changwei Zou via Phabricator via cfe-commits
sheisc added a comment.

In D125789#3519411 , @pengfei wrote:

> I think another way is to report the issue to GCC. From the perspective of 
> the user, GCC should support both `{%k1} {z}` and `{%k1}{z}`. Then we don't 
> need the clange on LLVM.

Yes. It is a good idea. 
However, it appears that there is no such white space in the instructions as 
described in Intel's manuals.
So I don't know which one should be the correct format.
Anyway, not a big issue.
I found this problem when using the fuzzer (i.e. AFL) to build Firefox.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125789

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


[PATCH] D125728: [WebAssembly] Update supported features in -mcpu=generic

2022-05-17 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

Based on the discussion we had, I think this makes sense. It's a bit 
repetitive, but could you please add a test to clang/test/Driver that checks 
the list of enabled features for generic (and for completeness, probably 
bleeding-edge as well). Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125728

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


[PATCH] D125728: [WebAssembly] Update supported features in -mcpu=generic

2022-05-17 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

Oh, and per recent updates 
 to the LLVM 
Developer policy I think it would be worth updating the Clang ReleaseNotes.rst 
to mention this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125728

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


[PATCH] D125789: FIX the assembly format of the x86 backend to make both clang and gcc happy

2022-05-17 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D125789#3519433 , @sheisc wrote:

> In D125789#3519411 , @pengfei wrote:
>
>> I think another way is to report the issue to GCC. From the perspective of 
>> the user, GCC should support both `{%k1} {z}` and `{%k1}{z}`. Then we don't 
>> need the clange on LLVM.
>
> Yes. It is a good idea. 
> However, it appears that there is no such white space in the instructions as 
> described in Intel's manuals.
> So I don't know which one should be the correct format.
> Anyway, not a big issue.
> I found this problem when using the fuzzer (i.e. AFL) to build Firefox.

Yeah. This is an interesting question. I didn't notice the difference between 
LLVM and GCC. I think either way changing here or GCC is OK :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125789

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


[PATCH] D125789: FIX the assembly format of the x86 backend to make both clang and gcc happy

2022-05-17 Thread Changwei Zou via Phabricator via cfe-commits
sheisc added a comment.

In D125789#3519493 , @pengfei wrote:

> In D125789#3519433 , @sheisc wrote:
>
>> In D125789#3519411 , @pengfei 
>> wrote:
>>
>>> I think another way is to report the issue to GCC. From the perspective of 
>>> the user, GCC should support both `{%k1} {z}` and `{%k1}{z}`. Then we don't 
>>> need the clange on LLVM.
>>
>> Yes. It is a good idea. 
>> However, it appears that there is no such white space in the instructions as 
>> described in Intel's manuals.
>> So I don't know which one should be the correct format.
>> Anyway, not a big issue.
>> I found this problem when using the fuzzer (i.e. AFL) to build Firefox.
>
> Yeah. This is an interesting question. I didn't notice the difference between 
> LLVM and GCC. I think either way changing here or GCC is OK :)

Hi Pengfei,

Thanks a lot.  The guys in the GCC community can make our life easier by 
supporting the white space.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125789

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


[PATCH] D125557: [APInt] Remove all uses of zextOrSelf, sextOrSelf and truncOrSelf

2022-05-17 Thread Philip Reames via Phabricator via cfe-commits
reames added a comment.

Coming into this late, but I'd have preferred to see this separated into at 
least two pieces.  One for each "non-obvious" adjustment, and one final one 
which just did the replace on the renaming sites.  This differs from feedback 
from other reviewers above, so don't feel bound by this in any way.  Just 
expressing the general preference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125557

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


[PATCH] D125789: FIX the assembly format of the x86 backend to make both clang and gcc happy

2022-05-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Is it gcc that needs a fix or binutils?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125789

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


  1   2   >