[PATCH] D97832: [X86] Refine "Support -march=alderlake"

2021-03-03 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 327691.
FreddyYe added a comment.

delete extra spaces. THX for review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97832

Files:
  clang/test/Preprocessor/predefined-arch-macros.c
  llvm/lib/Support/X86TargetParser.cpp
  llvm/lib/Target/X86/X86.td

Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -784,17 +784,6 @@
   list SPRFeatures =
 !listconcat(ICXFeatures, SPRAdditionalFeatures);
 
-  // Alderlake
-  list ADLAdditionalFeatures = [FeatureAVXVNNI,
-  FeatureCLDEMOTE,
-  FeatureHRESET,
-  FeaturePTWRITE,
-  FeatureSERIALIZE,
-  FeatureWAITPKG];
-  list ADLTuning = SKLTuning;
-  list ADLFeatures =
-!listconcat(SKLFeatures, ADLAdditionalFeatures);
-
   // Atom
   list AtomFeatures = [FeatureX87,
  FeatureCMPXCHG8B,
@@ -873,6 +862,31 @@
   list TRMFeatures =
 !listconcat(GLPFeatures, TRMAdditionalFeatures);
 
+  // Alderlake
+  list ADLAdditionalFeatures = [FeatureSERIALIZE,
+  FeaturePCONFIG,
+  FeatureSHSTK,
+  FeatureWIDEKL,
+  FeatureINVPCID,
+  FeatureADX,
+  FeatureFMA,
+  FeatureVAES,
+  FeatureVPCLMULQDQ,
+  FeatureF16C,
+  FeatureBMI,
+  FeatureBMI2,
+  FeatureLZCNT,
+  FeatureAVXVNNI,
+  FeaturePKU,
+  FeatureHRESET,
+  FeatureCLDEMOTE,
+  FeatureMOVDIRI,
+  FeatureMOVDIR64B,
+  FeatureWAITPKG];
+  list ADLTuning = SKLTuning;
+  list ADLFeatures =
+!listconcat(TRMFeatures, ADLAdditionalFeatures);
+
   // Knights Landing
   list KNLFeatures = [FeatureX87,
 FeatureCMPXCHG8B,
Index: llvm/lib/Support/X86TargetParser.cpp
===
--- llvm/lib/Support/X86TargetParser.cpp
+++ llvm/lib/Support/X86TargetParser.cpp
@@ -205,9 +205,6 @@
 FeatureENQCMD | FeatureMOVDIR64B | FeatureMOVDIRI | FeaturePTWRITE |
 FeatureSERIALIZE | FeatureSHSTK | FeatureTSXLDTRK | FeatureUINTR |
 FeatureWAITPKG | FeatureAVXVNNI;
-constexpr FeatureBitset FeaturesAlderlake =
-FeaturesSkylakeClient | FeatureCLDEMOTE | FeatureHRESET | FeaturePTWRITE |
-FeatureSERIALIZE | FeatureWAITPKG | FeatureAVXVNNI;
 
 // Intel Atom processors.
 // Bonnell has feature parity with Core2 and adds MOVBE.
@@ -223,6 +220,12 @@
 FeaturesGoldmont | FeaturePTWRITE | FeatureRDPID | FeatureSGX;
 constexpr FeatureBitset FeaturesTremont =
 FeaturesGoldmontPlus | FeatureCLWB | FeatureGFNI;
+constexpr FeatureBitset FeaturesAlderlake =
+FeaturesTremont | FeatureADX | FeatureBMI | FeatureBMI2 | FeatureF16C |
+FeatureFMA | FeatureINVPCID | FeatureLZCNT | FeaturePCONFIG | FeaturePKU |
+FeatureSERIALIZE | FeatureSHSTK | FeatureVAES | FeatureVPCLMULQDQ |
+FeatureCLDEMOTE | FeatureMOVDIR64B | FeatureMOVDIRI | FeatureWAITPKG |
+FeatureAVXVNNI | FeatureHRESET | FeatureWIDEKL;
 
 // Geode Processor.
 constexpr FeatureBitset FeaturesGeode =
Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -1791,32 +1791,53 @@
 // CHECK_ADL_M32: #define __BMI__ 1
 // CHECK_ADL_M32: #define __CLDEMOTE__ 1
 // CHECK_ADL_M32: #define __CLFLUSHOPT__ 1
+// CHECK_ADL_M32: #define __CLWB__ 1
 // CHECK_ADL_M32: #define __F16C__ 1
 // CHECK_ADL_M32: #define __FMA__ 1
+// CHECK_ADL_M32: #define __FSGSBASE__ 1
+// CHECK_ADL_M32: #define __FXSR__ 1
+// CHECK_ADL_M32: #define __GFNI__ 1
 // CHECK_ADL_M32: #define __HRESET__ 1
 // CHECK_ADL_M32: #define __INVPCID__ 1
+// CHECK_ADL_M32: #define __KL__ 1
 // CHECK_ADL_M32: #define __LZCNT__ 1
 // CHECK_ADL

[PATCH] D97832: [X86] Refine "Support -march=alderlake"

2021-03-03 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe marked an inline comment as done.
FreddyYe added a comment.

THX for review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97832

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


[PATCH] D97606: [Clang interpreter] Avoid storing pointers at unaligned locations

2021-03-03 Thread Nandor Licker via Phabricator via cfe-commits
nand added a comment.

The patches implementing more features/control flow constructs have not yet 
been committed, so if the pre-existing test passes, the functionality should be 
fine. Adjustments can be made later on when those patches are rebased.




Comment at: clang/lib/AST/Interp/Program.h:51
+  /// Returns the value of a marshalled native pointer.
+  const void *getNativePointer(unsigned Idx);
+

This works for now, but in the future we might want to have a unique integer - 
pointer mapping for all types that need to be stored in the bytecode.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97606

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


[PATCH] D96976: [analyzer] Fix reinterpret_cast handling for pointer-to-member

2021-03-03 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added inline comments.



Comment at: clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp:52-62
+void testMultiple() {
+  int F::*f = &F::field;
+  int A::*a = reinterpret_cast(f);
+  int C::*c = reinterpret_cast(f);
+  A aobj;
+  C cobj;
+  aobj.*a = 13;

steakhal wrote:
> RedDocMD wrote:
> > steakhal wrote:
> > > RedDocMD wrote:
> > > > steakhal wrote:
> > > > > Wait a minute. It's not how it works.
> > > > > How I imagine member pointers, they are just offsets.
> > > > > `&F::field` is notionally equivalent with `offsetof(F, field)`. That 
> > > > > being said, You can not apply this member pointer to any object 
> > > > > besides `F`.
> > > > > Imagine if the classes of the inheritance tree would have other 
> > > > > fields as well.
> > > > > Then the `offsetof(T, field)` would be different for `F`, and `C`.
> > > > > 
> > > > > This example demonstrates that both of these member pointer 
> > > > > dereferences are UB.
> > > > > https://godbolt.org/z/15sMEP
> > > > > It returns different values depending on the optimization level, 
> > > > > which is a clear sign of UB.
> > > > > BTW this issue is closely related to strict aliasing.
> > > > The member access on A is definitely UB, I guess I will do what I 
> > > > proposed in the `Some` case.
> > > > I don't think the other one is.  Consider the following:
> > > > ```
> > > > struct A {};
> > > > struct B : public A {};
> > > > struct C {
> > > >   int field;
> > > > };
> > > > struct D : public C {};
> > > > struct E : public B, public D {};
> > > > struct F : public E {};
> > > > 
> > > > int main() {
> > > >   int F::* ff = &F::field;
> > > >   int C::* cf1 = static_cast(ff);
> > > >   int C::* cf2 = reinterpret_cast(ff);
> > > >   C c;
> > > >   c.*cf1 = 10;
> > > >   c.*cf2 = 10;
> > > >   return 0;
> > > > }
> > > > ```
> > > > `cf1` and `cf2` are the same thing, except that they are declared 
> > > > differently (one via `static_cast`, other via `reinterpret_cast`). If 
> > > > we look at the AST (truncated to the first three lines of main):
> > > > ```
> > > > CompoundStmt 0x1a4fe18 
> > > > |-DeclStmt 0x1a4f3a8 
> > > > | `-VarDecl 0x1a21078  col:12 used ff 'int F::*' 
> > > > cinit
> > > > |   `-ImplicitCastExpr 0x1a4f378  'int F::*' 
> > > >  D -> C)>
> > > > | `-UnaryOperator 0x1a4f360  'int C::*' prefix 
> > > > '&' cannot overflow
> > > > |   `-DeclRefExpr 0x1a4f2f8  'int' lvalue Field 
> > > > 0x1a207d0 'field' 'int'
> > > > |-DeclStmt 0x1a4f560 
> > > > | `-VarDecl 0x1a4f428  col:12 used cf1 'int C::*' 
> > > > cinit
> > > > |   `-CXXStaticCastExpr 0x1a4f518  'int C::*' 
> > > > static_cast  D -> C)>
> > > > | `-ImplicitCastExpr 0x1a4f500  'int F::*' 
> > > >  part_of_explicit_cast
> > > > |   `-DeclRefExpr 0x1a4f498  'int F::*' lvalue Var 
> > > > 0x1a21078 'ff' 'int F::*'
> > > > |-DeclStmt 0x1a4f6e8 
> > > > | `-VarDecl 0x1a4f5c8  col:12 used cf2 'int C::*' 
> > > > cinit
> > > > |   `-CXXReinterpretCastExpr 0x1a4f6b8  'int C::*' 
> > > > reinterpret_cast 
> > > > | `-ImplicitCastExpr 0x1a4f6a0  'int F::*' 
> > > >  part_of_explicit_cast
> > > > |   `-DeclRefExpr 0x1a4f638  'int F::*' lvalue Var 
> > > > 0x1a21078 'ff' 'int F::*'
> > > > ```
> > > > Notice how the `static_cast` figures out the path to the correct 
> > > > subobject. This is how member-pointers are handled as far as I can tell.
> > > > Unfortunately, Stroustrup is surprisingly scant when it comes to this 
> > > > topic. I am trying to dig through the Standard.
> > > I tried to highlight that the classes could have non-static data members 
> > > which could cause your assumption about `cf1 == cf2` not to hold anymore. 
> > > See my previously attached godbolt link.
> > > 
> > > `static_cast(p)` makes sure that the //offset// that the member 
> > > pointer `p` represents is updated accordingly to match the //offset// of 
> > > the `field` member within the new type `T`. Usually, it involves some 
> > > addition/subtraction to accommodate this.
> > > While `static_cast(p)` does not update the value, just reinterprets it 
> > > in a different way - which usually results in an invalid pointer though 
> > > and a bunch of subtle rules kick in such as the type similarity, pointer 
> > > interchangeability, which in general known as //strict-aliasing//.
> > > While static_cast(p) does not update the value, just reinterprets it 
> > > in a different way - which usually results in an invalid pointer   though 
> > > and a bunch of subtle rules kick in such as the type similarity, pointer 
> > > interchangeability, which in general known as strict-aliasing.
> > Presumably you mean `reinterpret_cast`.
> > 
> > Ah, I see. This makes it glaringly obvious: [[ https://godbolt.org/z/f6vs77 
> > | Another Godbolt link ]]
> > So I guess handling `reinterpret_cast` for pointer-to-members pointless. I 
> > guess the idea will be to simply not analyze pointer-

[PATCH] D93377: [Clang] Add __ibm128 type to represent ppc_fp128

2021-03-03 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf updated this revision to Diff 327716.
qiucf marked 2 inline comments as done.
qiucf added a comment.

- Add helper method to count 'unordered' cases
- Add missing tests (in last update)
- Add test for openmp device-host case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93377

Files:
  clang/bindings/python/clang/cindex.py
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/BuiltinTypes.def
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/ibm128-cast.c
  clang/test/CodeGen/ibm128-unsupported.c
  clang/test/CodeGenCXX/ibm128-declarations.cpp
  clang/test/Sema/128bitfloat.cpp
  clang/tools/libclang/CXType.cpp

Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -60,6 +60,7 @@
 BTCASE(ULongAccum);
 BTCASE(Float16);
 BTCASE(Float128);
+BTCASE(Ibm128);
 BTCASE(NullPtr);
 BTCASE(Overload);
 BTCASE(Dependent);
@@ -577,6 +578,7 @@
 TKIND(ULongAccum);
 TKIND(Float16);
 TKIND(Float128);
+TKIND(Ibm128);
 TKIND(NullPtr);
 TKIND(Overload);
 TKIND(Dependent);
Index: clang/test/Sema/128bitfloat.cpp
===
--- clang/test/Sema/128bitfloat.cpp
+++ clang/test/Sema/128bitfloat.cpp
@@ -13,7 +13,7 @@
   return x + *y;
 }
 
-// expected-no-diagnostics
+// expected-no-error {{__float128 is not supported on this target}}
 #else
 #if !defined(__STRICT_ANSI__)
 __float128 f;  // expected-error {{__float128 is not supported on this target}}
@@ -37,3 +37,18 @@
 
 #endif
 #endif
+
+#ifdef __ppc__
+__ibm128 i;
+template<> struct __is_floating_point_helper<__ibm128> {};
+int w(int x, __ibm128 *y) {
+  return x + *y;
+}
+// expected-no-error {{__ibm128 is not supported on this target}}
+#else
+__ibm128 i; // expected-error {{__ibm128 is not supported on this target}}
+template<> struct __is_floating_point_helper<__ibm128> {}; // expected-error {{__ibm128 is not supported on this target}}
+int w(int x, __ibm128 *y) { // expected-error {{__ibm128 is not supported on this target}}
+  return x + *y;
+}
+#endif
Index: clang/test/CodeGenCXX/ibm128-declarations.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/ibm128-declarations.cpp
@@ -0,0 +1,168 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -emit-llvm -triple powerpc64-unknown-unknown \
+// RUN:   -std=c++20 %s -o - -debug-info-kind=limited | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple powerpc64le-unknown-unknown \
+// RUN:   -std=c++20 %s -o - -debug-info-kind=limited | FileCheck %s
+
+#include 
+
+static __ibm128 sgf;
+__ibm128 arrgf[10];
+__ibm128 func1(__ibm128 arg);
+
+class CTest {
+  __ibm128 pf;
+  static const __ibm128 scf;
+  volatile __ibm128 vf;
+public:
+  CTest(__ibm128 arg) : pf(arg), vf(arg) {}
+  __ibm128 func2(__ibm128 arg) {
+return pf + arg;
+  }
+  static __ibm128 func3(__ibm128 arg) {
+return arg * CTest::scf;
+  }
+};
+
+constexpr __ibm128 func_add(__ibm128 a, __ibm128 b) {
+  return a + b;
+}
+
+constinit const __ibm128 ci = func_add(1.0, 2.0);
+__ibm128 gf = ci;
+
+__ibm128 func_arith(__ibm128 a, __ibm128 b, __ibm128 c) {
+  __ibm128 v1 = a + b;
+  __ibm128 v2 = a - c;
+  __ibm128 v3 = v1 * c;
+  __ibm128 v4 = v2 / v3;
+  return v4;
+}
+
+__ibm128 func_vaarg(int n, ...) {
+  va_list ap;
+  va_start(ap, n);
+  __ibm128 r = va_arg(ap, __ibm128);
+  va_end(ap);
+  return r;
+}
+
+template  struct T1 {
+  T mem1;
+};
+templat

[PATCH] D97717: [SYCL] Rework the SYCL driver options

2021-03-03 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

@aaron.ballman, it looks like unittests should be updated as well. Please, take 
a look at failures in pre-merge checks.




Comment at: clang/include/clang/Basic/LangOptions.def:252
 LANGOPT(SYCLIsDevice  , 1, 0, "Generate code for SYCL device")
+LANGOPT(SYCLIsHost, 1, 0, "SYCL host compilation")
 ENUM_LANGOPT(SYCLVersion  , SYCLMajorVersion, 1, SYCL_None, "Version of the 
SYCL standard used")

I'm okay with that change, but IIRC, @ABataev suggested to have both -fsycl and 
-fsycl-is-device options to align with OpenMP mode (full discussion is here - 
https://reviews.llvm.org/D72857#inline-674377).


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

https://reviews.llvm.org/D97717

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


[PATCH] D97362: [clang][parser] Allow attributes in explicit template instantiations

2021-03-03 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 327718.
tbaeder added a comment.

Thanks for the suggestions, Aaron. The new version seems to work but I was not 
sure how to get the token at a source location. I could only find 
`Lexer::findNextToken()`.


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

https://reviews.llvm.org/D97362

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/Parser/cxx0x-attributes.cpp


Index: clang/test/Parser/cxx0x-attributes.cpp
===
--- clang/test/Parser/cxx0x-attributes.cpp
+++ clang/test/Parser/cxx0x-attributes.cpp
@@ -179,6 +179,7 @@
 struct [[]] Template t; // expected-error {{an attribute list cannot 
appear here}}
 struct [[]] ::template Template u; // expected-error {{an attribute list 
cannot appear here}}
 template struct [[]] Template; // expected-error {{an attribute list 
cannot appear here}}
+template struct __attribute__((pure)) Template; // We still allow 
GNU-style attributes here
 template <> struct [[]] Template;
 
 enum [[]] E1 {};
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1824,7 +1824,7 @@
 } else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation 
&&
 TUK == Sema::TUK_Declaration) {
   // This is an explicit instantiation of a class template.
-  ProhibitAttributes(attrs);
+  ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed, 
/*DiagnoseEmptyAttrs=*/true);
 
   TagOrTempResult = Actions.ActOnExplicitInstantiation(
   getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -1607,7 +1607,20 @@
 }
 
 void Parser::ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs,
- unsigned DiagID) {
+ unsigned DiagID, bool DiagnoseEmptyAttrs) 
{
+
+  if (DiagnoseEmptyAttrs && Attrs.empty() && Attrs.Range.isValid()) {
+// An attribute list has been parsed, but it was empty.
+// This is the case for [[]].
+auto &SM = PP.getSourceManager();
+auto Tok = Lexer::findNextToken(Attrs.Range.getBegin(), SM, getLangOpts());
+
+if (Tok && (*Tok).is(tok::l_square)) {
+  Diag(Attrs.Range.getBegin(), diag::err_attributes_not_allowed) << 
Attrs.Range;
+  return;
+}
+  }
+
   for (const ParsedAttr &AL : Attrs) {
 if (!AL.isCXX11Attribute() && !AL.isC2xAttribute())
   continue;
Index: clang/include/clang/Parse/Parser.h
===
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -2638,7 +2638,7 @@
   // which standard permits but we don't supported yet, for example, attributes
   // appertain to decl specifiers.
   void ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs,
-   unsigned DiagID);
+   unsigned DiagID, bool DiagnoseEmptyAttrs = 
false);
 
   /// Skip C++11 and C2x attributes and return the end location of the
   /// last one.


Index: clang/test/Parser/cxx0x-attributes.cpp
===
--- clang/test/Parser/cxx0x-attributes.cpp
+++ clang/test/Parser/cxx0x-attributes.cpp
@@ -179,6 +179,7 @@
 struct [[]] Template t; // expected-error {{an attribute list cannot appear here}}
 struct [[]] ::template Template u; // expected-error {{an attribute list cannot appear here}}
 template struct [[]] Template; // expected-error {{an attribute list cannot appear here}}
+template struct __attribute__((pure)) Template; // We still allow GNU-style attributes here
 template <> struct [[]] Template;
 
 enum [[]] E1 {};
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1824,7 +1824,7 @@
 } else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
 TUK == Sema::TUK_Declaration) {
   // This is an explicit instantiation of a class template.
-  ProhibitAttributes(attrs);
+  ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed, /*DiagnoseEmptyAttrs=*/true);
 
   TagOrTempResult = Actions.ActOnExplicitInstantiation(
   getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -1607,7 +1607,20 @@
 }
 
 void Parser::ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs,
-   

[PATCH] D96281: [clang-tidy] Add options to flag individual core increments and to ignore macros to readability-function-cognitive-complexity check.

2021-03-03 Thread Jens Massberg via Phabricator via cfe-commits
massberg updated this revision to Diff 327721.
massberg added a comment.

Remove IgnoreMacros option (to be added in a follow up patch) and sync to head.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96281

Files:
  clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
  clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
@@ -0,0 +1,42 @@
+// RUN: %check_clang_tidy %s readability-function-cognitive-complexity %t -- \
+// RUN:   -config='{CheckOptions: \
+// RUN: [{key: readability-function-cognitive-complexity.Threshold, \
+// RUN:   value: 0}, \
+// RUN:  {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
+// RUN:   value: "false"} ]}'
+// RUN: %check_clang_tidy -check-suffix=THRESHOLD5 %s readability-function-cognitive-complexity %t -- \
+// RUN:   -config='{CheckOptions: \
+// RUN: [{key: readability-function-cognitive-complexity.Threshold, \
+// RUN:   value: 5}, \
+// RUN:  {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
+// RUN:   value: "false"} ]}'
+
+void func_of_complexity_4() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_of_complexity_4' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+  if (1) {
+if (1) {
+}
+  }
+  if (1) {
+  }
+}
+
+#define MacroOfComplexity10 \
+  if (1) {  \
+if (1) {\
+  if (1) {  \
+if (1) {\
+}   \
+  } \
+}   \
+  }
+
+void function_with_macro() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-THRESHOLD5: :[[@LINE-2]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 5) [readability-function-cognitive-complexity]
+
+  MacroOfComplexity10;
+
+  if (1) {
+  }
+}
Index: clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
@@ -17,6 +17,13 @@
Flag functions with Cognitive Complexity exceeding this number.
The default is `25`.
 
+.. option:: DescribeBasicIncrements
+
+   If set to `true`, then for each function exceeding the complexity threshold
+   the check will issue additional diagnostics on every piece of code (loop,
+   `if` statement, etc.) which contributes to that complexity. See also the
+   examples below. Default is `true`.
+
 Building blocks
 ---
 
@@ -135,6 +142,11 @@
 return 0;
   }
 
+In the last example, the check will flag `function3` if the option Threshold is
+set to `2` or smaller. If the option DescribeBasicIncrements is set to `true`,
+it will additionally flag the two `if` statements with the amounts by which they
+increase to the complexity of the function and the current nesting level.
+
 Limitations
 ---
 
Index: clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h
===
--- clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h
+++ clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h
@@ -17,10 +17,15 @@
 
 /// Checks function Cognitive Complexity metric.
 ///
-/// There is only one configuration option:
+/// There are the following configuration option:
 ///
 ///   * `Threshold` - flag functions with Cognitive Complexity exceeding
 /// this number. The default is `25`.
+///   * `DescribeBasicIncrements`- if set to `true`, then for each function
+/// exceeding the complexity threshold the check will issue additional
+/// diagnostics on every piece of code (loop, `if` statement, etc.) which
+/// contributes to that complexity.
+//  Default is `true`
 ///
 /// For the user-facing documentation see:
 /// http://clang.llvm.org/extra/clang-tidy/checks/readability-function-cognitive-complexity.html
@@ -37,6 +42,7 @@
 
 private:
   const unsigned Threshold;
+  const bool DescribeBasicIncrem

[PATCH] D96281: [clang-tidy] Add options to describe individual core increments to readability-function-cognitive-complexity check.

2021-03-03 Thread Jens Massberg via Phabricator via cfe-commits
massberg added a comment.

In D96281#2596657 , @lebedev.ri wrote:

> Once again, can we please split this into two patches?
> I'm quite happy with the `DescribeBasicIncrements` stuff, that can be merged 
> right now.

I have removed the IgnoreMacros and will add it in an independent patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96281

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


[PATCH] D97775: [AArch64] Add missing intrinsics for vcls

2021-03-03 Thread JinGu Kang 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 rG394a4d04333e: [AArch64] Add missing intrinsics for vcls 
(authored by jaykang10).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97775

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/test/CodeGen/aarch64-neon-misc.c
  clang/test/CodeGen/arm_neon_intrinsics.c

Index: clang/test/CodeGen/arm_neon_intrinsics.c
===
--- clang/test/CodeGen/arm_neon_intrinsics.c
+++ clang/test/CodeGen/arm_neon_intrinsics.c
@@ -1776,6 +1776,31 @@
   return vcls_s32(a);
 }
 
+// CHECK-LABEL: @test_vcls_u8(
+// CHECK:   [[VCLS_V_I:%.*]] = call <8 x i8> @llvm.arm.neon.vcls.v8i8(<8 x i8> %a)
+// CHECK:   ret <8 x i8> [[VCLS_V_I]]
+int8x8_t test_vcls_u8(uint8x8_t a) {
+  return vcls_u8(a);
+}
+
+// CHECK-LABEL: @test_vcls_u16(
+// CHECK:   [[TMP0:%.*]] = bitcast <4 x i16> %a to <8 x i8>
+// CHECK:   [[VCLS_V1_I:%.*]] = call <4 x i16> @llvm.arm.neon.vcls.v4i16(<4 x i16> %a)
+// CHECK:   [[VCLS_V2_I:%.*]] = bitcast <4 x i16> [[VCLS_V1_I]] to <8 x i8>
+// CHECK:   ret <4 x i16> [[VCLS_V1_I]]
+int16x4_t test_vcls_u16(uint16x4_t a) {
+  return vcls_u16(a);
+}
+
+// CHECK-LABEL: @test_vcls_u32(
+// CHECK:   [[TMP0:%.*]] = bitcast <2 x i32> %a to <8 x i8>
+// CHECK:   [[VCLS_V1_I:%.*]] = call <2 x i32> @llvm.arm.neon.vcls.v2i32(<2 x i32> %a)
+// CHECK:   [[VCLS_V2_I:%.*]] = bitcast <2 x i32> [[VCLS_V1_I]] to <8 x i8>
+// CHECK:   ret <2 x i32> [[VCLS_V1_I]]
+int32x2_t test_vcls_u32(uint32x2_t a) {
+  return vcls_u32(a);
+}
+
 // CHECK-LABEL: @test_vclsq_s8(
 // CHECK:   [[VCLSQ_V_I:%.*]] = call <16 x i8> @llvm.arm.neon.vcls.v16i8(<16 x i8> %a)
 // CHECK:   ret <16 x i8> [[VCLSQ_V_I]]
@@ -1801,6 +1826,31 @@
   return vclsq_s32(a);
 }
 
+// CHECK-LABEL: @test_vclsq_u8(
+// CHECK:   [[VCLSQ_V_I:%.*]] = call <16 x i8> @llvm.arm.neon.vcls.v16i8(<16 x i8> %a)
+// CHECK:   ret <16 x i8> [[VCLSQ_V_I]]
+int8x16_t test_vclsq_u8(uint8x16_t a) {
+  return vclsq_u8(a);
+}
+
+// CHECK-LABEL: @test_vclsq_u16(
+// CHECK:   [[TMP0:%.*]] = bitcast <8 x i16> %a to <16 x i8>
+// CHECK:   [[VCLSQ_V1_I:%.*]] = call <8 x i16> @llvm.arm.neon.vcls.v8i16(<8 x i16> %a)
+// CHECK:   [[VCLSQ_V2_I:%.*]] = bitcast <8 x i16> [[VCLSQ_V1_I]] to <16 x i8>
+// CHECK:   ret <8 x i16> [[VCLSQ_V1_I]]
+int16x8_t test_vclsq_u16(uint16x8_t a) {
+  return vclsq_u16(a);
+}
+
+// CHECK-LABEL: @test_vclsq_u32(
+// CHECK:   [[TMP0:%.*]] = bitcast <4 x i32> %a to <16 x i8>
+// CHECK:   [[VCLSQ_V1_I:%.*]] = call <4 x i32> @llvm.arm.neon.vcls.v4i32(<4 x i32> %a)
+// CHECK:   [[VCLSQ_V2_I:%.*]] = bitcast <4 x i32> [[VCLSQ_V1_I]] to <16 x i8>
+// CHECK:   ret <4 x i32> [[VCLSQ_V1_I]]
+int32x4_t test_vclsq_u32(uint32x4_t a) {
+  return vclsq_u32(a);
+}
+
 // CHECK-LABEL: @test_vclt_s8(
 // CHECK:   [[CMP_I:%.*]] = icmp slt <8 x i8> %a, %b
 // CHECK:   [[SEXT_I:%.*]] = sext <8 x i1> [[CMP_I]] to <8 x i8>
Index: clang/test/CodeGen/aarch64-neon-misc.c
===
--- clang/test/CodeGen/aarch64-neon-misc.c
+++ clang/test/CodeGen/aarch64-neon-misc.c
@@ -1432,6 +1432,13 @@
   return vcls_s8(a);
 }
 
+// CHECK-LABEL: @test_vcls_u8(
+// CHECK:   [[VCLS_V_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.cls.v8i8(<8 x i8> %a)
+// CHECK:   ret <8 x i8> [[VCLS_V_I]]
+int8x8_t test_vcls_u8(uint8x8_t a) {
+  return vcls_u8(a);
+}
+
 // CHECK-LABEL: @test_vclsq_s8(
 // CHECK:   [[VCLSQ_V_I:%.*]] = call <16 x i8> @llvm.aarch64.neon.cls.v16i8(<16 x i8> %a)
 // CHECK:   ret <16 x i8> [[VCLSQ_V_I]]
@@ -1439,6 +1446,13 @@
   return vclsq_s8(a);
 }
 
+// CHECK-LABEL: @test_vclsq_u8(
+// CHECK:   [[VCLSQ_V_I:%.*]] = call <16 x i8> @llvm.aarch64.neon.cls.v16i8(<16 x i8> %a)
+// CHECK:   ret <16 x i8> [[VCLSQ_V_I]]
+int8x16_t test_vclsq_u8(uint8x16_t a) {
+  return vclsq_u8(a);
+}
+
 // CHECK-LABEL: @test_vcls_s16(
 // CHECK:   [[TMP0:%.*]] = bitcast <4 x i16> %a to <8 x i8>
 // CHECK:   [[VCLS_V1_I:%.*]] = call <4 x i16> @llvm.aarch64.neon.cls.v4i16(<4 x i16> %a)
@@ -1448,6 +1462,15 @@
   return vcls_s16(a);
 }
 
+// CHECK-LABEL: @test_vcls_u16(
+// CHECK:   [[TMP0:%.*]] = bitcast <4 x i16> %a to <8 x i8>
+// CHECK:   [[VCLS_V1_I:%.*]] = call <4 x i16> @llvm.aarch64.neon.cls.v4i16(<4 x i16> %a)
+// CHECK:   [[VCLS_V2_I:%.*]] = bitcast <4 x i16> [[VCLS_V1_I]] to <8 x i8>
+// CHECK:   ret <4 x i16> [[VCLS_V1_I]]
+int16x4_t test_vcls_u16(uint16x4_t a) {
+  return vcls_u16(a);
+}
+
 // CHECK-LABEL: @test_vclsq_s16(
 // CHECK:   [[TMP0:%.*]] = bitcast <8 x i16> %a to <16 x i8>
 // CHECK:   [[VCLSQ_V1_I:%.*]] = call <8 x i16> @llvm.aarch64.neon.cls.v8i16(<8 x i16> %a)
@@ -1457,6 +1480,15 @@
   return vclsq_s16(a);
 }
 
+// CHECK-LABEL: @test_vclsq_u16(
+// CHECK:   [[TMP0:%.*]] = bitcast <8 x i16> %a to <

[clang] 394a4d0 - [AArch64] Add missing intrinsics for vcls

2021-03-03 Thread Jingu Kang via cfe-commits

Author: JinGu Kang
Date: 2021-03-03T10:17:56Z
New Revision: 394a4d04333e8b26ff581eb1f6c56a6e50a157e4

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

LOG: [AArch64] Add missing intrinsics for vcls

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

Added: 


Modified: 
clang/include/clang/Basic/arm_neon.td
clang/test/CodeGen/aarch64-neon-misc.c
clang/test/CodeGen/arm_neon_intrinsics.c

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index 0b0105c665f5..5360729db307 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -646,7 +646,7 @@ def VABS: SInst<"vabs", "..", "csifQcQsQiQf">;
 def VQABS   : SInst<"vqabs", "..", "csiQcQsQi">;
 def VNEG: SOpInst<"vneg", "..", "csifQcQsQiQf", OP_NEG>;
 def VQNEG   : SInst<"vqneg", "..", "csiQcQsQi">;
-def VCLS: SInst<"vcls", "..", "csiQcQsQi">;
+def VCLS: SInst<"vcls", "S.", "csiUcUsUiQcQsQiQUcQUsQUi">;
 def VCLZ: IInst<"vclz", "..", "csiUcUsUiQcQsQiQUcQUsQUi">;
 def VCNT: WInst<"vcnt", "..", "UccPcQUcQcQPc">;
 def VRECPE  : SInst<"vrecpe", "..", "fUiQfQUi">;

diff  --git a/clang/test/CodeGen/aarch64-neon-misc.c 
b/clang/test/CodeGen/aarch64-neon-misc.c
index 5517fe3dc411..4f85f67cdaec 100644
--- a/clang/test/CodeGen/aarch64-neon-misc.c
+++ b/clang/test/CodeGen/aarch64-neon-misc.c
@@ -1432,6 +1432,13 @@ int8x8_t test_vcls_s8(int8x8_t a) {
   return vcls_s8(a);
 }
 
+// CHECK-LABEL: @test_vcls_u8(
+// CHECK:   [[VCLS_V_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.cls.v8i8(<8 x 
i8> %a)
+// CHECK:   ret <8 x i8> [[VCLS_V_I]]
+int8x8_t test_vcls_u8(uint8x8_t a) {
+  return vcls_u8(a);
+}
+
 // CHECK-LABEL: @test_vclsq_s8(
 // CHECK:   [[VCLSQ_V_I:%.*]] = call <16 x i8> 
@llvm.aarch64.neon.cls.v16i8(<16 x i8> %a)
 // CHECK:   ret <16 x i8> [[VCLSQ_V_I]]
@@ -1439,6 +1446,13 @@ int8x16_t test_vclsq_s8(int8x16_t a) {
   return vclsq_s8(a);
 }
 
+// CHECK-LABEL: @test_vclsq_u8(
+// CHECK:   [[VCLSQ_V_I:%.*]] = call <16 x i8> 
@llvm.aarch64.neon.cls.v16i8(<16 x i8> %a)
+// CHECK:   ret <16 x i8> [[VCLSQ_V_I]]
+int8x16_t test_vclsq_u8(uint8x16_t a) {
+  return vclsq_u8(a);
+}
+
 // CHECK-LABEL: @test_vcls_s16(
 // CHECK:   [[TMP0:%.*]] = bitcast <4 x i16> %a to <8 x i8>
 // CHECK:   [[VCLS_V1_I:%.*]] = call <4 x i16> @llvm.aarch64.neon.cls.v4i16(<4 
x i16> %a)
@@ -1448,6 +1462,15 @@ int16x4_t test_vcls_s16(int16x4_t a) {
   return vcls_s16(a);
 }
 
+// CHECK-LABEL: @test_vcls_u16(
+// CHECK:   [[TMP0:%.*]] = bitcast <4 x i16> %a to <8 x i8>
+// CHECK:   [[VCLS_V1_I:%.*]] = call <4 x i16> @llvm.aarch64.neon.cls.v4i16(<4 
x i16> %a)
+// CHECK:   [[VCLS_V2_I:%.*]] = bitcast <4 x i16> [[VCLS_V1_I]] to <8 x i8>
+// CHECK:   ret <4 x i16> [[VCLS_V1_I]]
+int16x4_t test_vcls_u16(uint16x4_t a) {
+  return vcls_u16(a);
+}
+
 // CHECK-LABEL: @test_vclsq_s16(
 // CHECK:   [[TMP0:%.*]] = bitcast <8 x i16> %a to <16 x i8>
 // CHECK:   [[VCLSQ_V1_I:%.*]] = call <8 x i16> 
@llvm.aarch64.neon.cls.v8i16(<8 x i16> %a)
@@ -1457,6 +1480,15 @@ int16x8_t test_vclsq_s16(int16x8_t a) {
   return vclsq_s16(a);
 }
 
+// CHECK-LABEL: @test_vclsq_u16(
+// CHECK:   [[TMP0:%.*]] = bitcast <8 x i16> %a to <16 x i8>
+// CHECK:   [[VCLSQ_V1_I:%.*]] = call <8 x i16> 
@llvm.aarch64.neon.cls.v8i16(<8 x i16> %a)
+// CHECK:   [[VCLSQ_V2_I:%.*]] = bitcast <8 x i16> [[VCLSQ_V1_I]] to <16 x i8>
+// CHECK:   ret <8 x i16> [[VCLSQ_V1_I]]
+int16x8_t test_vclsq_u16(uint16x8_t a) {
+  return vclsq_u16(a);
+}
+
 // CHECK-LABEL: @test_vcls_s32(
 // CHECK:   [[TMP0:%.*]] = bitcast <2 x i32> %a to <8 x i8>
 // CHECK:   [[VCLS_V1_I:%.*]] = call <2 x i32> @llvm.aarch64.neon.cls.v2i32(<2 
x i32> %a)
@@ -1466,6 +1498,15 @@ int32x2_t test_vcls_s32(int32x2_t a) {
   return vcls_s32(a);
 }
 
+// CHECK-LABEL: @test_vcls_u32(
+// CHECK:   [[TMP0:%.*]] = bitcast <2 x i32> %a to <8 x i8>
+// CHECK:   [[VCLS_V1_I:%.*]] = call <2 x i32> @llvm.aarch64.neon.cls.v2i32(<2 
x i32> %a)
+// CHECK:   [[VCLS_V2_I:%.*]] = bitcast <2 x i32> [[VCLS_V1_I]] to <8 x i8>
+// CHECK:   ret <2 x i32> [[VCLS_V1_I]]
+int32x2_t test_vcls_u32(uint32x2_t a) {
+  return vcls_u32(a);
+}
+
 // CHECK-LABEL: @test_vclsq_s32(
 // CHECK:   [[TMP0:%.*]] = bitcast <4 x i32> %a to <16 x i8>
 // CHECK:   [[VCLSQ_V1_I:%.*]] = call <4 x i32> 
@llvm.aarch64.neon.cls.v4i32(<4 x i32> %a)
@@ -1475,6 +1516,15 @@ int32x4_t test_vclsq_s32(int32x4_t a) {
   return vclsq_s32(a);
 }
 
+// CHECK-LABEL: @test_vclsq_u32(
+// CHECK:   [[TMP0:%.*]] = bitcast <4 x i32> %a to <16 x i8>
+// CHECK:   [[VCLSQ_V1_I:%.*]] = call <4 x i32> 
@llvm.aarch64.neon.cls.v4i32(<4 x i32> %a)
+// CHECK:   [[VCLSQ_V2_I:%.*]] = bitcast <4 x i32> [[VCLSQ_V1_I]] to <16 x i8>
+// CHECK:   ret <4 x i32> [[VCLSQ_V1_I]]
+int32x4_t test_vclsq_u32(uint32x4_

[PATCH] D96281: [clang-tidy] Add options to describe individual core increments to readability-function-cognitive-complexity check.

2021-03-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Does the test start to fail if you undo the .cpp change?
You may want to add some `  // CHECK-NOTES-NOT: warning`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96281

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


[clang-tools-extra] 1a4990a - [clangd] Fix uninit member

2021-03-03 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-03-03T11:45:16+01:00
New Revision: 1a4990a4f71adf1ea0b8f7e0ae2ddd8a85f9c393

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

LOG: [clangd] Fix uninit member

Added: 


Modified: 
clang-tools-extra/clangd/Protocol.h

Removed: 




diff  --git a/clang-tools-extra/clangd/Protocol.h 
b/clang-tools-extra/clangd/Protocol.h
index f918183716d2..71de24a763d5 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -981,7 +981,7 @@ struct DocumentSymbol {
   SymbolKind kind;
 
   /// Indicates if this symbol is deprecated.
-  bool deprecated;
+  bool deprecated = false;
 
   /// The range enclosing this symbol not including leading/trailing whitespace
   /// but everything else like comments. This information is typically used to



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


[PATCH] D97156: [ASTMatchers] Make Param functors variadic

2021-03-03 Thread Stephen Kelly 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 rG243cd0afadc7: [ASTMatchers] Make Param functors variadic 
(authored by stephenkelly).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97156

Files:
  clang/docs/tools/dump_ast_matchers.py
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/include/clang/ASTMatchers/ASTMatchersMacros.h

Index: clang/include/clang/ASTMatchers/ASTMatchersMacros.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersMacros.h
+++ clang/include/clang/ASTMatchers/ASTMatchersMacros.h
@@ -239,10 +239,10 @@
  *Builder) const override; \
   };   \
   }\
-  inline ::clang::ast_matchers::internal::PolymorphicMatcherWithParam0<\
+  inline ::clang::ast_matchers::internal::PolymorphicMatcher<  \
   internal::matcher_##DefineMatcher##Matcher, ReturnTypesF>\
   DefineMatcher() {\
-return ::clang::ast_matchers::internal::PolymorphicMatcherWithParam0<  \
+return ::clang::ast_matchers::internal::PolymorphicMatcher<\
 internal::matcher_##DefineMatcher##Matcher, ReturnTypesF>();   \
   }\
   template  \
@@ -284,18 +284,17 @@
 ParamType const Param; \
   };   \
   }\
-  inline ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1<\
-  internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType,   \
-  ReturnTypesF>\
+  inline ::clang::ast_matchers::internal::PolymorphicMatcher<  \
+  internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF,\
+  ParamType>   \
   DefineMatcher(ParamType const &Param) {  \
-return ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1<  \
-internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType, \
-ReturnTypesF>(Param);  \
+return ::clang::ast_matchers::internal::PolymorphicMatcher<\
+internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF,  \
+ParamType>(Param); \
   }\
-  typedef ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1<   \
-  internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType,   \
-  ReturnTypesF>(&DefineMatcher##_Type##OverloadId)(\
-  ParamType const &Param); \
+  typedef ::clang::ast_matchers::internal::PolymorphicMatcher< \
+  internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF,\
+  ParamType> (&DefineMatcher##_Type##OverloadId)(ParamType const &Param);  \
   template \
   bool internal::  \
   matcher_##DefineMatcher##OverloadId##Matcher::matches( \
@@ -338,17 +337,17 @@
 ParamType2 const Param2;   \
   };   \
   }\
-  inline ::clang::ast_matchers::internal::PolymorphicMatcherWithParam2<\
-  internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType1,  \
-  ParamType2, ReturnTypesF>\
+  inline ::clang::ast_matchers::internal::PolymorphicMatcher<  \
+  internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF,\
+  ParamType1, ParamType2>  \
   DefineMatcher(ParamType1 const &Param1, ParamType2 const &Param2) {  \
-return ::clang::ast_matchers::internal::PolymorphicMatcherWithParam2<  \
-internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType1,\
-

[clang] 243cd0a - [ASTMatchers] Make Param functors variadic

2021-03-03 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-03-03T11:41:20Z
New Revision: 243cd0afadc7b406ed6c314f7645b1d72748ddd1

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

LOG: [ASTMatchers] Make Param functors variadic

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

Added: 


Modified: 
clang/docs/tools/dump_ast_matchers.py
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/include/clang/ASTMatchers/ASTMatchersMacros.h

Removed: 




diff  --git a/clang/docs/tools/dump_ast_matchers.py 
b/clang/docs/tools/dump_ast_matchers.py
index 18afbdd36c6e..2a26d10f7a04 100755
--- a/clang/docs/tools/dump_ast_matchers.py
+++ b/clang/docs/tools/dump_ast_matchers.py
@@ -351,13 +351,17 @@ def act_on_decl(declaration, comment, allowed_types):
 
 m = re.match(
 r"""^.*internal::VariadicFunction\s*<\s*
-  internal::PolymorphicMatcherWithParam1<[\S\s]+
-  AST_POLYMORPHIC_SUPPORTED_TYPES\(([^)]*)\)>,\s*([^,]+),
-  \s*[^>]+>\s*([a-zA-Z]*);$""", 
+  internal::PolymorphicMatcher<[\S\s]+
+  AST_POLYMORPHIC_SUPPORTED_TYPES\(([^)]*)\),\s*(.*);$""",
 declaration, flags=re.X)
 
 if m:
-  results, arg, name = m.groups()[:3]
+  results, trailing = m.groups()
+  trailing, name = trailing.rsplit(">", 1)
+  name = name.strip()
+  trailing, _ = trailing.rsplit(",", 1)
+  _, arg = trailing.rsplit(",", 1)
+  arg = arg.strip()
 
   result_types = [r.strip() for r in results.split(',')]
   for result_type in result_types:

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index b82929019f6c..885bc74ad3ea 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -835,26 +835,16 @@ traverse(TraversalKind TK, const 
internal::ArgumentAdaptingMatcherFuncAdaptor<
ToTypes>>(TK, InnerMatcher);
 }
 
-template  class MatcherT, typename P1,
+template  class MatcherT, typename... P,
   typename ReturnTypesF>
 internal::TraversalWrapper<
-internal::PolymorphicMatcherWithParam1>
-traverse(TraversalKind TK, const internal::PolymorphicMatcherWithParam1<
-   MatcherT, P1, ReturnTypesF> &InnerMatcher) {
-  return internal::TraversalWrapper<
-  internal::PolymorphicMatcherWithParam1>(
-  TK, InnerMatcher);
-}
-
-template  class MatcherT,
-  typename P1, typename P2, typename ReturnTypesF>
-internal::TraversalWrapper<
-internal::PolymorphicMatcherWithParam2>
-traverse(TraversalKind TK, const internal::PolymorphicMatcherWithParam2<
-   MatcherT, P1, P2, ReturnTypesF> &InnerMatcher) {
+internal::PolymorphicMatcher>
+traverse(TraversalKind TK,
+ const internal::PolymorphicMatcher
+ &InnerMatcher) {
   return internal::TraversalWrapper<
-  internal::PolymorphicMatcherWithParam2>(
-  TK, InnerMatcher);
+  internal::PolymorphicMatcher>(TK,
+  
InnerMatcher);
 }
 
 template 
@@ -2996,14 +2986,15 @@ AST_MATCHER_REGEX(NamedDecl, matchesName, RegExp) {
 /// matches the declaration of \c A.
 ///
 /// Usable as: Matcher, Matcher
-inline internal::PolymorphicMatcherWithParam1<
-internal::HasOverloadedOperatorNameMatcher, std::vector,
-AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)>
+inline internal::PolymorphicMatcher<
+internal::HasOverloadedOperatorNameMatcher,
+AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl),
+std::vector>
 hasOverloadedOperatorName(StringRef Name) {
-  return internal::PolymorphicMatcherWithParam1<
-  internal::HasOverloadedOperatorNameMatcher, std::vector,
-  AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)>(
-  {std::string(Name)});
+  return internal::PolymorphicMatcher<
+  internal::HasOverloadedOperatorNameMatcher,
+  AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl),
+  std::vector>({std::string(Name)});
 }
 
 /// Matches overloaded operator names.
@@ -3015,9 +3006,10 @@ hasOverloadedOperatorName(StringRef Name) {
 /// Is equivalent to
 ///   anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
 extern const internal::VariadicFunction<
-internal::PolymorphicMatcherWithParam1<
-internal::HasOverloadedOperatorNameMatcher, std::vector,
-AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)>,
+internal::PolymorphicMatcher>,
 StringRef, internal::hasAnyOverloadedOperatorNameFunc>
 hasAnyOverloadedOperatorName;
 
@@ -3506,13 +3

[PATCH] D94554: [clangd] Add a Filesystem that overlays Dirty files.

2021-03-03 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.h:389
+
+  class DirtyFS : public ThreadsafeFS {
+  public:

Probably needs moving to its own place, but wasn't sure where best to put it.



Comment at: clang-tools-extra/clangd/DraftStore.cpp:287
+for (const auto &KV : DS.Drafts) {
+  // Query the base filesystem for file uniqueids.
+  auto BaseStatus = BaseView->status(KV.getKey());

sammccall wrote:
> njames93 wrote:
> > sammccall wrote:
> > > doing IO in view() doesn't seem obviously OK.
> > > 
> > > what's the practical consequence of the overlay's inodes not matching 
> > > that of the underlying FS? (It seems reasonable to say that the files 
> > > always have different identity, and may/may not have the same content)
> > It's probably not necessary, but I know preambles use the UniqueID. It may 
> > just be safer to create a uniqueID for each item in the DraftStore and 
> > leave it at that.
> The biggest risks I can see with this approach:
>  - in build-preamble-from-dirty-FS mode, would opening a draft cause the 
> preamble to be considered invalid and needing rebuilding? My read of 
> PrecompiledPreamble::CanReuse is no (UniqueIDs are not stored)
>  - when parsing, if the file can be read through the overlay *and* underlying 
> via different paths (e.g. hardlinks), these won't be deduplicated. However 
> giving them the same inode only changes the nature of the bug: the file would 
> get whichever content was read first.
> 
> So I think it's as good as we can expect.
Unfortunately in the current implementation, opening a draft will invalidate 
and preambles that use the underlying file. 
This is due to the last modification times not matching. 
This could be addressed by querying the TFS on the textDocument/didOpen request 
to get the actual last modification time, but we shouldn't really be doing any 
kind of IO on that thread.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94554

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


[PATCH] D96281: [clang-tidy] Add options to describe individual core increments to readability-function-cognitive-complexity check.

2021-03-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

In D96281#2599812 , @lebedev.ri wrote:

> Does the test start to fail if you undo the .cpp change?
> You may want to add some `  // CHECK-NOTES-NOT: warning`

Actually, i guess it should fail then, lgtm.
If you need help committing this, please specify `name ` to be used 
for git commit author field.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96281

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


[PATCH] D97849: [AST][PCH][ASTImporter] Fix UB caused by uninited SwitchStmt member

2021-03-03 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: riccibruno, aaron.ballman, shafik, teemperor, rsmith.
Herald added subscribers: gamesh411, Szelethus, dkrupp, rnkovacs.
Herald added a reviewer: a.sidorin.
martong requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The SwitchStmt::FirstCase member is not initialized when the AST is
built by the ASTStmtReader. See the below code of
ASTStmtReader::VisitSwitchStmt in the case where the for loop does not
have any iterations:

// ... more code ...
SwitchCase *PrevSC = nullptr;
for (auto E = Record.size(); Record.getIdx() != E; ) {
  SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
  if (PrevSC)
PrevSC->setNextSwitchCase(SC);
  else
S->setSwitchCaseList(SC); // Sets FirstCase !!!
  
  PrevSC = SC;
}
  } // return

Later, in ASTNodeImporter::VisitSwitchStmt,
we have a condition that depends on this uninited value:

  for (SwitchCase *SC = S->getSwitchCaseList(); SC != nullptr;
   SC = SC->getNextSwitchCase()) {
   // ... more code ...
  }

This is clearly an UB. This causes non-deterministic crashes when
ClangSA analyzes some code with CTU. See the below report by valgrind
(the whole valgrind output is attached):

  ==31019== Conditional jump or move depends on uninitialised value(s)
  ==31019==at 0x12ED1983: 
clang::ASTNodeImporter::VisitSwitchStmt(clang::SwitchStmt*) 
(ASTImporter.cpp:6195)
  ==31019==by 0x12F1D509: clang::StmtVisitorBase>::Visit(clang::Stmt*) 
(StmtNodes.inc:591)
  ==31019==by 0x12EE4FDF: clang::ASTImporter::Import(clang::Stmt*) 
(ASTImporter.cpp:8484)
  ==31019==by 0x12F09498: llvm::Expected 
clang::ASTNodeImporter::import(clang::Stmt*) (ASTImporter.cpp:164)
  ==31019==by 0x12F3A1F5: llvm::Error 
clang::ASTNodeImporter::ImportArrayChecked(clang::Stmt**, clang::Stmt**, clang::Stmt**) 
(ASTImporter.cpp:653)
  ==31019==by 0x12F13152: llvm::Error 
clang::ASTNodeImporter::ImportContainerChecked,
 llvm::SmallVector >(llvm::iterator_range 
const&, llvm::SmallVector&) (ASTImporter.cpp:669)
  ==31019==by 0x12ED099F: 
clang::ASTNodeImporter::VisitCompoundStmt(clang::CompoundStmt*) 
(ASTImporter.cpp:6077)
  ==31019==by 0x12F1CC2D: clang::StmtVisitorBase>::Visit(clang::Stmt*) 
(StmtNodes.inc:73)
  ==31019==by 0x12EE4FDF: clang::ASTImporter::Import(clang::Stmt*) 
(ASTImporter.cpp:8484)
  ==31019==by 0x12F09498: llvm::Expected 
clang::ASTNodeImporter::import(clang::Stmt*) (ASTImporter.cpp:164)
  ==31019==by 0x12F13275: clang::Stmt* 
clang::ASTNodeImporter::importChecked(llvm::Error&, clang::Stmt* 
const&) (ASTImporter.cpp:197)
  ==31019==by 0x12ED0CE6: 
clang::ASTNodeImporter::VisitCaseStmt(clang::CaseStmt*) (ASTImporter.cpp:6098)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97849

Files:
  clang/include/clang/AST/Stmt.h


Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -2119,7 +2119,7 @@
   friend TrailingObjects;
 
   /// Points to a linked list of case and default statements.
-  SwitchCase *FirstCase;
+  SwitchCase *FirstCase = nullptr;
 
   // SwitchStmt is followed by several trailing objects,
   // some of which optional. Note that it would be more convenient to


Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -2119,7 +2119,7 @@
   friend TrailingObjects;
 
   /// Points to a linked list of case and default statements.
-  SwitchCase *FirstCase;
+  SwitchCase *FirstCase = nullptr;
 
   // SwitchStmt is followed by several trailing objects,
   // some of which optional. Note that it would be more convenient to
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97849: [AST][PCH][ASTImporter] Fix UB caused by uninited SwitchStmt member

2021-03-03 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

F15719554: valgrind-output.txt 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97849

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


[PATCH] D96281: [clang-tidy] Add options to describe individual core increments to readability-function-cognitive-complexity check.

2021-03-03 Thread Jens Massberg via Phabricator via cfe-commits
massberg updated this revision to Diff 327746.
massberg added a comment.

Add checks to ensure that notes aren't added for specific options.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96281

Files:
  clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
  clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
@@ -0,0 +1,49 @@
+// RUN: %check_clang_tidy %s readability-function-cognitive-complexity %t -- \
+// RUN:   -config='{CheckOptions: \
+// RUN: [{key: readability-function-cognitive-complexity.Threshold, \
+// RUN:   value: 0}, \
+// RUN:  {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
+// RUN:   value: "false"} ]}'
+// RUN: %check_clang_tidy -check-suffix=THRESHOLD5 %s readability-function-cognitive-complexity %t -- \
+// RUN:   -config='{CheckOptions: \
+// RUN: [{key: readability-function-cognitive-complexity.Threshold, \
+// RUN:   value: 5}, \
+// RUN:  {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
+// RUN:   value: "false"} ]}'
+
+void func_of_complexity_4() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_of_complexity_4' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-THRESHOLD5-NOT: :[[@LINE-2]]:6: warning:
+  if (1) {
+// CHECK-NOTES-NOT: :[[@LINE-1]]:3: note:
+if (1) {
+  // CHECK-NOTES-NOT: :[[@LINE-1]]:5: note:
+}
+  }
+  if (1) {
+// CHECK-NOTES-NOT: :[[@LINE-1]]:3: note:
+  }
+}
+
+#define MacroOfComplexity10 \
+  if (1) {  \
+if (1) {\
+  if (1) {  \
+if (1) {\
+}   \
+  } \
+}   \
+  }
+
+void function_with_macro() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-THRESHOLD5: :[[@LINE-2]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 5) [readability-function-cognitive-complexity]
+
+  MacroOfComplexity10;
+  // CHECK-NOTES-NOT: :[[@LINE-1]]:3: note:
+  // CHECK-NOTES-NOT: :[[@LINE-15]]:3: note: expanded from macro 'MacroOfComplexity10'
+
+  if (1) {
+// CHECK-NOTES-NOT: :[[@LINE-1]]:3: note:
+  }
+}
Index: clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
@@ -17,6 +17,13 @@
Flag functions with Cognitive Complexity exceeding this number.
The default is `25`.
 
+.. option:: DescribeBasicIncrements
+
+   If set to `true`, then for each function exceeding the complexity threshold
+   the check will issue additional diagnostics on every piece of code (loop,
+   `if` statement, etc.) which contributes to that complexity. See also the
+   examples below. Default is `true`.
+
 Building blocks
 ---
 
@@ -135,6 +142,11 @@
 return 0;
   }
 
+In the last example, the check will flag `function3` if the option Threshold is
+set to `2` or smaller. If the option DescribeBasicIncrements is set to `true`,
+it will additionally flag the two `if` statements with the amounts by which they
+increase to the complexity of the function and the current nesting level.
+
 Limitations
 ---
 
Index: clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h
===
--- clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h
+++ clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h
@@ -17,10 +17,15 @@
 
 /// Checks function Cognitive Complexity metric.
 ///
-/// There is only one configuration option:
+/// There are the following configuration option:
 ///
 ///   * `Threshold` - flag functions with Cognitive Complexity exceeding
 /// this number. The default is `25`.
+///   * `DescribeBasicIncrements`- if set to `true`, then for each function
+/// exceeding the complexity threshold the check will issue additional
+/// diagnost

[PATCH] D96281: [clang-tidy] Add options to describe individual core increments to readability-function-cognitive-complexity check.

2021-03-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp:16
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_of_complexity_4' has 
cognitive complexity of 4 (threshold 0) 
[readability-function-cognitive-complexity]
+  // CHECK-NOTES-THRESHOLD5-NOT: :[[@LINE-2]]:6: warning:
+  if (1) {

Note that i'm not sure if we need negative checklines, but if we do, only 
checking for `warning:`
(without `@LINE` stuff) should be best.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96281

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


[PATCH] D97717: [SYCL] Rework the SYCL driver options

2021-03-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D97717#2599728 , @bader wrote:

> @aaron.ballman, it looks like unittests should be updated as well. Please, 
> take a look at failures in pre-merge checks.

Thanks, I'll correct those!




Comment at: clang/include/clang/Basic/LangOptions.def:252
 LANGOPT(SYCLIsDevice  , 1, 0, "Generate code for SYCL device")
+LANGOPT(SYCLIsHost, 1, 0, "SYCL host compilation")
 ENUM_LANGOPT(SYCLVersion  , SYCLMajorVersion, 1, SYCL_None, "Version of the 
SYCL standard used")

bader wrote:
> I'm okay with that change, but IIRC, @ABataev suggested to have both -fsycl 
> and -fsycl-is-device options to align with OpenMP mode (full discussion is 
> here - https://reviews.llvm.org/D72857#inline-674377).
Thanks for pointing this out!

As far as the frontend is concerned, being in "SCYL" mode is not a useful 
construct because you don't know *which* SYCL mode you're in (host or device). 
Downstream, we're finding that having `SYCL`, `SYCLIsDevice`, and `SYCLIsHost` 
introduces bugs because developers may check `SYCL` when they mean 
`SYCLIsDevice` or they do things like check `SYCL && SYCLIsDevice` which is 
redundant.


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

https://reviews.llvm.org/D97717

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


[PATCH] D97806: [clang-query] Fix help text after D91918

2021-03-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97806

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


[PATCH] D75041: [clang-tidy] Extend 'bugprone-easily-swappable-parameters' with mixability because of implicit conversions

2021-03-03 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 327743.
whisperity retitled this revision from "[clang-tidy] Approximate implicit 
conversion issues in 
'experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type'" to 
"[clang-tidy] Extend 'bugprone-easily-swappable-parameters' with mixability 
because of implicit conversions".
whisperity edited the summary of this revision.
whisperity added reviewers: hokein, alexfh, njames93.
whisperity set the repository for this revision to rG LLVM Github Monorepo.
whisperity added a comment.

- Rebased over updated, rewritten, newer base patch version, vastly increased 
the quality of the code.
- Tidied the tests and made them more self-explanatory.
- Implemented handling //function pointer conversion// (implicit losing of 
`noexcept`). This was missing from the previous uploaded patch.
- Ensured that implicit conversion sequences are diagnosed properly, even when 
typedefs are involved. This means that if the conversion takes 4-5-6 logical 
steps (e.g. instead of //`SomeFancyIntTypedef` -> `DoubleBoxingType`//, emit 
//`SomeFancyIntTypedef` -> `int` -> `double` -> `const double` -> 
`DoubleBoxingType` (user defined ctor)//) it's all explained properly.
- Respect the user's decision about the mixability of `T` and `const T` (the 
previous patch D96355 ) even in the context of 
implicit conversions (i.e. if the user did not allow that, do not consider a 
user-defined type which constructor takes a const mixable with a non-const 
other parameter).
- Put a diagnostic note to the location of the `FuntionDecl` of the conversion 
method involved in the mixability.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75041

Files:
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicit-qualifiers.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
@@ -3,7 +3,8 @@
 // RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: "bool;MyBool;struct U;MAKE_LOGICAL_TYPE(int)"}, \
-// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 0} \
+// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 0}, \
+// RUN: {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0} \
 // RUN:  ]}' -- -x c
 
 #define bool _Bool
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
@@ -3,7 +3,8 @@
 // RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""}, \
-// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 1} \
+// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 1}, \
+// RUN: {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0} \
 // RUN:  ]}' --
 
 typedef int MyInt1;
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-para

[PATCH] D97850: Fix PCM read from ModuleCache for ext4 filesystem

2021-03-03 Thread Ilya Kuteev via Phabricator via cfe-commits
ilyakuteev created this revision.
ilyakuteev requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97850

Files:
  clang/lib/Serialization/ModuleManager.cpp


Index: clang/lib/Serialization/ModuleManager.cpp
===
--- clang/lib/Serialization/ModuleManager.cpp
+++ clang/lib/Serialization/ModuleManager.cpp
@@ -470,6 +470,12 @@
   Optional FileOrErr =
   expectedToOptional(FileMgr.getFileRef(FileName, /*OpenFile=*/true,
 /*CacheFailure=*/false));
+  if (FileOrErr) {
+// On Linux ext4 FileManager's inode caching system does not
+// provide us correct behaviour for ModuleCache directories.
+// inode can be reused after PCM delete resulting in cache misleading.
+FileOrErr = FileMgr.getBypassFile(*FileOrErr);
+  }
   if (!FileOrErr)
 return false;
 


Index: clang/lib/Serialization/ModuleManager.cpp
===
--- clang/lib/Serialization/ModuleManager.cpp
+++ clang/lib/Serialization/ModuleManager.cpp
@@ -470,6 +470,12 @@
   Optional FileOrErr =
   expectedToOptional(FileMgr.getFileRef(FileName, /*OpenFile=*/true,
 /*CacheFailure=*/false));
+  if (FileOrErr) {
+// On Linux ext4 FileManager's inode caching system does not
+// provide us correct behaviour for ModuleCache directories.
+// inode can be reused after PCM delete resulting in cache misleading.
+FileOrErr = FileMgr.getBypassFile(*FileOrErr);
+  }
   if (!FileOrErr)
 return false;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92808: [ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of explicitly emitting retainRV or claimRV calls in the IR

2021-03-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

> Thank you. Let me know when you have more information.

Repro is moving along. 
https://bugs.chromium.org/p/chromium/issues/detail?id=1182642#c26 and onward 
are getting pretty close.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[clang] 8da0903 - Improve static_assert/_Static_assert diagnostics

2021-03-03 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-03-03T08:48:27-05:00
New Revision: 8da090381d567d0ec555840f6b2a651d2997e4b3

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

LOG: Improve static_assert/_Static_assert diagnostics

Our diagnostics relating to static assertions were a bit confused. For
instance, when in MS compatibility mode in C (where we accept
static_assert even without including ), we would fail
to warn the user that they were using the wrong spelling (even in
pedantic mode), we were missing a compatibility warning about using
_Static_assert in earlier standards modes, diagnostics for the optional
message were not reflected in C as they were in C++, etc.

Added: 
clang/test/Parser/static_assert.c
clang/test/Preprocessor/static_assert-already-defined.c
clang/test/Preprocessor/static_assert.c

Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/lib/Lex/PPDirectives.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/test/Sema/static-assert.c
clang/test/SemaCXX/static-assert.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 81d78c69cc44..14632210c818 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -253,6 +253,11 @@ def : DiagGroup<"c++1z-compat-mangling", 
[CXX17CompatMangling]>;
 // Name of this warning in GCC.
 def NoexceptType : DiagGroup<"noexcept-type", [CXX17CompatMangling]>;
 
+// Warnings for C2x code which is not compatible with prior C standards.
+def CPre2xCompat : DiagGroup<"pre-c2x-compat">;
+def CPre2xCompatPedantic : DiagGroup<"pre-c2x-compat-pedantic",
+ [CPre2xCompat]>;
+
 // Warnings for C++1y code which is not compatible with prior C++ standards.
 def CXXPre14Compat : DiagGroup<"c++98-c++11-compat">;
 def CXXPre14CompatPedantic : DiagGroup<"c++98-c++11-compat-pedantic",
@@ -1074,6 +1079,8 @@ def MicrosoftAnonTag : DiagGroup<"microsoft-anon-tag">;
 def MicrosoftCommentPaste : DiagGroup<"microsoft-comment-paste">;
 def MicrosoftEndOfFile : DiagGroup<"microsoft-end-of-file">;
 def MicrosoftInaccessibleBase : DiagGroup<"microsoft-inaccessible-base">;
+def MicrosoftStaticAssert : DiagGroup<"microsoft-static-assert">;
+
 // Aliases.
 def : DiagGroup<"msvc-include", [MicrosoftInclude]>;
 // -Wmsvc-include = -Wmicrosoft-include
@@ -1089,7 +1096,7 @@ def Microsoft : DiagGroup<"microsoft",
  MicrosoftRedeclareStatic, MicrosoftEnumForwardReference, MicrosoftGoto,
  MicrosoftFlexibleArray, MicrosoftExtraQualification, MicrosoftCast,
  MicrosoftConstInit, MicrosoftVoidPseudoDtor, MicrosoftAnonTag,
- MicrosoftCommentPaste, MicrosoftEndOfFile,
+ MicrosoftCommentPaste, MicrosoftEndOfFile, MicrosoftStaticAssert,
  MicrosoftInconsistentDllImport]>;
 
 def ClangClPch : DiagGroup<"clang-cl-pch">;

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index da228cc4be7a..ac7eb8e0764e 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -424,12 +424,21 @@ def err_bool_redeclaration : Error<
 def warn_cxx98_compat_static_assert : Warning<
   "static_assert declarations are incompatible with C++98">,
   InGroup, DefaultIgnore;
-def ext_static_assert_no_message : ExtWarn<
-  "static_assert with no message is a C++17 extension">, InGroup;
+def ext_ms_static_assert : ExtWarn<
+  "use of 'static_assert' without inclusion of  is a Microsoft "
+  "extension">, InGroup;
+def ext_cxx_static_assert_no_message : ExtWarn<
+  "'static_assert' with no message is a C++17 extension">, InGroup;
+def ext_c_static_assert_no_message : ExtWarn<
+  "'_Static_assert' with no message is a C2x extension">, InGroup;
 def warn_cxx14_compat_static_assert_no_message : Warning<
-  "static_assert with no message is incompatible with C++ standards before "
+  "'static_assert' with no message is incompatible with C++ standards before "
   "C++17">,
   DefaultIgnore, InGroup;
+def warn_c17_compat_static_assert_no_message : Warning<
+  "'_Static_assert' with no message is incompatible with C standards before "
+  "C2x">,
+  DefaultIgnore, InGroup;
 def err_function_definition_not_allowed : Error<
   "function definition is not allowed here">;
 def err_expected_end_of_enumerator : Error<

diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index d6b03d85913d..c854d3e9c02b 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -2870,6 +2870,23 @@ void Preprocessor::HandleDefineDirective(
   // If the callbacks want to know, tell them a

[PATCH] D95396: Improve static_assert/_Static_assert diagnostics

2021-03-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

In D95396#2598932 , @rsmith wrote:

> Looks like `test/FixIt/fixit-static-assert.cpp` is failing in Phabricator's 
> pre-merge checks: B91556 . Please take a 
> look at that before landing this; I think there's a decent chance that it's 
> indicative of a real problem.

The issue was that I was using `Extension` instead of `ExtWarn` for the 
`'static_assert' with no message` warnings -- I changed it to use `ExtWarn` and 
fixed up the new tests. If you prefer I use `Extension` instead, I'm happy to 
do that and change the fixit test instead.

I've commit in 8da090381d567d0ec555840f6b2a651d2997e4b3 
, thank 
you for the reviews!


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

https://reviews.llvm.org/D95396

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


[PATCH] D93594: [X86] Pass to transform amx intrinsics to scalar operation.

2021-03-03 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.
This revision is now accepted and ready to land.

LGTM with some nitpicks 😊




Comment at: llvm/include/llvm/CodeGen/Passes.h:496
+
+  /// The pass transform amx intrinsics to scalar operation if the function has
+  /// optnone attribute or it is O0.

transforms 



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:9
+//
+/// \file Pass to transform amx intrinsics to scalar operation.
+/// This pass is only enabled with -O0. With -O0, the def of shape to amx

operations



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:10
+/// \file Pass to transform amx intrinsics to scalar operation.
+/// This pass is only enabled with -O0. With -O0, the def of shape to amx
+/// intrinsics is near the amx intrinsics code. We are not able to find a

We always enable it. Also need to mention optnone.



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:46
+static bool isV256I32Ty(Type *Ty) {
+  if (auto *FVT = dyn_cast(Ty)) {
+return FVT->getNumElements() == 256 &&

Curly brackets are not necessary here.



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:82
+  DTU.applyUpdatesPermissive({
+  {DominatorTree::Delete, Preheader, Tmp},
+  {DominatorTree::Insert, Header, Body},

Do we need to remove the successor? Isn't it still being dominated?



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:96
+
+template 
+static Value *createTileLoadStoreLoops(BasicBlock *Start, BasicBlock *End,

IsTileLoad



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:117
+  BasicBlock *ColBody =
+  createLoop(RowBody, RowLatch, Col, B.getInt16(ColStep),
+ IntrinName + ".scalarize.cols", B, DTU, ColLoop, LI);

Use 1 directly?



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:121
+  BasicBlock *ColLoopLatch = ColBody->getSingleSuccessor();
+  BasicBlock *ColumnLoopHeader = ColBody->getSinglePredecessor();
+  BasicBlock *RowLoopHeader = RowBody->getSinglePredecessor();

Better use the same naming conversion, i.e. `ColLoopHeader`



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:125-126
+  Value *CurrentCol = &*ColumnLoopHeader->begin();
+  FixedVectorType *V256I32Ty = FixedVectorType::get(B.getInt32Ty(), 256);
+  Type *EltTy = V256I32Ty->getElementType();
+

Better to change the order, e.g.
```
Type *EltTy = B.getInt32Ty();
FixedVectorType *V256I32Ty = FixedVectorType::get(EltTy, 256);
```



Comment at: llvm/test/CodeGen/X86/AMX/amx-low-intrinsics-no-amx-bitcast.ll:1
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -mtriple=x86_64 -lower-amx-intrinsics %s -S | FileCheck %s

I think we should move the files to llvm/test/Transforms/



Comment at: llvm/test/CodeGen/X86/AMX/amx-type.ll:2
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -lower-amx-type %s -S | FileCheck %s
+; RUN: opt --codegen-opt-level=2 -mtriple=x86_64 -lower-amx-type %s -S | 
FileCheck %s
 

Why adding this? Is it O2 by default?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93594

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


[PATCH] D75041: [clang-tidy] Extend 'bugprone-easily-swappable-parameters' with mixability because of implicit conversions

2021-03-03 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 327761.
whisperity added a comment.

After reading through the diff as rendered by Phabricateur, I realised I left 
in a few crappy debug prints and commented-out values that are not needed in 
the end. This is fixed now.


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

https://reviews.llvm.org/D75041

Files:
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicit-qualifiers.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
@@ -3,7 +3,8 @@
 // RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: "bool;MyBool;struct U;MAKE_LOGICAL_TYPE(int)"}, \
-// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 0} \
+// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 0}, \
+// RUN: {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0} \
 // RUN:  ]}' -- -x c
 
 #define bool _Bool
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
@@ -3,7 +3,8 @@
 // RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""}, \
-// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 1} \
+// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 1}, \
+// RUN: {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0} \
 // RUN:  ]}' --
 
 typedef int MyInt1;
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
@@ -3,7 +3,8 @@
 // RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 3}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""}, \
-// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 0} \
+// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 0}, \
+// RUN: {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0} \
 // RUN:  ]}' --
 
 int add(int Left, int Right) { return Left + Right; } // NO-WARN: Only 2 parameters.
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
@@ -3,7 +3,8 @@
 // RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""}, \
-// RUN: {key: bugprone-ea

[PATCH] D92808: [ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of explicitly emitting retainRV or claimRV calls in the IR

2021-03-03 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D92808#2600031 , @thakis wrote:

>> Thank you. Let me know when you have more information.
>
> Repro is moving along. 
> https://bugs.chromium.org/p/chromium/issues/detail?id=1182642#c26 and onward 
> are getting pretty close.

That's interesting, thanks for sharing! I had a look at the linked good.s/bad.s 
and the sequence mentioned in the comments looks unexpected. `mov   x29, 
x29` should be exactly between a regular call and 
`_objc_retainAutoreleasedReturnValue`, but this is not what's happening in this 
case. I could not find a link to download the (pre-processed) source file. 
Would it be possible to get that file?

  Ltmp239:
bl  _objc_msgSend
  Ltmp705:
mov x29, x29
  Ltmp240:
b   LBB19_3
  LBB19_3:; %invoke.cont4
.loc149 0 9 ; 
../../ios/chrome/browser/ui/infobars/infobar_container_coordinator.mm:0:9
bl  _objc_retainAutoreleasedReturnValue


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[PATCH] D69560: [clang-tidy] Add 'bugprone-easily-swappable-parameters' check

2021-03-03 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

@aaron.ballman I've reworked and uploaded the final addition to this line, the 
crown jewel, the very reason this checker was developed (D75041 
). So, AFAIK, the "let's rewrite the whole 
thing with better code quality" work can be considered done, and we may move on 
with the review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69560

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


[PATCH] D96344: [flang][driver] Add options for -fdefault* and -flarge-sizes

2021-03-03 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski requested changes to this revision.
awarzynski added a comment.
This revision now requires changes to proceed.

This patch won't build with `BUILD_SHARED_LIBS` set to `On`. That's because a 
new dependency in `CompilerInvocation` is introduced (on 
`IntrinsicTypeDefaultKinds`). This dependency is currently not satisfied in the 
unit tests. This should fix it:

  diff --git a/flang/unittests/Frontend/CMakeLists.txt 
b/flang/unittests/Frontend/CMakeLists.txt
  index 88ec86f49291..a288aa0c99c9 100644
  --- a/flang/unittests/Frontend/CMakeLists.txt
  +++ b/flang/unittests/Frontend/CMakeLists.txt
  @@ -10,4 +10,5 @@ target_link_libraries(FlangFrontendTests
 flangFrontendTool
 FortranParser
 FortranSemantics
  +  FortranCommon
   )

I've left a few other comments inline.




Comment at: clang/include/clang/Driver/Options.td:4307-4314
+def fdefault_double_8 : Flag<["-"],"fdefault-double-8">, Group, 
+  HelpText<"Set the DOUBLE PRECISION type and double real constants like 1.d0 
to an 8 byte wide type">;
+def fdefault_integer_8 : Flag<["-"],"fdefault-integer-8">, Group, 
+  HelpText<"Set the default integer and logical types to an 8 byte wide type">;
+def fdefault_real_8 : Flag<["-"],"fdefault-real-8">, Group, 
+  HelpText<"Set the default real type to an 8 byte wide type">;
+def flarge_sizes : Flag<["-"],"flarge-sizes">, Group, 

[nit] I believe that you copied the long version from [[ 
https://gcc.gnu.org/onlinedocs/gfortran/Fortran-Dialect-Options.html | here ]]. 
I would instead use the short versions from this:
```
 gcc --help=fortran | grep default
  -Wreturn-type   Warn whenever a function's return type defaults 
to "int" (C), or about inconsistent return types (C++).
  -fdefault-double-8  Set the default double precision kind to an 8 
byte wide type.
  -fdefault-integer-8 Set the default integer kind to an 8 byte wide 
type.
  -fdefault-real-8Set the default real kind to an 8 byte wide type.
  -fmodule-privateSet default accessibility of module entities to 
PRIVATE.
  -fopenacc-dim=  Specify default OpenACC compute dimensions.
```



Comment at: flang/test/Flang-Driver/fdefault.f90:53
+!-
+! ERROR: error: Use of `-fdefault-double-8` requires `-fdefault-real-8`
+

Fails for `f18` as it does not print `error` here.



Comment at: flang/test/Flang-Driver/pipeline.f90:1
+! This file tests that flang-new forwards 
+! all Flang frontend options to flang-new -fc1

This test will fail with `FLANG_BUILD_NEW_DRIVER` set to `Off` (because it 
should not be run with `f18`). If you add `! REQUIRES: new-flang-driver` then 
everything will be fine. 

Instead of adding that ^^^, could you move it to [[ 
https://github.com/llvm/llvm-project/blob/main/flang/test/Flang-Driver/frontend-forwarding.f90
 | frontend-forwarding.f90 ]]?


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

https://reviews.llvm.org/D96344

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


[PATCH] D97362: [clang][parser] Allow attributes in explicit template instantiations

2021-03-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:1618
+
+if (Tok && (*Tok).is(tok::l_square)) {
+  Diag(Attrs.Range.getBegin(), diag::err_attributes_not_allowed) << 
Attrs.Range;

This will incorrectly classify an empty MS attribute `[]` as being a prohibited 
`[[]]` attribute. I think we need something like:
```
if (Tok && Tok->is(tok::l_square)) {  
 SourceLocation NextTokLoc = 
Lexer::findLocationAfterToken(Attrs.Range.getBegin(), Tok.getKind(), SM, 
getLangOpts(), true);
 auto NextTok = Lexer::findNextToken(NextTokLoc, SM, getLangOpts());
 if (NextTok && NextTok->is(tok::l_square)) {
   ...
 }
}
```
Also, I think it should use `DiagID` rather than hard-coding the diagnostic to 
use.


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

https://reviews.llvm.org/D97362

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


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-03 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov updated this revision to Diff 327767.
azabaznov added a comment.

Check 'isEnabled' is now private: it is used only for non-core or non-optional 
core features;
creation of implicit type definitions is guarder with extension support check; 
minor refactoring


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/OpenCLOptions.h
  clang/lib/Basic/OpenCLOptions.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Parser/opencl-atomics-cl20.cl
  clang/test/SemaOpenCL/access-qualifier.cl
  clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
  clang/test/SemaOpenCL/extension-begin.cl
  clang/test/SemaOpenCL/extensions.cl

Index: clang/test/SemaOpenCL/extensions.cl
===
--- clang/test/SemaOpenCL/extensions.cl
+++ clang/test/SemaOpenCL/extensions.cl
@@ -43,8 +43,8 @@
 #endif
 
 #if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 120)
-void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
-  double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
+void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 support}}
+  double d; // expected-error {{type 'double' requires cl_khr_fp64 support}}
   (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
 }
 #endif
@@ -72,14 +72,14 @@
 void f2(void) {
   double d;
 #ifdef NOFP64
-// expected-error@-2{{use of type 'double' requires cl_khr_fp64 extension to be enabled}}
+// expected-error@-2{{use of type 'double' requires cl_khr_fp64 support}}
 #endif
 
   typedef double double4 __attribute__((ext_vector_type(4)));
   double4 d4 = {0.0f, 2.0f, 3.0f, 1.0f};
 #ifdef NOFP64
-// expected-error@-3 {{use of type 'double' requires cl_khr_fp64 extension to be enabled}}
-// expected-error@-3 {{use of type 'double4' (vector of 4 'double' values) requires cl_khr_fp64 extension to be enabled}}
+// expected-error@-3 {{use of type 'double' requires cl_khr_fp64 support}}
+// expected-error@-3 {{use of type 'double4' (vector of 4 'double' values) requires cl_khr_fp64 support}}
 #endif
 
   (void) 1.0;
@@ -96,6 +96,6 @@
 
 #if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 120)
 void f3(void) {
-  double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
+  double d; // expected-error {{type 'double' requires cl_khr_fp64 support}}
 }
 #endif
Index: clang/test/SemaOpenCL/extension-begin.cl
===
--- clang/test/SemaOpenCL/extension-begin.cl
+++ clang/test/SemaOpenCL/extension-begin.cl
@@ -41,11 +41,11 @@
 
 #pragma OPENCL EXTENSION my_ext : disable 
 void test_f2(void) {
-  struct A test_A2; // expected-error {{use of type 'struct A' requires my_ext extension to be enabled}}
-  const struct A test_A_local; // expected-error {{use of type 'struct A' requires my_ext extension to be enabled}}
-  TypedefOfA test_typedef_A; // expected-error {{use of type 'TypedefOfA' (aka 'struct A') requires my_ext extension to be enabled}}
-  PointerOfA test_A_pointer; // expected-error {{use of type 'PointerOfA' (aka 'const __private struct A *') requires my_ext extension to be enabled}}
-  f(); // expected-error {{use of declaration 'f' requires my_ext extension to be enabled}}
+  struct A test_A2; // expected-error {{use of type 'struct A' requires my_ext support}}
+  const struct A test_A_local; // expected-error {{use of type 'struct A' requires my_ext support}}
+  TypedefOfA test_typedef_A; // expected-error {{use of type 'TypedefOfA' (aka 'struct A') requires my_ext support}}
+  PointerOfA test_A_pointer; // expected-error {{use of type 'PointerOfA' (aka 'const __private struct A *') requires my_ext support}}
+  f(); // expected-error {{use of declaration 'f' requires my_ext support}}
   g(0); // expected-error {{no matching function for call to 'g'}}
 // expected-note@extension-begin.h:18 {{candidate unavailable as it requires OpenCL extension 'my_ext' to be enabled}}
 // expected-note@extension-begin.h:23 {{candidate function not viable: requires 0 arguments, but 1 was provided}}
Index: clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
===
--- clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
+++ clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
@@ -235,11 +235,11 @@
 kernel void foo1(global unsigned int *buf)
 {
   ndrange_t n;
-  buf[0] = get_kernel_max_sub_group_size_for_ndrange(n, ^(){});

[PATCH] D97717: [SYCL] Rework the SYCL driver options

2021-03-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 327769.
aaron.ballman added a comment.

Fixed the failing unit tests.


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

https://reviews.llvm.org/D97717

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/CodeGenSYCL/convergent.cpp
  clang/test/CodeGenSYCL/filescope_asm.c
  clang/test/Frontend/sycl-aux-triple.cpp
  clang/test/Frontend/sycl.cpp
  clang/test/Preprocessor/sycl-macro.cpp
  clang/test/SemaSYCL/float128.cpp
  clang/test/SemaSYCL/int128.cpp
  clang/test/SemaSYCL/kernel-attribute.cpp
  clang/test/SemaSYCL/prohibit-thread-local.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp

Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -515,7 +515,8 @@
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
   ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_FALSE(Invocation.getLangOpts()->SYCL);
+  ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsDevice);
+  ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsHost);
   ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_None);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -530,13 +531,21 @@
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
   ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_FALSE(Invocation.getLangOpts()->SYCL);
-  ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_None);
+  ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsDevice);
+  ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsHost);
+  ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_2017);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl";
-  ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-sycl-std=";
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl-is-device";
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl-is-host";
+
+  // FIXME: generateCC1CommandLine is only used by the unit test system and
+  // cannot handle this case. It passes along the -sycl-std because the option
+  // definition does not specify that it relies on -fsycl any longer (because
+  // there is no syntax I could find that would allow it). However, the option
+  // is handled properly on a real invocation. See: Clang::ConstructJob().
+  ASSERT_THAT(GeneratedArgs, Contains(HasSubstr("-sycl-std=")));
 }
 
 TEST_F(CommandLineTest, ConditionalParsingIfTrueFlagNotPresent) {
@@ -544,13 +553,12 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_TRUE(Invocation.getLangOpts()->SYCL);
+  ASSERT_TRUE(Diags->hasErrorOccurred());
   ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_None);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl")));
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl";
   ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-sycl-std=";
 }
 
@@ -559,13 +567,12 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_TRUE(Invocation.getLangOpts()->SYCL);
+  ASSERT_TRUE(Diags->hasErrorOccurred());
   ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_2017);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl")));
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl";
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-sycl-std=2017")));
 }
 
Index: clang/test/SemaSYCL/prohibit-thread-local.cpp
===
--- clang/test/SemaSYCL/prohibit-thread-local.cpp
+++ clang/test/SemaSYCL/prohibit-thread-local.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -fsycl-is-device -triple spir64 -verify -fsyntax-only %s
 
 thread_local const int prohobit_ns_scope = 0;
 thread_local int prohobit_ns_scope2 = 0;
Index: clang/test/SemaSYCL/kernel-attribute.cpp
===
--- clang/test/SemaSYCL/kernel-attribute.cpp
+++ clang/test/SemaSYCL/kernel-attribute.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl -fsycl-is-device -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
 
 // Only function templates
 [[clang::sycl_kernel]] int gv2 = 0; // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
Inde

[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-03 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added inline comments.



Comment at: clang/lib/Basic/OpenCLOptions.cpp:22-26
+  auto &OptInfo = OptMap.find(Ext)->getValue();
+  if (OptInfo.isCoreIn(LO) || OptInfo.isOptionalCoreIn(LO))
+return isSupported(Ext, LO);
+
+  return isEnabled(Ext);

Note that I can't use `isWithPragma` from https://reviews.llvm.org/D97052 as 
some extensions are promoted to core or optional core in different versions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D97849: [AST][PCH][ASTImporter] Fix UB caused by uninited SwitchStmt member

2021-03-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

This looks reasonable to me (good catch!), but is there a way for us to add a 
regression test for it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97849

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


[PATCH] D92808: [ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of explicitly emitting retainRV or claimRV calls in the IR

2021-03-03 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

The preprocessed source is attached to this comment: 
https://bugs.chromium.org/p/chromium/issues/detail?id=1182642#c26

good.s and bad.s are here: 
https://bugs.chromium.org/p/chromium/issues/detail?id=1182642#c28

And this shows the problematic difference between them: 
https://bugs.chromium.org/p/chromium/issues/detail?id=1182642#c30

After this change, for some reason x0 is getting clobbered in the prologue.

In https://bugs.chromium.org/p/chromium/issues/detail?id=1182642#c31 I verify 
that manually changing the register back to x1 fixes the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[clang-tools-extra] 188373f - [clangd] Make WorkspaceSymbols request work with empty queries

2021-03-03 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-03-03T15:41:39+01:00
New Revision: 188373fb46979d8141e9f844f13a85157b1ce5dd

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

LOG: [clangd] Make WorkspaceSymbols request work with empty queries

Clangd uses codecompletion limit as the limit for workspacesymbols, so
in theory this should only be an order of magnitude slower than a
codecompletion request with empty identifier (as code completion limits
the available symbols).

This is also what LSP suggests "Clients may send an empty string here to 
request all symbols.".
Clangd doesn't really fulfill the "all" part of that statement, but we
never do unless user set the index query limit to zero explicitly.

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

Added: 


Modified: 
clang-tools-extra/clangd/FindSymbols.cpp
clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindSymbols.cpp 
b/clang-tools-extra/clangd/FindSymbols.cpp
index cf517717a27a..bda5dcadf12e 100644
--- a/clang-tools-extra/clangd/FindSymbols.cpp
+++ b/clang-tools-extra/clangd/FindSymbols.cpp
@@ -88,7 +88,7 @@ llvm::Expected>
 getWorkspaceSymbols(llvm::StringRef Query, int Limit,
 const SymbolIndex *const Index, llvm::StringRef HintPath) {
   std::vector Result;
-  if (Query.empty() || !Index)
+  if (!Index)
 return Result;
 
   // Lookup for qualified names are performed as:

diff  --git a/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp 
b/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
index fa9af8637304..30aca71a0570 100644
--- a/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -216,7 +216,9 @@ TEST(WorkspaceSymbols, GlobalNamespaceQueries) {
   AllOf(QName("foo"), WithKind(SymbolKind::Function)),
   AllOf(QName("ns"), WithKind(SymbolKind::Namespace;
   EXPECT_THAT(getSymbols(TU, ":"), IsEmpty());
-  EXPECT_THAT(getSymbols(TU, ""), IsEmpty());
+  EXPECT_THAT(getSymbols(TU, ""),
+  UnorderedElementsAre(QName("foo"), QName("Foo"), QName("Foo::a"),
+   QName("ns"), QName("ns::foo2")));
 }
 
 TEST(WorkspaceSymbols, Enums) {



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


[PATCH] D97773: [clangd] Make WorkspaceSymbols request work with empty queries

2021-03-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG188373fb4697: [clangd] Make WorkspaceSymbols request work 
with empty queries (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97773

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp


Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -216,7 +216,9 @@
   AllOf(QName("foo"), WithKind(SymbolKind::Function)),
   AllOf(QName("ns"), WithKind(SymbolKind::Namespace;
   EXPECT_THAT(getSymbols(TU, ":"), IsEmpty());
-  EXPECT_THAT(getSymbols(TU, ""), IsEmpty());
+  EXPECT_THAT(getSymbols(TU, ""),
+  UnorderedElementsAre(QName("foo"), QName("Foo"), QName("Foo::a"),
+   QName("ns"), QName("ns::foo2")));
 }
 
 TEST(WorkspaceSymbols, Enums) {
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -88,7 +88,7 @@
 getWorkspaceSymbols(llvm::StringRef Query, int Limit,
 const SymbolIndex *const Index, llvm::StringRef HintPath) {
   std::vector Result;
-  if (Query.empty() || !Index)
+  if (!Index)
 return Result;
 
   // Lookup for qualified names are performed as:


Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -216,7 +216,9 @@
   AllOf(QName("foo"), WithKind(SymbolKind::Function)),
   AllOf(QName("ns"), WithKind(SymbolKind::Namespace;
   EXPECT_THAT(getSymbols(TU, ":"), IsEmpty());
-  EXPECT_THAT(getSymbols(TU, ""), IsEmpty());
+  EXPECT_THAT(getSymbols(TU, ""),
+  UnorderedElementsAre(QName("foo"), QName("Foo"), QName("Foo::a"),
+   QName("ns"), QName("ns::foo2")));
 }
 
 TEST(WorkspaceSymbols, Enums) {
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -88,7 +88,7 @@
 getWorkspaceSymbols(llvm::StringRef Query, int Limit,
 const SymbolIndex *const Index, llvm::StringRef HintPath) {
   std::vector Result;
-  if (Query.empty() || !Index)
+  if (!Index)
 return Result;
 
   // Lookup for qualified names are performed as:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97805: [clang-query] Add option to enable only displaying main file matches

2021-03-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-query/Query.cpp:60-61
+"main-file-only  "
+"Only match nodes from the main source file. This mode is the "
+"default.\n"
 "  set output   "

I'm not super keen on this being the default behavior. One of the big uses for 
clang-query is to experiment with matchers and I think ignoring nodes by 
default makes it harder to know whether you've written the matcher correctly or 
not. e.g., you write the matcher, run it over a source file, don't get any 
results -- is that because the matcher was nonsense or because the mode 
excluded matching on nodes in headers by default?

The fact that we print how many nodes were skipped does help (so it's not a 
silent when you match only in headers), but I think the default behavior should 
be to match on what's in the source code (which includes header contents) and 
users should have to opt into getting less results. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97805

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


[PATCH] D97849: [AST][PCH][ASTImporter] Fix UB caused by uninited SwitchStmt member

2021-03-03 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D97849#2600201 , @aaron.ballman 
wrote:

> This looks reasonable to me (good catch!), but is there a way for us to add a 
> regression test for it?

I'm not sure if it's possible to write a test for deterministically 
demonstrating the bug - which is a non-deterministic crash.
So, even if we would have a test case, that would not catch the regression 
deterministically.
We could include the minimal reproducer for CTU analysis - the way we observed 
and tracked down this crash.

AFAIK, it did not reproduce with memory sanitizers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97849

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


[clang] 0a5dd06 - Revert "[ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of explicitly emitting retainRV or claimRV calls in the IR"

2021-03-03 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-03-03T15:51:40+01:00
New Revision: 0a5dd067181dac2a8882a139ea3bd19bdea5fa44

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

LOG: Revert "[ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of 
explicitly emitting retainRV or claimRV calls in the IR"

This caused miscompiles of Chromium tests for iOS due clobbering of live
registers. See discussion on the code review for details.

> Background:
>
> This fixes a longstanding problem where llvm breaks ARC's autorelease
> optimization (see the link below) by separating calls from the marker
> instructions or retainRV/claimRV calls. The backend changes are in
> https://reviews.llvm.org/D92569.
>
> https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-autoreleasereturnvalue
>
> What this patch does to fix the problem:
>
> - The front-end adds operand bundle "clang.arc.attachedcall" to calls,
>   which indicates the call is implicitly followed by a marker
>   instruction and an implicit retainRV/claimRV call that consumes the
>   call result. In addition, it emits a call to
>   @llvm.objc.clang.arc.noop.use, which consumes the call result, to
>   prevent the middle-end passes from changing the return type of the
>   called function. This is currently done only when the target is arm64
>   and the optimization level is higher than -O0.
>
> - ARC optimizer temporarily emits retainRV/claimRV calls after the calls
>   with the operand bundle in the IR and removes the inserted calls after
>   processing the function.
>
> - ARC contract pass emits retainRV/claimRV calls after the call with the
>   operand bundle. It doesn't remove the operand bundle on the call since
>   the backend needs it to emit the marker instruction. The retainRV and
>   claimRV calls are emitted late in the pipeline to prevent optimization
>   passes from transforming the IR in a way that makes it harder for the
>   ARC middle-end passes to figure out the def-use relationship between
>   the call and the retainRV/claimRV calls (which is the cause of
>   PR31925).
>
> - The function inliner removes an autoreleaseRV call in the callee if
>   nothing in the callee prevents it from being paired up with the
>   retainRV/claimRV call in the caller. It then inserts a release call if
>   claimRV is attached to the call since autoreleaseRV+claimRV is
>   equivalent to a release. If it cannot find an autoreleaseRV call, it
>   tries to transfer the operand bundle to a function call in the callee.
>   This is important since the ARC optimizer can remove the autoreleaseRV
>   returning the callee result, which makes it impossible to pair it up
>   with the retainRV/claimRV call in the caller. If that fails, it simply
>   emits a retain call in the IR if retainRV is attached to the call and
>   does nothing if claimRV is attached to it.
>
> - SCCP refrains from replacing the return value of a call with a
>   constant value if the call has the operand bundle. This ensures the
>   call always has at least one user (the call to
>   @llvm.objc.clang.arc.noop.use).
>
> - This patch also fixes a bug in replaceUsesOfNonProtoConstant where
>   multiple operand bundles of the same kind were being added to a call.
>
> Future work:
>
> - Use the operand bundle on x86-64.
>
> - Fix the auto upgrader to convert call+retainRV/claimRV pairs into
>   calls with the operand bundles.
>
> rdar://71443534
>
> Differential Revision: https://reviews.llvm.org/D92808

This reverts commit ed4718eccb12bd42214ca4fb17d196d49561c0c7.

Added: 


Modified: 
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/test/CodeGenObjC/arc-unsafeclaim.m
llvm/docs/LangRef.rst
llvm/include/llvm/IR/InstrTypes.h
llvm/include/llvm/IR/Intrinsics.td
llvm/include/llvm/IR/LLVMContext.h
llvm/lib/Analysis/ObjCARCInstKind.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/IR/LLVMContext.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
llvm/lib/Transforms/ObjCARC/ObjCARC.cpp
llvm/lib/Transforms/ObjCARC/ObjCARC.h
llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
llvm/lib/Transforms/ObjCARC/PtrState.cpp
llvm/lib/Transforms/ObjCARC/PtrState.h
llvm/lib/Transforms/Scalar/SCCP.cpp
llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/test/Bitcode/operand-bundles-bc-analyzer.ll
llvm/test/CodeGen/AArch64/call-rv-marker.ll
llvm/test/Transforms/DeadArgElim/deadretval.ll
llvm/test/Transforms/ObjCARC/contract-marker

[PATCH] D92808: [ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of explicitly emitting retainRV or claimRV calls in the IR

2021-03-03 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Reverted in 
https://github.com/llvm/llvm-project/commit/0a5dd067181dac2a8882a139ea3bd19bdea5fa44
 until this can be fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[clang] 25ad188 - [OpenCL] Prevent adding extension pragma by default.

2021-03-03 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2021-03-03T15:02:21Z
New Revision: 25ad188bfcdb2a85416013c6303f30cbc7775674

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

LOG: [OpenCL] Prevent adding extension pragma by default.

This commit refactors extension support to allow
specifying whether pragma is needed or not explicitly.

For backward compatibility pragmas are set to required
for all extensions that were added prior to this but
not for OpenCL 3.0 features.

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

Added: 


Modified: 
clang/include/clang/Basic/OpenCLExtensions.def
clang/include/clang/Basic/OpenCLOptions.h
clang/lib/Basic/OpenCLOptions.cpp
clang/lib/Basic/Targets.cpp
clang/lib/Parse/ParsePragma.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/SemaOpenCL/extension-version.cl

Removed: 




diff  --git a/clang/include/clang/Basic/OpenCLExtensions.def 
b/clang/include/clang/Basic/OpenCLExtensions.def
index 8e6f723a53a6..c5352dadc0de 100644
--- a/clang/include/clang/Basic/OpenCLExtensions.def
+++ b/clang/include/clang/Basic/OpenCLExtensions.def
@@ -16,8 +16,12 @@
 // If extensions are to be enumerated with information about whether
 // an extension is core or optional core and minimum OpenCL version
 // when an extension becomes available,
-// define OPENCL_GENERIC_EXTENSION(ext, avail, core, opt) where
+// define OPENCL_GENERIC_EXTENSION(ext, pragma, avail, core, opt) where
 //   ext - name of the extension or optional core feature.
+//   pragma - true if extension needs pragmas or false otherwise.
+//NOTE: extension pragma without any documentation detailing
+//its behavior explicitly is deprecated. Therefore the default
+//value is false.
 //   avail - minimum OpenCL version supporting it.
 //   core - OpenCL versions mask when the extension becomes core feature.
 //  0U indicates not a core feature.
@@ -50,67 +54,67 @@
 #endif // OPENCL_GENERIC_EXTENSION
 
 // Declaration helpers
-#define OPENCL_EXTENSION(ext, avail) OPENCL_GENERIC_EXTENSION(ext, avail, 0U, 
0U)
-#define OPENCL_COREFEATURE(ext, avail, core)  OPENCL_GENERIC_EXTENSION(ext, 
avail, core, 0U)
-#define OPENCL_OPTIONALCOREFEATURE(ext, avail, opt) 
OPENCL_GENERIC_EXTENSION(ext, avail, 0U, opt)
+#define OPENCL_EXTENSION(ext, pragma, avail) OPENCL_GENERIC_EXTENSION(ext, 
pragma, avail, 0U, 0U)
+#define OPENCL_COREFEATURE(ext, pragma, avail, core)  
OPENCL_GENERIC_EXTENSION(ext, pragma, avail, core, 0U)
+#define OPENCL_OPTIONALCOREFEATURE(ext, pragma, avail, opt) 
OPENCL_GENERIC_EXTENSION(ext, pragma, avail, 0U, opt)
 
 // OpenCL 1.0.
-OPENCL_COREFEATURE(cl_khr_byte_addressable_store, 100, OCL_C_11P)
-OPENCL_COREFEATURE(cl_khr_global_int32_base_atomics, 100, OCL_C_11P)
-OPENCL_COREFEATURE(cl_khr_global_int32_extended_atomics, 100, OCL_C_11P)
-OPENCL_COREFEATURE(cl_khr_local_int32_base_atomics, 100, OCL_C_11P)
-OPENCL_COREFEATURE(cl_khr_local_int32_extended_atomics, 100, OCL_C_11P)
-OPENCL_OPTIONALCOREFEATURE(cl_khr_fp64, 100, OCL_C_12P)
-OPENCL_EXTENSION(cl_khr_fp16, 100)
-OPENCL_EXTENSION(cl_khr_int64_base_atomics, 100)
-OPENCL_EXTENSION(cl_khr_int64_extended_atomics, 100)
-OPENCL_COREFEATURE(cl_khr_3d_image_writes, 100, OCL_C_20)
+OPENCL_COREFEATURE(cl_khr_byte_addressable_store, true, 100, OCL_C_11P)
+OPENCL_COREFEATURE(cl_khr_global_int32_base_atomics, true, 100, OCL_C_11P)
+OPENCL_COREFEATURE(cl_khr_global_int32_extended_atomics, true, 100, OCL_C_11P)
+OPENCL_COREFEATURE(cl_khr_local_int32_base_atomics, true, 100, OCL_C_11P)
+OPENCL_COREFEATURE(cl_khr_local_int32_extended_atomics, true, 100, OCL_C_11P)
+OPENCL_OPTIONALCOREFEATURE(cl_khr_fp64, true, 100, OCL_C_12P)
+OPENCL_EXTENSION(cl_khr_fp16, true, 100)
+OPENCL_EXTENSION(cl_khr_int64_base_atomics, true, 100)
+OPENCL_EXTENSION(cl_khr_int64_extended_atomics, true, 100)
+OPENCL_COREFEATURE(cl_khr_3d_image_writes, true, 100, OCL_C_20)
 
 // EMBEDDED_PROFILE
-OPENCL_EXTENSION(cles_khr_int64, 110)
+OPENCL_EXTENSION(cles_khr_int64, true, 110)
 
 // OpenCL 1.2.
-OPENCL_EXTENSION(cl_khr_depth_images, 120)
-OPENCL_EXTENSION(cl_khr_gl_msaa_sharing, 120)
+OPENCL_EXTENSION(cl_khr_depth_images, true, 120)
+OPENCL_EXTENSION(cl_khr_gl_msaa_sharing,true, 120)
 
 // OpenCL 2.0.
-OPENCL_EXTENSION(cl_khr_mipmap_image, 200)
-OPENCL_EXTENSION(cl_khr_mipmap_image_writes, 200)
-OPENCL_EXTENSION(cl_khr_srgb_image_writes, 200)
-OPENCL_EXTENSION(cl_khr_subgroups, 200)
+OPENCL_EXTENSION(cl_khr_mipmap_image, true, 200)
+OPENCL_EXTENSION(cl_khr_mipmap_image_writes, true, 200)
+OPENCL_EXTENSION(cl_khr_srgb_image_writes, true, 200)
+OPENCL_EXTENSION(cl_khr_subgroups, true, 200)
 
 // Clang Extensions.
-OPENCL_EXTENSION(cl_clang_storage_class_specifiers, 100)
-OPENCL_EXTEN

[PATCH] D97052: [OpenCL] Prevent adding extension pragma by default

2021-03-03 Thread Anastasia Stulova 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 rG25ad188bfcdb: [OpenCL] Prevent adding extension pragma by 
default. (authored by Anastasia).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97052

Files:
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/include/clang/Basic/OpenCLOptions.h
  clang/lib/Basic/OpenCLOptions.cpp
  clang/lib/Basic/Targets.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/SemaOpenCL/extension-version.cl

Index: clang/test/SemaOpenCL/extension-version.cl
===
--- clang/test/SemaOpenCL/extension-version.cl
+++ clang/test/SemaOpenCL/extension-version.cl
@@ -3,15 +3,13 @@
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
 // RUN: %clang_cc1 -x cl -cl-std=clc++ %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple spir-unknown-unknown
 // RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=clc++ %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
-
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) && !defined(TEST_CORE_FEATURES)
-// expected-no-diagnostics
-#endif
+// RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 
 // Extensions in all versions
 #ifndef cl_clang_storage_class_specifiers
@@ -100,7 +98,7 @@
 #error "Missing cl_khr_3d_image_writes define"
 #endif
 #pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) && defined TEST_CORE_FEATURES
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200) && defined TEST_CORE_FEATURES
 // expected-warning@-2{{OpenCL extension 'cl_khr_3d_image_writes' is core feature or supported optional core feature - ignoring}}
 #endif
 
@@ -215,3 +213,55 @@
 // expected-warning@+2{{unsupported OpenCL extension 'cl_intel_device_side_avc_motion_estimation' - ignoring}}
 #endif
 #pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : enable
+
+// Check that pragmas for the OpenCL 3.0 features are rejected.
+
+#pragma OPENCL EXTENSION __opencl_c_int64 : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_int64' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_3d_image_writes : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_3d_image_writes' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_atomic_order_acq_rel : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_atomic_order_acq_rel' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_atomic_order_seq_cst : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_atomic_order_seq_cst' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_device_enqueue : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_device_enqueue' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_fp64 : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_fp64' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_generic_address_space : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_generic_address_space' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_images : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_images' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_pipes : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_pipes' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_program_scope_global_variables : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_program_scope_global_variables' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_read_write_images : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_read_write_images' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_subgroups : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_subgroups' - ignoring}}
+
+#pragma OPENCL EXTENSION __opencl_c_int64 : enable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_int64' - ignoring}}
+#pragma OPENCL EXTENSION

[PATCH] D97857: [Matrix] Add support for matrix-by-scalar division.

2021-03-03 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
fhahn added reviewers: anemet, rjmccall, rsmith, Bigcheese.
Herald added subscribers: dexonsmith, tschuett.
fhahn requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: llvm-commits.

This patch extends the matrix spec to allow matrix-by-scalar division.

Originally support for `/` was left out to avoid ambiguity for the
matrix-matrix version of `/`, which could either be elementwise or
specified as matrix multiplication M1  * (1/M2 
).

For the matrix-scalar version, no ambiguity exists; `*` is also
an elementwise operation in that case. Matrix-by-scalar division
is commonly supported by systems including Matlab, Mathematica
or NumPy.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97857

Files:
  clang/docs/MatrixTypes.rst
  clang/lib/AST/Type.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/Sema/matrix-type-operators.c
  llvm/include/llvm/IR/MatrixBuilder.h

Index: llvm/include/llvm/IR/MatrixBuilder.h
===
--- llvm/include/llvm/IR/MatrixBuilder.h
+++ llvm/include/llvm/IR/MatrixBuilder.h
@@ -215,6 +215,22 @@
 return B.CreateMul(LHS, RHS);
   }
 
+  /// Divide matrix \p LHS by scalar \p RHS. If the operands are integers, \p
+  /// IsUnsigned indicates whether UDiv or SDiv should be used.
+  Value *CreateScalarDiv(Value *LHS, Value *RHS, bool IsUnsigned) {
+assert(LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy());
+assert(!isa(LHS->getType()) &&
+   "LHS Assumed to be fixed width");
+RHS =
+B.CreateVectorSplat(cast(LHS->getType())->getElementCount(),
+RHS, "scalar.splat");
+return cast(LHS->getType())
+   ->getElementType()
+   ->isFloatingPointTy()
+   ? B.CreateFDiv(LHS, RHS)
+   : (IsUnsigned ? B.CreateUDiv(LHS, RHS) : B.CreateSDiv(LHS, RHS));
+  }
+
   /// Extracts the element at (\p RowIdx, \p ColumnIdx) from \p Matrix.
   Value *CreateExtractElement(Value *Matrix, Value *RowIdx, Value *ColumnIdx,
   unsigned NumRows, Twine const &Name = "") {
Index: clang/test/Sema/matrix-type-operators.c
===
--- clang/test/Sema/matrix-type-operators.c
+++ clang/test/Sema/matrix-type-operators.c
@@ -70,6 +70,40 @@
   // expected-error@-1 {{assigning to 'float' from incompatible type 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))')}}
 }
 
+void mat_scalar_divide(sx10x10_t a, sx5x10_t b, float sf, char *p) {
+  // Shape of multiplication result does not match the type of b.
+  b = a / sf;
+  // expected-error@-1 {{assigning to 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') from incompatible type 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))')}}
+  b = sf / a;
+  // expected-error@-1 {{invalid operands to binary expression ('float' and 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))'))}}
+
+  a = a / p;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'char *')}}
+  a = p / a;
+  // expected-error@-1 {{invalid operands to binary expression ('char *' and 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))'))}}
+
+  sf = a / sf;
+  // expected-error@-1 {{assigning to 'float' from incompatible type 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))')}}
+}
+
+void matrix_matrix_divide(sx10x10_t a, sx5x10_t b, ix10x5_t c, ix10x10_t d, float sf, char *p) {
+  // Matrix by matrix division is not supported.
+  a = a / a;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
+
+  b = a / a;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
+
+  // Check element type mismatches.
+  a = b / c;
+  // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'ix10x5_t' (aka 'int __attribute__((matrix_type(10, 5)))'))}}
+  d = a / a;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
+
+  p = a / a;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
+}
+
 sx5x10_t get_matrix();
 
 void insert(sx5x10_t a, float f) {
Index: clang/test/CodeGen/matrix-type-operators.c
===
--- clang/test/CodeGen/matrix-type-operators.c
+++ clang/test/CodeGen/matrix-type-operators.c
@@ -301,6

[clang] b2bc0a3 - Implement P2173 for attributes on lambdas

2021-03-03 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-03-03T10:05:39-05:00
New Revision: b2bc0a32545f9b066fed1631c6fba92a2a5a6d84

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

LOG: Implement P2173 for attributes on lambdas

https://wg21.link/P2173 is making its way through WG21 currently and
has not been formally adopted yet. This feature provides very useful
functionality in that you can specify attributes on the various
function *declarations* generated by a lambda expression, where the
current C++ grammar only allows attributes which apply to the various
function *types* so generated.

This patch implements P2173 on the assumption that it will be adopted
by WG21 with this syntax for C++23.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/lib/Parse/ParseExprCXX.cpp
clang/test/AST/ast-dump-lambda.cpp
clang/test/Parser/cxx0x-lambda-expressions.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 14632210c818..34876e9945b5 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -269,6 +269,9 @@ def CXXPre17CompatPedantic : 
DiagGroup<"c++98-c++11-c++14-compat-pedantic",
 def CXXPre20Compat : DiagGroup<"c++98-c++11-c++14-c++17-compat">;
 def CXXPre20CompatPedantic : 
DiagGroup<"c++98-c++11-c++14-c++17-compat-pedantic",
[CXXPre20Compat]>;
+def CXXPre2bCompat : DiagGroup<"pre-c++2b-compat">;
+def CXXPre2bCompatPedantic :
+  DiagGroup<"pre-c++2b-compat-pedantic", [CXXPre2bCompat]>;
 
 def CXX98CompatBindToTemporaryCopy :
   DiagGroup<"c++98-compat-bind-to-temporary-copy">;
@@ -282,7 +285,8 @@ def CXX98Compat : DiagGroup<"c++98-compat",
  CXX98CompatUnnamedTypeTemplateArgs,
  CXXPre14Compat,
  CXXPre17Compat,
- CXXPre20Compat]>;
+ CXXPre20Compat,
+ CXXPre2bCompat]>;
 // Warnings for C++11 features which are Extensions in C++98 mode.
 def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic",
 [CXX98Compat,
@@ -290,7 +294,8 @@ def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic",
  CXX98CompatExtraSemi,
  CXXPre14CompatPedantic,
  CXXPre17CompatPedantic,
- CXXPre20CompatPedantic]>;
+ CXXPre20CompatPedantic,
+ CXXPre2bCompatPedantic]>;
 
 def CXX11Narrowing : DiagGroup<"c++11-narrowing">;
 
@@ -319,33 +324,40 @@ def CXX11Compat : DiagGroup<"c++11-compat",
  CXX11CompatDeprecatedWritableStr,
  CXXPre14Compat,
  CXXPre17Compat,
- CXXPre20Compat]>;
+ CXXPre20Compat,
+ CXXPre2bCompat]>;
 def : DiagGroup<"c++0x-compat", [CXX11Compat]>;
 def CXX11CompatPedantic : DiagGroup<"c++11-compat-pedantic",
 [CXX11Compat,
  CXXPre14CompatPedantic,
  CXXPre17CompatPedantic,
- CXXPre20CompatPedantic]>;
+ CXXPre20CompatPedantic,
+ CXXPre2bCompatPedantic]>;
 
 def CXX14Compat : DiagGroup<"c++14-compat", [CXXPre17Compat,
- CXXPre20Compat]>;
+ CXXPre20Compat,
+ CXXPre2bCompat]>;
 def CXX14CompatPedantic : DiagGroup<"c++14-compat-pedantic",
 [CXX14Compat,
  CXXPre17CompatPedantic,
- CXXPre20CompatPedantic]>;
+ CXXPre20CompatPedantic,
+ CXXPre2bCompatPedantic]>;
 
 def CXX17Compat : DiagGroup<"c++17-compat", [DeprecatedRegister,
  DeprecatedIncrementBool,
  CXX17CompatMangling,
- CXXPre20Compat]>;
+ CXXPre20Compat,
+ CXXPre2bCompat]>;
 def CXX17CompatPedantic : DiagGroup<"c++17-compat-pedantic",
 [CXX17Comp

[PATCH] D95691: Implement P2173 for attributes on lambdas

2021-03-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I've commit in b2bc0a32545f9b066fed1631c6fba92a2a5a6d84 
 and will 
work on a patch for the remainder of the diagnostic groups. Thanks for the 
reviews!


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

https://reviews.llvm.org/D95691

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


[clang] cc3d25b - [clang][patch] To solve PR26413, x86 interrupt routines may only call routines with no_saved_reg

2021-03-03 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-03-03T10:11:13-05:00
New Revision: cc3d25be0116fc3cc41a08f8bf9eef73d6dc5d62

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

LOG: [clang][patch] To solve PR26413, x86 interrupt routines may only call 
routines with no_saved_reg

Reviewed By: Aaron Ballman

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/arm-interrupt-attr.c
clang/test/Sema/attr-x86-interrupt.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 481ed57c0b58..1ffc9884013d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,6 +293,9 @@ def err_anyx86_interrupt_attribute : Error<
   "a pointer as the first parameter|a %2 type as the second parameter}1">;
 def err_anyx86_interrupt_called : Error<
   "interrupt service routine cannot be called directly">;
+def err_anyx86_interrupt_regsave : Error<
+  "interrupt service routine may only call a function"
+  " with attribute 'no_caller_saved_registers'">;
 def warn_arm_interrupt_calling_convention : Warning<
"call to function without interrupt attribute could clobber interruptee's 
VFP registers">,
InGroup;

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 98097b6fb381..79dd3c0c1184 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6552,12 +6552,25 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, 
NamedDecl *NDecl,
   // so there's some risk when calling out to non-interrupt handler functions
   // that the callee might not preserve them. This is easy to diagnose here,
   // but can be very challenging to debug.
-  if (auto *Caller = getCurFunctionDecl())
+  // Likewise, X86 interrupt handlers may only call routines with attribute
+  // no_caller_saved_registers since there is no efficient way to
+  // save and restore the non-GPR state.
+  if (auto *Caller = getCurFunctionDecl()) {
 if (Caller->hasAttr()) {
   bool VFP = Context.getTargetInfo().hasFeature("vfp");
-  if (VFP && (!FDecl || !FDecl->hasAttr()))
+  if (VFP && (!FDecl || !FDecl->hasAttr())) {
 Diag(Fn->getExprLoc(), diag::warn_arm_interrupt_calling_convention);
+if (FDecl)
+  Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
+  }
+}
+if (Caller->hasAttr() &&
+((!FDecl || !FDecl->hasAttr( {
+  Diag(Fn->getExprLoc(), diag::err_anyx86_interrupt_regsave);
+  if (FDecl)
+Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 }
+  }
 
   // Promote the function operand.
   // We special-case function promotion here because we only allow promoting

diff  --git a/clang/test/Sema/arm-interrupt-attr.c 
b/clang/test/Sema/arm-interrupt-attr.c
index 60691ab7f8e8..5a844d0e2d79 100644
--- a/clang/test/Sema/arm-interrupt-attr.c
+++ b/clang/test/Sema/arm-interrupt-attr.c
@@ -19,6 +19,9 @@ __attribute__((interrupt)) void foo8() {}
 __attribute__((interrupt())) void foo9() {}
 __attribute__((interrupt(""))) void foo10() {}
 
+#ifndef SOFT
+// expected-note@+2 {{'callee1' declared here}}
+#endif
 void callee1();
 __attribute__((interrupt("IRQ"))) void callee2();
 void caller1() {

diff  --git a/clang/test/Sema/attr-x86-interrupt.c 
b/clang/test/Sema/attr-x86-interrupt.c
index 0785fdfcb1b3..952433e2cb8a 100644
--- a/clang/test/Sema/attr-x86-interrupt.c
+++ b/clang/test/Sema/attr-x86-interrupt.c
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -triple x86_64-pc-win32  -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple i386-pc-win32  -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnux32  -fsyntax-only -verify 
%s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu  -fsyntax-only -verify %s 
-DNOCALLERSAVE=1
 
 struct a {
   int b;
@@ -39,6 +40,23 @@ __attribute__((interrupt)) void foo6(float *a, int b) {}
 __attribute__((interrupt)) void foo7(int *a, unsigned b) {}
 __attribute__((interrupt)) void foo8(int *a) {}
 
+#ifdef _LP64
+typedef unsigned long Arg2Type;
+#elif defined(__x86_64__)
+typedef unsigned long long Arg2Type;
+#else
+typedef unsigned int Arg2Type;
+#endif
+#ifndef NOCALLERSAVE
+__attribute__((no_caller_saved_registers))
+#else
+// expected-note@+3 {{'foo9' declared here}}
+// expected-error@+4 {{interrupt service routine may only call a function with 
attribute 'no_caller_saved_registers'}}
+#endif
+void foo9(int *a, Arg2Type b) {}
+__attribute__((interrupt)) void fooA(int *a, Arg2Type b) {
+  foo9(a, b);
+}
 void g(void (*fp)(int *));
 int main(int argc, char **argv) {
   void *ptr = (void *)&foo7;



[PATCH] D97764: [clang][patch] To solve PR26413, x86 interrupt routines may only call routines with no_saved_reg

2021-03-03 Thread Melanie Blower 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 rGcc3d25be0116: [clang][patch] To solve PR26413, x86 interrupt 
routines may only call routines… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97764

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/arm-interrupt-attr.c
  clang/test/Sema/attr-x86-interrupt.c


Index: clang/test/Sema/attr-x86-interrupt.c
===
--- clang/test/Sema/attr-x86-interrupt.c
+++ clang/test/Sema/attr-x86-interrupt.c
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -triple x86_64-pc-win32  -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple i386-pc-win32  -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnux32  -fsyntax-only -verify 
%s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu  -fsyntax-only -verify %s 
-DNOCALLERSAVE=1
 
 struct a {
   int b;
@@ -39,6 +40,23 @@
 __attribute__((interrupt)) void foo7(int *a, unsigned b) {}
 __attribute__((interrupt)) void foo8(int *a) {}
 
+#ifdef _LP64
+typedef unsigned long Arg2Type;
+#elif defined(__x86_64__)
+typedef unsigned long long Arg2Type;
+#else
+typedef unsigned int Arg2Type;
+#endif
+#ifndef NOCALLERSAVE
+__attribute__((no_caller_saved_registers))
+#else
+// expected-note@+3 {{'foo9' declared here}}
+// expected-error@+4 {{interrupt service routine may only call a function with 
attribute 'no_caller_saved_registers'}}
+#endif
+void foo9(int *a, Arg2Type b) {}
+__attribute__((interrupt)) void fooA(int *a, Arg2Type b) {
+  foo9(a, b);
+}
 void g(void (*fp)(int *));
 int main(int argc, char **argv) {
   void *ptr = (void *)&foo7;
Index: clang/test/Sema/arm-interrupt-attr.c
===
--- clang/test/Sema/arm-interrupt-attr.c
+++ clang/test/Sema/arm-interrupt-attr.c
@@ -19,6 +19,9 @@
 __attribute__((interrupt())) void foo9() {}
 __attribute__((interrupt(""))) void foo10() {}
 
+#ifndef SOFT
+// expected-note@+2 {{'callee1' declared here}}
+#endif
 void callee1();
 __attribute__((interrupt("IRQ"))) void callee2();
 void caller1() {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6552,12 +6552,25 @@
   // so there's some risk when calling out to non-interrupt handler functions
   // that the callee might not preserve them. This is easy to diagnose here,
   // but can be very challenging to debug.
-  if (auto *Caller = getCurFunctionDecl())
+  // Likewise, X86 interrupt handlers may only call routines with attribute
+  // no_caller_saved_registers since there is no efficient way to
+  // save and restore the non-GPR state.
+  if (auto *Caller = getCurFunctionDecl()) {
 if (Caller->hasAttr()) {
   bool VFP = Context.getTargetInfo().hasFeature("vfp");
-  if (VFP && (!FDecl || !FDecl->hasAttr()))
+  if (VFP && (!FDecl || !FDecl->hasAttr())) {
 Diag(Fn->getExprLoc(), diag::warn_arm_interrupt_calling_convention);
+if (FDecl)
+  Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
+  }
+}
+if (Caller->hasAttr() &&
+((!FDecl || !FDecl->hasAttr( {
+  Diag(Fn->getExprLoc(), diag::err_anyx86_interrupt_regsave);
+  if (FDecl)
+Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 }
+  }
 
   // Promote the function operand.
   // We special-case function promotion here because we only allow promoting
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,6 +293,9 @@
   "a pointer as the first parameter|a %2 type as the second parameter}1">;
 def err_anyx86_interrupt_called : Error<
   "interrupt service routine cannot be called directly">;
+def err_anyx86_interrupt_regsave : Error<
+  "interrupt service routine may only call a function"
+  " with attribute 'no_caller_saved_registers'">;
 def warn_arm_interrupt_calling_convention : Warning<
"call to function without interrupt attribute could clobber interruptee's 
VFP registers">,
InGroup;


Index: clang/test/Sema/attr-x86-interrupt.c
===
--- clang/test/Sema/attr-x86-interrupt.c
+++ clang/test/Sema/attr-x86-interrupt.c
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -triple x86_64-pc-win32  -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple i386-pc-win32  -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnux32  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu  -fsyntax-only -verify %s -DNOCALLERSAV

[PATCH] D97805: [clang-query] Add option to enable only displaying main file matches

2021-03-03 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clang-query/Query.cpp:60-61
+"main-file-only  "
+"Only match nodes from the main source file. This mode is the "
+"default.\n"
 "  set output   "

aaron.ballman wrote:
> I'm not super keen on this being the default behavior. One of the big uses 
> for clang-query is to experiment with matchers and I think ignoring nodes by 
> default makes it harder to know whether you've written the matcher correctly 
> or not. e.g., you write the matcher, run it over a source file, don't get any 
> results -- is that because the matcher was nonsense or because the mode 
> excluded matching on nodes in headers by default?
> 
> The fact that we print how many nodes were skipped does help (so it's not a 
> silent when you match only in headers), but I think the default behavior 
> should be to match on what's in the source code (which includes header 
> contents) and users should have to opt into getting less results. WDYT?
I thought of making main-file-only the default as its the behaviour that 
clang-tidy exhibits by default. That's also the reason I included printing 
details of skipped matching nodes. But you're right there's definitely a 
compelling argument to leave the default as matching from header files as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97805

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


[PATCH] D96344: [flang][driver] Add options for -fdefault* and -flarge-sizes

2021-03-03 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 327789.
arnamoy10 added a comment.
Herald added a subscriber: mgorny.

Fixing build failures, also moved the pipeline check to an existing file.


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

https://reviews.llvm.org/D96344

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/fdefault.f90
  flang/test/Flang-Driver/flarge_sizes.f90
  flang/test/Flang-Driver/frontend-forwarding.f90
  flang/unittests/Frontend/CMakeLists.txt

Index: flang/unittests/Frontend/CMakeLists.txt
===
--- flang/unittests/Frontend/CMakeLists.txt
+++ flang/unittests/Frontend/CMakeLists.txt
@@ -10,4 +10,5 @@
   flangFrontendTool
   FortranParser
   FortranSemantics
+  FortranCommon
 )
Index: flang/test/Flang-Driver/frontend-forwarding.f90
===
--- flang/test/Flang-Driver/frontend-forwarding.f90
+++ flang/test/Flang-Driver/frontend-forwarding.f90
@@ -5,6 +5,14 @@
 
 ! RUN: %flang-new -fsyntax-only -### %s -o %t 2>&1 \
 ! RUN: -finput-charset=utf-8 \
+! RUN: -fdefault-double-8 \
+! RUN: -fdefault-integer-8 \
+! RUN: -fdefault-real-8 \
+! RUN: -flarge-sizes \
 ! RUN:   | FileCheck %s
 
 ! CHECK: "-finput-charset=utf-8"
+! CHECK: "-fdefault-double-8"
+! CHECK: "-fdefault-integer-8"
+! CHECK: "-fdefault-real-8"
+! CHECK: "-flarge-sizes"
Index: flang/test/Flang-Driver/flarge_sizes.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/flarge_sizes.f90
@@ -0,0 +1,36 @@
+! Ensure argument -flarge-sizes works as expected.
+! TODO: Add checks when actual codegen is possible.
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: rm -rf %t/dir-flang-new  && mkdir -p %t/dir-flang-new && %flang -fsyntax-only -module-dir %t/dir-flang-new %s  2>&1
+! RUN: cat %t/dir-flang-new/m.mod | FileCheck %s --check-prefix=NOLARGE
+! RUN: rm -rf %t/dir-flang-new  && mkdir -p %t/dir-flang-new && %flang -fsyntax-only -flarge-sizes -module-dir %t/dir-flang-new %s  2>&1
+! RUN: cat %t/dir-flang-new/m.mod | FileCheck %s --check-prefix=LARGE
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: rm -rf %t/dir-flang-new  && mkdir -p %t/dir-flang-new && %flang_fc1 -fsyntax-only -module-dir %t/dir-flang-new %s  2>&1
+! RUN: cat %t/dir-flang-new/m.mod | FileCheck %s --check-prefix=NOLARGE
+! RUN: rm -rf %t/dir-flang-new  && mkdir -p %t/dir-flang-new && %flang_fc1 -fsyntax-only -flarge-sizes -module-dir %t/dir-flang-new %s  2>&1
+! RUN: cat %t/dir-flang-new/m.mod | FileCheck %s --check-prefix=LARGE
+
+!-
+! EXPECTED OUTPUT WITHOUT -flarge-sizes
+!-
+! NOLARGE: real(4)::z(1_8:10_8)
+! NOLARGE-NEXT: integer(4),parameter::size_kind=4_4
+
+!-
+! EXPECTED OUTPUT FOR -flarge-sizes
+!-
+! LARGE: real(4)::z(1_8:10_8)
+! LARGE-NEXT: integer(4),parameter::size_kind=8_4
+
+module m
+  implicit none
+  real :: z(10)
+  integer, parameter :: size_kind = kind(ubound(z, 1)) !-flarge-sizes
+end
Index: flang/test/Flang-Driver/fdefault.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/fdefault.f90
@@ -0,0 +1,61 @@
+! Ensure argument -fdefault* work as expected.
+! TODO: Add checks when actual codegen is possible for this family
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: rm -rf %t/dir-flang-new  && mkdir -p %t/dir-flang-new && %flang -fsyntax-only -module-dir %t/dir-flang-new %s  2>&1
+! RUN: cat %t/dir-flang-new/m.mod | FileCheck %s --check-prefix=NOOPTION
+! RUN: rm -rf %t/dir-flang-new  && mkdir -p %t/dir-flang-new && %flang -fsyntax-only -fdefault-real-8 -module-dir %t/dir-flang-new %s  2>&1
+! RUN: cat %t/dir-flang-new/m.mod | FileCheck %s --check-prefix=REAL8
+! RUN: rm -rf %t/dir-flang-new  && mkdir -p %t/dir-flang-new && %flang -fsyntax-only -fdefault-real-8 -fdefault-double-8 -module-dir %t/dir-flang-new %s  2>&1
+! RUN: cat %t/dir-flang-new/m.mod | FileCheck %s --check-prefix=DOUBLE8
+! RUN: not %flang -fsyntax-only -fdefault-double-8 %s  2>&1 | FileCheck %s --check-prefix=ERROR
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: rm -rf %t/dir-flang-new  && mkdir -p %t/dir-flang-new && %flang_fc1 -fsyntax-only -module-dir %t/dir-flang-new %s  2>&1
+! RUN: cat %t/dir-flang-new/m.mod | FileCheck %s -

[PATCH] D97785: [SystemZ][z/OS] Distinguish between text and binary files on z/OS

2021-03-03 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 327790.
abhina.sreeskantharajan added a comment.

Remove some changes that cause lit failures.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97785

Files:
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/tools/arcmt-test/arcmt-test.cpp
  llvm/include/llvm/Support/FileSystem.h
  llvm/include/llvm/Support/MemoryBuffer.h
  llvm/lib/IRReader/IRReader.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/ToolOutputFile.cpp
  llvm/lib/TableGen/Main.cpp
  llvm/utils/FileCheck/FileCheck.cpp

Index: llvm/utils/FileCheck/FileCheck.cpp
===
--- llvm/utils/FileCheck/FileCheck.cpp
+++ llvm/utils/FileCheck/FileCheck.cpp
@@ -803,7 +803,9 @@
 
   // Read the expected strings from the check file.
   ErrorOr> CheckFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(CheckFilename);
+  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*FileSize*/ -1,
+   /*RequiresNullTerminator*/ true,
+   /*IsText*/ true);
   if (std::error_code EC = CheckFileOrErr.getError()) {
 errs() << "Could not open check file '" << CheckFilename
<< "': " << EC.message() << '\n';
@@ -825,7 +827,9 @@
 
   // Open the file to check and add it to SourceMgr.
   ErrorOr> InputFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize*/ -1,
+   /*RequiresNullTerminator*/ true,
+   /*IsText*/ true);
   if (InputFilename == "-")
 InputFilename = ""; // Overwrite for improved diagnostic messages
   if (std::error_code EC = InputFileOrErr.getError()) {
Index: llvm/lib/TableGen/Main.cpp
===
--- llvm/lib/TableGen/Main.cpp
+++ llvm/lib/TableGen/Main.cpp
@@ -70,7 +70,7 @@
 return reportError(argv0, "the option -d must be used together with -o\n");
 
   std::error_code EC;
-  ToolOutputFile DepOut(DependFilename, EC, sys::fs::OF_None);
+  ToolOutputFile DepOut(DependFilename, EC, sys::fs::OF_Text);
   if (EC)
 return reportError(argv0, "error opening " + DependFilename + ":" +
   EC.message() + "\n");
@@ -93,7 +93,7 @@
 
   Records.startTimer("Parse, build records");
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, -1, true, true);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(argv0, "Could not open input file '" + InputFilename +
   "': " + EC.message() + "\n");
@@ -137,13 +137,14 @@
 // Only updates the real output file if there are any differences.
 // This prevents recompilation of all the files depending on it if there
 // aren't any.
-if (auto ExistingOrErr = MemoryBuffer::getFile(OutputFilename))
+if (auto ExistingOrErr = MemoryBuffer::getFile(OutputFilename, -1,
+   true, false, true))
   if (std::move(ExistingOrErr.get())->getBuffer() == Out.str())
 WriteFile = false;
   }
   if (WriteFile) {
 std::error_code EC;
-ToolOutputFile OutFile(OutputFilename, EC, sys::fs::OF_None);
+ToolOutputFile OutFile(OutputFilename, EC, sys::fs::OF_Text);
 if (EC)
   return reportError(argv0, "error opening " + OutputFilename + ": " +
 EC.message() + "\n");
Index: llvm/lib/Support/ToolOutputFile.cpp
===
--- llvm/lib/Support/ToolOutputFile.cpp
+++ llvm/lib/Support/ToolOutputFile.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "llvm/Support/ToolOutputFile.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Signals.h"
 using namespace llvm;
@@ -45,7 +46,12 @@
 EC = std::error_code();
 return;
   }
-  OSHolder.emplace(Filename, EC, Flags);
+
+  llvm::Triple HostTriple(LLVM_HOST_TRIPLE);
+  // On Windows, we set the OF_None flag even for text files to avoid
+  // CRLF translation.
+  OSHolder.emplace(Filename, EC,
+   HostTriple.isOSWindows() ? sys::fs::OF_None : Flags);
   OS = OSHolder.getPointer();
   // If open fails, no cleanup is needed.
   if (EC)
Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -816,13 +816,7 @@
 
 std::error_code createUniqueFile(const Twine &Model, int &ResultFd,
  SmallVectorImpl &ResultPath,
-   

[PATCH] D97849: [AST][PCH][ASTImporter] Fix UB caused by uninited SwitchStmt member

2021-03-03 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

We can (and do) run LIT tests under valgrind, so if you have a test that 
triggers this valgrind error then that seems like the way to go. I don't think 
the test has to deterministically fail outside valgrind to be a valid test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97849

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


[clang] 9403b59 - [test] Fix apparent typo in clang/test/Driver/std.c

2021-03-03 Thread Abhina Sreeskantharajan via cfe-commits

Author: Daniel McIntosh
Date: 2021-03-03T10:31:47-05:00
New Revision: 9403b59a7dbbf35714b5786df0e535281b926746

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

LOG: [test] Fix apparent typo in clang/test/Driver/std.c

Currently the test on line 3 is identical to the test on line 1.
Looking at the rest of the file (particularily the use of FOVERRIDE
as the check-prefix), I think it's pretty clear that this line
was supposed to use `-ftrigraphs` instead of `-trigraphs`.

Reviewed By: thakis

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

Added: 


Modified: 
clang/test/Driver/std.c

Removed: 




diff  --git a/clang/test/Driver/std.c b/clang/test/Driver/std.c
index 02dca6698d34..54f746cc63d0 100644
--- a/clang/test/Driver/std.c
+++ b/clang/test/Driver/std.c
@@ -1,6 +1,6 @@
 // RUN: %clang -w -std=c99 -trigraphs -std=gnu99 %s -E -o - | FileCheck 
-check-prefix=OVERRIDE %s
 // OVERRIDE: ??(??)
-// RUN: %clang -w -std=c99 -trigraphs -std=gnu99 %s -E -o - | FileCheck 
-check-prefix=FOVERRIDE %s
+// RUN: %clang -w -std=c99 -ftrigraphs -std=gnu99 %s -E -o - | FileCheck 
-check-prefix=FOVERRIDE %s
 // FOVERRIDE: ??(??)
 // RUN: %clang -w -ansi %s -E -o - | FileCheck -check-prefix=ANSI %s
 // ANSI: []



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


[PATCH] D97796: [test] Fix apparent typo in clang/test/Driver/std.c

2021-03-03 Thread Abhina Sree 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 rG9403b59a7dbb: [test] Fix apparent typo in 
clang/test/Driver/std.c (authored by DanielMcIntosh-IBM, committed by 
abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97796

Files:
  clang/test/Driver/std.c


Index: clang/test/Driver/std.c
===
--- clang/test/Driver/std.c
+++ clang/test/Driver/std.c
@@ -1,6 +1,6 @@
 // RUN: %clang -w -std=c99 -trigraphs -std=gnu99 %s -E -o - | FileCheck 
-check-prefix=OVERRIDE %s
 // OVERRIDE: ??(??)
-// RUN: %clang -w -std=c99 -trigraphs -std=gnu99 %s -E -o - | FileCheck 
-check-prefix=FOVERRIDE %s
+// RUN: %clang -w -std=c99 -ftrigraphs -std=gnu99 %s -E -o - | FileCheck 
-check-prefix=FOVERRIDE %s
 // FOVERRIDE: ??(??)
 // RUN: %clang -w -ansi %s -E -o - | FileCheck -check-prefix=ANSI %s
 // ANSI: []


Index: clang/test/Driver/std.c
===
--- clang/test/Driver/std.c
+++ clang/test/Driver/std.c
@@ -1,6 +1,6 @@
 // RUN: %clang -w -std=c99 -trigraphs -std=gnu99 %s -E -o - | FileCheck -check-prefix=OVERRIDE %s
 // OVERRIDE: ??(??)
-// RUN: %clang -w -std=c99 -trigraphs -std=gnu99 %s -E -o - | FileCheck -check-prefix=FOVERRIDE %s
+// RUN: %clang -w -std=c99 -ftrigraphs -std=gnu99 %s -E -o - | FileCheck -check-prefix=FOVERRIDE %s
 // FOVERRIDE: ??(??)
 // RUN: %clang -w -ansi %s -E -o - | FileCheck -check-prefix=ANSI %s
 // ANSI: []
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97823: Update default arch on AIX

2021-03-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:405
+  T.getOSVersion(major, minor, micro);
+  TargetCPUName = major == 7 && minor < 2 ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)

jsji wrote:
> jsji wrote:
> > Please add comments here about AIX 7.2's minimal arch is P7.
> `major == 7 ` should this be `major <= 7 `? Or else, we may get `pwr7` for 
> AIX 5.1.
That's a great idea. Although I think we'd need to change `major == 7 && minor 
< 2` to `major < 7 || minor < 2` to also handle 4.3 and 5.3 properly. Let me 
know if you have further comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97823

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


[PATCH] D97823: Update default arch on AIX

2021-03-03 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:403
+if (T.isOSAIX()) {
+  unsigned major, minor, micro;
+  T.getOSVersion(major, minor, micro);

`micro` unsed.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:405
+  T.getOSVersion(major, minor, micro);
+  TargetCPUName = major == 7 && minor < 2 ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)

stevewan wrote:
> jsji wrote:
> > jsji wrote:
> > > Please add comments here about AIX 7.2's minimal arch is P7.
> > `major == 7 ` should this be `major <= 7 `? Or else, we may get `pwr7` for 
> > AIX 5.1.
> That's a great idea. Although I think we'd need to change `major == 7 && 
> minor < 2` to `major < 7 || minor < 2` to also handle 4.3 and 5.3 properly. 
> Let me know if you have further comments.
`major < 7 || minor < 2` will have problem with AIX 8.1 later if we have AIX 8.

Maybe it is better to use
` (major < 7 || (major == 7 && minor < 2))? "pwr4": "pwr7"`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97823

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


[PATCH] D97823: Update default arch on AIX

2021-03-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 327798.
stevewan added a comment.

Address comments with regard to handling older AIX versions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97823

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-mcpu-default.c


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,13 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, micro;
+  T.getOSVersion(major, minor, micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName = major < 7 || minor < 2 ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,13 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, micro;
+  T.getOSVersion(major, minor, micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName = major < 7 || minor < 2 ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
h

[clang] 66799bf - [AIX][clang][driver] Restrict /usr/lib to internal library search paths

2021-03-03 Thread David Tenty via cfe-commits

Author: David Tenty
Date: 2021-03-03T10:48:35-05:00
New Revision: 66799bf0e281099f05b781e5279a7025b1e365cf

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

LOG: [AIX][clang][driver] Restrict /usr/lib to internal library search paths

Adding it to the general filepaths results in it being added to the
linker arguments. The AIX linker always looks in this path anyway
and adds it as a default library path component. Adding this duplicate
explicitly results in duplicate entries in path in the loader section
of executables and messes up tools like CMake that parse the default
library flags.

Reviewed By: ZarkoCA

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/AIX.cpp
clang/test/Driver/aix-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 36fe578fcb3d..6cd12e16ec02 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -176,7 +176,7 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 /// AIX - AIX tool chain which can call as(1) and ld(1) directly.
 AIX::AIX(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
 : ToolChain(D, Triple, Args) {
-  getFilePaths().push_back(getDriver().SysRoot + "/usr/lib");
+  getLibraryPaths().push_back(getDriver().SysRoot + "/usr/lib");
 }
 
 // Returns the effective header sysroot path to use.

diff  --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index 6abfa10c92f6..467374b93720 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -17,7 +17,6 @@
 // CHECK-LD32: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
 // CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
-// CHECK-LD32: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-NOT: "-lc++"
 // CHECK-LD32: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-NOT: "-lm"
@@ -39,7 +38,6 @@
 // CHECK-LD64: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
 // CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
-// CHECK-LD64: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-NOT: "-lc++"
 // CHECK-LD64: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64-NOT: "-lm"
@@ -62,7 +60,6 @@
 // CHECK-LD32-PTHREAD: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
 // CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
-// CHECK-LD32-PTHREAD: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PTHREAD-NOT: "-lc++"
 // CHECK-LD32-PTHREAD: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-PTHREAD: "-lpthreads"
@@ -86,7 +83,6 @@
 // CHECK-LD64-PTHREAD: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
 // CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
-// CHECK-LD64-PTHREAD: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-PTHREAD-NOT: "-lc++"
 // CHECK-LD64-PTHREAD: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64-PTHREAD: "-lpthreads"
@@ -110,7 +106,6 @@
 // CHECK-LD32-PROF: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-PROF: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
 // CHECK-LD32-PROF: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
-// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PROF-NOT: "-lc++"
 // CHECK-LD32-PROF: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-PROF-NOT: "-lm"
@@ -133,7 +128,6 @@
 // CHECK-LD64-GPROF: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-GPROF: "[[SYSROOT]]/usr/lib{{/|}}gcrt0_64.o"
 // CHECK-LD64-GPROF: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
-// CHECK-LD64-GPROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-GPROF-NOT: "-lc++"
 // CHECK-LD64-GPROF: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64-GPROF-NOT: "-lm"
@@ -156,7 +150,6 @@
 // CHECK-LD32-STATIC: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-STATIC: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
 // CHECK-LD32-STATIC: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
-// CHECK-LD32-STATIC: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-STATIC-NOT: "-lc++"
 // CHECK-LD32-STATIC: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-STATIC-NOT: "-lm"
@@ -180,7 +173,6 @@
 // CHECK-LD32-LIBP: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
 // CHECK-LD3

[PATCH] D97574: [AIX][clang][driver] Restrict /usr/lib to internal library search paths

2021-03-03 Thread David Tenty via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG66799bf0e281: [AIX][clang][driver] Restrict /usr/lib to 
internal library search paths (authored by daltenty).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97574

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -17,7 +17,6 @@
 // CHECK-LD32: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
 // CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
-// CHECK-LD32: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-NOT: "-lc++"
 // CHECK-LD32: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-NOT: "-lm"
@@ -39,7 +38,6 @@
 // CHECK-LD64: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
 // CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
-// CHECK-LD64: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-NOT: "-lc++"
 // CHECK-LD64: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64-NOT: "-lm"
@@ -62,7 +60,6 @@
 // CHECK-LD32-PTHREAD: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
 // CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
-// CHECK-LD32-PTHREAD: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PTHREAD-NOT: "-lc++"
 // CHECK-LD32-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-PTHREAD: "-lpthreads"
@@ -86,7 +83,6 @@
 // CHECK-LD64-PTHREAD: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
 // CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
-// CHECK-LD64-PTHREAD: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-PTHREAD-NOT: "-lc++"
 // CHECK-LD64-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64-PTHREAD: "-lpthreads"
@@ -110,7 +106,6 @@
 // CHECK-LD32-PROF: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-PROF: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
 // CHECK-LD32-PROF: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
-// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PROF-NOT: "-lc++"
 // CHECK-LD32-PROF: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-PROF-NOT: "-lm"
@@ -133,7 +128,6 @@
 // CHECK-LD64-GPROF: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-GPROF: "[[SYSROOT]]/usr/lib{{/|}}gcrt0_64.o"
 // CHECK-LD64-GPROF: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
-// CHECK-LD64-GPROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-GPROF-NOT: "-lc++"
 // CHECK-LD64-GPROF: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64-GPROF-NOT: "-lm"
@@ -156,7 +150,6 @@
 // CHECK-LD32-STATIC: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-STATIC: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
 // CHECK-LD32-STATIC: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
-// CHECK-LD32-STATIC: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-STATIC-NOT: "-lc++"
 // CHECK-LD32-STATIC: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-STATIC-NOT: "-lm"
@@ -180,7 +173,6 @@
 // CHECK-LD32-LIBP: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
 // CHECK-LD32-LIBP: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-LIBP: "-L[[SYSROOT]]/powerpc-ibm-aix7.1.0.0"
-// CHECK-LD32-LIBP: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-LIBP-NOT: "-lc++"
 // CHECK-LD32-LIBP: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-LIBP-NOT: "-lm"
@@ -204,7 +196,6 @@
 // CHECK-LD32-NO-STD-LIB: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-NO-STD-LIB-NOT: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
 // CHECK-LD32-NO-STD-LIB-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
-// CHECK-LD32-NO-STD-LIB: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-NO-STD-LIB-NOT: "-lc++"
 // CHECK-LD32-NO-STD-LIB-NOT: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-NO-STD-LIB-NOT: "-lpthreads"
@@ -229,7 +220,6 @@
 // CHECK-LD64-NO-DEFAULT-LIBS: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-NO-DEFAULT-LIBS: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
 // CHECK-LD64-NO-DEFAULT-LIBS: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
-// CHECK-LD64-NO-DEFAULT-LIBS: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc++"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-po

[clang-tools-extra] e7080aa - [clang-query] Fix help text after D91918

2021-03-03 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-03-03T15:57:49Z
New Revision: e7080aa2253356effed6c381313a93ec2420b44a

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

LOG: [clang-query] Fix help text after D91918

After rG5e1801813d93210acae84ff3c68a01512c2df9bc The help command still lists 
IgnoreImplicitCastsAndParentheses as a valid option.

Reviewed By: aaron.ballman, rsmith

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

Added: 


Modified: 
clang-tools-extra/clang-query/Query.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-query/Query.cpp 
b/clang-tools-extra/clang-query/Query.cpp
index e33612a2e16d..5cf24dbb58a7 100644
--- a/clang-tools-extra/clang-query/Query.cpp
+++ b/clang-tools-extra/clang-query/Query.cpp
@@ -48,8 +48,6 @@ bool HelpQuery::run(llvm::raw_ostream &OS, QuerySession &QS) 
const {
 "AsIs"
 "Print and match the AST as clang sees it.  This mode is the "
 "default.\n"
-"IgnoreImplicitCastsAndParentheses  "
-"Omit implicit casts and parens in matching and dumping.\n"
 "IgnoreUnlessSpelledInSource "
 "Omit AST nodes unless spelled in the source.\n"
 "  set output   "



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


[PATCH] D97806: [clang-query] Fix help text after D91918

2021-03-03 Thread Nathan James 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 rGe7080aa22533: [clang-query] Fix help text after D91918 
(authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97806

Files:
  clang-tools-extra/clang-query/Query.cpp


Index: clang-tools-extra/clang-query/Query.cpp
===
--- clang-tools-extra/clang-query/Query.cpp
+++ clang-tools-extra/clang-query/Query.cpp
@@ -48,8 +48,6 @@
 "AsIs"
 "Print and match the AST as clang sees it.  This mode is the "
 "default.\n"
-"IgnoreImplicitCastsAndParentheses  "
-"Omit implicit casts and parens in matching and dumping.\n"
 "IgnoreUnlessSpelledInSource "
 "Omit AST nodes unless spelled in the source.\n"
 "  set output   "


Index: clang-tools-extra/clang-query/Query.cpp
===
--- clang-tools-extra/clang-query/Query.cpp
+++ clang-tools-extra/clang-query/Query.cpp
@@ -48,8 +48,6 @@
 "AsIs"
 "Print and match the AST as clang sees it.  This mode is the "
 "default.\n"
-"IgnoreImplicitCastsAndParentheses  "
-"Omit implicit casts and parens in matching and dumping.\n"
 "IgnoreUnlessSpelledInSource "
 "Omit AST nodes unless spelled in the source.\n"
 "  set output   "
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97491: [clang-tidy] Deprecate readability-deleted-default check

2021-03-03 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG19aefd2d5dc3: [clang-tidy] Deprecate 
readability-deleted-default check (authored by njames93).

Changed prior to commit:
  https://reviews.llvm.org/D97491?vs=326449&id=327802#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97491

Files:
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-deleted-default.rst


Index: clang-tools-extra/docs/clang-tidy/checks/readability-deleted-default.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-deleted-default.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-deleted-default.rst
@@ -3,20 +3,6 @@
 readability-deleted-default
 ===
 
-Checks that constructors and assignment operators marked as ``= default`` are
-not actually deleted by the compiler.
-
-.. code-block:: c++
-
-  class Example {
-  public:
-// This constructor is deleted because I is missing a default value.
-Example() = default;
-// This is fine.
-Example(const Example& Other) = default;
-// This operator is deleted because I cannot be assigned (it is const).
-Example& operator=(const Example& Other) = default;
-
-  private:
-const int I;
-  };
+This check has been deprecated prefer to make use of the 
`Wdefaulted-function-deleted
+`_
+flag.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -112,6 +112,16 @@
   function or assignment to ``nullptr``.
   Added support for pointers to ``std::unique_ptr``.
 
+Deprecated checks
+^
+
+- The :doc:`readability-deleted-default
+  ` check has been deprecated.
+  
+  The clang warning `Wdefaulted-function-deleted
+  
`_
+  will diagnose the same issues and is enabled by default.
+
 Improvements to include-fixer
 -
 


Index: clang-tools-extra/docs/clang-tidy/checks/readability-deleted-default.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-deleted-default.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-deleted-default.rst
@@ -3,20 +3,6 @@
 readability-deleted-default
 ===
 
-Checks that constructors and assignment operators marked as ``= default`` are
-not actually deleted by the compiler.
-
-.. code-block:: c++
-
-  class Example {
-  public:
-// This constructor is deleted because I is missing a default value.
-Example() = default;
-// This is fine.
-Example(const Example& Other) = default;
-// This operator is deleted because I cannot be assigned (it is const).
-Example& operator=(const Example& Other) = default;
-
-  private:
-const int I;
-  };
+This check has been deprecated prefer to make use of the `Wdefaulted-function-deleted
+`_
+flag.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -112,6 +112,16 @@
   function or assignment to ``nullptr``.
   Added support for pointers to ``std::unique_ptr``.
 
+Deprecated checks
+^
+
+- The :doc:`readability-deleted-default
+  ` check has been deprecated.
+  
+  The clang warning `Wdefaulted-function-deleted
+  `_
+  will diagnose the same issues and is enabled by default.
+
 Improvements to include-fixer
 -
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 19aefd2 - [clang-tidy] Deprecate readability-deleted-default check

2021-03-03 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-03-03T16:01:13Z
New Revision: 19aefd2d5dc3a8d3b8e81219973828170b7fcd2c

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

LOG: [clang-tidy] Deprecate readability-deleted-default check

... For removal in next release cycle.
The clang warning that does the same thing is enabled by default and typically 
emits better diagnostics making this check surplus to requirements.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/readability-deleted-default.rst

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 77a01b2001aa..91207090902d 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -112,6 +112,16 @@ Changes in existing checks
   function or assignment to ``nullptr``.
   Added support for pointers to ``std::unique_ptr``.
 
+Deprecated checks
+^
+
+- The :doc:`readability-deleted-default
+  ` check has been deprecated.
+  
+  The clang warning `Wdefaulted-function-deleted
+  
`_
+  will diagnose the same issues and is enabled by default.
+
 Improvements to include-fixer
 -
 

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/readability-deleted-default.rst 
b/clang-tools-extra/docs/clang-tidy/checks/readability-deleted-default.rst
index 00134eb05484..5f2083e00061 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/readability-deleted-default.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability-deleted-default.rst
@@ -3,20 +3,6 @@
 readability-deleted-default
 ===
 
-Checks that constructors and assignment operators marked as ``= default`` are
-not actually deleted by the compiler.
-
-.. code-block:: c++
-
-  class Example {
-  public:
-// This constructor is deleted because I is missing a default value.
-Example() = default;
-// This is fine.
-Example(const Example& Other) = default;
-// This operator is deleted because I cannot be assigned (it is const).
-Example& operator=(const Example& Other) = default;
-
-  private:
-const int I;
-  };
+This check has been deprecated prefer to make use of the 
`Wdefaulted-function-deleted
+`_
+flag.



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


[PATCH] D97512: [clang] removes check against integral-to-pointer conversion...

2021-03-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:10326
+  !isa(
+  Cast->getSubExpr()->IgnoreImplicitAsWritten()->IgnoreParens()))
+return;

cjdb wrote:
> cjdb wrote:
> > aaron.ballman wrote:
> > > I'm not 100% certain, but would `IgnoreParenImpCasts()` be sufficient 
> > > here? (`IgnoreImplicitAsWritten() seems to be a bit special -- the only 
> > > use of it I can find in tree is for rewritten binary operator 
> > > expressions.)
> > @rsmith would you mind weighing in here please? My original use-case for 
> > `IgnoreImplicitAsWritten` might be different to here and I don't have an 
> > answer for @aaron.ballman.
> I've tried out `IgnoreParenImpCasts` and it seems to work, but I'd appreciate 
> an answer here for future patches please.
Can you rephrase your question? I'm not sure what exactly you want to know.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97512

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


[PATCH] D97823: Update default arch on AIX

2021-03-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 327803.
stevewan added a comment.

Improve handling different AIX versions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97823

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-mcpu-default.c


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,14 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, micro;
+  T.getOSVersion(major, minor, micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName =
+  (major < 7 || (major == 7 && minor < 2)) ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,14 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, micro;
+  T.getOSVersion(major, minor, micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName =
+  (major < 7 || (major == 7 && minor < 2)) ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";
___
cfe-commits mai

[PATCH] D96281: [clang-tidy] Add options to describe individual core increments to readability-function-cognitive-complexity check.

2021-03-03 Thread Jens Massberg via Phabricator via cfe-commits
massberg updated this revision to Diff 327805.
massberg added a comment.

Remove unnecessary checks.

After testing locally it turned out that we do not need these checks.
If there is an unexpected note, the test fails.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96281

Files:
  clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
  clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
@@ -0,0 +1,42 @@
+// RUN: %check_clang_tidy %s readability-function-cognitive-complexity %t -- \
+// RUN:   -config='{CheckOptions: \
+// RUN: [{key: readability-function-cognitive-complexity.Threshold, \
+// RUN:   value: 0}, \
+// RUN:  {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
+// RUN:   value: "false"} ]}'
+// RUN: %check_clang_tidy -check-suffix=THRESHOLD5 %s readability-function-cognitive-complexity %t -- \
+// RUN:   -config='{CheckOptions: \
+// RUN: [{key: readability-function-cognitive-complexity.Threshold, \
+// RUN:   value: 5}, \
+// RUN:  {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
+// RUN:   value: "false"} ]}'
+
+void func_of_complexity_4() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_of_complexity_4' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+  if (1) {
+if (1) {
+}
+  }
+  if (1) {
+  }
+}
+
+#define MacroOfComplexity10 \
+  if (1) {  \
+if (1) {\
+  if (1) {  \
+if (1) {\
+}   \
+  } \
+}   \
+  }
+
+void function_with_macro() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-THRESHOLD5: :[[@LINE-2]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 5) [readability-function-cognitive-complexity]
+
+  MacroOfComplexity10;
+
+  if (1) {
+  }
+}
Index: clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
@@ -17,6 +17,13 @@
Flag functions with Cognitive Complexity exceeding this number.
The default is `25`.
 
+.. option:: DescribeBasicIncrements
+
+   If set to `true`, then for each function exceeding the complexity threshold
+   the check will issue additional diagnostics on every piece of code (loop,
+   `if` statement, etc.) which contributes to that complexity. See also the
+   examples below. Default is `true`.
+
 Building blocks
 ---
 
@@ -135,6 +142,11 @@
 return 0;
   }
 
+In the last example, the check will flag `function3` if the option Threshold is
+set to `2` or smaller. If the option DescribeBasicIncrements is set to `true`,
+it will additionally flag the two `if` statements with the amounts by which they
+increase to the complexity of the function and the current nesting level.
+
 Limitations
 ---
 
Index: clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h
===
--- clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h
+++ clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h
@@ -17,10 +17,15 @@
 
 /// Checks function Cognitive Complexity metric.
 ///
-/// There is only one configuration option:
+/// There are the following configuration option:
 ///
 ///   * `Threshold` - flag functions with Cognitive Complexity exceeding
 /// this number. The default is `25`.
+///   * `DescribeBasicIncrements`- if set to `true`, then for each function
+/// exceeding the complexity threshold the check will issue additional
+/// diagnostics on every piece of code (loop, `if` statement, etc.) which
+/// contributes to that complexity.
+//  Default is `true`
 ///
 /// For the user-facing documentation see:
 /// http://clang.llvm.org/extra/clang-tidy/checks/readability-function-cognitive-complexity.html
@@ -37,6 +42,7 @@
 
 priva

[PATCH] D96281: [clang-tidy] Add options to describe individual core increments to readability-function-cognitive-complexity check.

2021-03-03 Thread Jens Massberg via Phabricator via cfe-commits
massberg marked an inline comment as done.
massberg added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp:16
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_of_complexity_4' has 
cognitive complexity of 4 (threshold 0) 
[readability-function-cognitive-complexity]
+  // CHECK-NOTES-THRESHOLD5-NOT: :[[@LINE-2]]:6: warning:
+  if (1) {

lebedev.ri wrote:
> Note that i'm not sure if we need negative checklines, but if we do, only 
> checking for `warning:`
> (without `@LINE` stuff) should be best.
We do not need them, so I have removed them.
If there are unexpected notes, the test fails.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96281

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


[PATCH] D96281: [clang-tidy] Add options to describe individual core increments to readability-function-cognitive-complexity check.

2021-03-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D96281#2599951 , @lebedev.ri wrote:

> If you need help committing this, please specify `name ` to be 
> used for git commit author field.






Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp:16
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_of_complexity_4' has 
cognitive complexity of 4 (threshold 0) 
[readability-function-cognitive-complexity]
+  // CHECK-NOTES-THRESHOLD5-NOT: :[[@LINE-2]]:6: warning:
+  if (1) {

massberg wrote:
> lebedev.ri wrote:
> > Note that i'm not sure if we need negative checklines, but if we do, only 
> > checking for `warning:`
> > (without `@LINE` stuff) should be best.
> We do not need them, so I have removed them.
> If there are unexpected notes, the test fails.
Great, thanks for checking!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96281

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


[PATCH] D89986: [AIX] do not emit visibility attribute into IR when there is -mignore-xcoff-visibility

2021-03-03 Thread Digger Lin via Phabricator via cfe-commits
DiggerLin updated this revision to Diff 327804.
DiggerLin added a comment.

rebased the patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89986

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/LangOptions.def
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
  clang/test/CodeGen/aix-visibility-inlines-hidden.cpp

Index: clang/test/CodeGen/aix-visibility-inlines-hidden.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-visibility-inlines-hidden.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large \
+// RUN:-fvisibility-inlines-hidden -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -fvisibility-inlines-hidden \
+// RUN:-fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=VISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -mignore-xcoff-visibility -emit-llvm \
+// RUN:-fvisibility-inlines-hidden -fvisibility default -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
+
+int x = 66;
+__attribute__((__noinline__)) inline void f() {
+  x = 55;
+}
+
+#pragma GCC visibility push(hidden)
+__attribute__((__noinline__)) inline void foo() {
+  x = 55;
+}
+#pragma GCC visibility pop
+
+int bar() {
+  f();
+  foo();
+  return x;
+}
+
+// VISIBILITY-IR: define linkonce_odr hidden void @_Z1fv()
+// NOVISIBILITY-IR:   define linkonce_odr void @_Z1fv()
+
+// VISIBILITY-IR: define linkonce_odr hidden void @_Z3foov()
+// NOVISIBILITY-IR:   define linkonce_odr void @_Z3foov()
Index: clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
===
--- clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
+++ clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
@@ -1,24 +1,8 @@
-// REQUIRES: powerpc-registered-target
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -o - -x c++ -S  %s  |\
-// RUN:   FileCheck --check-prefix=IGNOREVISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=IGNOREVISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=IGNOREVISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=VISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=IGNOREVISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=VISIBILITY-ASM %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
 // RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -emit-llvm -o - -x c++ %s  | \
-// RUN: FileCheck -check-prefix=VISIBILITY-IR %s
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
 // RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -emit-llvm -o - -x c++ %s  | \
 // RUN: FileCheck -check-prefix=VISIBILITY-IR %s
@@ -70,28 +54,11 @@
 // VISIBILITY-IR:define weak_odr protected i32 @_ZN5basicIiE7getdataEv(%class.basic* {{[^,]*}} %this)
 // VISIBILITY-IR:define hidden void @_Z7prambarv()
 
-// VISIBILITY-ASM: .globl  _Z5foo_hPi[DS],hidden
-// VISIBILITY-ASM: .globl  ._Z5foo_hPi,hidden
-// VISIBILITY-ASM: .globl  _Z3barv[DS],protected
-// VISIBILITY-ASM: .globl  ._Z3barv,protected
-// VISIBILITY-ASM: .weak   _ZNK9TestClass5valueEv[DS],hidden
-// VISIBILITY-ASM: .weak   ._ZNK9TestClass5valueEv,hidden
-// VISIBILITY-ASM: .weak   _ZN5basicIiE7getdataEv[DS],protected
-// VISIBILITY-ASM: .weak   ._ZN5basicIiE7getdataEv,protected
-// VISIBILITY-ASM: .globl  _Z7prambarv[DS],hidden
-// VISIBILITY-ASM: .globl  ._Z7prambarv,hidden
-// VISIBILITY-ASM: .globl  b,protected
-// VISIBILITY-ASM: .globl  pramb,hidden
-
-// IGNOREVISIBILITY-ASM: .globl  _Z5foo_hPi[DS]
-// IGNOREVISIBILITY-ASM: .globl  ._Z5foo_hPi
-// IGNOREVISIBILITY-ASM: .globl  _Z3barv[DS]
-// IGNOREVISIBILITY-ASM: .globl  ._Z3barv
-// IGNOREVISIBILITY-ASM: .weak   _ZNK9TestClass5valueEv[DS]
-// IGNOREVISIBILITY-ASM: .weak   ._ZNK9TestClass5valueEv
-// IGNOREVISIBILITY-ASM: .weak   _ZN5basicIiE7getdataEv[DS]
-// IGNOREVI

[PATCH] D97854: [RFC][nsan] A Floating-point numerical sanitizer.

2021-03-03 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.

When bootstrapping LLVM with nsan, there are only a few issues.

Several of them stem from using `double` to measure elapsed time in seconds: We 
measure start time, end time, and subtract them. The resulting error depends on 
the arbitrary magnitude of the time since epoch, so as time passes the error 
will increase. This is especially visible when we measure short intervals of 
time (e.g. a few microseconds, which are small compared to the time since 
epoch).

For example one test has more than 2% error:

  WARNING: NumericalStabilitySanitizer: inconsistent shadow results while 
checking store to address 0x4b87860
  double   precision  (native): dec: 0.0858306884765625  hex: 
0x1.2000p-17
  __float128   precision  (shadow): dec: 0.08806000  hex: 
0x9.3bd7b64e9fe4fc00p-20
  shadow truncated to double  : dec: 0.08806000  hex: 
0x1.277af6c9d3fca000p-17
  Relative error: 2.53158247040370201937% (2^47 epsilons)
  Absolute error: 0x1.debdb274ff27e000p-23
  (131595325226954 ULPs == 14.1 digits == 46.9 bits)
  #0 0x119db71 in llvm::TimeRecord::operator-=(llvm::TimeRecord const&) 
[...]/llvm/llvm-project/llvm/include/llvm/Support/Timer.h:63:14
  #1 0x119db71 in llvm::Timer::stopTimer() 
[...]/llvm/llvm-project/llvm/lib/Support/Timer.cpp:176:8
  #2 0x108b1d2 in llvm::TimePassesHandler::stopTimer(llvm::StringRef) 
[...]/llvm/llvm-project/llvm/lib/IR/PassTimingInfo.cpp:248:14
  #3 0x108b1d2 in llvm::TimePassesHandler::runAfterPass(llvm::StringRef) 
[...]/llvm/llvm-project/llvm/lib/IR/PassTimingInfo.cpp:267:3
  #4 0x108e159 in 
llvm::TimePassesHandler::registerCallbacks(llvm::PassInstrumentationCallbacks&)::$_2::operator()(llvm::StringRef,
 llvm::Any, llvm::PreservedAnalyses const&) const 
[...]/llvm/llvm-project/llvm/lib/IR/PassTimingInfo.cpp:281:15
  #5 0x108e159 in void llvm::detail::UniqueFunctionBase::CallImpl(void*,
 llvm::StringRef, llvm::Any&, llvm::PreservedAnalyses const&) 
[...]/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:204:12
  #6 0xa4f826 in llvm::unique_function::operator()(llvm::StringRef, llvm::Any, 
llvm::PreservedAnalyses const&) 
[...]/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:366:12
  #7 0xa4f826 in void llvm::PassInstrumentation::runAfterPass((anonymous namespace)::MyPass2 const&, 
llvm::Module const&, llvm::PreservedAnalyses const&) const 
[...]/llvm/llvm-project/llvm/include/llvm/IR/PassInstrumentation.h:227:9
  #8 0xa4f826 in (anonymous 
namespace)::TimePassesTest_CustomOut_Test::TestBody() 
[...]/llvm/llvm-project/llvm/unittests/IR/TimePassesTest.cpp:137:6
  ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97854

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


[PATCH] D95745: Support unwinding from inline assembly

2021-03-03 Thread Paul via Phabricator via cfe-commits
cynecx added a comment.

Weekly ping :)


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

https://reviews.llvm.org/D95745

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


[PATCH] D97823: Update default arch on AIX

2021-03-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:403
+if (T.isOSAIX()) {
+  unsigned major, minor, micro;
+  T.getOSVersion(major, minor, micro);

jsji wrote:
> `micro` unsed.
Sorry I missed this comment. I agree that the unused `micro` is a bit ugly, do 
you have a preference on how you'd like it to be improved? We don't have an 
existing query for only `major` and `minor`, and creating one seems unnecessary 
IMHO. If you think renaming the variable to `unused_micro` mitigates the 
problem, I can do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97823

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


[PATCH] D97857: [Matrix] Add support for matrix-by-scalar division.

2021-03-03 Thread Everton Constantino via Phabricator via cfe-commits
everton.constantino added inline comments.



Comment at: clang/test/CodeGen/matrix-type-operators.c:303
 }
 
+// CHECK-LABEL: @divide_double_matrix_scalar_float(

Shouldn't a test for half floating point be added here as well? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97857

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


[PATCH] D97823: Update default arch on AIX

2021-03-03 Thread Jinsong Ji via Phabricator via cfe-commits
jsji accepted this revision.
jsji added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:403
+if (T.isOSAIX()) {
+  unsigned major, minor, micro;
+  T.getOSVersion(major, minor, micro);

stevewan wrote:
> jsji wrote:
> > `micro` unsed.
> Sorry I missed this comment. I agree that the unused `micro` is a bit ugly, 
> do you have a preference on how you'd like it to be improved? We don't have 
> an existing query for only `major` and `minor`, and creating one seems 
> unnecessary IMHO. If you think renaming the variable to `unused_micro` 
> mitigates the problem, I can do that.
That's ok to me


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97823

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


[PATCH] D97869: [OpenCL][Draft] Add OpenCL builtin test generator

2021-03-03 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added reviewers: Anastasia, azabaznov.
Herald added subscribers: jfb, yaxunl.
svenvh requested review of this revision.

Add a new clang-tblgen flag `-gen-clang-opencl-builtin-tests` that
generates a .cl file containing calls to every builtin function
defined in the .td input.

This patch does not add any use of the new flag, so the only way to
obtain a generated test file is through a manual invocation of
clang-tblgen.


https://reviews.llvm.org/D97869

Files:
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -118,6 +118,8 @@
 
 void EmitClangOpenCLBuiltins(llvm::RecordKeeper &Records,
  llvm::raw_ostream &OS);
+void EmitClangOpenCLBuiltinTests(llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
 
 void EmitClangDataCollectors(llvm::RecordKeeper &Records,
  llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -63,6 +63,7 @@
   GenClangCommentCommandInfo,
   GenClangCommentCommandList,
   GenClangOpenCLBuiltins,
+  GenClangOpenCLBuiltinTests,
   GenArmNeon,
   GenArmFP16,
   GenArmBF16,
@@ -191,6 +192,8 @@
"documentation comments"),
 clEnumValN(GenClangOpenCLBuiltins, "gen-clang-opencl-builtins",
"Generate OpenCL builtin declaration handlers"),
+clEnumValN(GenClangOpenCLBuiltinTests, "gen-clang-opencl-builtin-tests",
+   "Generate OpenCL builtin declaration tests"),
 clEnumValN(GenArmNeon, "gen-arm-neon", "Generate arm_neon.h for clang"),
 clEnumValN(GenArmFP16, "gen-arm-fp16", "Generate arm_fp16.h for clang"),
 clEnumValN(GenArmBF16, "gen-arm-bf16", "Generate arm_bf16.h for clang"),
@@ -362,6 +365,9 @@
   case GenClangOpenCLBuiltins:
 EmitClangOpenCLBuiltins(Records, OS);
 break;
+  case GenClangOpenCLBuiltinTests:
+EmitClangOpenCLBuiltinTests(Records, OS);
+break;
   case GenClangSyntaxNodeList:
 EmitClangSyntaxNodeList(Records, OS);
 break;
Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -228,6 +228,64 @@
   // same entry ().
   MapVector SignatureListMap;
 };
+
+// OpenCL builtin test generator.  This class processes the same TableGen input
+// as BuiltinNameEmitter, but generates a .cl file that contains a call to each
+// builtin function described in the .td input.
+class OpenCLBuiltinTestEmitter {
+public:
+  OpenCLBuiltinTestEmitter(RecordKeeper &Records, raw_ostream &OS)
+  : Records(Records), OS(OS) {}
+
+  // Entrypoint to generate the functions for testing all OpenCL builtin
+  // functions.
+  void Emit();
+
+private:
+  struct TypeFlags {
+TypeFlags() : IsConst(false), IsVolatile(false), IsPointer(false) {}
+bool IsConst : 1;
+bool IsVolatile : 1;
+bool IsPointer : 1;
+StringRef AddrSpace;
+  };
+
+  // Return a string representation of the given type, such that it can be
+  // used as a type in OpenCL C code.
+  std::string getTypeString(const Record *Type, TypeFlags Flags,
+int VectorSize) const;
+
+  // Return the type(s) and vector size(s) for the given type.  For
+  // non-GenericTypes, the resulting vectors will contain 1 element.  For
+  // GenericTypes, the resulting vectors typically contain multiple elements.
+  void getTypeLists(Record *Type, TypeFlags &Flags,
+std::vector &TypeList,
+std::vector &VectorList) const;
+
+  // Expand the TableGen Records representing a builtin function signature into
+  // one or more function signatures.  Return them as a vector of a vector of
+  // strings, with each string containing an OpenCL C type and optional
+  // qualifiers.
+  //
+  // The Records may contain GenericTypes, which expand into multiple
+  // signatures.  Repeated occurrences of GenericType in a signature expand to
+  // the same types.  For example [char, FGenType, FGenType] expands to:
+  //   [char, float, float]
+  //   [char, float2, float2]
+  //   [char, float3, float3]
+  //   ...
+  void
+  expandTypesInSignature(const std::vector &Signature,
+ SmallVectorImpl> &Types);
+
+  // Contains OpenCL builtin functions and related information, stored as
+  // Record instances. They are coming from the associated TableGen file.
+  RecordKeeper &Records;
+
+  // The output file.
+  raw_ostream &O

[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-03 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D97058#2600160 , @azabaznov wrote:

> Check 'isEnabled' is now private: it is used only for non-core or 
> non-optional core features;
> creation of implicit type definitions is guarder with extension support 
> check; minor refactoring

Ok, I think we could remove further the differences between extensions and 
features wrt pragmas as suggested in the comments but it is also ok if we do 
separately. This is definitely a step closer to the end goal of simplifying and 
unifying the handling of extensions and features and removing the confusion 
about the pragmas.




Comment at: clang/lib/Sema/Sema.cpp:364
   for (auto &I : Atomic64BitTypes)
 setOpenCLExtensionForType(I,
 "cl_khr_int64_base_atomics cl_khr_int64_extended_atomics");

I think this should be lifted into the above if statement? Although since we 
are adding the types conditionally we could even drop this code completely and 
let the developers just use the types as they are already added and made 
available by the frontend.



Comment at: clang/lib/Sema/Sema.cpp:376
+addImplicitTypedef(#ExtType, Context.Id##Ty);  
\
+setOpenCLExtensionForType(Context.Id##Ty, #Ext);   
\
+  }

Since we are guarding by the feature/extension support we could even remove the 
need for pragma in order to use the types?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D97869: [OpenCL][Draft] Add OpenCL builtin test generator

2021-03-03 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

If possible to add a fragment of what is generated it would be great!


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

https://reviews.llvm.org/D97869

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


[PATCH] D97823: Update default arch on AIX

2021-03-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 327825.
stevewan added a comment.

Reflect varible is unused in its name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97823

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-mcpu-default.c


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,14 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, unused_micro;
+  T.getOSVersion(major, minor, unused_micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName =
+  (major < 7 || (major == 7 && minor < 2)) ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,14 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, unused_micro;
+  T.getOSVersion(major, minor, unused_micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName =
+  (major < 7 || (major == 7 && minor < 2)) ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";
_

[PATCH] D97101: [Coverage] Emit gap region between statements if first statements contains terminate statements.

2021-03-03 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Thanks, this looks great.




Comment at: clang/test/CoverageMapping/switch.cpp:62
   default:  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #4
 break;  // CHECK-NEXT: Branch,File 0, [[@LINE-1]]:3 -> 
[[@LINE-1]]:10 = #4, (#0 - #4)
+  }

zequanwu wrote:
> vsk wrote:
> > The blank space after `default: break;` and before the closing '}' should 
> > have the same count as the switch condition, I thought (this goes for all 
> > of the unreachable code within a switch body)? The idea is to prevent 
> > 'not-executed' regions from appearing after the `break` stmt.
> Yes, they are unreachable. So, shouldn't they always have zero count instead 
> of same count as switch condition?
I see, you're right. We use a gap region with zero count to cover the area 
after break. That's actually documented here: 
https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#switch-statements. One 
interesting point is that there's only one gap region that covers the whole 
body; in this example, that would be `Gap,File 0, [[@LINE]]:13 -> 
[[@LINE+8]]:10 = 0`. So, perhaps the new gaps emitted in switches are 
redundant, but getting rid of them is just a performance optimization.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97101

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


[PATCH] D96344: [flang][driver] Add options for -fdefault* and -flarge-sizes

2021-03-03 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski accepted this revision.
awarzynski added a comment.
This revision is now accepted and ready to land.

I tested this with `FLANG_BUILD_NEW_DRIVER` set to`On` and `Off` - all works 
fine. It's been a tricky patch @arnamoy10 , thank you for all the effort!

I believe that you've addressed all of @tskeith comments too. In my opinion 
this is ready to be merged (though I'd wait 1 day just in case).


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

https://reviews.llvm.org/D96344

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


[PATCH] D97871: Update diagnostic groups for pre-compat warnings

2021-03-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, rjmccall.
aaron.ballman requested review of this revision.
Herald added a project: clang.

As a follow-up to D95691 , add new diagnostic 
groups named `pre-c++N-compat` to replace the old diagnostic groups with the 
standards listed out explicitly. The old group names are retained for backwards 
compatibility.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97871

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/test/Parser/static_assert.c
  clang/test/SemaCXX/cxx98-compat-pedantic.cpp
  clang/test/SemaCXX/inline.cpp


Index: clang/test/SemaCXX/inline.cpp
===
--- clang/test/SemaCXX/inline.cpp
+++ clang/test/SemaCXX/inline.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s 
-Wc++98-c++11-c++14-compat
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s -Wpre-c++17-compat
 
 // Check that we don't allow illegal uses of inline
 // (checking C++-only constructs here)
Index: clang/test/SemaCXX/cxx98-compat-pedantic.cpp
===
--- clang/test/SemaCXX/cxx98-compat-pedantic.cpp
+++ clang/test/SemaCXX/cxx98-compat-pedantic.cpp
@@ -4,7 +4,7 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -Werror %s
 // RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror %s -DCXX98
 
-// RUN: %clang_cc1 -fsyntax-only -std=c++1y -Wc++98-compat-pedantic -verify %s 
-Wno-c++98-c++11-compat-pedantic -DCXX1Y2
+// RUN: %clang_cc1 -fsyntax-only -std=c++1y -Wc++98-compat-pedantic -verify %s 
-Wno-pre-c++14-compat-pedantic -DCXX1Y2
 
 // -Wc++98-compat-pedantic warns on C++11 features which we accept without a
 // warning in C++98 mode.
Index: clang/test/Parser/static_assert.c
===
--- clang/test/Parser/static_assert.c
+++ clang/test/Parser/static_assert.c
@@ -7,7 +7,7 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++17 -pedantic -verify=cxx17-pedantic 
-x c++ %s
 // RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify=cxx98 -x c++ %s
 // RUN: %clang_cc1 -fsyntax-only -std=c++98 -pedantic -verify=cxx98-pedantic 
-x c++ %s
-// RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wc++98-c++11-c++14-compat 
-verify=cxx17-compat -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wpre-c++17-compat 
-verify=cxx17-compat -x c++ %s
 
 // cxx17-no-diagnostics
 
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -253,22 +253,30 @@
 // Name of this warning in GCC.
 def NoexceptType : DiagGroup<"noexcept-type", [CXX17CompatMangling]>;
 
-// Warnings for C2x code which is not compatible with prior C standards.
+// Warnings for C code which is not compatible with previous C standards.
 def CPre2xCompat : DiagGroup<"pre-c2x-compat">;
 def CPre2xCompatPedantic : DiagGroup<"pre-c2x-compat-pedantic",
  [CPre2xCompat]>;
 
-// Warnings for C++1y code which is not compatible with prior C++ standards.
-def CXXPre14Compat : DiagGroup<"c++98-c++11-compat">;
-def CXXPre14CompatPedantic : DiagGroup<"c++98-c++11-compat-pedantic",
+// Warnings for C++ code which is not compatible with previous C++ standards.
+def CXXPre14Compat : DiagGroup<"pre-c++14-compat">;
+def : DiagGroup<"c++98-c++11-compat", [CXXPre14Compat]>;
+def CXXPre14CompatPedantic : DiagGroup<"pre-c++14-compat-pedantic",
[CXXPre14Compat,
 CXXPre14CompatBinaryLiteral]>;
-def CXXPre17Compat : DiagGroup<"c++98-c++11-c++14-compat">;
-def CXXPre17CompatPedantic : DiagGroup<"c++98-c++11-c++14-compat-pedantic",
+def : DiagGroup<"c++98-c++11-compat-pedantic", [CXXPre14CompatPedantic]>;
+def CXXPre17Compat : DiagGroup<"pre-c++17-compat">;
+def : DiagGroup<"c++98-c++11-c++14-compat", [CXXPre17Compat]>;
+def CXXPre17CompatPedantic : DiagGroup<"pre-c++17-compat-pedantic",
[CXXPre17Compat]>;
-def CXXPre20Compat : DiagGroup<"c++98-c++11-c++14-c++17-compat">;
-def CXXPre20CompatPedantic : 
DiagGroup<"c++98-c++11-c++14-c++17-compat-pedantic",
+def : DiagGroup<"c++98-c++11-c++14-compat-pedantic",
+[CXXPre17CompatPedantic]>;
+def CXXPre20Compat : DiagGroup<"pre-c++20-compat">;
+def : DiagGroup<"c++98-c++11-c++14-c++17-compat", [CXXPre20Compat]>;
+def CXXPre20CompatPedantic : DiagGroup<"pre-c++20-compat-pedantic",
[CXXPre20Compat]>;
+def : DiagGroup<"c++98-c++11-c++14-c++17-compat-pedantic",
+[CXXPre20CompatPedantic]>;
 def CXXPre2bCompat : DiagGroup<"pre-c++2b-compat">;
 def CXXPre2b

[PATCH] D94627: [PowerPC][PC Rel] Implement option to omit Power10 instructions from stubs

2021-03-03 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 327839.
Conanap added a comment.

Updated 2 test cases and some nits


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

https://reviews.llvm.org/D94627

Files:
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/Options.td
  lld/ELF/Thunks.cpp
  lld/ELF/Thunks.h
  lld/test/ELF/ppc64-call-reach.s
  lld/test/ELF/ppc64-long-branch-localentry-offset.s
  lld/test/ELF/ppc64-long-branch-pi.s
  lld/test/ELF/ppc64-long-branch-rel14.s
  lld/test/ELF/ppc64-long-branch.s
  lld/test/ELF/ppc64-pcrel-call-to-extern.s
  lld/test/ELF/ppc64-pcrel-call-to-toc.s
  lld/test/ELF/ppc64-plt-stub-compatible.s
  lld/test/ELF/ppc64-tls-pcrel-gd.s
  lld/test/ELF/ppc64-toc-call-to-pcrel-long-jump.s
  lld/test/ELF/ppc64-toc-call-to-pcrel.s
  llvm/include/llvm/Object/ELF.h

Index: llvm/include/llvm/Object/ELF.h
===
--- llvm/include/llvm/Object/ELF.h
+++ llvm/include/llvm/Object/ELF.h
@@ -87,6 +87,9 @@
 
 enum PPCInstrMasks : uint64_t {
   PADDI_R12_NO_DISP = 0x06103980,
+  ADDIS_R12_TO_R2_NO_DISP = 0x3D82,
+  ADDI_R12_TO_R2_NO_DISP = 0x3982,
+  ADDI_R12_TO_R12_NO_DISP = 0x398C,
   PLD_R12_NO_DISP = 0x0410E580,
   MTCTR_R12 = 0x7D8903A6,
   BCTR = 0x4E800420,
Index: lld/test/ELF/ppc64-toc-call-to-pcrel.s
===
--- lld/test/ELF/ppc64-toc-call-to-pcrel.s
+++ lld/test/ELF/ppc64-toc-call-to-pcrel.s
@@ -14,6 +14,12 @@
 # RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL
 # RUN: llvm-objdump -d --no-show-raw-insn --mcpu=future %t | FileCheck %s
 
+# RUN: llvm-mc -filetype=obj -triple=powerpc64 %s -o %t.o
+# RUN: ld.lld -T %t.script %t.o -o %t --no-power10-stubs
+# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL
+# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=future %t \
+# RUN: | FileCheck %s
+
 # The point of this test is to make sure that when a function with TOC access
 # a local function with st_other=1, a TOC save stub is inserted.
 
Index: lld/test/ELF/ppc64-toc-call-to-pcrel-long-jump.s
===
--- lld/test/ELF/ppc64-toc-call-to-pcrel-long-jump.s
+++ lld/test/ELF/ppc64-toc-call-to-pcrel-long-jump.s
@@ -11,15 +11,20 @@
 # RUN: llvm-objdump --mcpu=pwr10 --no-show-raw-insn -d %t_be | FileCheck %s
 # RUN: llvm-readelf -s %t_be | FileCheck %s --check-prefix=SYM
 
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/asm -o %t.o
+# RUN: ld.lld -T %t/lts %t.o -o %t_le --no-power10-stubs
+# RUN: llvm-objdump --mcpu=pwr10 --no-show-raw-insn -d %t_le | FileCheck %s --check-prefix=NoP10
+# RUN: llvm-readelf -s %t_le | FileCheck %s --check-prefix=SYM
+
 # SYM:  Symbol table '.symtab' contains 9 entries:
 # SYM:  1: 1001 0 NOTYPE  LOCAL  DEFAULT []   1 callee
 # SYM-NEXT: 2: 10020008 0 NOTYPE  LOCAL  DEFAULT  2 caller_close
 # SYM-NEXT: 3: 20020008 0 NOTYPE  LOCAL  DEFAULT []   3 caller
 # SYM-NEXT: 4: 000520020008 0 NOTYPE  LOCAL  DEFAULT  4 caller_far
-# SYM-NEXT: 5: 000520028038 0 NOTYPE  LOCAL  HIDDEN   6 .TOC.
+# SYM-NEXT: 5: 000520028040 0 NOTYPE  LOCAL  HIDDEN   6 .TOC.
 # SYM-NEXT: 6: 10020020 8 FUNCLOCAL  DEFAULT  2 __toc_save_callee
-# SYM-NEXT: 7: 2002002020 FUNCLOCAL  DEFAULT  3 __toc_save_callee
-# SYM-NEXT: 8: 00052002002020 FUNCLOCAL  DEFAULT  4 __toc_save_callee
+# SYM-NEXT: 7: 2002002032 FUNCLOCAL  DEFAULT  3 __toc_save_callee
+# SYM-NEXT: 8: 00052002002032 FUNCLOCAL  DEFAULT  4 __toc_save_callee
 
 #--- lts
 PHDRS {
@@ -72,6 +77,17 @@
 # CHECK-NEXT:paddi 12, 0, -268501028, 1
 # CHECK-NEXT:mtctr 12
 # CHECK-NEXT:bctr
+
+# NoP10-LABEL: :
+# NoP10: bl 0x20020020
+# NoP10-NEXT:ld 2, 24(1)
+# NoP10-NEXT:blr
+# NoP10-LABEL: <__toc_save_callee>:
+# NoP10-NEXT: std 2, 24(1)
+# NoP10-NEXT:addis 12, 2, -4098
+# NoP10-NEXT:addi 12, 12, 32704
+# NoP10-NEXT:mtctr 12
+# NoP10-NEXT:bctr
 .section .text_caller, "ax", %progbits
 .Lfunc_toc2:
   .quad .TOC.-.Lfunc_gep2
Index: lld/test/ELF/ppc64-tls-pcrel-gd.s
===
--- lld/test/ELF/ppc64-tls-pcrel-gd.s
+++ lld/test/ELF/ppc64-tls-pcrel-gd.s
@@ -42,10 +42,10 @@
 #--- asm
 
 # GD-RELOC: Relocation section '.rela.dyn' at offset 0x100b8 contains 4 entries:
-# GD-RELOC: 01001160  00010044 R_PPC64_DTPMOD64    x + 0
-# GD-RELOC: 01001168  0001004e R_PPC64_DTPREL64    x + 0
-# GD-RELOC: 01001170  00030044 R_PPC64_DTPMOD64    y + 0
-# GD-RELOC: 01001178  0003004e R_PPC64_DTPREL64    y + 

[PATCH] D97872: [clang] Don't assert in EmitAggregateCopy on trivial_abi types

2021-03-03 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
aeubanks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes PR42961.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97872

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/test/CodeGenCXX/trivial_abi.cpp


Index: clang/test/CodeGenCXX/trivial_abi.cpp
===
--- clang/test/CodeGenCXX/trivial_abi.cpp
+++ clang/test/CodeGenCXX/trivial_abi.cpp
@@ -262,3 +262,6 @@
 void testExceptionLarge() {
   calleeExceptionLarge(Large(), Large());
 }
+
+// PR42961
+Small (*fp)() = []() -> Small {};
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -2056,7 +2056,7 @@
   Record->hasTrivialCopyAssignment() ||
   Record->hasTrivialMoveConstructor() ||
   Record->hasTrivialMoveAssignment() ||
-  Record->isUnion()) &&
+  Record->hasAttr() || Record->isUnion()) &&
  "Trying to aggregate-copy a type without a trivial copy/move "
  "constructor or assignment operator");
   // Ignore empty classes in C++.


Index: clang/test/CodeGenCXX/trivial_abi.cpp
===
--- clang/test/CodeGenCXX/trivial_abi.cpp
+++ clang/test/CodeGenCXX/trivial_abi.cpp
@@ -262,3 +262,6 @@
 void testExceptionLarge() {
   calleeExceptionLarge(Large(), Large());
 }
+
+// PR42961
+Small (*fp)() = []() -> Small {};
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -2056,7 +2056,7 @@
   Record->hasTrivialCopyAssignment() ||
   Record->hasTrivialMoveConstructor() ||
   Record->hasTrivialMoveAssignment() ||
-  Record->isUnion()) &&
+  Record->hasAttr() || Record->isUnion()) &&
  "Trying to aggregate-copy a type without a trivial copy/move "
  "constructor or assignment operator");
   // Ignore empty classes in C++.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97874: [analyzer] Improve SVal cast from integer to bool using known RangeSet

2021-03-03 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: steakhal, NoQ, xazax.hun, vsavchenko, 
Eugene.Zelenko.
ASDenysPetrov added a project: clang.
Herald added subscribers: martong, Charusso, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware.
ASDenysPetrov requested review of this revision.
Herald added a subscriber: cfe-commits.

Improve `SValBuilder::evalCast` function in a part of **integer **to **bool 
**cast. Сonvert known `SymbolVal` `RangeSet` to `ConcreteInt` if possible.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97874

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/test/Analysis/cast_symbolic_ints_to_bool.cpp

Index: clang/test/Analysis/cast_symbolic_ints_to_bool.cpp
===
--- /dev/null
+++ clang/test/Analysis/cast_symbolic_ints_to_bool.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+template 
+void clang_analyzer_dump(T);
+
+void test_int_to_bool(bool b, int x) {
+  clang_analyzer_dump(b); // expected-warning{{reg_$0<_Bool b>}}
+  b = x;
+  clang_analyzer_dump(b); // expected-warning{{reg_$1}}
+  if (x < 0) {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else if (x > 0) {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{0 U1b}}
+  }
+}
+
+void test_char_to_bool(char x) {
+  bool b = x;
+  clang_analyzer_dump(b); // expected-warning{{reg_$0}}
+  if (x < 0) {
+bool b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else if (x > 0) {
+bool b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else {
+bool b = x;
+clang_analyzer_dump(b); // expected-warning{{0 U1b}}
+  }
+}
+
+void test_unsigned_to_bool(bool b, unsigned x) {
+  clang_analyzer_dump(b); // expected-warning{{reg_$0<_Bool b>}}
+  b = x;
+  clang_analyzer_dump(b); // expected-warning{{reg_$1}}
+  if (x) {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{0 U1b}}
+  }
+}
+
+void test_unsigned_to_bool(unsigned char x) {
+  bool b = x;
+  clang_analyzer_dump(b); // expected-warning{{reg_$0}}
+  if (x < 42) {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{reg_$0}}
+if (x) {
+  b = x;
+  clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+} else {
+  b = x;
+  clang_analyzer_dump(b); // expected-warning{{0 U1b}}
+}
+  } else {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -870,11 +870,18 @@
   // Symbol to bool.
   if (!OriginalTy.isNull() && CastTy->isBooleanType()) {
 // Non-float to bool.
-if (Loc::isLocType(OriginalTy) ||
-OriginalTy->isIntegralOrEnumerationType() ||
-OriginalTy->isMemberPointerType()) {
+if (OriginalTy->isIntegralOrEnumerationType()) {
   BasicValueFactory &BVF = getBasicValueFactory();
-  return makeNonLoc(SE, BO_NE, BVF.getValue(0, SE->getType()), CastTy);
+  const llvm::APSInt &Zero = BVF.getValue(0, OriginalTy);
+  bool IsZero, IsNotZero;
+  std::tie(IsZero, IsNotZero) =
+  getStateManager().getConstraintManager().isSymValWithinOrOutsideRange(
+  State, SE, Zero, Zero);
+  // Symbolic pointer, integer to bool.
+  if (IsZero || IsNotZero)
+return makeTruthVal(IsNotZero, CastTy);
+  // Symbolic integer to bool.
+  return V;
 }
   } else {
 // Symbol to integer.
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1278,6 +1278,9 @@
 
   const llvm::APSInt *getSymVal(ProgramStateRef State,
 SymbolRef Sym) const override;
+  std::pair
+  isSymValWithinOrOutsideRange(ProgramStateRef State, SymbolRef Sym,
+   llvm::APSInt lower, llvm::APSInt upper) override;
 
   ProgramStateRef removeDeadBindings(ProgramStateRef State,
  SymbolReaper &SymReaper) override;
@@ -1875,6 +1878,15 @@
   return T ? T->getConcreteValue() : nullptr;
 }
 
+std::pair RangeConstraintManager::isSymValWithinOrOutsideRange(
+ProgramStateRef St, SymbolRef Sym, llvm::APSInt lower, llvm::APSInt upper) {
+  if (const RangeSet *T = getConstraint(St, Sym

[PATCH] D97849: [AST][PCH][ASTImporter] Fix UB caused by uninited SwitchStmt member

2021-03-03 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D97849#2600220 , @steakhal wrote:

> In D97849#2600201 , @aaron.ballman 
> wrote:
>
>> This looks reasonable to me (good catch!), but is there a way for us to add 
>> a regression test for it?
>
> I'm not sure if it's possible to write a test for deterministically 
> demonstrating the bug - which is a non-deterministic crash.
> So, even if we would have a test case, that would not catch the regression 
> deterministically.
> We could include the minimal reproducer for CTU analysis - the way we 
> observed and tracked down this crash.
>
> AFAIK, it did not reproduce with memory sanitizers.

Address and ubsan could not catch it (LLVM_USE_SANITIZER: Address;Undefined). 
And I had trouble with the Memory and MemoryWithOrigins setup because ninja 
could not generate the .inc files since clang-tblgen failed always with 
uninited errors. Fortunately, vlagrind could catch the error consistently all 
the time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97849

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


[PATCH] D97849: [AST][PCH][ASTImporter] Fix UB caused by uninited SwitchStmt member

2021-03-03 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D97849#2600300 , @teemperor wrote:

> We can (and do) run LIT tests under valgrind, so if you have a test that 
> triggers this valgrind error then that seems like the way to go. I don't 
> think the test has to deterministically fail outside valgrind to be a valid 
> test.

Do you mean to use lit with `--vg` or should we explicitly call valgrind in a 
lit test? If the latter, could you please show an example how to do that 
properly (I could not find any explicit valgrind call, not even in lldb) ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97849

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


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2021-03-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Just a few minor nits from me, but I'm mostly wondering: where are we at with 
this and are there still substantive changes required? (I looked through the 
comments, but there's a lot of back-and-forth since Oct and I'm not certain 
what's holding the patch back currently.)




Comment at: clang/include/clang/AST/Type.h:492
+(isPtrSizeAddressSpace(B) || B == LangAS::Default)) ||
+   // Default is a superset of SYCL address spaces
+   (A == LangAS::Default &&





Comment at: clang/lib/AST/ItaniumMangle.cpp:2379
   unsigned TargetAS = Context.getASTContext().getTargetAddressSpace(AS);
-  if (TargetAS != 0)
+  if (TargetAS != 0 || 
(Context.getASTContext().getLangOpts().SYCLIsDevice))
 ASString = "AS" + llvm::utostr(TargetAS);





Comment at: clang/lib/Basic/Targets/SPIR.h:71-75
+if (Triple.getEnvironment() == llvm::Triple::SYCLDevice) {
+  AddrSpaceMap = &SYCLAddrSpaceMap;
+} else {
+  AddrSpaceMap = &SPIRAddrSpaceMap;
+}





Comment at: clang/lib/CodeGen/TargetInfo.cpp:9997
+if (auto ConstAS = CGM.getTarget().getConstantAddressSpace())
+  return ConstAS.getValue();
+  }

I called it out because it wasn't clear to me what the type actually was, but I 
see now that it's an `Optional`. I think it's useful to know that we're 
dealing with an optional, but it's not crucial.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89909

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


[PATCH] D97849: [AST][PCH][ASTImporter] Fix UB caused by uninited SwitchStmt member

2021-03-03 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.

I don't think we have any tests that explicitly use valgrind and testing with 
valgrind enabled is an optional thing. I would be fine landing this as-is 
without a test case if it turns out that testing this is too involved, so I'm 
accepting the review. However, if it turns out there is a way to test it that 
others can think of, I would appreciate adding the test coverage (even if it's 
post-commit).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97849

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


[PATCH] D89490: Introduce __attribute__((darwin_abi))

2021-03-03 Thread Adrien Guinet via Phabricator via cfe-commits
aguinet added a comment.

So, what could be the futur of that patch? Would that be okay to merge with a 
`target_abi` Clang attribute?

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89490

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


[PATCH] D97834: [WebAssembly] Disable uses of __clang_call_terminate

2021-03-03 Thread Thomas Lively via Phabricator via cfe-commits
tlively accepted this revision.
tlively added a comment.
This revision is now accepted and ready to land.

Nice, this actually looks like a good simplification in addition to fixing the 
specific problem.




Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4650
+  // Itanium ABI calls __clang_call_terminate(), which __cxa_begin_catch() on
+  // the violating exception to mark it handled, but it is currently hard to dl
+  // with wasm EH instruction structure with catch/catch_all, we just call




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97834

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


[PATCH] D97535: [clangd] Use URIs instead of paths in the index file list

2021-03-03 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 327853.
ArcsinX added a comment.

- use URIs as keys
- create the file list from the keys


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97535

Files:
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/test/memory_tree.test
  clang-tools-extra/clangd/unittests/DexTests.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp

Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -229,7 +229,7 @@
   RefSlab Refs;
   auto Size = Symbols.bytes() + Refs.bytes();
   auto Data = std::make_pair(std::move(Symbols), std::move(Refs));
-  llvm::StringSet<> Files = {testPath("foo.cc"), testPath("bar.cc")};
+  llvm::StringSet<> Files = {"unittest:///foo.cc", "unittest:///bar.cc"};
   MemIndex I(std::move(Data.first), std::move(Data.second), RelationSlab(),
  std::move(Files), IndexContents::All, std::move(Data), Size);
   auto ContainsFile = I.indexedFiles();
@@ -506,7 +506,7 @@
   RefSlab DynRefs;
   auto DynSize = DynSymbols.bytes() + DynRefs.bytes();
   auto DynData = std::make_pair(std::move(DynSymbols), std::move(DynRefs));
-  llvm::StringSet<> DynFiles = {testPath("foo.cc")};
+  llvm::StringSet<> DynFiles = {"unittest:///foo.cc"};
   MemIndex DynIndex(std::move(DynData.first), std::move(DynData.second),
 RelationSlab(), std::move(DynFiles), IndexContents::Symbols,
 std::move(DynData), DynSize);
@@ -514,7 +514,7 @@
   RefSlab StaticRefs;
   auto StaticData =
   std::make_pair(std::move(StaticSymbols), std::move(StaticRefs));
-  llvm::StringSet<> StaticFiles = {testPath("foo.cc"), testPath("bar.cc")};
+  llvm::StringSet<> StaticFiles = {"unittest:///foo.cc", "unittest:///bar.cc"};
   MemIndex StaticIndex(
   std::move(StaticData.first), std::move(StaticData.second), RelationSlab(),
   std::move(StaticFiles), IndexContents::References, std::move(StaticData),
Index: clang-tools-extra/clangd/unittests/DexTests.cpp
===
--- clang-tools-extra/clangd/unittests/DexTests.cpp
+++ clang-tools-extra/clangd/unittests/DexTests.cpp
@@ -737,7 +737,7 @@
   RefSlab Refs;
   auto Size = Symbols.bytes() + Refs.bytes();
   auto Data = std::make_pair(std::move(Symbols), std::move(Refs));
-  llvm::StringSet<> Files = {testPath("foo.cc"), testPath("bar.cc")};
+  llvm::StringSet<> Files = {"unittest:///foo.cc", "unittest:///bar.cc"};
   Dex I(std::move(Data.first), std::move(Data.second), RelationSlab(),
 std::move(Files), IndexContents::All, std::move(Data), Size);
   auto ContainsFile = I.indexedFiles();
Index: clang-tools-extra/clangd/test/memory_tree.test
===
--- clang-tools-extra/clangd/test/memory_tree.test
+++ clang-tools-extra/clangd/test/memory_tree.test
@@ -23,7 +23,9 @@
 # CHECK-NEXT: "_total": {{[0-9]+}}
 # CHECK-NEXT:   },
 # CHECK-NEXT:   "slabs": {
-# CHECK-NEXT: "{{.*}}main.cpp": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}},
+# CHECK-NEXT: "test:///main.cpp": {
 # CHECK-NEXT:   "_self": {{[0-9]+}},
 # CHECK-NEXT:   "_total": {{[0-9]+}},
 # CHECK-NEXT:   "references": {
@@ -38,9 +40,7 @@
 # CHECK-NEXT: "_self": {{[0-9]+}},
 # CHECK-NEXT: "_total": {{[0-9]+}}
 # CHECK-NEXT:   }
-# CHECK-NEXT: },
-# CHECK-NEXT: "_self": {{[0-9]+}},
-# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT: }
 # CHECK-NEXT:   }
 # CHECK-NEXT: },
 # CHECK-NEXT: "preamble": {
Index: clang-tools-extra/clangd/index/dex/Dex.cpp
===
--- clang-tools-extra/clangd/index/dex/Dex.cpp
+++ clang-tools-extra/clangd/index/dex/Dex.cpp
@@ -316,14 +316,7 @@
 llvm::unique_function
 Dex::indexedFiles() const {
   return [this](llvm::StringRef FileURI) {
-if (Files.empty())
-  return IndexContents::None;
-auto Path = URI::resolve(FileURI, Files.begin()->first());
-if (!Path) {
-  vlog("Failed to resolve the URI {0} : {1}", FileURI, Path.takeError());
-  return IndexContents::None;
-}
-return Files.contains(*Path) ? IdxContents : IndexContents::None;
+return Files.contains(FileURI) ? IdxContents : IndexContents::None;
   };
 }
 
Index: clang-tools-extra/clangd/index/MemIndex.cpp
===
--- clang-tools-extra/cl

[PATCH] D97819: [CMake] Enable Polly for Fuchsia toolchain build

2021-03-03 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

As a contributor to Polly, this makes me happy to see ;-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97819

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


[PATCH] D97101: [Coverage] Emit gap region between statements if first statements contains terminate statements.

2021-03-03 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 327859.
zequanwu added a comment.

use itanium abi in terminate-statements.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97101

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/break.c
  clang/test/CoverageMapping/classtemplate.cpp
  clang/test/CoverageMapping/continue.c
  clang/test/CoverageMapping/coroutine.cpp
  clang/test/CoverageMapping/deferred-region.cpp
  clang/test/CoverageMapping/label.cpp
  clang/test/CoverageMapping/return.c
  clang/test/CoverageMapping/switch.cpp
  clang/test/CoverageMapping/switchmacro.c
  clang/test/CoverageMapping/terminate-statements.cpp
  clang/test/CoverageMapping/trycatch.cpp
  clang/test/CoverageMapping/unreachable-macro.c
  compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c

Index: compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c
===
--- compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c
+++ compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c
@@ -21,9 +21,9 @@
 
 // CHECK-COVERAGE: Filename RegionsMissed Regions Cover   Functions  Missed Functions  Executed   Lines  Missed Lines Cover
 // CHECK-COVERAGE-NEXT: ---
-// CHECK-COVERAGE-NEXT: runtime-counter-relocation.c  4 175.00%   1 0   100.00%   5 260.00%
+// CHECK-COVERAGE-NEXT: runtime-counter-relocation.c  4 175.00%   1 0   100.00%   5 180.00%
 // CHECK-COVERAGE-NEXT: ---
-// CHECK-COVERAGE-NEXT: TOTAL 4 175.00%   1 0   100.00%   5 260.00%
+// CHECK-COVERAGE-NEXT: TOTAL 4 175.00%   1 0   100.00%   5 180.00%
 
 extern int __llvm_profile_is_continuous_mode_enabled(void);
 
Index: clang/test/CoverageMapping/unreachable-macro.c
===
--- clang/test/CoverageMapping/unreachable-macro.c
+++ clang/test/CoverageMapping/unreachable-macro.c
@@ -6,6 +6,7 @@
 void counters_in_macro_following_unreachable() {
   // CHECK-NEXT: File 0, [[@LINE-1]]:48 -> {{[0-9]+}}:2 = #0
   return;
+  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:10 -> [[@LINE+3]]:3 = 0
   // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:3 -> [[@LINE+2]]:8 = 0
   // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> [[@LINE+2]]:2 = 0
   WHILE
Index: clang/test/CoverageMapping/trycatch.cpp
===
--- clang/test/CoverageMapping/trycatch.cpp
+++ clang/test/CoverageMapping/trycatch.cpp
@@ -13,7 +13,7 @@
 void func(int i) {// CHECK-NEXT: File 0, [[@LINE]]:18 -> {{[0-9]+}}:2 = #0
   // CHECK-NEXT: File 0, [[@LINE+1]]:6 -> [[@LINE+1]]:11 = #0
   if(i % 2) { // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+4]]:4 = #1
-throw Error();
+throw Error();// CHECK-NEXT: Gap,File 0, [[@LINE]]:19 -> [[@LINE+1]]:5 = 0
 int j = 0;// CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE+2]]:4 = 0
   // CHECK: File 0, [[@LINE+1]]:10 -> [[@LINE+2]]:27 = (#0 - #1)
   } else if(i == 8)   // CHECK-NEXT: File 0, [[@LINE]]:13 -> [[@LINE]]:19 = (#0 - #1)
Index: clang/test/CoverageMapping/terminate-statements.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/terminate-statements.cpp
@@ -0,0 +1,343 @@
+// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -fexceptions -fcxx-exceptions -emit-llvm-only -triple %itanium_abi_triple -main-file-name terminate-statements.cpp -I %S/Inputs %s | FileCheck %s
+
+int f1() {
+  return 0;
+  return 0; // CHECK: Gap,File 0, [[@LINE-1]]:12 -> [[@LINE]]:3 = 0
+}
+
+int f2(int i) {
+  if (i)
+return 0;
+  else
+;   // CHECK: Gap,File 0, [[@LINE]]:6 -> [[@LINE+1]]:3 = (#0 - #1)
+  return 1; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:11 = (#0 - #1)
+}
+
+int f3() {
+  for (int a = 1; a < 9; a--)
+return a; // CHECK: Gap,File 0, [[@LINE]]:14 -> [[@LINE+1]]:3 = (#0 - #1)
+  return 0;   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:11 = (#0 - #1)
+}
+
+int f4(int i) {
+  while (i > 0) {
+i++;
+return i;
+  } // CHECK: File 0, [[@LINE]]:4 -> [[@LINE+1]]:3 = (#0 - #1)
+  return 0; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:11 = (#0 - #1)
+}
+
+int f5(int i) {
+  do {
+return i;
+  } while (i > 0); // CHECK: Gap,File 0, [[@LIN

[PATCH] D97101: [Coverage] Emit gap region between statements if first statements contains terminate statements.

2021-03-03 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

Thanks for reviewing.




Comment at: clang/test/CoverageMapping/switch.cpp:62
   default:  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #4
 break;  // CHECK-NEXT: Branch,File 0, [[@LINE-1]]:3 -> 
[[@LINE-1]]:10 = #4, (#0 - #4)
+  }

vsk wrote:
> zequanwu wrote:
> > vsk wrote:
> > > The blank space after `default: break;` and before the closing '}' should 
> > > have the same count as the switch condition, I thought (this goes for all 
> > > of the unreachable code within a switch body)? The idea is to prevent 
> > > 'not-executed' regions from appearing after the `break` stmt.
> > Yes, they are unreachable. So, shouldn't they always have zero count 
> > instead of same count as switch condition?
> I see, you're right. We use a gap region with zero count to cover the area 
> after break. That's actually documented here: 
> https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#switch-statements. 
> One interesting point is that there's only one gap region that covers the 
> whole body; in this example, that would be `Gap,File 0, [[@LINE]]:13 -> 
> [[@LINE+8]]:10 = 0`. So, perhaps the new gaps emitted in switches are 
> redundant, but getting rid of them is just a performance optimization.
Yes, they are redundant. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97101

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


[clang-tools-extra] 7d2fba8 - [clangd] ObjC fixes for semantic highlighting and xref highlights

2021-03-03 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-03-03T20:16:08+01:00
New Revision: 7d2fba8ddb90cf018d9cfc852b68e4584b15678e

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

LOG: [clangd] ObjC fixes for semantic highlighting and xref highlights

- highlight references to protocols in class/protocol/extension decls
- support multi-token selector highlights in semantic + xref highlights
  (method calls and declarations only)
- In `@interface I(C)`, I now references the interface and C the category
- highlight uses of interfaces as types
- added semantic highlightings of protocol names (as "interface") and
  category names (as "namespace").
  These are both standard kinds, maybe "extension" will be standardized...
- highlight `auto` as "class" when it resolves to an ObjC pointer
- don't highlight `self` as a variable even though the AST models it as one

Not fixed: uses of protocols in type names (needs some refactoring of
unrelated code first)

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/SemanticHighlighting.h
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 64053797867d..16433151d902 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -12,6 +12,7 @@
 #include "support/Logger.h"
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/DeclVisitor.h"
@@ -633,6 +634,61 @@ llvm::SmallVector refInDecl(const Decl *D,
   /*IsDecl=*/false,
   {DG->getDeducedTemplate()}});
 }
+
+void VisitObjCMethodDecl(const ObjCMethodDecl *OMD) {
+  // The name may have several tokens, we can only report the first.
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  OMD->getSelectorStartLoc(),
+  /*IsDecl=*/true,
+  {OMD}});
+}
+
+void visitProtocolList(
+llvm::iterator_range Protocols,
+llvm::iterator_range Locations) {
+  for (const auto &P : llvm::zip(Protocols, Locations)) {
+Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+std::get<1>(P),
+/*IsDecl=*/false,
+{std::get<0>(P)}});
+  }
+}
+
+void VisitObjCInterfaceDecl(const ObjCInterfaceDecl *OID) {
+  if (OID->isThisDeclarationADefinition())
+visitProtocolList(OID->protocols(), OID->protocol_locs());
+  Base::VisitObjCInterfaceDecl(OID); // Visit the interface's name.
+}
+
+void VisitObjCCategoryDecl(const ObjCCategoryDecl *OCD) {
+  visitProtocolList(OCD->protocols(), OCD->protocol_locs());
+  // getLocation is the extended class's location, not the category's.
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  OCD->getLocation(),
+  /*IsDecl=*/false,
+  {OCD->getClassInterface()}});
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  OCD->getCategoryNameLoc(),
+  /*IsDecl=*/true,
+  {OCD}});
+}
+
+void VisitObjCCategoryImplDecl(const ObjCCategoryImplDecl *OCID) {
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  OCID->getLocation(),
+  /*IsDecl=*/false,
+  {OCID->getClassInterface()}});
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  OCID->getCategoryNameLoc(),
+  /*IsDecl=*/true,
+  {OCID->getCategoryDecl()}});
+}
+
+void VisitObjCProtocolDecl(const ObjCProtocolDecl *OPD) {
+  if (OPD->isThisDeclarationADefinition())
+visitProtocolList(OPD->protocols(), OPD->protocol_locs());
+  Base::VisitObjCProtocolDecl(OPD); // Visit the protocol's name.
+}
   };
 
   Visitor V{Resolver};
@@ -711,6 +767,14 @@ llvm::SmallVector refInStmt(const Stmt *S,
   explicitReferenceTargets(DynTypedNode::create(*E), {}, Resolv

[PATCH] D97617: [clangd] ObjC fixes for semantic highlighting and xref highlights

2021-03-03 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 rG7d2fba8ddb90: [clangd] ObjC fixes for semantic highlighting 
and xref highlights (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97617

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -115,10 +115,23 @@
   f.[[^~]]Foo();
 }
   )cpp",
+  R"cpp(// ObjC methods with split selectors.
+@interface Foo
+  +(void) [[x]]:(int)a [[y]]:(int)b;
+@end
+@implementation Foo
+  +(void) [[x]]:(int)a [[y]]:(int)b {}
+@end
+void go() {
+  [Foo [[x]]:2 [[^y]]:4];
+}
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
-auto AST = TestTU::withCode(T.code()).build();
+auto TU = TestTU::withCode(T.code());
+TU.ExtraArgs.push_back("-xobjective-c++");
+auto AST = TU.build();
 EXPECT_THAT(findDocumentHighlights(AST, T.point()), HighlightsFrom(T))
 << Test;
   }
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -75,6 +75,7 @@
   TU.Code = std::string(Test.code());
 
   TU.ExtraArgs.push_back("-std=c++20");
+  TU.ExtraArgs.push_back("-xobjective-c++");
 
   for (auto File : AdditionalFiles)
 TU.AdditionalFiles.insert({File.first, std::string(File.second)});
@@ -645,6 +646,48 @@
   R"cpp(
   <:[deprecated]:> int $Variable_decl_deprecated[[x]];
   )cpp",
+  R"cpp(
+// ObjC: Classes and methods
+@class $Class_decl[[Forward]];
+
+@interface $Class_decl[[Foo]]
+@end
+@interface $Class_decl[[Bar]] : $Class[[Foo]]
+-($Class[[id]]) $Method_decl[[x]]:(int)$Parameter_decl[[a]] $Method_decl[[y]]:(int)$Parameter_decl[[b]];
++(void) $StaticMethod_decl_static[[explode]];
+@end
+@implementation $Class_decl[[Bar]]
+-($Class[[id]]) $Method_decl[[x]]:(int)$Parameter_decl[[a]] $Method_decl[[y]]:(int)$Parameter_decl[[b]] {
+  return self;
+}
++(void) $StaticMethod_decl_static[[explode]] {}
+@end
+
+void $Function_decl[[m]]($Class[[Bar]] *$Parameter_decl[[b]]) {
+  [$Parameter[[b]] $Method[[x]]:1 $Method[[y]]:2];
+  [$Class[[Bar]] $StaticMethod_static[[explode]]];
+}
+  )cpp",
+  R"cpp(
+// ObjC: Protocols
+@protocol $Interface_decl[[Protocol]]
+@end
+@protocol $Interface_decl[[Protocol2]] <$Interface[[Protocol]]>
+@end
+@interface $Class_decl[[Klass]] <$Interface[[Protocol]]>
+@end
+// FIXME: protocol list in ObjCObjectType should be highlighted.
+id $Variable_decl[[x]];
+  )cpp",
+  R"cpp(
+// ObjC: Categories
+@interface $Class_decl[[Foo]]
+@end
+@interface $Class[[Foo]]($Namespace_decl[[Bar]])
+@end
+@implementation $Class[[Foo]]($Namespace_decl[[Bar]])
+@end
+  )cpp",
   };
   for (const auto &TestCase : TestCases)
 // Mask off scope modifiers to keep the tests manageable.
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1593,6 +1593,35 @@
   "0: targets = {f}\n"
   "1: targets = {I::x}\n"
   "2: targets = {I::setY:}\n"},
+  {
+  // Objective-C: methods
+  R"cpp(
+@interface I
+  -(void) a:(int)x b:(int)y;
+@end
+void foo(I *i) {
+  [$0^i $1^a:1 b:2];
+}
+  )cpp",
+  "0: targets = {i}\n"
+  "1: targets = {I::a:b:}\n"
+  },
+  {
+  // Objective-C: protocols
+  R"cpp(
+@interface I
+@end
+@protocol P
+@end
+void foo() {
+  // FIXME: should reference P
+  $0^I *$1^x;
+}
+  

  1   2   >