[clang] db4ff98 - DebugInfo: Add support for template parameters with qualifiers

2021-09-14 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-14T00:04:40-07:00
New Revision: db4ff98bf9733605c713e75ab6677523e6d267cb

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

LOG: DebugInfo: Add support for template parameters with qualifiers

eg: t1 - DWARF doesn't have a particularly nice way to
encode this, for real member function types (like `void (t1::*)()
const`) the const-ness is encoded in the type of the artificial first
parameter. But `void () const` has no parameters, so encode it like a
normal const-qualified type, using DW_TAG_const_type. (similarly for
restrict and volatile)

Reference qualifiers (& and &&) coming in a separate commit shortly.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/test/CodeGenCXX/debug-info-template.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 0b10343f29a61..b7a6cd4fdf845 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -915,29 +915,41 @@ llvm::DIType *CGDebugInfo::CreateType(const ComplexType 
*Ty) {
   return DBuilder.createBasicType("complex", Size, Encoding);
 }
 
+static void stripUnusedQualifiers(Qualifiers &Q) {
+  // Ignore these qualifiers for now.
+  Q.removeObjCGCAttr();
+  Q.removeAddressSpace();
+  Q.removeObjCLifetime();
+  Q.removeUnaligned();
+}
+
+static llvm::dwarf::Tag getNextQualifier(Qualifiers &Q) {
+  if (Q.hasConst()) {
+Q.removeConst();
+return llvm::dwarf::DW_TAG_const_type;
+  }
+  if (Q.hasVolatile()) {
+Q.removeVolatile();
+return llvm::dwarf::DW_TAG_volatile_type;
+  }
+  if (Q.hasRestrict()) {
+Q.removeRestrict();
+return llvm::dwarf::DW_TAG_restrict_type;
+  }
+  return (llvm::dwarf::Tag)0;
+}
+
 llvm::DIType *CGDebugInfo::CreateQualifiedType(QualType Ty,
llvm::DIFile *Unit) {
   QualifierCollector Qc;
   const Type *T = Qc.strip(Ty);
 
-  // Ignore these qualifiers for now.
-  Qc.removeObjCGCAttr();
-  Qc.removeAddressSpace();
-  Qc.removeObjCLifetime();
+  stripUnusedQualifiers(Qc);
 
   // We will create one Derived type for one qualifier and recurse to handle 
any
   // additional ones.
-  llvm::dwarf::Tag Tag;
-  if (Qc.hasConst()) {
-Tag = llvm::dwarf::DW_TAG_const_type;
-Qc.removeConst();
-  } else if (Qc.hasVolatile()) {
-Tag = llvm::dwarf::DW_TAG_volatile_type;
-Qc.removeVolatile();
-  } else if (Qc.hasRestrict()) {
-Tag = llvm::dwarf::DW_TAG_restrict_type;
-Qc.removeRestrict();
-  } else {
+  llvm::dwarf::Tag Tag = getNextQualifier(Qc);
+  if (!Tag) {
 assert(Qc.empty() && "Unknown type qualifier for debug info");
 return getOrCreateType(QualType(T, 0), Unit);
   }
@@ -949,6 +961,30 @@ llvm::DIType *CGDebugInfo::CreateQualifiedType(QualType Ty,
   return DBuilder.createQualifiedType(Tag, FromTy);
 }
 
+llvm::DIType *CGDebugInfo::CreateQualifiedType(const FunctionProtoType *F,
+   llvm::DIFile *Unit) {
+  FunctionProtoType::ExtProtoInfo EPI = F->getExtProtoInfo();
+  Qualifiers &Q = EPI.TypeQuals;
+  stripUnusedQualifiers(Q);
+
+  // We will create one Derived type for one qualifier and recurse to handle 
any
+  // additional ones.
+  llvm::dwarf::Tag Tag = getNextQualifier(Q);
+  if (!Tag) {
+assert(Q.empty() && "Unknown type qualifier for debug info");
+return nullptr;
+  }
+
+  auto *FromTy =
+  getOrCreateType(CGM.getContext().getFunctionType(F->getReturnType(),
+   F->getParamTypes(), 
EPI),
+  Unit);
+
+  // No need to fill in the Name, Line, Size, Alignment, Offset in case of
+  // CVR derived types.
+  return DBuilder.createQualifiedType(Tag, FromTy);
+}
+
 llvm::DIType *CGDebugInfo::CreateType(const ObjCObjectPointerType *Ty,
   llvm::DIFile *Unit) {
 
@@ -1304,6 +1340,14 @@ static unsigned getDwarfCC(CallingConv CC) {
 
 llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,
   llvm::DIFile *Unit) {
+  const auto *FPT = dyn_cast(Ty);
+  if (FPT) {
+if (llvm::DIType *QTy = CreateQualifiedType(FPT, Unit))
+  return QTy;
+  }
+
+  // Create the type without any qualifiers
+
   SmallVector EltTys;
 
   // Add the result type at least.
@@ -1311,9 +1355,9 @@ llvm::DIType *CGDebugInfo::CreateType(const FunctionType 
*Ty,
 
   // Set up remainder of arguments if there is a prototype.
   // otherwise emit it as a variadic function.
-  if (isa(Ty))
+  if (!FPT)
 EltTys.push_back(DBuilder.createUnspecifiedParameter());
-  else if (const auto *FPT = dyn_cast(Ty)) {
+  else {
 for (const QualType &ParamType : FPT->param_types())
   E

[PATCH] D108556: [clangd] Don't highlight ObjC `id` and `instancetype`

2021-09-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

sorry, I thought I've already LGTM'd it in previous iteration. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108556

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


[PATCH] D108045: [clangd] Fix clangd crash when including a header

2021-09-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

Thanks a lot, LGTM!

Do you want me to land this for you?


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

https://reviews.llvm.org/D108045

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


[clang] e4b9f5e - DebugInfo: Add support for template parameters with reference qualifiers

2021-09-14 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-14T00:39:47-07:00
New Revision: e4b9f5e851d1fe0ba93cbb11b2ed4558602c379e

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

LOG: DebugInfo: Add support for template parameters with reference qualifiers

Followon from the previous commit supporting cvr qualifiers.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-template.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index b7a6cd4fdf84..e4dc3121a10f 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1338,6 +1338,15 @@ static unsigned getDwarfCC(CallingConv CC) {
   return 0;
 }
 
+static llvm::DINode::DIFlags getRefFlags(const FunctionProtoType *Func) {
+  llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
+  if (Func->getExtProtoInfo().RefQualifier == RQ_LValue)
+Flags |= llvm::DINode::FlagLValueReference;
+  if (Func->getExtProtoInfo().RefQualifier == RQ_RValue)
+Flags |= llvm::DINode::FlagRValueReference;
+  return Flags;
+}
+
 llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,
   llvm::DIFile *Unit) {
   const auto *FPT = dyn_cast(Ty);
@@ -1353,11 +1362,13 @@ llvm::DIType *CGDebugInfo::CreateType(const 
FunctionType *Ty,
   // Add the result type at least.
   EltTys.push_back(getOrCreateType(Ty->getReturnType(), Unit));
 
+  llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
   // Set up remainder of arguments if there is a prototype.
   // otherwise emit it as a variadic function.
   if (!FPT)
 EltTys.push_back(DBuilder.createUnspecifiedParameter());
   else {
+Flags = getRefFlags(FPT);
 for (const QualType &ParamType : FPT->param_types())
   EltTys.push_back(getOrCreateType(ParamType, Unit));
 if (FPT->isVariadic())
@@ -1365,7 +1376,7 @@ llvm::DIType *CGDebugInfo::CreateType(const FunctionType 
*Ty,
   }
 
   llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(EltTys);
-  llvm::DIType *F = DBuilder.createSubroutineType(EltTypeArray, 
llvm::DINode::FlagZero,
+  llvm::DIType *F = DBuilder.createSubroutineType(EltTypeArray, Flags,
getDwarfCC(Ty->getCallConv()));
   return F;
 }
@@ -1640,15 +1651,17 @@ CGDebugInfo::getOrCreateInstanceMethodType(QualType 
ThisPtr,
   Qc.removeUnaligned();
   // Keep the removed qualifiers in sync with
   // CreateQualifiedType(const FunctionPrototype*, DIFile *Unit)
+  // on a 'real' member function type, these qualifiers are carried on the type
+  // of the first parameter, not as separate DW_TAG_const_type (etc) decorator
+  // tags around them. (but in the raw function types with qualifiers, they 
have
+  // to use wrapper types)
 
   // Add "this" pointer.
-  llvm::DITypeRefArray Args(
-  cast(
-  getOrCreateType(
-  CGM.getContext().getFunctionType(Func->getReturnType(),
-   Func->getParamTypes(), EPI),
-  Unit))
-  ->getTypeArray());
+  const auto *OriginalFunc = cast(
+  getOrCreateType(CGM.getContext().getFunctionType(
+  Func->getReturnType(), Func->getParamTypes(), EPI),
+  Unit));
+  llvm::DITypeRefArray Args = OriginalFunc->getTypeArray();
   assert(Args.size() && "Invalid number of arguments!");
 
   SmallVector Elts;
@@ -1690,13 +1703,7 @@ CGDebugInfo::getOrCreateInstanceMethodType(QualType 
ThisPtr,
 
   llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
 
-  llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
-  if (Func->getExtProtoInfo().RefQualifier == RQ_LValue)
-Flags |= llvm::DINode::FlagLValueReference;
-  if (Func->getExtProtoInfo().RefQualifier == RQ_RValue)
-Flags |= llvm::DINode::FlagRValueReference;
-
-  return DBuilder.createSubroutineType(EltTypeArray, Flags,
+  return DBuilder.createSubroutineType(EltTypeArray, OriginalFunc->getFlags(),
getDwarfCC(Func->getCallConv()));
 }
 

diff  --git a/clang/test/CodeGenCXX/debug-info-template.cpp 
b/clang/test/CodeGenCXX/debug-info-template.cpp
index 0abb669b6535..510c82a5074f 100644
--- a/clang/test/CodeGenCXX/debug-info-template.cpp
+++ b/clang/test/CodeGenCXX/debug-info-template.cpp
@@ -218,13 +218,13 @@ template void f1<>();
 
 namespace RawFuncQual {
 struct t1; // use this to ensure the type parameter doesn't shift due to other 
test cases in this file
-template
+template
 void f1() { }
-template void f1();
-// CHECK: !DISubprogram(name: "f1", 
+template void f1();
+// CHECK: !DISubprogram(name: "f1", 
 // CHECK-SAME: templateParams: ![[RAW_FUNC_QUAL_ARGS:[0-9]*]],
 
-// CHECK: ![[RAW_FUNC_QUAL_ARGS]] = !{![[RA

[clang] 13e34f9 - Fixup some formatting from a recent commit

2021-09-14 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-14T00:41:19-07:00
New Revision: 13e34f9fc13fbe08af69b206eacac2e0008dd126

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

LOG: Fixup some formatting from a recent commit

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index e4dc3121a10f..8abdff010d25 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1376,8 +1376,8 @@ llvm::DIType *CGDebugInfo::CreateType(const FunctionType 
*Ty,
   }
 
   llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(EltTys);
-  llvm::DIType *F = DBuilder.createSubroutineType(EltTypeArray, Flags,
-   getDwarfCC(Ty->getCallConv()));
+  llvm::DIType *F = DBuilder.createSubroutineType(
+  EltTypeArray, Flags, getDwarfCC(Ty->getCallConv()));
   return F;
 }
 



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


[clang] 9aeecdf - Check supported architectures in sseXYZ/avxXYZ headers

2021-09-14 Thread via cfe-commits

Author: serge-sans-paille
Date: 2021-09-14T09:57:54+02:00
New Revision: 9aeecdfa8e9104392b435444a5f978d2eb71e51a

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

LOG: Check supported architectures in sseXYZ/avxXYZ headers

It doesn't make sense to include those headers on the wrong architecture,
provide an explicit error message in that case.

Fix https://bugs.llvm.org/show_bug.cgi?id=48915

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

Added: 
clang/test/Headers/xmmintrin-unsupported.c

Modified: 
clang/lib/Headers/ammintrin.h
clang/lib/Headers/emmintrin.h
clang/lib/Headers/immintrin.h
clang/lib/Headers/mmintrin.h
clang/lib/Headers/nmmintrin.h
clang/lib/Headers/pmmintrin.h
clang/lib/Headers/smmintrin.h
clang/lib/Headers/tmmintrin.h
clang/lib/Headers/wmmintrin.h
clang/lib/Headers/xmmintrin.h

Removed: 




diff  --git a/clang/lib/Headers/ammintrin.h b/clang/lib/Headers/ammintrin.h
index 3806be6ebc437..1af2096595cac 100644
--- a/clang/lib/Headers/ammintrin.h
+++ b/clang/lib/Headers/ammintrin.h
@@ -10,6 +10,10 @@
 #ifndef __AMMINTRIN_H
 #define __AMMINTRIN_H
 
+#if !defined(__i386__) && !defined(__x86_64__)
+#error "This header is only meant to be used on x86 and x64 architecture"
+#endif
+
 #include 
 
 /* Define the default attributes for the functions in this file. */

diff  --git a/clang/lib/Headers/emmintrin.h b/clang/lib/Headers/emmintrin.h
index b79a4f17f9c7f..6e9c3032c21f7 100644
--- a/clang/lib/Headers/emmintrin.h
+++ b/clang/lib/Headers/emmintrin.h
@@ -10,6 +10,10 @@
 #ifndef __EMMINTRIN_H
 #define __EMMINTRIN_H
 
+#if !defined(__i386__) && !defined(__x86_64__)
+#error "This header is only meant to be used on x86 and x64 architecture"
+#endif
+
 #include 
 
 typedef double __m128d __attribute__((__vector_size__(16), __aligned__(16)));

diff  --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h
index 8a75895c6c5f1..2b9ef61d27d2c 100644
--- a/clang/lib/Headers/immintrin.h
+++ b/clang/lib/Headers/immintrin.h
@@ -10,6 +10,10 @@
 #ifndef __IMMINTRIN_H
 #define __IMMINTRIN_H
 
+#if !defined(__i386__) && !defined(__x86_64__)
+#error "This header is only meant to be used on x86 and x64 architecture"
+#endif
+
 #include 
 
 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\

diff  --git a/clang/lib/Headers/mmintrin.h b/clang/lib/Headers/mmintrin.h
index 79a8b55016b19..03bac92198ad8 100644
--- a/clang/lib/Headers/mmintrin.h
+++ b/clang/lib/Headers/mmintrin.h
@@ -10,6 +10,10 @@
 #ifndef __MMINTRIN_H
 #define __MMINTRIN_H
 
+#if !defined(__i386__) && !defined(__x86_64__)
+#error "This header is only meant to be used on x86 and x64 architecture"
+#endif
+
 typedef long long __m64 __attribute__((__vector_size__(8), __aligned__(8)));
 
 typedef long long __v1di __attribute__((__vector_size__(8)));

diff  --git a/clang/lib/Headers/nmmintrin.h b/clang/lib/Headers/nmmintrin.h
index 672aea4966817..59fc7ec99e614 100644
--- a/clang/lib/Headers/nmmintrin.h
+++ b/clang/lib/Headers/nmmintrin.h
@@ -10,6 +10,10 @@
 #ifndef __NMMINTRIN_H
 #define __NMMINTRIN_H
 
+#if !defined(__i386__) && !defined(__x86_64__)
+#error "This header is only meant to be used on x86 and x64 architecture"
+#endif
+
 /* To match expectations of gcc we put the sse4.2 definitions into smmintrin.h,
just include it now then.  */
 #include 

diff  --git a/clang/lib/Headers/pmmintrin.h b/clang/lib/Headers/pmmintrin.h
index a83b2eb6d8e26..eda83567cd058 100644
--- a/clang/lib/Headers/pmmintrin.h
+++ b/clang/lib/Headers/pmmintrin.h
@@ -10,6 +10,10 @@
 #ifndef __PMMINTRIN_H
 #define __PMMINTRIN_H
 
+#if !defined(__i386__) && !defined(__x86_64__)
+#error "This header is only meant to be used on x86 and x64 architecture"
+#endif
+
 #include 
 
 /* Define the default attributes for the functions in this file. */

diff  --git a/clang/lib/Headers/smmintrin.h b/clang/lib/Headers/smmintrin.h
index 5028fd5ea5955..710e55aaa1203 100644
--- a/clang/lib/Headers/smmintrin.h
+++ b/clang/lib/Headers/smmintrin.h
@@ -10,6 +10,10 @@
 #ifndef __SMMINTRIN_H
 #define __SMMINTRIN_H
 
+#if !defined(__i386__) && !defined(__x86_64__)
+#error "This header is only meant to be used on x86 and x64 architecture"
+#endif
+
 #include 
 
 /* Define the default attributes for the functions in this file. */

diff  --git a/clang/lib/Headers/tmmintrin.h b/clang/lib/Headers/tmmintrin.h
index dbd959d0a62cb..bcffa8187801c 100644
--- a/clang/lib/Headers/tmmintrin.h
+++ b/clang/lib/Headers/tmmintrin.h
@@ -10,6 +10,10 @@
 #ifndef __TMMINTRIN_H
 #define __TMMINTRIN_H
 
+#if !defined(__i386__) && !defined(__x86_64__)
+#error "This header is only meant to be used on x86 and x64 architecture"
+#endif
+
 #include 
 
 /* Define the default attributes for the functions in this fil

[PATCH] D109686: Check supported architectures in sseXYZ/avxXYZ headers

2021-09-14 Thread serge 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 rG9aeecdfa8e91: Check supported architectures in sseXYZ/avxXYZ 
headers (authored by serge-sans-paille).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109686

Files:
  clang/lib/Headers/ammintrin.h
  clang/lib/Headers/emmintrin.h
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/mmintrin.h
  clang/lib/Headers/nmmintrin.h
  clang/lib/Headers/pmmintrin.h
  clang/lib/Headers/smmintrin.h
  clang/lib/Headers/tmmintrin.h
  clang/lib/Headers/wmmintrin.h
  clang/lib/Headers/xmmintrin.h
  clang/test/Headers/xmmintrin-unsupported.c

Index: clang/test/Headers/xmmintrin-unsupported.c
===
--- /dev/null
+++ clang/test/Headers/xmmintrin-unsupported.c
@@ -0,0 +1,5 @@
+// RUN: not %clang_cc1 %s -triple aarch64-eabi -fsyntax-only 2>&1 | FileCheck %s
+//
+// REQUIRES: x86-registered-target
+// CHECK: This header is only meant to be used on x86 and x64 architecture
+#include 
Index: clang/lib/Headers/xmmintrin.h
===
--- clang/lib/Headers/xmmintrin.h
+++ clang/lib/Headers/xmmintrin.h
@@ -10,6 +10,10 @@
 #ifndef __XMMINTRIN_H
 #define __XMMINTRIN_H
 
+#if !defined(__i386__) && !defined(__x86_64__)
+#error "This header is only meant to be used on x86 and x64 architecture"
+#endif
+
 #include 
 
 typedef int __v4si __attribute__((__vector_size__(16)));
Index: clang/lib/Headers/wmmintrin.h
===
--- clang/lib/Headers/wmmintrin.h
+++ clang/lib/Headers/wmmintrin.h
@@ -10,6 +10,10 @@
 #ifndef __WMMINTRIN_H
 #define __WMMINTRIN_H
 
+#if !defined(__i386__) && !defined(__x86_64__)
+#error "This header is only meant to be used on x86 and x64 architecture"
+#endif
+
 #include 
 
 #include <__wmmintrin_aes.h>
Index: clang/lib/Headers/tmmintrin.h
===
--- clang/lib/Headers/tmmintrin.h
+++ clang/lib/Headers/tmmintrin.h
@@ -10,6 +10,10 @@
 #ifndef __TMMINTRIN_H
 #define __TMMINTRIN_H
 
+#if !defined(__i386__) && !defined(__x86_64__)
+#error "This header is only meant to be used on x86 and x64 architecture"
+#endif
+
 #include 
 
 /* Define the default attributes for the functions in this file. */
Index: clang/lib/Headers/smmintrin.h
===
--- clang/lib/Headers/smmintrin.h
+++ clang/lib/Headers/smmintrin.h
@@ -10,6 +10,10 @@
 #ifndef __SMMINTRIN_H
 #define __SMMINTRIN_H
 
+#if !defined(__i386__) && !defined(__x86_64__)
+#error "This header is only meant to be used on x86 and x64 architecture"
+#endif
+
 #include 
 
 /* Define the default attributes for the functions in this file. */
Index: clang/lib/Headers/pmmintrin.h
===
--- clang/lib/Headers/pmmintrin.h
+++ clang/lib/Headers/pmmintrin.h
@@ -10,6 +10,10 @@
 #ifndef __PMMINTRIN_H
 #define __PMMINTRIN_H
 
+#if !defined(__i386__) && !defined(__x86_64__)
+#error "This header is only meant to be used on x86 and x64 architecture"
+#endif
+
 #include 
 
 /* Define the default attributes for the functions in this file. */
Index: clang/lib/Headers/nmmintrin.h
===
--- clang/lib/Headers/nmmintrin.h
+++ clang/lib/Headers/nmmintrin.h
@@ -10,6 +10,10 @@
 #ifndef __NMMINTRIN_H
 #define __NMMINTRIN_H
 
+#if !defined(__i386__) && !defined(__x86_64__)
+#error "This header is only meant to be used on x86 and x64 architecture"
+#endif
+
 /* To match expectations of gcc we put the sse4.2 definitions into smmintrin.h,
just include it now then.  */
 #include 
Index: clang/lib/Headers/mmintrin.h
===
--- clang/lib/Headers/mmintrin.h
+++ clang/lib/Headers/mmintrin.h
@@ -10,6 +10,10 @@
 #ifndef __MMINTRIN_H
 #define __MMINTRIN_H
 
+#if !defined(__i386__) && !defined(__x86_64__)
+#error "This header is only meant to be used on x86 and x64 architecture"
+#endif
+
 typedef long long __m64 __attribute__((__vector_size__(8), __aligned__(8)));
 
 typedef long long __v1di __attribute__((__vector_size__(8)));
Index: clang/lib/Headers/immintrin.h
===
--- clang/lib/Headers/immintrin.h
+++ clang/lib/Headers/immintrin.h
@@ -10,6 +10,10 @@
 #ifndef __IMMINTRIN_H
 #define __IMMINTRIN_H
 
+#if !defined(__i386__) && !defined(__x86_64__)
+#error "This header is only meant to be used on x86 and x64 architecture"
+#endif
+
 #include 
 
 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  \
Index: clang/lib/Headers/emmintrin.h
===
--- clang/lib/Headers/

[PATCH] D109344: [AMDGPU][OpenMP] Use complex definitions from complex_cmath.h

2021-09-14 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal added a comment.

Even with declare variant separated using ifdef's, the error is still there. So 
I don't think we have workaround for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109344

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


[PATCH] D69764: [clang-format] Add Left/Right Const fixer capability

2021-09-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 372430.
MyDeveloperDay added a comment.

Allow more QualifierFixer functions to be directly tested, remove some older 
commented code.


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

https://reviews.llvm.org/D69764

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/CMakeLists.txt
  clang/lib/Format/Format.cpp
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/lib/Format/QualifierAlignmentFixer.h
  clang/tools/clang-format/ClangFormat.cpp
  clang/unittests/Format/CMakeLists.txt
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/QualifierFixerTest.cpp

Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- /dev/null
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -0,0 +1,803 @@
+//===- unittest/Format/QualifierFixerTest.cpp - Formatting unit tests -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+
+#include "FormatTestUtils.h"
+#include "TestLexer.h"
+#include "gtest/gtest.h"
+
+#include "../../lib/Format/QualifierAlignmentFixer.h"
+
+#define DEBUG_TYPE "format-qualifier-fixer-test"
+
+using testing::ScopedTrace;
+
+namespace clang {
+namespace format {
+namespace {
+
+#define CHECK_PARSE(TEXT, FIELD, VALUE)\
+  EXPECT_NE(VALUE, Style.FIELD) << "Initial value already the same!";  \
+  EXPECT_EQ(0, parseConfiguration(TEXT, &Style).value());  \
+  EXPECT_EQ(VALUE, Style.FIELD) << "Unexpected value after parsing!"
+
+#define FAIL_PARSE(TEXT, FIELD, VALUE) \
+  EXPECT_NE(0, parseConfiguration(TEXT, &Style).value());  \
+  EXPECT_EQ(VALUE, Style.FIELD) << "Unexpected value after parsing!"
+
+class QualifierFixerTest : public ::testing::Test {
+protected:
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
+
+  TokenList annotate(llvm::StringRef Code,
+ const FormatStyle &Style = getLLVMStyle()) {
+return TestLexer(Allocator, Buffers, Style).annotate(Code);
+  }
+  llvm::SpecificBumpPtrAllocator Allocator;
+  std::vector> Buffers;
+
+  std::string format(llvm::StringRef Code,
+ const FormatStyle &Style = getLLVMStyle(),
+ StatusCheck CheckComplete = SC_ExpectComplete) {
+LLVM_DEBUG(llvm::errs() << "---\n");
+LLVM_DEBUG(llvm::errs() << Code << "\n\n");
+std::vector Ranges(1, tooling::Range(0, Code.size()));
+FormattingAttemptStatus Status;
+tooling::Replacements Replaces =
+reformat(Style, Code, Ranges, "", &Status);
+if (CheckComplete != SC_DoNotCheck) {
+  bool ExpectedCompleteFormat = CheckComplete == SC_ExpectComplete;
+  EXPECT_EQ(ExpectedCompleteFormat, Status.FormatComplete)
+  << Code << "\n\n";
+}
+ReplacementCount = Replaces.size();
+auto Result = applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(Result));
+LLVM_DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
+return *Result;
+  }
+
+  FormatStyle getStyleWithColumns(FormatStyle Style, unsigned ColumnLimit) {
+Style.ColumnLimit = ColumnLimit;
+return Style;
+  }
+
+  FormatStyle getLLVMStyleWithColumns(unsigned ColumnLimit) {
+return getStyleWithColumns(getLLVMStyle(), ColumnLimit);
+  }
+
+  void _verifyFormat(const char *File, int Line, llvm::StringRef Expected,
+ llvm::StringRef Code,
+ const FormatStyle &Style = getLLVMStyle()) {
+ScopedTrace t(File, Line, ::testing::Message() << Code.str());
+EXPECT_EQ(Expected.str(), format(Expected, Style))
+<< "Expected code is not stable";
+EXPECT_EQ(Expected.str(), format(Code, Style));
+if (Style.Language == FormatStyle::LK_Cpp) {
+  // Objective-C++ is a superset of C++, so everything checked for C++
+  // needs to be checked for Objective-C++ as well.
+  FormatStyle ObjCStyle = Style;
+  ObjCStyle.Language = FormatStyle::LK_ObjC;
+  EXPECT_EQ(Expected.str(), format(test::messUp(Code), ObjCStyle));
+}
+  }
+
+  void _verifyFormat(const char *File, int Line, llvm::StringRef Code,
+ const FormatStyle &Style = getLLVMStyle()) {
+_verifyFormat(File, Line, Code, test::messUp(Code), Style);
+  }
+
+  void _verifyIncompleteFormat(const char *File, int Line, llvm::StringRef Code,
+   const FormatStyle &Style = getLLVMStyle()) {
+ScopedTrace t(File, Line, ::testing::Message() << Code.str());
+EXPECT_EQ(Code.str(),
+  format(t

[PATCH] D69764: [clang-format] Add Left/Right Const fixer capability

2021-09-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked 3 inline comments as done.
MyDeveloperDay added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:2101
 
+**CVQualifierAlignment** (``CVQualifierAlignmentStyle``)
+  Different ways to arrange const/volatile qualifiers.

curdeius wrote:
> Why not just `Qualifier` to allow future additions for other qualifiers?
> Technically, `static` or `inline` are not qualifiers, but that maybe is clear 
> enough?
> 
> Other possibility, `Specifier` (as in "inline specifier")?
> OTOH, `Keyword` may be too generic.
If its ok I think we can stick with Qualifier although it does support 
`static/inline/const/volatile/restrcit/constexpr` I think the primary usage 
will be `type const` and `const type`


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

https://reviews.llvm.org/D69764

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


[PATCH] D109654: [clang] disable implicit moves when not in CPlusPLus

2021-09-14 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 372434.
mizvekov edited the summary of this revision.
mizvekov added a comment.

include repro for analyzer crash.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109654

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/AST/nrvo.c
  clang/test/Analysis/blocks-nrvo.c


Index: clang/test/Analysis/blocks-nrvo.c
===
--- /dev/null
+++ clang/test/Analysis/blocks-nrvo.c
@@ -0,0 +1,14 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -fblocks -verify %s
+
+// expected-no-diagnostics
+
+typedef struct {
+  int x;
+} S;
+
+void foo() {
+  ^{
+S s;
+return s; // no-crash
+  };
+}
Index: clang/test/AST/nrvo.c
===
--- /dev/null
+++ clang/test/AST/nrvo.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -ast-dump -fblocks %s | FileCheck -strict-whitespace %s
+
+struct A {};
+
+struct A f1() {
+  // CHECK:  FunctionDecl 0x{{[^ ]*}}  line:[[@LINE-1]]:10 f1 'struct A ()'
+  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
+  struct A a;
+  // CHECK-NEXT: DeclStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: VarDecl 0x{{[^ ]*}}  col:12 used a 'struct 
A':'struct A' nrvo
+  return a;
+  // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}  'struct A':'struct A' 

+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'struct A':'struct A' lvalue 
Var 0x{{[^ ]*}} 'a' 'struct A':'struct A'
+}
+
+void f2() {
+  (void)^{
+// CHECK:  BlockDecl 0x{{[^ ]*}}  line:[[@LINE-1]]:9
+// CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
+struct A a;
+// CHECK-NEXT: DeclStmt 0x{{[^ ]*}} 
+// CHECK-NEXT: VarDecl 0x{{[^ ]*}}  col:14 used a 'struct 
A':'struct A' nrvo
+return a;
+// CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} 
+// CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}  'struct A':'struct A' 

+// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'struct A':'struct A' 
lvalue Var 0x{{[^ ]*}} 'a' 'struct A':'struct A'
+  }();
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3481,7 +3481,8 @@
 ExprResult Sema::PerformMoveOrCopyInitialization(
 const InitializedEntity &Entity, const NamedReturnInfo &NRInfo, Expr 
*Value,
 bool SupressSimplerImplicitMoves) {
-  if ((!getLangOpts().CPlusPlus2b || SupressSimplerImplicitMoves) &&
+  if (getLangOpts().CPlusPlus &&
+  (!getLangOpts().CPlusPlus2b || SupressSimplerImplicitMoves) &&
   NRInfo.isMoveEligible()) {
 ImplicitCastExpr AsRvalue(ImplicitCastExpr::OnStack, Value->getType(),
   CK_NoOp, Value, VK_XValue, FPOptionsOverride());


Index: clang/test/Analysis/blocks-nrvo.c
===
--- /dev/null
+++ clang/test/Analysis/blocks-nrvo.c
@@ -0,0 +1,14 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -fblocks -verify %s
+
+// expected-no-diagnostics
+
+typedef struct {
+  int x;
+} S;
+
+void foo() {
+  ^{
+S s;
+return s; // no-crash
+  };
+}
Index: clang/test/AST/nrvo.c
===
--- /dev/null
+++ clang/test/AST/nrvo.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -ast-dump -fblocks %s | FileCheck -strict-whitespace %s
+
+struct A {};
+
+struct A f1() {
+  // CHECK:  FunctionDecl 0x{{[^ ]*}}  line:[[@LINE-1]]:10 f1 'struct A ()'
+  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
+  struct A a;
+  // CHECK-NEXT: DeclStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: VarDecl 0x{{[^ ]*}}  col:12 used a 'struct A':'struct A' nrvo
+  return a;
+  // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}  'struct A':'struct A' 
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'struct A':'struct A' lvalue Var 0x{{[^ ]*}} 'a' 'struct A':'struct A'
+}
+
+void f2() {
+  (void)^{
+// CHECK:  BlockDecl 0x{{[^ ]*}}  line:[[@LINE-1]]:9
+// CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
+struct A a;
+// CHECK-NEXT: DeclStmt 0x{{[^ ]*}} 
+// CHECK-NEXT: VarDecl 0x{{[^ ]*}}  col:14 used a 'struct A':'struct A' nrvo
+return a;
+// CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} 
+// CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}  'struct A':'struct A' 
+// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'struct A':'struct A' lvalue Var 0x{{[^ ]*}} 'a' 'struct A':'struct A'
+  }();
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3481,7 +3481,8 @@
 ExprResult Sema::PerformMoveOrCopyInitialization(
 const InitializedEntity &Entity, const NamedReturnInfo &NRInfo, Expr *Value,
 bool SupressSimplerImplicitMoves) {
-  if ((!getLangOpts().CPlusPlus2b || SupressSimplerImplicitMoves) &&
+  if (getLangOpts().CPlusPlus &&
+  (!getLangOpts().

[clang] ad88632 - [OpenCL] Tests C++ for OpenCL version macros

2021-09-14 Thread Justas Janickas via cfe-commits

Author: Justas Janickas
Date: 2021-09-14T09:49:20+01:00
New Revision: ad88632b650325af755ae42ff29114c1f6eb2841

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

LOG: [OpenCL] Tests C++ for OpenCL version macros

Version macro definitions are tested for C++ for OpenCL when
explicit version is provided on command line via `-cl-std` flag.

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

Added: 


Modified: 
clang/test/Preprocessor/predefined-macros.c

Removed: 




diff  --git a/clang/test/Preprocessor/predefined-macros.c 
b/clang/test/Preprocessor/predefined-macros.c
index 82077fcdbc76a..14b2d9529e9c2 100644
--- a/clang/test/Preprocessor/predefined-macros.c
+++ b/clang/test/Preprocessor/predefined-macros.c
@@ -137,6 +137,10 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++ \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++1.0 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++2021 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP2021
 // CHECK-CL10: #define CL_VERSION_1_0 100
 // CHECK-CL10: #define CL_VERSION_1_1 110
 // CHECK-CL10: #define CL_VERSION_1_2 120
@@ -174,9 +178,15 @@
 // CHECK-CL30-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP10: #define __CL_CPP_VERSION_2021__ 202100
 // CHECK-CLCPP10: #define __OPENCL_CPP_VERSION__ 100
 // CHECK-CLCPP10-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10-NOT: #define __ENDIAN_LITTLE__ 1
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_2021__ 202100
+// CHECK-CLCPP2021: #define __OPENCL_CPP_VERSION__ 202100
+// CHECK-CLCPP2021-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP2021-NOT: #define __ENDIAN_LITTLE__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl \
 // RUN:   | FileCheck %s --check-prefix=MSCOPE



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


[PATCH] D109366: [OpenCL] Tests C++ for OpenCL version macros

2021-09-14 Thread Justas Janickas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGad88632b6503: [OpenCL] Tests C++ for OpenCL version macros 
(authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109366

Files:
  clang/test/Preprocessor/predefined-macros.c


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -137,6 +137,10 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++ \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++1.0 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++2021 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP2021
 // CHECK-CL10: #define CL_VERSION_1_0 100
 // CHECK-CL10: #define CL_VERSION_1_1 110
 // CHECK-CL10: #define CL_VERSION_1_2 120
@@ -174,9 +178,15 @@
 // CHECK-CL30-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP10: #define __CL_CPP_VERSION_2021__ 202100
 // CHECK-CLCPP10: #define __OPENCL_CPP_VERSION__ 100
 // CHECK-CLCPP10-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10-NOT: #define __ENDIAN_LITTLE__ 1
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_2021__ 202100
+// CHECK-CLCPP2021: #define __OPENCL_CPP_VERSION__ 202100
+// CHECK-CLCPP2021-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP2021-NOT: #define __ENDIAN_LITTLE__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl \
 // RUN:   | FileCheck %s --check-prefix=MSCOPE


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -137,6 +137,10 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++ \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++1.0 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++2021 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP2021
 // CHECK-CL10: #define CL_VERSION_1_0 100
 // CHECK-CL10: #define CL_VERSION_1_1 110
 // CHECK-CL10: #define CL_VERSION_1_2 120
@@ -174,9 +178,15 @@
 // CHECK-CL30-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP10: #define __CL_CPP_VERSION_2021__ 202100
 // CHECK-CLCPP10: #define __OPENCL_CPP_VERSION__ 100
 // CHECK-CLCPP10-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10-NOT: #define __ENDIAN_LITTLE__ 1
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_2021__ 202100
+// CHECK-CLCPP2021: #define __OPENCL_CPP_VERSION__ 202100
+// CHECK-CLCPP2021-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP2021-NOT: #define __ENDIAN_LITTLE__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl \
 // RUN:   | FileCheck %s --check-prefix=MSCOPE
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109157: [ARM] Mitigate the cve-2021-35465 security vulnurability.

2021-09-14 Thread Alexandros Lamprineas via Phabricator via cfe-commits
labrinea added a comment.

@ostannard, can you explain what you meant with supporting LTO? I didn't quite 
undestand. Are you happy with the rest of the changes?


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

https://reviews.llvm.org/D109157

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


[PATCH] D109654: [clang] disable implicit moves when not in CPlusPLus

2021-09-14 Thread Matheus Izvekov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2d6829bbbe68: [clang] disable implicit moves when not in 
CPlusPLus (authored by mizvekov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109654

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/AST/nrvo.c
  clang/test/Analysis/blocks-nrvo.c


Index: clang/test/Analysis/blocks-nrvo.c
===
--- /dev/null
+++ clang/test/Analysis/blocks-nrvo.c
@@ -0,0 +1,14 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -fblocks -verify %s
+
+// expected-no-diagnostics
+
+typedef struct {
+  int x;
+} S;
+
+void foo() {
+  ^{
+S s;
+return s; // no-crash
+  };
+}
Index: clang/test/AST/nrvo.c
===
--- /dev/null
+++ clang/test/AST/nrvo.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -ast-dump -fblocks %s | FileCheck -strict-whitespace %s
+
+struct A {};
+
+struct A f1() {
+  // CHECK:  FunctionDecl 0x{{[^ ]*}}  line:[[@LINE-1]]:10 f1 'struct A ()'
+  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
+  struct A a;
+  // CHECK-NEXT: DeclStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: VarDecl 0x{{[^ ]*}}  col:12 used a 'struct 
A':'struct A' nrvo
+  return a;
+  // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}  'struct A':'struct A' 

+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'struct A':'struct A' lvalue 
Var 0x{{[^ ]*}} 'a' 'struct A':'struct A'
+}
+
+void f2() {
+  (void)^{
+// CHECK:  BlockDecl 0x{{[^ ]*}}  line:[[@LINE-1]]:9
+// CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
+struct A a;
+// CHECK-NEXT: DeclStmt 0x{{[^ ]*}} 
+// CHECK-NEXT: VarDecl 0x{{[^ ]*}}  col:14 used a 'struct 
A':'struct A' nrvo
+return a;
+// CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} 
+// CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}  'struct A':'struct A' 

+// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'struct A':'struct A' 
lvalue Var 0x{{[^ ]*}} 'a' 'struct A':'struct A'
+  }();
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3481,7 +3481,8 @@
 ExprResult Sema::PerformMoveOrCopyInitialization(
 const InitializedEntity &Entity, const NamedReturnInfo &NRInfo, Expr 
*Value,
 bool SupressSimplerImplicitMoves) {
-  if ((!getLangOpts().CPlusPlus2b || SupressSimplerImplicitMoves) &&
+  if (getLangOpts().CPlusPlus &&
+  (!getLangOpts().CPlusPlus2b || SupressSimplerImplicitMoves) &&
   NRInfo.isMoveEligible()) {
 ImplicitCastExpr AsRvalue(ImplicitCastExpr::OnStack, Value->getType(),
   CK_NoOp, Value, VK_XValue, FPOptionsOverride());


Index: clang/test/Analysis/blocks-nrvo.c
===
--- /dev/null
+++ clang/test/Analysis/blocks-nrvo.c
@@ -0,0 +1,14 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -fblocks -verify %s
+
+// expected-no-diagnostics
+
+typedef struct {
+  int x;
+} S;
+
+void foo() {
+  ^{
+S s;
+return s; // no-crash
+  };
+}
Index: clang/test/AST/nrvo.c
===
--- /dev/null
+++ clang/test/AST/nrvo.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -ast-dump -fblocks %s | FileCheck -strict-whitespace %s
+
+struct A {};
+
+struct A f1() {
+  // CHECK:  FunctionDecl 0x{{[^ ]*}}  line:[[@LINE-1]]:10 f1 'struct A ()'
+  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
+  struct A a;
+  // CHECK-NEXT: DeclStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: VarDecl 0x{{[^ ]*}}  col:12 used a 'struct A':'struct A' nrvo
+  return a;
+  // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}  'struct A':'struct A' 
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'struct A':'struct A' lvalue Var 0x{{[^ ]*}} 'a' 'struct A':'struct A'
+}
+
+void f2() {
+  (void)^{
+// CHECK:  BlockDecl 0x{{[^ ]*}}  line:[[@LINE-1]]:9
+// CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
+struct A a;
+// CHECK-NEXT: DeclStmt 0x{{[^ ]*}} 
+// CHECK-NEXT: VarDecl 0x{{[^ ]*}}  col:14 used a 'struct A':'struct A' nrvo
+return a;
+// CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} 
+// CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}  'struct A':'struct A' 
+// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'struct A':'struct A' lvalue Var 0x{{[^ ]*}} 'a' 'struct A':'struct A'
+  }();
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3481,7 +3481,8 @@
 ExprResult Sema::PerformMoveOrCopyInitialization(
 const InitializedEntity &Entity, const NamedReturnInfo &NRInfo, Expr *Value,
 bool SupressSimplerImplicitMoves) {
-  if ((!getLangOpts().CPlusPlus2b || SupressSimplerImplicitMoves) &&
+  if (getLangOpts().CPlusP

[clang] 2d6829b - [clang] disable implicit moves when not in CPlusPLus

2021-09-14 Thread Matheus Izvekov via cfe-commits

Author: Matheus Izvekov
Date: 2021-09-14T11:29:47+02:00
New Revision: 2d6829bbbe6877920d9be1db93b9f3fc85b43d10

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

LOG: [clang] disable implicit moves when not in CPlusPLus

See PR51842.

This fixes an assert firing in the static analyzer, triggered by implicit moves
in blocks in C mode:

This also simplifies the AST a little bit when compiling non C++ code,
as the xvalue implicit casts are not inserted.

We keep and test that the nrvo flag is still being set on the VarDecls,
as that is still a bit beneficial while not really making anything
more complicated.

Signed-off-by: Matheus Izvekov 

Reviewed By: NoQ

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

Added: 
clang/test/AST/nrvo.c
clang/test/Analysis/blocks-nrvo.c

Modified: 
clang/lib/Sema/SemaStmt.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index dc93e9e1c51c5..813925460241e 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3481,7 +3481,8 @@ VerifyInitializationSequenceCXX98(const Sema &S,
 ExprResult Sema::PerformMoveOrCopyInitialization(
 const InitializedEntity &Entity, const NamedReturnInfo &NRInfo, Expr 
*Value,
 bool SupressSimplerImplicitMoves) {
-  if ((!getLangOpts().CPlusPlus2b || SupressSimplerImplicitMoves) &&
+  if (getLangOpts().CPlusPlus &&
+  (!getLangOpts().CPlusPlus2b || SupressSimplerImplicitMoves) &&
   NRInfo.isMoveEligible()) {
 ImplicitCastExpr AsRvalue(ImplicitCastExpr::OnStack, Value->getType(),
   CK_NoOp, Value, VK_XValue, FPOptionsOverride());

diff  --git a/clang/test/AST/nrvo.c b/clang/test/AST/nrvo.c
new file mode 100644
index 0..4f50d6a1e384b
--- /dev/null
+++ b/clang/test/AST/nrvo.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -ast-dump -fblocks %s | FileCheck -strict-whitespace %s
+
+struct A {};
+
+struct A f1() {
+  // CHECK:  FunctionDecl 0x{{[^ ]*}}  line:[[@LINE-1]]:10 f1 'struct A ()'
+  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
+  struct A a;
+  // CHECK-NEXT: DeclStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: VarDecl 0x{{[^ ]*}}  col:12 used a 'struct 
A':'struct A' nrvo
+  return a;
+  // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}  'struct A':'struct A' 

+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'struct A':'struct A' lvalue 
Var 0x{{[^ ]*}} 'a' 'struct A':'struct A'
+}
+
+void f2() {
+  (void)^{
+// CHECK:  BlockDecl 0x{{[^ ]*}}  line:[[@LINE-1]]:9
+// CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
+struct A a;
+// CHECK-NEXT: DeclStmt 0x{{[^ ]*}} 
+// CHECK-NEXT: VarDecl 0x{{[^ ]*}}  col:14 used a 'struct 
A':'struct A' nrvo
+return a;
+// CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} 
+// CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}  'struct A':'struct A' 

+// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'struct A':'struct A' 
lvalue Var 0x{{[^ ]*}} 'a' 'struct A':'struct A'
+  }();
+}

diff  --git a/clang/test/Analysis/blocks-nrvo.c 
b/clang/test/Analysis/blocks-nrvo.c
new file mode 100644
index 0..bb0be869ee767
--- /dev/null
+++ b/clang/test/Analysis/blocks-nrvo.c
@@ -0,0 +1,14 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -fblocks -verify %s
+
+// expected-no-diagnostics
+
+typedef struct {
+  int x;
+} S;
+
+void foo() {
+  ^{
+S s;
+return s; // no-crash
+  };
+}



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


[PATCH] D109608: [clang][ASTImporter] Generic attribute import handling (first step).

2021-09-14 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:656-671
+// Helper for chaining together multiple imports. If an error is detected,
+// subsequent imports will return default constructed nodes, so that 
failure
+// can be detected with a single conditional branch after a sequence of
+// imports.
+template  T importChecked(Error &Err, const T &From) {
+  // Don't attempt to import nodes if we hit an error earlier.
+  if (Err)

martong wrote:
> What's the reason of moving this hunk?
This is moved into the public section. Other such functions are public already.



Comment at: clang/lib/AST/ASTImporter.cpp:8473-8474
+
+ToAttrName = Importer.Import(FromAttr->getAttrName());
+ToScopeName = Importer.Import(FromAttr->getScopeName());
+ToAttrRange = NImporter.importChecked(Err, FromAttr->getRange());

martong wrote:
> Why can't we use `importChecked` here?
For `Identifier*` no error is possible and `importChecked` does not work (could 
be added to have uniform code).



Comment at: clang/lib/AST/ASTImporter.cpp:8547-8548
+Expected ToAttrOrErr = AI.createImportedAttr(
+From, AI.importArrayArg(From->args(), From->args_size()).value(),
+From->args_size());
+if (ToAttrOrErr)

martong wrote:
> Could we hide these arguments?
> I mean we probably need a higher abstraction, something like
> ```
> Expected ToAttrOrErr = AI.createImportedAttr(From);
> ```
> should be sufficient, isn't it. We do want to import all arguments of all 
> kind of attributes, don't we?
It should be possible to pass every kind of needed arguments (after it is 
imported) to the constructor of the newly created `Attr` object. The problem is 
solved here by the `AttrArgImporter` that imports the object and can store it 
in a temporary value until it is passed to the constructor. The temporary value 
is important if an array is imported. To import the array the size must be 
passed to the array importer before, and the size must be passed to the 
constructor of the `Attr` too, therefore it exists 2 times in the code. An 
`AttrArgImporter` can provide only one value to the constructor of the new 
`Attr` object. (Probably other solution is possible with `std::tuple` and 
`std::apply` but not sure if it is better.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109608

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


[PATCH] D109751: [Clang] Support conversion between PPC double-double and IEEE float128

2021-09-14 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf created this revision.
qiucf added reviewers: PowerPC, hubert.reinterpretcast, nemanjai, jsji.
Herald added a subscriber: shchenz.
qiucf 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/D109751

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/ibm128-cast.c
  clang/test/Sema/float128-ld-incompatibility.cpp

Index: clang/test/Sema/float128-ld-incompatibility.cpp
===
--- clang/test/Sema/float128-ld-incompatibility.cpp
+++ clang/test/Sema/float128-ld-incompatibility.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
 // RUN: -triple powerpc64le-unknown-linux-gnu -target-cpu pwr9 \
-// RUN: -target-feature +float128 %s
+// RUN: -Wno-unused-value -Wno-parentheses -target-feature +float128 %s
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -triple x86_64-unknown-linux-gnu -Wno-unused-value -Wno-parentheses %s
 
 __float128 qf();
@@ -12,12 +12,12 @@
 long double ld{qf()}; // expected-error {{cannot initialize a variable of type 'long double' with an rvalue of type '__float128'}}
 __float128 q{ldf()};  // expected-error {{cannot initialize a variable of type '__float128' with an rvalue of type 'long double'}}
 
-auto test1(__float128 q, long double ld) -> decltype(q + ld) { // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}}
-  return q + ld;  // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}}
+auto test1(__float128 q, long double ld) -> decltype(q + ld) { // expected-no-error {{invalid operands to binary expression ('__float128' and 'long double')}}
+  return q + ld;  // expected-no-error {{invalid operands to binary expression ('__float128' and 'long double')}}
 }
 
-auto test2(long double a, __float128 b) -> decltype(a + b) { // expected-error {{invalid operands to binary expression ('long double' and '__float128')}}
-  return a + b;  // expected-error {{invalid operands to binary expression ('long double' and '__float128')}}
+auto test2(long double a, __float128 b) -> decltype(a + b) { // expected-eno-rror {{invalid operands to binary expression ('long double' and '__float128')}}
+  return a + b;  // expected-no-error {{invalid operands to binary expression ('long double' and '__float128')}}
 }
 #endif
 
@@ -25,15 +25,15 @@
   long double ld;
   __float128 q;
 
-  ld + q; // expected-error {{invalid operands to binary expression ('long double' and '__float128')}}
-  q + ld; // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}}
-  ld - q; // expected-error {{invalid operands to binary expression ('long double' and '__float128')}}
-  q - ld; // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}}
-  ld * q; // expected-error {{invalid operands to binary expression ('long double' and '__float128')}}
-  q * ld; // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}}
-  ld / q; // expected-error {{invalid operands to binary expression ('long double' and '__float128')}}
-  q / ld; // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}}
+  ld + q; // expected-no-error {{invalid operands to binary expression ('long double' and '__float128')}}
+  q + ld; // expected-no-error {{invalid operands to binary expression ('__float128' and 'long double')}}
+  ld - q; // expected-no-error {{invalid operands to binary expression ('long double' and '__float128')}}
+  q - ld; // expected-no-error {{invalid operands to binary expression ('__float128' and 'long double')}}
+  ld * q; // expected-no-error {{invalid operands to binary expression ('long double' and '__float128')}}
+  q * ld; // expected-no-error {{invalid operands to binary expression ('__float128' and 'long double')}}
+  ld / q; // expected-no-error {{invalid operands to binary expression ('long double' and '__float128')}}
+  q / ld; // expected-no-error {{invalid operands to binary expression ('__float128' and 'long double')}}
   ld = q; // expected-error {{assigning to 'long double' from incompatible type '__float128'}}
   q = ld; // expected-error {{assigning to '__float128' from incompatible type 'long double'}}
-  q + b ? q : ld; // expected-error {{incompatible operand types ('__float128' and 'long double')}}
+  q + b ? q : ld; // expected-no-error {{incompatible operand types ('__float128' and 'long double')}}
 }
Index: clang/test/CodeGen/ibm128-cast.c
===
--- clang/test/CodeGen/ibm128-cast.c
+++ clang/test/CodeGen/ibm128-cast.c
@@ -1,61 +1,115 @@
-// RUN: %clang_cc1 -emit-llvm -triple powerpc64le-unknown-unknown -verify \
-// RUN:   -target-feature +float128 -mabi=ieeelongdouble -fsyntax-only -Wno-un

[PATCH] D109752: [clang-format] Top-level unwrapped lines don't follow a left brace

2021-09-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, HazardyKnusperkeks.
owenpan added a project: clang-format.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch makes characterizing top-level unwrapped lines more precise. There 
are no test cases to add unless we want to include invalid ones, e.g.:

  {
int f(i)
int i;
{
  return i + 1;
}
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109752

Files:
  clang/lib/Format/UnwrappedLineParser.cpp


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -431,7 +431,7 @@
   }
   LLVM_FALLTHROUGH;
 default:
-  parseStructuralElement(/*IsTopLevel=*/true);
+  parseStructuralElement(!HasOpeningBrace);
   break;
 }
   } while (!eof());


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -431,7 +431,7 @@
   }
   LLVM_FALLTHROUGH;
 default:
-  parseStructuralElement(/*IsTopLevel=*/true);
+  parseStructuralElement(!HasOpeningBrace);
   break;
 }
   } while (!eof());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108695: [analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it

2021-09-14 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

Hi @Szelethus 
A couple of tests fail for me on trunk with this patch:

  Failed Tests (3):
Clang-Unit :: 
StaticAnalyzer/./StaticAnalysisTests/FalsePositiveRefutationBRVisitorTestBase.UnSatAtErrorNodeDueToRefinedConstraintNoReport
Clang-Unit :: 
StaticAnalyzer/./StaticAnalysisTests/FalsePositiveRefutationBRVisitorTestBase.UnSatAtErrorNodeWithNewSymbolNoReport
Clang-Unit :: 
StaticAnalyzer/./StaticAnalysisTests/FalsePositiveRefutationBRVisitorTestBase.UnSatInTheMiddleNoReport

Details from one failure below:

  seroius03977 [12:05] [uabelho/master-github/llvm] -> 
/repo/uabelho/master-github/llvm/build-all/tools/clang/unittests/StaticAnalyzer/./StaticAnalysisTests
 
--gtest_filter=FalsePositiveRefutationBRVisitorTestBase.UnSatAtErrorNodeWithNewSymbolNoReport
  Note: Google Test filter = 
FalsePositiveRefutationBRVisitorTestBase.UnSatAtErrorNodeWithNewSymbolNoReport
  [==] Running 1 test from 1 test suite.
  [--] Global test environment set-up.
  [--] 1 test from FalsePositiveRefutationBRVisitorTestBase
  [ RUN  ] 
FalsePositiveRefutationBRVisitorTestBase.UnSatAtErrorNodeWithNewSymbolNoReport
  UnSatAtErrorNodeWithNewSymbolNoReport.cc:8:7: warning: 
REACHED_WITH_NO_CONTRADICTION [test.FalsePositiveGenerator]
reachedWithNoContradiction();
^~~~
  1 warning generated.
  
/repo/uabelho/master-github/clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp:162:
 Failure
  Expected equality of these values:
Diags
  Which is: "test.FalsePositiveGenerator: Assuming the condition is false | 
REACHED_WITH_NO_CONTRADICTION\n"
"test.FalsePositiveGenerator: REACHED_WITH_NO_CONTRADICTION\n"
  UnSatAtErrorNodeWithNewSymbolNoReport.cc:8:7: warning: 
REACHED_WITH_NO_CONTRADICTION [test.FalsePositiveGenerator]
reachedWithNoContradiction();
^~~~
  UnSatAtErrorNodeWithNewSymbolNoReport.cc:9:7: warning: CAN_BE_TRUE 
[test.FalsePositiveGenerator]
reportIfCanBeTrue(x == 0); // contradiction
^
  2 warnings generated.
  
/repo/uabelho/master-github/clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp:171:
 Failure
  Expected equality of these values:
Diags2
  Which is: "test.FalsePositiveGenerator: Assuming the condition is false | 
REACHED_WITH_NO_CONTRADICTION\ntest.FalsePositiveGenerator: Assuming the 
condition is false | CAN_BE_TRUE\n"
"test.FalsePositiveGenerator: REACHED_WITH_NO_CONTRADICTION\n" 
"test.FalsePositiveGenerator: CAN_BE_TRUE\n"
  Which is: "test.FalsePositiveGenerator: 
REACHED_WITH_NO_CONTRADICTION\ntest.FalsePositiveGenerator: CAN_BE_TRUE\n"
  With diff:
  @@ -1,2 +1,2 @@
  -test.FalsePositiveGenerator: Assuming the condition is false | 
REACHED_WITH_NO_CONTRADICTION
  -test.FalsePositiveGenerator: Assuming the condition is false | CAN_BE_TRUE\n
  +test.FalsePositiveGenerator: REACHED_WITH_NO_CONTRADICTION
  +test.FalsePositiveGenerator: CAN_BE_TRUE\n
  
  [  FAILED  ] 
FalsePositiveRefutationBRVisitorTestBase.UnSatAtErrorNodeWithNewSymbolNoReport 
(41 ms)
  [--] 1 test from FalsePositiveRefutationBRVisitorTestBase (41 ms 
total)
  
  [--] Global test environment tear-down
  [==] 1 test from 1 test suite ran. (42 ms total)
  [  PASSED  ] 0 tests.
  [  FAILED  ] 1 test, listed below:
  [  FAILED  ] 
FalsePositiveRefutationBRVisitorTestBase.UnSatAtErrorNodeWithNewSymbolNoReport
  
   1 FAILED TEST


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108695

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


[PATCH] D109234: [PGO] Change ThinLTO test for targets with loop unrolling disabled

2021-09-14 Thread Sherwin via Phabricator via cfe-commits
sherwin-dc added a comment.

@tejohnson would you be able to take another look at this again


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

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


RE: [clang] bdce8d4 - Revert "[X86] Adjust Keylocker handle mem size"

2021-09-14 Thread Zhang, Xiang1 via cfe-commits
Sorry, I’ll keep in mind.
This revert is just for “wrong patch ID in commit comment”

it should be D109488 not D109354.
Sorry for my mistake!

Thank you so much!
From: Craig Topper 
Sent: Tuesday, September 14, 2021 5:52 AM
To: Zhang, Xiang1 ; Xiang1 Zhang 
Cc: cfe-commits 
Subject: Re: [clang] bdce8d4 - Revert "[X86] Adjust Keylocker handle mem size"

When reverting patches, please include the reason in the commit message.

~Craig


On Mon, Sep 13, 2021 at 3:01 AM Xiang1 Zhang via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:

Author: Xiang1 Zhang
Date: 2021-09-13T18:00:46+08:00
New Revision: bdce8d40c6da56f1c95a8d7bfeac12b1ffce79cf

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

LOG: Revert "[X86] Adjust Keylocker handle mem size"

This reverts commit 3731de6b7f2d42d40151f9574636bc4d5ccfa5e3.

Added:


Modified:
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Headers/keylockerintrin.h
clang/test/CodeGen/X86/keylocker.c
llvm/test/CodeGen/X86/keylocker-intrinsics.ll

Removed:




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index d485e8e767692..727fc19f1a23f 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -14905,7 +14905,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,

 Value *Call = Builder.CreateCall(CGM.getIntrinsic(IID), {Ops[0], Ops[1]});

-for (int i = 0; i < 3; ++i) {
+for (int i = 0; i < 6; ++i) {
   Value *Extract = Builder.CreateExtractValue(Call, i + 1);
   Value *Ptr = Builder.CreateConstGEP1_32(Int8Ty, Ops[2], i * 16);
   Ptr = Builder.CreateBitCast(
@@ -14921,7 +14921,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
 Value *Call =
 Builder.CreateCall(CGM.getIntrinsic(IID), {Ops[0], Ops[1], Ops[2]});

-for (int i = 0; i < 4; ++i) {
+for (int i = 0; i < 7; ++i) {
   Value *Extract = Builder.CreateExtractValue(Call, i + 1);
   Value *Ptr = Builder.CreateConstGEP1_32(Int8Ty, Ops[3], i * 16);
   Ptr = Builder.CreateBitCast(

diff  --git a/clang/lib/Headers/keylockerintrin.h 
b/clang/lib/Headers/keylockerintrin.h
index ad9428e6c8b57..68b0a5689618a 100644
--- a/clang/lib/Headers/keylockerintrin.h
+++ b/clang/lib/Headers/keylockerintrin.h
@@ -99,7 +99,7 @@ _mm_loadiwkey (unsigned int __ctl, __m128i __intkey,
 }

 /// Wrap a 128-bit AES key from __key into a key handle and output in
-/// ((__m128i*)__h) to ((__m128i*)__h) + 2  and a 32-bit value as return.
+/// ((__m128i*)__h) to ((__m128i*)__h) + 5  and a 32-bit value as return.
 /// The explicit source operand __htype specifies handle restrictions.
 ///
 /// \headerfile 
@@ -120,6 +120,9 @@ _mm_loadiwkey (unsigned int __ctl, __m128i __intkey,
 /// MEM[__h+127:__h] := Handle[127:0]   // AAD
 /// MEM[__h+255:__h+128] := Handle[255:128] // Integrity Tag
 /// MEM[__h+383:__h+256] := Handle[383:256] // CipherText
+/// MEM[__h+511:__h+384] := 0 // Reserved for future usage
+/// MEM[__h+639:__h+512] := 0 // Reserved for future usage
+/// MEM[__h+767:__h+640] := 0 // Reserved for future usage
 /// OF := 0
 /// SF := 0
 /// ZF := 0
@@ -133,7 +136,7 @@ _mm_encodekey128_u32(unsigned int __htype, __m128i __key, 
void *__h) {
 }

 /// Wrap a 256-bit AES key from __key_hi:__key_lo into a key handle, then
-/// output handle in ((__m128i*)__h) to ((__m128i*)__h) + 3 and
+/// output handle in ((__m128i*)__h) to ((__m128i*)__h) + 6 and
 /// a 32-bit value as return.
 /// The explicit source operand __htype specifies handle restrictions.
 ///
@@ -157,6 +160,9 @@ _mm_encodekey128_u32(unsigned int __htype, __m128i __key, 
void *__h) {
 /// MEM[__h+255:__h+128] := Handle[255:128] // Tag
 /// MEM[__h+383:__h+256] := Handle[383:256] // CipherText[127:0]
 /// MEM[__h+511:__h+384] := Handle[511:384] // CipherText[255:128]
+/// MEM[__h+639:__h+512] := 0 // Reserved for future usage
+/// MEM[__h+767:__h+640] := 0 // Reserved for future usage
+/// MEM[__h+895:__h+768] := 0 Integrity// Reserved for future usage
 /// OF := 0
 /// SF := 0
 /// ZF := 0

diff  --git a/clang/test/CodeGen/X86/keylocker.c 
b/clang/test/CodeGen/X86/keylocker.c
index a87281c5bd3fc..ded6e57bfb8b6 100644
--- a/clang/test/CodeGen/X86/keylocker.c
+++ b/clang/test/CodeGen/X86/keylocker.c
@@ -98,8 +98,20 @@ void test_loadiwkey(unsigned int ctl, __m128i intkey, 
__m128i enkey_lo, __m128i
 // CHECK64-NEXT:[[TMP13:%.*]] = getelementptr i8, i8* [[TMP5]], i32 32
 // CHECK64-NEXT:[[TMP14:%.*]] = bitcast i8* [[TMP13]] to <2 x i64>*
 // CHECK64-NEXT:store <2 x i64> [[TMP12]], <2 x i64>* [[TMP14]], align 1
-// CHECK64-NEXT:[[TMP15:%.*]] = extractvalue { i32, <2 x i64>, <2 x i64>, 
<2 x i64>, <2 x i64>, <2 x i64>, <2 x i64> } [[TMP6]], 0
-// CHECK64-NEXT:ret i32 [[TMP15]]
+// CHECK64-NEXT:[[T

[PATCH] D108695: [analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it

2021-09-14 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

I'll attend to this ASAP. Thanks for the heads up!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108695

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


[PATCH] D108695: [analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it

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

In D108695#2999378 , @uabelho wrote:

> Hi @Szelethus 
> A couple of tests fail for me on trunk with this patch

Uh, that's my unittest :D
I suspect you are running some sort of CI where you set up Z3.

I suspect we should slightly modify the expected output then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108695

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


[PATCH] D105191: [Clang][OpenMP] Add support for Static Device Libraries

2021-09-14 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam added a comment.

In D105191#2998372 , @ye-luo wrote:

> the modf test still doesn't work. The issue was from unbundle.
> case 1 works.
>
>   clang++ -fopenmp -fopenmp-targets=nvptx64 modf.cpp -c
>   clang++ -fopenmp -fopenmp-targets=nvptx64 modf.o
>
> case 2
>
>   clang++ -fopenmp -fopenmp-targets=nvptx64 -Xopenmp-target=nvptx64 
> -march=sm_80 modf.cpp -c
>   clang++ -fopenmp -fopenmp-targets=nvptx64 -Xopenmp-target=nvptx64 
> -march=sm_80 modf.o 
>
> doesn't work. The issue was a failure in unbundling
>
>   "/soft/llvm/main-patched/bin/clang-offload-bundler" -type=o 
> -targets=host-x86_64-unknown-linux-gnu,openmp-nvptx64-sm_80 -inputs=modf.o 
> -outputs=/tmp/modf-99be57.o,/tmp/modf-88a9eb.cubin -unbundle 
> -allow-missing-bundles
>
> ends up an empty cubin file. If I remove -sm_80 on the unbundle line
> It seems that we need to have sm_80 when the object file is created.
>
> When clang is compiled CLANG_OPENMP_NVPTX_DEFAULT_ARCH can be used to set the 
> default sm_XX so it doesn't needs to be provided at compile time. If not set 
> default is sm_35.
> So in general sm_XX is always known when the compiler is used for compiling.

Both cases 1 and 2 are working fine in my setup using these commands. I have 
sm_50, though.
If you think unbundler is the the issue, can you please tell what all bundles 
are inside modf.o in both cases with following command:

> clang-offload-bundler -type=o --inputs=modf.o --list

In my case it prints the following for case 2:

> /work/saiyedul/openmp-target/tests/math$ clang-offload-bundler -type=o 
> --inputs=modf.o --list
> openmp-nvptx64-sm_50
> host-x86_64-unknown-linux-gnu


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105191

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


[PATCH] D108695: [analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it

2021-09-14 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

In D108695#2999432 , @steakhal wrote:

> In D108695#2999378 , @uabelho wrote:
>
>> Hi @Szelethus 
>> A couple of tests fail for me on trunk with this patch
>
> Uh, that's my unittest :D
> I suspect you are running some sort of CI where you set up Z3.

Yes, I have Z3 enabled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108695

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


[clang] 09dc454 - [OpenCL] Enables .rgba vector extension in C++ for OpenCL 2021

2021-09-14 Thread Justas Janickas via cfe-commits

Author: Justas Janickas
Date: 2021-09-14T13:05:42+01:00
New Revision: 09dc454b00b8ed0a19f766f760fa19e86a0b9059

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

LOG: [OpenCL] Enables .rgba vector extension in C++ for OpenCL 2021

`.rgba` vector extension setting in C++ for OpenCL 2021 is now
performed analogously to OpenCL C 3.0. Test case added.

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

Added: 


Modified: 
clang/lib/Sema/SemaExprMember.cpp
clang/test/SemaOpenCL/ext_vectors.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 92b7464cd0bbf..0f0dd8a42cfca 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -340,7 +340,8 @@ CheckExtVectorComponent(Sema &S, QualType baseType, 
ExprValueKind &VK,
 
 // Emit a warning if an rgba selector is used earlier than OpenCL C 3.0.
 if (HasRGBA || (*compStr && IsRGBA(*compStr))) {
-  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion < 300) {
+  if (S.getLangOpts().OpenCL &&
+  S.getLangOpts().getOpenCLCompatibleVersion() < 300) {
 const char *DiagBegin = HasRGBA ? CompName->getNameStart() : compStr;
 S.Diag(OpLoc, diag::ext_opencl_ext_vector_type_rgba_selector)
 << StringRef(DiagBegin, 1) << SourceRange(CompLoc);

diff  --git a/clang/test/SemaOpenCL/ext_vectors.cl 
b/clang/test/SemaOpenCL/ext_vectors.cl
index 7404f037d93f5..ce5b333bd8aab 100644
--- a/clang/test/SemaOpenCL/ext_vectors.cl
+++ b/clang/test/SemaOpenCL/ext_vectors.cl
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
@@ -9,13 +10,13 @@ void test_ext_vector_accessors(float4 V) {
   V = V.wzyx;
 
   V = V.abgr;
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || 
(defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
   // expected-warning@-2 {{vector component name 'a' is a feature from OpenCL 
version 3.0 onwards}}
 #endif
 
   V = V.xyzr;
   // expected-error@-1 {{illegal vector component name 'r'}}
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || 
(defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
   // expected-warning@-3 {{vector component name 'r' is a feature from OpenCL 
version 3.0 onwards}}
 #endif
 }



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


[PATCH] D109370: [OpenCL] Enables .rgba vector extension in C++ for OpenCL 2021

2021-09-14 Thread Justas Janickas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG09dc454b00b8: [OpenCL] Enables .rgba vector extension in C++ 
for OpenCL 2021 (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109370

Files:
  clang/lib/Sema/SemaExprMember.cpp
  clang/test/SemaOpenCL/ext_vectors.cl


Index: clang/test/SemaOpenCL/ext_vectors.cl
===
--- clang/test/SemaOpenCL/ext_vectors.cl
+++ clang/test/SemaOpenCL/ext_vectors.cl
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
@@ -9,13 +10,13 @@
   V = V.wzyx;
 
   V = V.abgr;
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || 
(defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
   // expected-warning@-2 {{vector component name 'a' is a feature from OpenCL 
version 3.0 onwards}}
 #endif
 
   V = V.xyzr;
   // expected-error@-1 {{illegal vector component name 'r'}}
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || 
(defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
   // expected-warning@-3 {{vector component name 'r' is a feature from OpenCL 
version 3.0 onwards}}
 #endif
 }
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -340,7 +340,8 @@
 
 // Emit a warning if an rgba selector is used earlier than OpenCL C 3.0.
 if (HasRGBA || (*compStr && IsRGBA(*compStr))) {
-  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion < 300) {
+  if (S.getLangOpts().OpenCL &&
+  S.getLangOpts().getOpenCLCompatibleVersion() < 300) {
 const char *DiagBegin = HasRGBA ? CompName->getNameStart() : compStr;
 S.Diag(OpLoc, diag::ext_opencl_ext_vector_type_rgba_selector)
 << StringRef(DiagBegin, 1) << SourceRange(CompLoc);


Index: clang/test/SemaOpenCL/ext_vectors.cl
===
--- clang/test/SemaOpenCL/ext_vectors.cl
+++ clang/test/SemaOpenCL/ext_vectors.cl
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
@@ -9,13 +10,13 @@
   V = V.wzyx;
 
   V = V.abgr;
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || (defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
   // expected-warning@-2 {{vector component name 'a' is a feature from OpenCL version 3.0 onwards}}
 #endif
 
   V = V.xyzr;
   // expected-error@-1 {{illegal vector component name 'r'}}
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || (defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
   // expected-warning@-3 {{vector component name 'r' is a feature from OpenCL version 3.0 onwards}}
 #endif
 }
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -340,7 +340,8 @@
 
 // Emit a warning if an rgba selector is used earlier than OpenCL C 3.0.
 if (HasRGBA || (*compStr && IsRGBA(*compStr))) {
-  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion < 300) {
+  if (S.getLangOpts().OpenCL &&
+  S.getLangOpts().getOpenCLCompatibleVersion() < 300) {
 const char *DiagBegin = HasRGBA ? CompName->getNameStart() : compStr;
 S.Diag(OpLoc, diag::ext_opencl_ext_vector_type_rgba_selector)
 << StringRef(DiagBegin, 1) << SourceRange(CompLoc);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109721: [IR] Reduce max supported integer from 2^24-1 to 2^23.

2021-09-14 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/D109721/new/

https://reviews.llvm.org/D109721

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


[PATCH] D108893: clang-tidy: introduce readability-containter-data-pointer check

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

LGTM modulo the testing request (I forgot to mention that when marking it 
yesterday, oops!).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108893

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


[PATCH] D105701: [clang-format] test revision (NOT FOR COMMIT) to demonstrate east/west const fixer capability

2021-09-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 372460.
MyDeveloperDay added a comment.
Herald added subscribers: dexonsmith, jdoerfert, sstefan1, mgrang, martong, 
aheejin, dschuff.
Herald added a reviewer: shafik.
Herald added a reviewer: jdoerfert.

Further Demonstration of D69764: [clang-format] Add Left/Right Const fixer 
capability  with new QualifierOrder


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

https://reviews.llvm.org/D105701

Files:
  clang/.clang-format
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/AST/APValue.cpp
  clang/lib/AST/ASTConcept.cpp
  clang/lib/AST/ASTConsumer.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTDiagnostic.cpp
  clang/lib/AST/ASTDumper.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTImporterLookupTable.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/ASTTypeTraits.cpp
  clang/lib/AST/AttrDocTable.cpp
  clang/lib/AST/AttrImpl.cpp
  clang/lib/AST/CXXInheritance.cpp
  clang/lib/AST/Comment.cpp
  clang/lib/AST/CommentBriefParser.cpp
  clang/lib/AST/CommentCommandTraits.cpp
  clang/lib/AST/CommentLexer.cpp
  clang/lib/AST/CommentParser.cpp
  clang/lib/AST/CommentSema.cpp
  clang/lib/AST/ComparisonCategories.cpp
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/DeclFriend.cpp
  clang/lib/AST/DeclGroup.cpp
  clang/lib/AST/DeclObjC.cpp
  clang/lib/AST/DeclOpenMP.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/AST/DeclarationName.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConcepts.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ExprObjC.cpp
  clang/lib/AST/ExternalASTMerger.cpp
  clang/lib/AST/ExternalASTSource.cpp
  clang/lib/AST/FormatString.cpp
  clang/lib/AST/InheritViz.cpp
  clang/lib/AST/ItaniumCXXABI.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/Mangle.cpp
  clang/lib/AST/MicrosoftCXXABI.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/NestedNameSpecifier.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/OSLog.cpp
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/ParentMap.cpp
  clang/lib/AST/ParentMapContext.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/QualTypeNames.cpp
  clang/lib/AST/RawCommentList.cpp
  clang/lib/AST/RecordLayout.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/AST/ScanfFormatString.cpp
  clang/lib/AST/SelectorLocationsKind.cpp
  clang/lib/AST/Stmt.cpp
  clang/lib/AST/StmtCXX.cpp
  clang/lib/AST/StmtIterator.cpp
  clang/lib/AST/StmtObjC.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/StmtViz.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TemplateName.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/AST/VTTBuilder.cpp
  clang/lib/AST/VTableBuilder.cpp
  clang/lib/Basic/Attributes.cpp
  clang/lib/Basic/Builtins.cpp
  clang/lib/Basic/CharInfo.cpp
  clang/lib/Basic/CodeGenOptions.cpp
  clang/lib/Basic/Cuda.cpp
  clang/lib/Basic/DarwinSDKInfo.cpp
  clang/lib/Basic/Diagnostic.cpp
  clang/lib/Basic/DiagnosticIDs.cpp
  clang/lib/Basic/ExpressionTraits.cpp
  clang/lib/Basic/FileManager.cpp
  clang/lib/Basic/FileSystemStatCache.cpp
  clang/lib/Basic/IdentifierTable.cpp
  clang/lib/Basic/LangOptions.cpp
  clang/lib/Basic/LangStandards.cpp
  clang/lib/Basic/Module.cpp
  clang/lib/Basic/NoSanitizeList.cpp
  clang/lib/Basic/ObjCRuntime.cpp
  clang/lib/Basic/OpenCLOptions.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/Basic/OperatorPrecedence.cpp
  clang/lib/Basic/ProfileList.cpp
  clang/lib/Basic/SanitizerSpecialCaseList.cpp
  clang/lib/Basic/Sanitizers.cpp
  clang/lib/Basic/SourceLocation.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Basic/Stack.cpp
  clang/lib/Basic/TargetID.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets.h
  clang/lib/Basic/TokenKinds.cpp
  clang/lib/Basic/TypeTraits.cpp
  clang/lib/Basic/Version.cpp
  clang/lib/Basic/Warnings.cpp
  clang/lib/Format/AffectedRangeManager.cpp
  clang/lib/Format/AffectedRangeManager.h
  clang/lib/Format/BreakableToken.cpp
  clang/lib/Format/BreakableToken.h
  clang/lib/Format/CMakeLists.txt
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/ContinuationIndenter.h
  clang/lib/Format/Encoding.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatInternal.h
  clang/lib/Format/FormatToken.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/FormatTokenLexer.h
  clang/lib/Format/MacroExpander.cpp
  clang/lib/Format/Macros.h
  clang/lib/Format/NamespaceEndCommentsFixer.cpp
  clang/lib/Format/NamespaceEndComments

[PATCH] D108560: [clang-tidy] Add support for NOLINTBEGIN ... NOLINTEND comments to suppress clang-tidy warnings over multiple lines

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



Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp:6
+
+// NOLINTEND
+class B1 { B1(int i); };

salman-javed-nz wrote:
> aaron.ballman wrote:
> > Do you think this should be diagnosed as a sign of user confusion with the 
> > markings?
> For a stray `NOLINTEND` like this one, I don't think so. The original warning 
> is still raised, so I see this as clang-tidy failing safe. The user is forced 
> to fix their mistake before the warning goes away.
> 
> The consequences are of the same severity as misusing the existing `NOLINT` 
> and `NOLINTNEXTLINE` markers, e.g. putting `NOLINT` on the wrong line, or 
> adding a blank line after `NOLINTNEXTLINE`.
Hmm, I'm not yet convinced we don't want to diagnose this situation. I agree 
that the behavior of *other* diagnostics is good (the user still gets those 
diagnostics because no range has been suppressed). But it seems like the 
programmer made a mistake if they don't balance the begin and end markers. I 
don't think this causes major issues, but I think the code is a bit harder to 
read because someone who spots the end marker may try looking for the begin 
marker that doesn't exist.

I suppose there's a small chance that a stray END may surprise users for more 
than just code readability -- consider a file with a stray end marker where the 
user wants to lazily suppress the end file by putting `NOLINTBEGIN` at the head 
of the file and `NOLINTEND` at the end of the file -- the stray `NOLINTEND` in 
the middle interrupts the full range.



Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp:86
+
+// NOLINTBEGIN
+class H1 { H1(int i); };

salman-javed-nz wrote:
> aaron.ballman wrote:
> > Should this be diagnosed as user confusion?
> > 
> > My concern in both of these cases isn't so much that someone writes this 
> > intentionally, but that one of the begin/end pair gets removed accidentally 
> > when refactoring. Helping the user to identify *where* the unmatched 
> > delimiters are seems like it could be user-friendly behavior.
> The consequences of this one are higher, as there is the potential to 
> suppress warnings unintentionally and allow clang-tidy rule violations to go 
> undetected. I agree that something more could be done here.
> 
> I can think of two improvements:
> 
> 1. In `LineIsMarkedWithNOLINT()`, when a `NOLINTBEGIN` is found, only return 
> true if the corresponding `NOLINTEND` is found as well. Raise the original 
> warning if the `NOLINTEND` is omitted.
> 
> 2. Raise an additional warning regarding the unmatched pair of delimiters. 
> Some guidance on how to implement it would be appreciated. In the call stack 
> of the `LineIsMarkedWithNOLINT()` function, I can't see any exposed 
> functionality to generate new diagnostics on the fly. Would a new clang-tidy 
> check be the place to implement this?
That's a good question -- I don't know that I would expect 
`LineIsMarkedWithNOLINT()` to generate a diagnostic, but it's the obvious place 
for checking the validity of the markers. Naively, I would not expect to have 
to run a linter to check my lint markings, I would expect the linting tool to 
do that for me.

Would it make sense for `shouldSuppressDiagnostic()` to take a container of 
diagnostics generated (so `LineIsMarkedWithNOLINT()` has a place to store 
diagnostics), and `ClangTidyDiagnosticConsumer::HandleDiagnostic()` then checks 
whether the container is empty and if not, emits the additional diagnostics 
from there?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108560

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


[clang] 601102d - Cleanup identifier parsing; NFC

2021-09-14 Thread Aaron Ballman via cfe-commits

Author: Corentin Jabot
Date: 2021-09-14T09:12:22-04:00
New Revision: 601102d282d5e9a1429fea52ee17303aec8a7c10

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

LOG: Cleanup identifier parsing; NFC

Rename methods to clearly signal when they only deal with ASCII,
simplify the parsing of identifier, and use start/continue instead of
head/body for consistency with Unicode terminology.

Added: 


Modified: 
clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/refactor/Rename.cpp
clang/include/clang/Basic/CharInfo.h
clang/include/clang/Lex/Lexer.h
clang/lib/ARCMigrate/ObjCMT.cpp
clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/Basic/Module.cpp
clang/lib/Edit/EditedSource.cpp
clang/lib/Frontend/LayoutOverrideSource.cpp
clang/lib/Frontend/Rewrite/FrontendActions.cpp
clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
clang/lib/Lex/Lexer.cpp
clang/lib/Lex/ModuleMap.cpp
clang/lib/Sema/SemaAvailability.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaExprObjC.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Tooling/Transformer/Parsing.cpp
clang/unittests/Basic/CharInfoTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp 
b/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
index 1a765666563ca..2af1f622aa92f 100644
--- a/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
+++ b/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
@@ -245,7 +245,7 @@ clang::TypoCorrection IncludeFixerSemaSource::CorrectTypo(
 // parent_path.
 // FIXME: Don't rely on source text.
 const char *End = Source.end();
-while (isIdentifierBody(*End) || *End == ':')
+while (isAsciiIdentifierContinue(*End) || *End == ':')
   ++End;
 
 return std::string(Source.begin(), End);

diff  --git a/clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp 
b/clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp
index b5600c19a6d53..e6bda4f6abc37 100644
--- a/clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp
@@ -129,7 +129,7 @@ void IntegerTypesCheck::check(const 
MatchFinder::MatchResult &Result) {
   const StringRef Port = "unsigned short port";
   const char *Data = Result.SourceManager->getCharacterData(Loc);
   if (!std::strncmp(Data, Port.data(), Port.size()) &&
-  !isIdentifierBody(Data[Port.size()]))
+  !isAsciiIdentifierContinue(Data[Port.size()]))
 return;
 
   std::string Replacement =

diff  --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
index 2bb97eca14ab2..d719f847f50d8 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -464,7 +464,7 @@ void RenamerClangTidyCheck::check(const 
MatchFinder::MatchResult &Result) {
 Failure.FixStatus = ShouldFixStatus::ConflictsWithKeyword;
   else if (Ident->hasMacroDefinition())
 Failure.FixStatus = ShouldFixStatus::ConflictsWithMacroDefinition;
-} else if (!isValidIdentifier(Info.Fixup)) {
+} else if (!isValidAsciiIdentifier(Info.Fixup)) {
   Failure.FixStatus = ShouldFixStatus::FixInvalidIdentifier;
 }
 

diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index abaedff82686c..54d0e69c4cf45 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -1842,14 +1842,14 @@ CompletionPrefix guessCompletionPrefix(llvm::StringRef 
Content,
   CompletionPrefix Result;
 
   // Consume the unqualified name. We only handle ASCII characters.
-  // isIdentifierBody will let us match "0invalid", but we don't mind.
-  while (!Rest.empty() && isIdentifierBody(Rest.back()))
+  // isAsciiIdentifierContinue will let us match "0invalid", but we don't mind.
+  while (!Rest.empty() && isAsciiIdentifierContinue(Rest.back()))
 Rest = Rest.drop_back();
   Result.Name = Content.slice(Rest.size(), Offset);
 
   // Consume qualifiers.
   while (Rest.consume_back("::") && !Rest.endswith(":")) // reject 
-while (!Rest.empty() && isIdentifierBody(Rest.back()))
+while (!Rest.empty() && isAsciiIdentifierContinue(Rest.back()))
   Rest = Rest.drop_back();
   Result.Qualifier =
   Content.slice(Rest.size(), Result.Name.begin() - Content.begin());
@@ -2057,8 +2057,8 @@ 

[PATCH] D108308: Cleanup identifier parsing.

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

Thank you for the cleanup! I've landed in 
601102d282d5e9a1429fea52ee17303aec8a7c10 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108308

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


[PATCH] D103835: [CUDA][HIP] Fix store of vtbl in ctor

2021-09-14 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

Merging this change broke our out-of-tree CHERI targets (and Arm Morello). We 
use addrspace(200) for *all* globals (including vtables). It would have been 
nice if I had been added to this review considering that I added line you are 
changing here.

If vtables are not in the default globals address space, I think we need 
another way of expressing this. I think 
`CGM.getContext().getTargetAddressSpace(LangAS::Default))` should also be 
correct for your use-case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103835

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


[PATCH] D109517: [Clang][ARM][AArch64] Add support for Armv9-A, Armv9.1-A and Armv9.2-A

2021-09-14 Thread Victor Campos via Phabricator via cfe-commits
vhscampos updated this revision to Diff 372473.
vhscampos marked 3 inline comments as done.
vhscampos added a comment.

1. Enable the SVE2 extension as default.
2. Remove out of date comments in tests.
3. Remove unrelated change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109517

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  clang/test/Preprocessor/aarch64-target-features.c
  clang/test/Preprocessor/arm-target-features.c
  llvm/include/llvm/ADT/Triple.h
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/AArch64TargetParser.cpp
  llvm/lib/Support/ARMTargetParser.cpp
  llvm/lib/Support/Triple.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
  llvm/test/MC/AArch64/SME/directives-negative.s
  llvm/test/MC/AArch64/SME/directives.s
  llvm/test/MC/AArch64/SVE2/directive-arch-negative.s
  llvm/test/MC/AArch64/SVE2/directive-arch.s
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -31,6 +31,7 @@
 "armv8.5a","armv8.6-a","armv8.6a","armv8.7-a","armv8.7a",
 "armv8-r", "armv8r",   "armv8-m.base","armv8m.base",  "armv8-m.main",
 "armv8m.main", "iwmmxt",   "iwmmxt2", "xscale",   "armv8.1-m.main",
+"armv9-a", "armv9.1-a","armv9.2-a",
 };
 
 template 
@@ -492,6 +493,15 @@
   EXPECT_TRUE(
   testARMArch("armv8.7-a", "generic", "v8.7a",
   ARMBuildAttrs::CPUArch::v8_A));
+  EXPECT_TRUE(
+  testARMArch("armv9-a", "generic", "v9a",
+  ARMBuildAttrs::CPUArch::v8_A));
+  EXPECT_TRUE(
+  testARMArch("armv9.1-a", "generic", "v9.1a",
+  ARMBuildAttrs::CPUArch::v8_A));
+  EXPECT_TRUE(
+  testARMArch("armv9.2-a", "generic", "v9.2a",
+  ARMBuildAttrs::CPUArch::v8_A));
   EXPECT_TRUE(
   testARMArch("armv8-r", "cortex-r52", "v8r",
   ARMBuildAttrs::CPUArch::v8_R));
@@ -821,6 +831,9 @@
 case ARM::ArchKind::ARMV8_5A:
 case ARM::ArchKind::ARMV8_6A:
 case ARM::ArchKind::ARMV8_7A:
+case ARM::ArchKind::ARMV9A:
+case ARM::ArchKind::ARMV9_1A:
+case ARM::ArchKind::ARMV9_2A:
   EXPECT_EQ(ARM::ProfileKind::A, ARM::parseArchProfile(ARMArch[i]));
   break;
 default:
@@ -1204,6 +1217,12 @@
   ARMBuildAttrs::CPUArch::v8_A));
   EXPECT_TRUE(testAArch64Arch("armv8.7-a", "generic", "v8.7a",
   ARMBuildAttrs::CPUArch::v8_A));
+  EXPECT_TRUE(testAArch64Arch("armv9-a", "generic", "v9a",
+  ARMBuildAttrs::CPUArch::v8_A));
+  EXPECT_TRUE(testAArch64Arch("armv9.1-a", "generic", "v9.1a",
+  ARMBuildAttrs::CPUArch::v8_A));
+  EXPECT_TRUE(testAArch64Arch("armv9.2-a", "generic", "v9.2a",
+  ARMBuildAttrs::CPUArch::v8_A));
 }
 
 bool testAArch64Extension(StringRef CPUName, AArch64::ArchKind AK,
Index: llvm/test/MC/AArch64/SVE2/directive-arch.s
===
--- llvm/test/MC/AArch64/SVE2/directive-arch.s
+++ llvm/test/MC/AArch64/SVE2/directive-arch.s
@@ -1,21 +1,21 @@
 // RUN: llvm-mc -triple aarch64 -filetype asm -o - %s 2>&1 | FileCheck %s
 
-.arch armv8-a+sve2
+.arch armv9-a+sve2
 tbx z0.b, z1.b, z2.b
 // CHECK: tbx z0.b, z1.b, z2.b
 
-.arch armv8-a+sve2-aes
+.arch armv9-a+sve2-aes
 aesd z23.b, z23.b, z13.b
 // CHECK: aesd z23.b, z23.b, z13.b
 
-.arch armv8-a+sve2-sm4
+.arch armv9-a+sve2-sm4
 sm4e z0.s, z0.s, z0.s
 // CHECK: sm4e z0.s, z0.s, z0.s
 
-.arch armv8-a+sve2-sha3
+.arch armv9-a+sve2-sha3
 rax1 z0.d, z0.d, z0.d
 // CHECK: rax1 z0.d, z0.d, z0.d
 
-.arch armv8-a+sve2-bitperm
+.arch armv9-a+sve2-bitperm
 bgrp z21.s, z10.s, z21.s
 // CHECK: bgrp z21.s, z10.s, z21.s
Index: llvm/test/MC/AArch64/SVE2/directive-arch-negative.s
===
--- llvm/test/MC/AArch64/SVE2/directive-arch-negative.s
+++ llvm/test/MC/AArch64/SVE2/directive-arch-negative.s
@@ -1,31 +1,31 @@
 // RUN: not llvm-mc -triple aarch64 -filetype asm -o - %s 2>&1 | FileCheck %s
 
-.arch armv8-a+sve2
-.arch armv8-a+nosve2
+.arch armv9-a+sve2
+.arch armv9-a+nosve2
 tbx z0.b, z1.b, z2.b
 // CHECK: error: instruct

[PATCH] D105191: [Clang][OpenMP] Add support for Static Device Libraries

2021-09-14 Thread Ye Luo via Phabricator via cfe-commits
ye-luo added a comment.

  yeluo@epyc-server:~/opt/openmp-target/tests/math$ clang++ -fopenmp 
-fopenmp-targets=nvptx64 -Xopenmp-target=nvptx64 -march=sm_80 modf.cpp -c
  yeluo@epyc-server:~/opt/openmp-target/tests/math$ clang-offload-bundler 
-type=o --inputs=modf.o --list
  openmp-nvptx64
  host-x86_64-unknown-linux-gnu
  yeluo@epyc-server:~/opt/openmp-target/tests/math$ clang++ -fopenmp 
-fopenmp-targets=nvptx64 modf.cpp -c
  yeluo@epyc-server:~/opt/openmp-target/tests/math$ clang-offload-bundler 
-type=o --inputs=modf.o --list
  openmp-nvptx64
  host-x86_64-unknown-linux-gnu
  yeluo@epyc-server:~/opt/openmp-target/tests/math$ clang++ -fopenmp 
-fopenmp-targets=nvptx64-nvidia-cuda modf.cpp -c
  warning: linking module 
'/soft/llvm/main-20210910/lib/libomptarget-nvptx-sm_80.bc': Linking two modules 
of different target triples: 
'/soft/llvm/main-20210910/lib/libomptarget-nvptx-sm_80.bc' is 'nvptx64' whereas 
'modf.cpp' is 'nvptx64-nvidia-cuda'
   [-Wlinker-warnings]
  1 warning generated.
  yeluo@epyc-server:~/opt/openmp-target/tests/math$ clang-offload-bundler 
-type=o --inputs=modf.o --list
  openmp-nvptx64-nvidia-cuda
  host-x86_64-unknown-linux-gnu

Here is my clang build recipe

  cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=$INSTALL_FOLDER \
  -DLLVM_ENABLE_BACKTRACES=ON \
  -DLLVM_ENABLE_WERROR=OFF \
  -DBUILD_SHARED_LIBS=OFF \
  -DLLVM_ENABLE_RTTI=ON \
  -DLLVM_TARGETS_TO_BUILD="X86;AMDGPU;NVPTX" \
  -DLLVM_ENABLE_ASSERTIONS=ON \
  -DLLVM_ENABLE_PROJECTS="clang;lld" \
  -DLLVM_ENABLE_RUNTIMES="libcxxabi;libcxx;openmp" \
  -DLIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES="80,61" \
  -DCLANG_OPENMP_NVPTX_DEFAULT_ARCH=sm_80 \
  -DLIBOMPTARGET_NVPTX_MAX_SM=38 \
  -DLIBOMPTARGET_ENABLE_DEBUG=ON \
  ../llvm-project/llvm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105191

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


[PATCH] D109517: [Clang][ARM][AArch64] Add support for Armv9-A, Armv9.1-A and Armv9.2-A

2021-09-14 Thread Victor Campos via Phabricator via cfe-commits
vhscampos added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:413
 
-  auto V8_6Pos = llvm::find(Features, "+v8.6a");
-  if (V8_6Pos != std::end(Features))
-V8_6Pos = Features.insert(std::next(V8_6Pos), {"+i8mm", "+bf16"});
+  const char *Archs[] = {"+v8.6a", "+v8.7a", "+v9.1a", "+v9.2a"};
+  auto Pos = std::find_first_of(Features.begin(), Features.end(),

SjoerdMeijer wrote:
> How about `+v9a`?
Since v9a maps to v8.5a, and the latter was skipped in the original code, I did 
not include v9a here.



Comment at: llvm/unittests/Support/TargetParserTest.cpp:495
   ARMBuildAttrs::CPUArch::v8_A));
+  EXPECT_TRUE(
+  testARMArch("armv9-a", "generic", "v9a",

SjoerdMeijer wrote:
> I haven't looked, but in these target parser tests, do we also not need to 
> check the architecture descriptions?
> Copied this for example from the target parser def file:
> 
>  (ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
>   ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS |
>   ARM::AEK_DOTPROD)
If I understand it correctly, we only check architecture extensions for CPUs, 
not for the architectures themselves.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109517

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


[PATCH] D109362: [SystemZ][z/OS] Add GOFF Support to the DataLayout

2021-09-14 Thread Anirudh Prasad via Phabricator via cfe-commits
anirudhp added a comment.

Ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

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


[PATCH] D108893: clang-tidy: introduce readability-containter-data-pointer check

2021-09-14 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

What about adding `modernize`/`bugprone` aliases?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108893

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


[clang-tools-extra] 8401713 - [clangd] Ignore ObjC `id` and `instancetype` in FindTarget

2021-09-14 Thread David Goldman via cfe-commits

Author: David Goldman
Date: 2021-09-14T09:53:42-04:00
New Revision: 8401713b3ef1456a603874d96a99b2d5953df49c

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

LOG: [clangd] Ignore ObjC `id` and `instancetype` in FindTarget

Even though they're implemented via typedefs, we typically
want to treat them like keywords.

We could add hover information / xrefs, but it's very unlikely
to provide any value.

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index b68e5c6c1e899..8419043f4462a 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -94,6 +94,16 @@ const NamedDecl *getTemplatePattern(const NamedDecl *D) {
   return nullptr;
 }
 
+// Returns true if the `TypedefNameDecl` should not be reported.
+bool shouldSkipTypedef(const TypedefNameDecl *TD) {
+  // These should be treated as keywords rather than decls - the typedef is an
+  // odd implementation detail.
+  if (TD == TD->getASTContext().getObjCInstanceTypeDecl() ||
+  TD == TD->getASTContext().getObjCIdDecl())
+return true;
+  return false;
+}
+
 // TargetFinder locates the entities that an AST node refers to.
 //
 // Typically this is (possibly) one declaration and (possibly) one type, but
@@ -395,6 +405,8 @@ struct TargetFinder {
 }
   }
   void VisitTypedefType(const TypedefType *TT) {
+if (shouldSkipTypedef(TT->getDecl()))
+  return;
 Outer.add(TT->getDecl(), Flags);
   }
   void
@@ -903,6 +915,8 @@ refInTypeLoc(TypeLoc L, const HeuristicResolver *Resolver) {
 }
 
 void VisitTypedefTypeLoc(TypedefTypeLoc L) {
+  if (shouldSkipTypedef(L.getTypedefNameDecl()))
+return;
   Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
   L.getNameLoc(),
   /*IsDecl=*/false,

diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index bccf98ee07ab4..14cb15a7644b0 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -995,6 +995,20 @@ TEST_F(TargetDeclTest, ObjC) {
 }
   )cpp";
   EXPECT_DECLS("ObjCPropertyRefExpr", "+ (id)sharedInstance");
+
+  Code = R"cpp(
+@interface Foo
++ ([[id]])sharedInstance;
+@end
+  )cpp";
+  EXPECT_DECLS("TypedefTypeLoc");
+
+  Code = R"cpp(
+@interface Foo
++ ([[instancetype]])sharedInstance;
+@end
+  )cpp";
+  EXPECT_DECLS("TypedefTypeLoc");
 }
 
 class FindExplicitReferencesTest : public ::testing::Test {

diff  --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp 
b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index 646c6ec184652..1a9220e911e32 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -661,13 +661,15 @@ sizeof...($TemplateParameter[[Elements]]);
 @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]];
+-(id) $Method_decl[[x]]:(int)$Parameter_decl[[a]] 
$Method_decl[[y]]:(int)$Parameter_decl[[b]];
++(instancetype)$StaticMethod_decl_static[[sharedInstance]];
 +(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]] {
+-(id) $Method_decl[[x]]:(int)$Parameter_decl[[a]] 
$Method_decl[[y]]:(int)$Parameter_decl[[b]] {
   return self;
 }
++(instancetype)$StaticMethod_decl_static[[sharedInstance]] { return 0; 
}
 +(void) $StaticMethod_decl_static[[explode]] {}
 @end
 



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


[PATCH] D108556: [clangd] Don't highlight ObjC `id` and `instancetype`

2021-09-14 Thread David Goldman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8401713b3ef1: [clangd] Ignore ObjC `id` and `instancetype` 
in FindTarget (authored by dgoldman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108556

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -661,13 +661,15 @@
 @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]];
+-(id) $Method_decl[[x]]:(int)$Parameter_decl[[a]] 
$Method_decl[[y]]:(int)$Parameter_decl[[b]];
++(instancetype)$StaticMethod_decl_static[[sharedInstance]];
 +(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]] {
+-(id) $Method_decl[[x]]:(int)$Parameter_decl[[a]] 
$Method_decl[[y]]:(int)$Parameter_decl[[b]] {
   return self;
 }
++(instancetype)$StaticMethod_decl_static[[sharedInstance]] { return 0; 
}
 +(void) $StaticMethod_decl_static[[explode]] {}
 @end
 
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -995,6 +995,20 @@
 }
   )cpp";
   EXPECT_DECLS("ObjCPropertyRefExpr", "+ (id)sharedInstance");
+
+  Code = R"cpp(
+@interface Foo
++ ([[id]])sharedInstance;
+@end
+  )cpp";
+  EXPECT_DECLS("TypedefTypeLoc");
+
+  Code = R"cpp(
+@interface Foo
++ ([[instancetype]])sharedInstance;
+@end
+  )cpp";
+  EXPECT_DECLS("TypedefTypeLoc");
 }
 
 class FindExplicitReferencesTest : public ::testing::Test {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -94,6 +94,16 @@
   return nullptr;
 }
 
+// Returns true if the `TypedefNameDecl` should not be reported.
+bool shouldSkipTypedef(const TypedefNameDecl *TD) {
+  // These should be treated as keywords rather than decls - the typedef is an
+  // odd implementation detail.
+  if (TD == TD->getASTContext().getObjCInstanceTypeDecl() ||
+  TD == TD->getASTContext().getObjCIdDecl())
+return true;
+  return false;
+}
+
 // TargetFinder locates the entities that an AST node refers to.
 //
 // Typically this is (possibly) one declaration and (possibly) one type, but
@@ -395,6 +405,8 @@
 }
   }
   void VisitTypedefType(const TypedefType *TT) {
+if (shouldSkipTypedef(TT->getDecl()))
+  return;
 Outer.add(TT->getDecl(), Flags);
   }
   void
@@ -903,6 +915,8 @@
 }
 
 void VisitTypedefTypeLoc(TypedefTypeLoc L) {
+  if (shouldSkipTypedef(L.getTypedefNameDecl()))
+return;
   Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
   L.getNameLoc(),
   /*IsDecl=*/false,


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -661,13 +661,15 @@
 @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]];
+-(id) $Method_decl[[x]]:(int)$Parameter_decl[[a]] $Method_decl[[y]]:(int)$Parameter_decl[[b]];
++(instancetype)$StaticMethod_decl_static[[sharedInstance]];
 +(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]] {
+-(id) $Method_decl[[x]]:(int)$Parameter_decl[[a]] $Method_decl[[y]]:(int)$Parameter_decl[[b]] {
   return self;
 }
++(instancetype)$StaticMethod_decl_static[[sharedInstance]] { return 0; }
 +(void) $StaticMethod_decl_static[[explode]] {}
 @end
 
Index: clang-tools-extra/clangd/unittests/FindTargetTests

[PATCH] D108893: clang-tidy: introduce readability-containter-data-pointer check

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

In D108893#2999645 , @Eugene.Zelenko 
wrote:

> What about adding `modernize`/`bugprone` aliases?

I'd be fine if we wanted to add aliases, but I'd sort of expect some extra 
functionality out of a check in those modules. I think it's fine to land this 
now, and we can add aliases in a follow-up. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108893

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


[clang] fb4d590 - Fix a unittest file after D108695 when Z3 is enabled

2021-09-14 Thread Kristóf Umann via cfe-commits

Author: Kristóf Umann
Date: 2021-09-14T16:11:11+02:00
New Revision: fb4d590a622f4031900516360c07ee6ace01c5e6

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

LOG: Fix a unittest file after D108695 when Z3 is enabled

Added: 


Modified: 
clang/unittests/StaticAnalyzer/CheckerRegistration.h
clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp

Removed: 




diff  --git a/clang/unittests/StaticAnalyzer/CheckerRegistration.h 
b/clang/unittests/StaticAnalyzer/CheckerRegistration.h
index de804236229ad..bccdb94d29383 100644
--- a/clang/unittests/StaticAnalyzer/CheckerRegistration.h
+++ b/clang/unittests/StaticAnalyzer/CheckerRegistration.h
@@ -20,11 +20,27 @@
 namespace clang {
 namespace ento {
 
-class DiagConsumer : public PathDiagnosticConsumer {
+class OnlyWarningsDiagConsumer : public PathDiagnosticConsumer {
   llvm::raw_ostream &Output;
 
 public:
-  DiagConsumer(llvm::raw_ostream &Output) : Output(Output) {}
+  OnlyWarningsDiagConsumer(llvm::raw_ostream &Output) : Output(Output) {}
+  void FlushDiagnosticsImpl(std::vector &Diags,
+FilesMade *filesMade) override {
+for (const auto *PD : Diags) {
+  Output << PD->getCheckerName() << ": ";
+  Output << PD->getShortDescription() << '\n';
+}
+  }
+
+  StringRef getName() const override { return "Test"; }
+};
+
+class PathDiagConsumer : public PathDiagnosticConsumer {
+  llvm::raw_ostream &Output;
+
+public:
+  PathDiagConsumer(llvm::raw_ostream &Output) : Output(Output) {}
   void FlushDiagnosticsImpl(std::vector &Diags,
 FilesMade *filesMade) override {
 for (const auto *PD : Diags) {
@@ -65,18 +81,24 @@ void addChecker(AnalysisASTConsumer &AnalysisConsumer,
   Fn1(AnalysisConsumer, AnOpts);
 }
 
-template 
-class TestAction : public ASTFrontendAction {
+template  class TestAction : public ASTFrontendAction {
   llvm::raw_ostream &DiagsOutput;
+  bool OnlyEmitWarnings;
 
 public:
-  TestAction(llvm::raw_ostream &DiagsOutput) : DiagsOutput(DiagsOutput) {}
+  TestAction(llvm::raw_ostream &DiagsOutput, bool OnlyEmitWarnings)
+  : DiagsOutput(DiagsOutput), OnlyEmitWarnings(OnlyEmitWarnings) {}
 
   std::unique_ptr CreateASTConsumer(CompilerInstance &Compiler,
  StringRef File) override {
 std::unique_ptr AnalysisConsumer =
 CreateAnalysisConsumer(Compiler);
-AnalysisConsumer->AddDiagnosticConsumer(new DiagConsumer(DiagsOutput));
+if (OnlyEmitWarnings)
+  AnalysisConsumer->AddDiagnosticConsumer(
+  new OnlyWarningsDiagConsumer(DiagsOutput));
+else
+  AnalysisConsumer->AddDiagnosticConsumer(
+  new PathDiagConsumer(DiagsOutput));
 addChecker(*AnalysisConsumer, *Compiler.getAnalyzerOpts());
 return std::move(AnalysisConsumer);
   }
@@ -92,15 +114,16 @@ inline SmallString<80> getCurrentTestNameAsFileName() {
 }
 
 template 
-bool runCheckerOnCode(const std::string &Code, std::string &Diags) {
+bool runCheckerOnCode(const std::string &Code, std::string &Diags,
+  bool OnlyEmitWarnings = false) {
   const SmallVectorImpl &FileName = getCurrentTestNameAsFileName();
   llvm::raw_string_ostream OS(Diags);
-  return tooling::runToolOnCode(std::make_unique>(OS), Code,
-FileName);
+  return tooling::runToolOnCode(
+  std::make_unique>(OS, OnlyEmitWarnings), Code,
+  FileName);
 }
 
-template 
-bool runCheckerOnCode(const std::string &Code) {
+template  bool runCheckerOnCode(const std::string &Code) {
   std::string Diags;
   return runCheckerOnCode(Code, Diags);
 }
@@ -108,11 +131,13 @@ bool runCheckerOnCode(const std::string &Code) {
 template 
 bool runCheckerOnCodeWithArgs(const std::string &Code,
   const std::vector &Args,
-  std::string &Diags) {
+  std::string &Diags,
+  bool OnlyEmitWarnings = false) {
   const SmallVectorImpl &FileName = getCurrentTestNameAsFileName();
   llvm::raw_string_ostream OS(Diags);
   return tooling::runToolOnCodeWithArgs(
-  std::make_unique>(OS), Code, Args, FileName);
+  std::make_unique>(OS, OnlyEmitWarnings), Code, Args,
+  FileName);
 }
 
 template 

diff  --git 
a/clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp 
b/clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
index beaaebdd36cf9..28dad31f54f3e 100644
--- a/clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
+++ b/clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
@@ -126,7 +126,7 @@ TEST_F(FalsePositiveRefutationBRVisitorTestBase, 
UnSatInTheMiddleNoReport) {
 
   std::string Dia

[PATCH] D108695: [analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it

2021-09-14 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

rGfb4d590a622f4031900516360c07ee6ace01c5e6 
 should 
sort this out!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108695

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


[PATCH] D108893: clang-tidy: introduce readability-containter-data-pointer check

2021-09-14 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

In D108893#2999654 , @aaron.ballman 
wrote:

> In D108893#2999645 , 
> @Eugene.Zelenko wrote:
>
>> What about adding `modernize`/`bugprone` aliases?
>
> I'd be fine if we wanted to add aliases, but I'd sort of expect some extra 
> functionality out of a check in those modules. I think it's fine to land this 
> now, and we can add aliases in a follow-up. WDYT?

Aliases code is trivial comparing with check itself, so it make sense to add it 
in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108893

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


[PATCH] D109362: [SystemZ][z/OS] Add GOFF Support to the DataLayout

2021-09-14 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

Looking at the common code parts, it seems the behavior of MM_GOFF is actually 
identical to MM_ELF.   Is this correct?   If so, do we really need a different 
format type here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

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


[PATCH] D109710: [PowerPC] Add range checks for P10 Vector Builtins

2021-09-14 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 372479.
quinnp added a comment.

Fixing failing test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109710

Files:
  clang/lib/Headers/altivec.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-p10vector-error.c
  clang/test/CodeGen/builtins-ppc-p10vector.c

Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -1370,10 +1370,12 @@
 }
 
 vector signed int test_vec_vec_splati_ins_si(void) {
+  // CHECK-BE: [[T0:%.+]] = and i32 %{{.+}}, 1
   // CHECK-BE: insertelement <4 x i32> %{{.+}}, i32 %{{.+}}, i32 %{{.+}}
   // CHECK-BE:  [[T1:%.+]] = add i32 2, %{{.+}}
   // CHECK-BE: insertelement <4 x i32> %{{.+}}, i32 %{{.+}}, i32 [[T1]]
   // CHECK-BE: ret <4 x i32>
+  // CHECK-LE: [[T0:%.+]] = and i32 %{{.+}}, 1
   // CHECK-LE:  [[T1:%.+]] = sub i32 1, %{{.+}}
   // CHECK-LE: insertelement <4 x i32> %{{.+}}, i32 %{{.+}}, i32 [[T1]]
   // CHECK-LE:  [[T2:%.+]] = sub i32 3, %{{.+}}
@@ -1383,10 +1385,12 @@
 }
 
 vector unsigned int test_vec_vec_splati_ins_ui(void) {
+  // CHECK-BE: [[T0:%.+]] = and i32 %{{.+}}, 1
   // CHECK-BE: insertelement <4 x i32> %{{.+}}, i32 %{{.+}}, i32 %{{.+}}
   // CHECK-BE:  [[T1:%.+]] = add i32 2, %{{.+}}
   // CHECK-BE: insertelement <4 x i32> %{{.+}}, i32 %{{.+}}, i32 [[T1]]
   // CHECK-BE: ret <4 x i32>
+  // CHECK-LE: [[T0:%.+]] = and i32 %{{.+}}, 1
   // CHECK-LE:  [[T1:%.+]] = sub i32 1, %{{.+}}
   // CHECK-LE: insertelement <4 x i32> %{{.+}}, i32 %{{.+}}, i32 [[T1]]
   // CHECK-LE:  [[T2:%.+]] = sub i32 3, %{{.+}}
@@ -1396,10 +1400,12 @@
 }
 
 vector float test_vec_vec_splati_ins_f(void) {
+  // CHECK-BE: [[T0:%.+]] = and i32 %{{.+}}, 1
   // CHECK-BE: insertelement <4 x float> %{{.+}}, float %{{.+}}, i32 %{{.+}}
   // CHECK-BE:  [[T1:%.+]] = add i32 2, %{{.+}}
   // CHECK-BE: insertelement <4 x float> %{{.+}}, float %{{.+}}, i32 [[T1]]
   // CHECK-BE: ret <4 x float>
+  // CHECK-LE: [[T0:%.+]] = and i32 %{{.+}}, 1
   // CHECK-LE:  [[T1:%.+]] = sub i32 1, %{{.+}}
   // CHECK-LE: insertelement <4 x float> %{{.+}}, float %{{.+}}, i32 [[T1]]
   // CHECK-LE:  [[T2:%.+]] = sub i32 3, %{{.+}}
Index: clang/test/CodeGen/builtins-ppc-p10vector-error.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-p10vector-error.c
@@ -0,0 +1,32 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-cpu pwr10 \
+// RUN:   -fsyntax-only -Wall -Werror -verify %s
+// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -target-cpu pwr10 \
+// RUN:   -fsyntax-only -Wall -Werror -verify %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -target-cpu pwr10 \
+// RUN:   -fsyntax-only -Wall -Werror -verify %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -target-cpu pwr10 \
+// RUN:   -fsyntax-only -Wall -Werror -verify %s
+
+#include 
+
+vector unsigned char vuca;
+vector unsigned short vusa;
+vector unsigned int vuia;
+vector unsigned long long vulla;
+
+unsigned long long test_vec_cntm_uc(void) {
+  return vec_cntm(vuca, -1); // expected-error 1+ {{argument value 255 is outside the valid range [0, 1]}}
+}
+
+unsigned long long test_vec_cntm_us(void) {
+  return vec_cntm(vusa, -1); // expected-error 1+ {{argument value 255 is outside the valid range [0, 1]}}
+}
+
+unsigned long long test_vec_cntm_ui(void) {
+  return vec_cntm(vuia, 2); // expected-error 1+ {{argument value 2 is outside the valid range [0, 1]}}
+}
+
+unsigned long long test_vec_cntm_ull(void) {
+  return vec_cntm(vulla, 2); // expected-error 1+  {{argument value 2 is outside the valid range [0, 1]}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3473,6 +3473,11 @@
 return SemaFeatureCheck(*this, TheCall, "isa-v207-instructions",
 diag::err_ppc_builtin_only_on_arch, "8") ||
SemaBuiltinConstantArgRange(TheCall, 1, 1, 16);
+  case PPC::BI__builtin_altivec_vcntmbb:
+  case PPC::BI__builtin_altivec_vcntmbh:
+  case PPC::BI__builtin_altivec_vcntmbw:
+  case PPC::BI__builtin_altivec_vcntmbd:
+return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1);
 #define CUSTOM_BUILTIN(Name, Intr, Types, Acc) \
   case PPC::BI__builtin_##Name: \
 return SemaBuiltinPPCMMACall(TheCall, Types);
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ -18191,13 +18191,13 @@
 
 #define vec_cntm(__a, __mp)\
   _Generic((__a), vector unsigned char \
-  

[PATCH] D108893: clang-tidy: introduce readability-containter-data-pointer check

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

In D108893#2999681 , @Eugene.Zelenko 
wrote:

> In D108893#2999654 , @aaron.ballman 
> wrote:
>
>> In D108893#2999645 , 
>> @Eugene.Zelenko wrote:
>>
>>> What about adding `modernize`/`bugprone` aliases?
>>
>> I'd be fine if we wanted to add aliases, but I'd sort of expect some extra 
>> functionality out of a check in those modules. I think it's fine to land 
>> this now, and we can add aliases in a follow-up. WDYT?
>
> Aliases code is trivial comparing with check itself, so it make sense to add 
> it in this patch.

So you'd like to see that extra functionality added now? (I don't think it 
makes sense to have the check as-is in both `readability` and `modernize`.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108893

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


[PATCH] D108893: clang-tidy: introduce readability-containter-data-pointer check

2021-09-14 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

> So you'd like to see that extra functionality added now? (I don't think it 
> makes sense to have the check as-is in both `readability` and `modernize`.)

There are plenty  of 
other cross-module aliases already.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108893

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


[PATCH] D108893: clang-tidy: introduce readability-containter-data-pointer check

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

In D108893#2999698 , @Eugene.Zelenko 
wrote:

>> So you'd like to see that extra functionality added now? (I don't think it 
>> makes sense to have the check as-is in both `readability` and `modernize`.)
>
> There are plenty  
> of other cross-module aliases already.

Those are most often checks shared with coding guidelines or they have 
configurable differences between the modules. I do not think we commonly share 
identical checks between modules that are not coding standards.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108893

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


[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

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

In D108643#2991995 , @hjl.tools wrote:

>>> The choice that high bits are unspecified rather than extended is an 
>>> interesting one.  Can you speak to that?  That's good for +, -, *, &, |, ^, 
>>> <<, and narrowing conversions, but bad for ==, <, /, >>, and widening 
>>> conversions.
>>
>> I've added @hjl.tools to the review for his opinions, as he was the primary 
>> driver for the x64 ABI proposal. HJ, can you help me out here?
>
> Please follow up x86-64 psABI proposal with any feedbacks:
>
> https://groups.google.com/g/x86-64-abi/c/XQiSj-zU3w8

We don't have feedback yet, @hjl.tools; we're asking for rationale on the 
behavior of unused bits in the proposed psABI for x86-64. Can you help us 
understand why the bits are unspecified rather than extended and whether there 
are potential performance concerns from this decision (before it gets 
solidified)? Thanks!


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

https://reviews.llvm.org/D108643

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


[PATCH] D103835: [CUDA][HIP] Fix store of vtbl in ctor

2021-09-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D103835#2999545 , @arichardson 
wrote:

> Merging this change broke our out-of-tree CHERI targets (and Arm Morello). We 
> use addrspace(200) for *all* globals (including vtables). It would have been 
> nice if I had been added to this review considering that I added line you are 
> changing here.
>
> If vtables are not in the default globals address space, I think we need 
> another way of expressing this. I think 
> `CGM.getContext().getTargetAddressSpace(LangAS::Default))` should also be 
> correct for your use-case?

vtbl addr space should be the same as `this` pointer. If I use addr space of 
`this` pointer and not assuming it is default addr space, will it work for you? 
Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103835

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


[PATCH] D103835: [CUDA][HIP] Fix store of vtbl in ctor

2021-09-14 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

In D103835#2999731 , @yaxunl wrote:

> In D103835#2999545 , @arichardson 
> wrote:
>
>> Merging this change broke our out-of-tree CHERI targets (and Arm Morello). 
>> We use addrspace(200) for *all* globals (including vtables). It would have 
>> been nice if I had been added to this review considering that I added line 
>> you are changing here.
>>
>> If vtables are not in the default globals address space, I think we need 
>> another way of expressing this. I think 
>> `CGM.getContext().getTargetAddressSpace(LangAS::Default))` should also be 
>> correct for your use-case?
>
> vtbl addr space should be the same as `this` pointer. If I use addr space of 
> `this` pointer and not assuming it is default addr space, will it work for 
> you? Thanks.

Yes that would also work. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103835

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


[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

2021-09-14 Thread H.J Lu via Phabricator via cfe-commits
hjl.tools added a comment.

In D108643#2999724 , @aaron.ballman 
wrote:

> In D108643#2991995 , @hjl.tools 
> wrote:
>
 The choice that high bits are unspecified rather than extended is an 
 interesting one.  Can you speak to that?  That's good for +, -, *, &, |, 
 ^, <<, and narrowing conversions, but bad for ==, <, /, >>, and widening 
 conversions.
>>>
>>> I've added @hjl.tools to the review for his opinions, as he was the primary 
>>> driver for the x64 ABI proposal. HJ, can you help me out here?
>>
>> Please follow up x86-64 psABI proposal with any feedbacks:
>>
>> https://groups.google.com/g/x86-64-abi/c/XQiSj-zU3w8
>
> We don't have feedback yet, @hjl.tools; we're asking for rationale on the 
> behavior of unused bits in the proposed psABI for x86-64. Can you help us 
> understand why the bits are unspecified rather than extended and whether 
> there are potential performance concerns from this decision (before it gets 
> solidified)? Thanks!

It was suggested by people who proposed _BitInt.


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

https://reviews.llvm.org/D108643

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


[clang] 2fd180b - [IR] Reduce max supported integer from 2^24-1 to 2^23.

2021-09-14 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-09-14T07:52:10-07:00
New Revision: 2fd180bbb9a7bb8604a5aca31f1ca9dc5358a433

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

LOG: [IR] Reduce max supported integer from 2^24-1 to 2^23.

SelectionDAG will promote illegal types up to a power of 2 before
splitting down to a legal type. This will create an IntegerType
with a bit width that must be <= MAX_INT_BITS. This places an
effective upper limit on any type of 2^23 so that we don't try
create a 2^24 type.

I considered putting a fatal error somewhere in the path from
TargetLowering::getTypeConversion down to IntegerType::get, but
limiting the type in IR seemed better.

This breaks backwards compatibility with IR that is using a really
large type. I suspect such IR is going to be very rare due to the
the compile time costs such a type likely incurs.

Prevents the ICE in PR51829.

Reviewed By: efriedma, aaron.ballman

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/test/CodeGen/ext-int.c
clang/test/CodeGenCXX/ext-int.cpp
clang/test/SemaCXX/ext-int.cpp
llvm/docs/LangRef.rst
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/IR/DerivedTypes.h
llvm/test/Assembler/invalid-inttype.ll
llvm/test/Assembler/max-inttype.ll

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 56f91b4e5877f..4c2bf04e9a09e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -56,7 +56,8 @@ Improvements to Clang's diagnostics
 Non-comprehensive list of changes in this release
 -
 
-- ...
+- Maximum _ExtInt size was decreased from 16,777,215 bits to 8,388,608 bits.
+  Motivation for this was discussed in PR51829.
 
 New Compiler Flags
 --

diff  --git a/clang/test/CodeGen/ext-int.c b/clang/test/CodeGen/ext-int.c
index d8e763283bfd9..44ac45b425ac2 100644
--- a/clang/test/CodeGen/ext-int.c
+++ b/clang/test/CodeGen/ext-int.c
@@ -28,7 +28,7 @@ void VLATest(_ExtInt(3) A, _ExtInt(99) B, _ExtInt(123456) C) {
 
 struct S {
   _ExtInt(17) A;
-  _ExtInt(16777200) B;
+  _ExtInt(8388600) B;
   _ExtInt(17) C;
 };
 
@@ -41,9 +41,9 @@ void OffsetOfTest() {
   // LIN32: store i32 4, i32* %{{.+}}
   // WINCHECK32: store i32 8, i32* %{{.+}}
   int C = __builtin_offsetof(struct S,C);
-  // CHECK64: store i32 2097160, i32* %{{.+}}
-  // LIN32: store i32 2097156, i32* %{{.+}}
-  // WIN32: store i32 2097160, i32* %{{.+}}
+  // CHECK64: store i32 1048584, i32* %{{.+}}
+  // LIN32: store i32 1048580, i32* %{{.+}}
+  // WIN32: store i32 1048584, i32* %{{.+}}
 }
 
 void Size1ExtIntParam(unsigned _ExtInt(1) A) {

diff  --git a/clang/test/CodeGenCXX/ext-int.cpp 
b/clang/test/CodeGenCXX/ext-int.cpp
index 7f3bc07e98dd4..3cbcf1331eaff 100644
--- a/clang/test/CodeGenCXX/ext-int.cpp
+++ b/clang/test/CodeGenCXX/ext-int.cpp
@@ -223,23 +223,23 @@ void TakesVarargs(int i, ...) {
   // WIN: %[[LOADV4:.+]] = load i129, i129* %[[LOADP4]]
   // WIN: store i129 %[[LOADV4]], i129*
 
-  _ExtInt(16777200) E = __builtin_va_arg(args, _ExtInt(16777200));
+  _ExtInt(8388600) E = __builtin_va_arg(args, _ExtInt(8388600));
   // LIN: %[[AD5:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 
x %struct.__va_list_tag]* %[[ARGS]]
   // LIN: %[[OFA_P5:.+]] = getelementptr inbounds %struct.__va_list_tag, 
%struct.__va_list_tag* %[[AD5]], i32 0, i32 2
   // LIN: %[[OFA5:.+]] = load i8*, i8** %[[OFA_P5]]
-  // LIN: %[[BC5:.+]] = bitcast i8* %[[OFA5]] to i16777200*
-  // LIN: %[[OFANEXT5:.+]] = getelementptr i8, i8* %[[OFA5]], i32 2097152
+  // LIN: %[[BC5:.+]] = bitcast i8* %[[OFA5]] to i8388600*
+  // LIN: %[[OFANEXT5:.+]] = getelementptr i8, i8* %[[OFA5]], i32 1048576
   // LIN: store i8* %[[OFANEXT5]], i8** %[[OFA_P5]]
-  // LIN: %[[LOAD5:.+]] = load i16777200, i16777200* %[[BC5]]
-  // LIN: store i16777200 %[[LOAD5]], i16777200*
+  // LIN: %[[LOAD5:.+]] = load i8388600, i8388600* %[[BC5]]
+  // LIN: store i8388600 %[[LOAD5]], i8388600*
 
   // WIN: %[[CUR5:.+]] = load i8*, i8** %[[ARGS]]
   // WIN: %[[NEXT5:.+]] = getelementptr inbounds i8, i8* %[[CUR5]], i64 8
   // WIN: store i8* %[[NEXT5]], i8** %[[ARGS]]
-  // WIN: %[[BC5:.+]] = bitcast i8* %[[CUR5]] to i16777200**
-  // WIN: %[[LOADP5:.+]] = load i16777200*, i16777200** %[[BC5]]
-  // WIN: %[[LOADV5:.+]] = load i16777200, i16777200* %[[LOADP5]]
-  // WIN: store i16777200 %[[LOADV5]], i16777200*
+  // WIN: %[[BC5:.+]] = bitcast i8* %[[CUR5]] to i8388600**
+  // WIN: %[[LOADP5:.+]] = load i8388600*, i8388600** %[[BC5]]
+  // WIN: %[[LOADV5:.+]] = load i8388600, i8388600* %[[LOADP5]]
+  // WIN: store i8388600 %[[LOADV5]], i8388600*
 
   __builtin_va_end(args);
   // LIN: %[[ENDAD:.+]] = getelementptr inb

[PATCH] D109721: [IR] Reduce max supported integer from 2^24-1 to 2^23.

2021-09-14 Thread Craig Topper via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2fd180bbb9a7: [IR] Reduce max supported integer from 2^24-1 
to 2^23. (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109721

Files:
  clang/docs/ReleaseNotes.rst
  clang/test/CodeGen/ext-int.c
  clang/test/CodeGenCXX/ext-int.cpp
  clang/test/SemaCXX/ext-int.cpp
  llvm/docs/LangRef.rst
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/IR/DerivedTypes.h
  llvm/test/Assembler/invalid-inttype.ll
  llvm/test/Assembler/max-inttype.ll

Index: llvm/test/Assembler/max-inttype.ll
===
--- llvm/test/Assembler/max-inttype.ll
+++ llvm/test/Assembler/max-inttype.ll
@@ -1,4 +1,4 @@
 ; RUN: llvm-as < %s | llvm-dis
 
-; i16777215 is the maximum integer type represented in LLVM IR
-@i2 = common global i16777215 0, align 4
+; i838608 is the maximum integer type represented in LLVM IR
+@i2 = common global i838608 0, align 4
Index: llvm/test/Assembler/invalid-inttype.ll
===
--- llvm/test/Assembler/invalid-inttype.ll
+++ llvm/test/Assembler/invalid-inttype.ll
@@ -1,5 +1,5 @@
 ; RUN: not llvm-as < %s 2>&1 | FileCheck %s
 
-; i16777216 is the smallest integer type that can't be represented in LLVM IR
-@i2 = common global i16777216 0, align 4
+; i8388609 is the smallest integer type that can't be represented in LLVM IR
+@i2 = common global i8388609 0, align 4
 ; CHECK: expected type
Index: llvm/include/llvm/IR/DerivedTypes.h
===
--- llvm/include/llvm/IR/DerivedTypes.h
+++ llvm/include/llvm/IR/DerivedTypes.h
@@ -49,10 +49,11 @@
   /// This enum is just used to hold constants we need for IntegerType.
   enum {
 MIN_INT_BITS = 1,///< Minimum number of bits that can be specified
-MAX_INT_BITS = (1<<24)-1 ///< Maximum number of bits that can be specified
+MAX_INT_BITS = (1<<23)   ///< Maximum number of bits that can be specified
   ///< Note that bit width is stored in the Type classes SubclassData field
-  ///< which has 24 bits. This yields a maximum bit width of 16,777,215
-  ///< bits.
+  ///< which has 24 bits. SelectionDAG type legalization can require a
+  ///< power of 2 IntegerType, so limit to the largest representable power
+  ///< of 2, 8388608.
   };
 
   /// This static method is the primary way of constructing an IntegerType.
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -59,6 +59,7 @@
 * Using the legacy pass manager for the optimization pipeline is deprecated and
   will be removed after LLVM 14. In the meantime, only minimal effort will be
   made to maintain the legacy pass manager for the optimization pipeline.
+* Max allowed integer type was reduced from 2^24-1 bits to 2^23 bits.
 
 Changes to building LLVM
 
Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -3303,7 +3303,7 @@
 
 The integer type is a very simple type that simply specifies an
 arbitrary bit width for the integer type desired. Any bit width from 1
-bit to 2\ :sup:`23`\ -1 (about 8 million) can be specified.
+bit to 2\ :sup:`23`\ (about 8 million) can be specified.
 
 :Syntax:
 
Index: clang/test/SemaCXX/ext-int.cpp
===
--- clang/test/SemaCXX/ext-int.cpp
+++ clang/test/SemaCXX/ext-int.cpp
@@ -29,8 +29,8 @@
   constexpr _ExtInt(7) o = 33;
 
   // Check LLVM imposed max size.
-  _ExtInt(0xFF) p; // expected-error {{signed _ExtInt of bit sizes greater than 16777215 not supported}}
-  unsigned _ExtInt(0xFF) q; // expected-error {{unsigned _ExtInt of bit sizes greater than 16777215 not supported}}
+  _ExtInt(8388609) p; // expected-error {{signed _ExtInt of bit sizes greater than 8388608 not supported}}
+  unsigned _ExtInt(0xFF) q; // expected-error {{unsigned _ExtInt of bit sizes greater than 8388608 not supported}}
 
 // Ensure template params are instantiated correctly.
   // expected-error@5{{signed _ExtInt must have a bit size of at least 2}}
Index: clang/test/CodeGenCXX/ext-int.cpp
===
--- clang/test/CodeGenCXX/ext-int.cpp
+++ clang/test/CodeGenCXX/ext-int.cpp
@@ -223,23 +223,23 @@
   // WIN: %[[LOADV4:.+]] = load i129, i129* %[[LOADP4]]
   // WIN: store i129 %[[LOADV4]], i129*
 
-  _ExtInt(16777200) E = __builtin_va_arg(args, _ExtInt(16777200));
+  _ExtInt(8388600) E = __builtin_va_arg(ar

[clang-tools-extra] d0d9e6f - clang-tidy: introduce readability-containter-data-pointer check

2021-09-14 Thread Saleem Abdulrasool via cfe-commits

Author: Saleem Abdulrasool
Date: 2021-09-14T08:12:10-07:00
New Revision: d0d9e6f0849b2e76e980e2edf365302f47f4e35f

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

LOG: clang-tidy: introduce readability-containter-data-pointer check

This introduces a new check, readability-containter-data-pointer.  This
check is meant to catch the cases where the user may be trying to
materialize the data pointer by taking the address of the 0-th member of
a container.  With C++11 or newer, the `data` member should be used for
this.  This provides the following benefits:

- `.data()` is easier to read than `&[0]`
- it avoids an unnecessary re-materialization of the pointer
  * this doesn't matter in the case of optimized code, but in the case
of unoptimized code, this will be visible
- it avoids a potential invalid memory de-reference caused by the
  indexing when the container is empty (in debug mode, clang will
  normally optimize away the re-materialization in optimized builds).

The small potential behavioural change raises the question of where the
check should belong.  A reasoning of defense in depth applies here, and
this does an unchecked conversion, with the assumption that users can
use the static analyzer to catch cases where we can statically identify
an invalid memory de-reference.  For the cases where the static analysis
is unable to prove the size of the container, UBSan can be used to track
the invalid access.

Special thanks to Aaron Ballmann for the discussion on whether this
check would be useful and where to place it.

This also partially resolves PR26817!

Reviewed By: aaron.ballman

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

Added: 
clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
clang-tools-extra/docs/clang-tidy/checks/readability-data-pointer.rst

clang-tools-extra/test/clang-tidy/checkers/readability-container-data-pointer.cpp

Modified: 
clang-tools-extra/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
index 78256d6f73251..eba0ab98cb37a 100644
--- a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
@@ -7,6 +7,7 @@ add_clang_library(clangTidyReadabilityModule
   AvoidConstParamsInDecls.cpp
   BracesAroundStatementsCheck.cpp
   ConstReturnTypeCheck.cpp
+  ContainerDataPointerCheck.cpp
   ContainerSizeEmptyCheck.cpp
   ConvertMemberFunctionsToStatic.cpp
   DeleteNullPointerCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
new file mode 100644
index 0..3a670509ec2e2
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
@@ -0,0 +1,117 @@
+//===--- ContainerDataPointerCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ContainerDataPointerCheck.h"
+
+#include "clang/Lex/Lexer.h"
+#include "llvm/ADT/StringRef.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace readability {
+ContainerDataPointerCheck::ContainerDataPointerCheck(StringRef Name,
+ ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context) {}
+
+void ContainerDataPointerCheck::registerMatchers(MatchFinder *Finder) {
+  const auto Record =
+  cxxRecordDecl(
+  isSameOrDerivedFrom(
+  namedDecl(
+  has(cxxMethodDecl(isPublic(), hasName("data")).bind("data")))
+  .bind("container")))
+  .bind("record");
+
+  const auto NonTemplateContainerType =
+  
qualType(hasUnqualifiedDesugaredType(recordType(hasDeclaration(Record;
+  const auto TemplateContainerType =
+  qualType(hasUnqualifiedDesugaredType(templateSpecializationType(
+  hasDeclaration(classTemplateDecl(has(Record));
+
+  const auto Container =
+  qualType(anyOf(NonTemplateContainerType, TemplateContainerType));
+
+  Finder->addMatcher(
+  unaryOperator(
+  unless(isExpansionInSystemHeader()), hasOperatorName("&"),
+  hasUnaryOperand(anyOf(
+

[PATCH] D108893: clang-tidy: introduce readability-containter-data-pointer check

2021-09-14 Thread Saleem Abdulrasool via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
compnerd marked an inline comment as done.
Closed by commit rGd0d9e6f0849b: clang-tidy: introduce 
readability-containter-data-pointer check (authored by compnerd).

Changed prior to commit:
  https://reviews.llvm.org/D108893?vs=372285&id=372485#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108893

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
  clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-data-pointer.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-container-data-pointer.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-container-data-pointer.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-container-data-pointer.cpp
@@ -0,0 +1,110 @@
+// RUN: %check_clang_tidy %s readability-container-data-pointer %t
+
+typedef __SIZE_TYPE__ size_t;
+
+namespace std {
+template 
+struct vector {
+  using size_type = size_t;
+
+  vector();
+  explicit vector(size_type);
+
+  T *data();
+  const T *data() const;
+
+  T &operator[](size_type);
+  const T &operator[](size_type) const;
+};
+
+template 
+struct basic_string {
+  using size_type = size_t;
+
+  basic_string();
+
+  T *data();
+  const T *data() const;
+
+  T &operator[](size_t);
+  const T &operator[](size_type) const;
+};
+
+typedef basic_string string;
+typedef basic_string wstring;
+
+template 
+struct is_integral;
+
+template <>
+struct is_integral {
+  static const bool value = true;
+};
+
+template 
+struct enable_if { };
+
+template 
+struct enable_if {
+  typedef T type;
+};
+}
+
+template 
+void f(const T *);
+
+#define z (0)
+
+void g(size_t s) {
+  std::vector b(s);
+  f(&((b)[(z)]));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
+  // CHECK-FIXES: {{^  }}f(b.data());{{$}}
+}
+
+void h() {
+  std::string s;
+  f(&((s).operator[]((z;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
+  // CHECK-FIXES: {{^  }}f(s.data());{{$}}
+
+  std::wstring w;
+  f(&((&(w))->operator[]((z;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
+  // CHECK-FIXES: {{^  }}f(w.data());{{$}}
+}
+
+template ::value>::type>
+void i(U s) {
+  std::vector b(s);
+  f(&b[0]);
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
+  // CHECK-FIXES: {{^  }}f(b.data());{{$}}
+}
+
+template void i(size_t);
+
+void j(std::vector * const v) {
+  f(&(*v)[0]);
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
+  // CHECK-FIXES: {{^  }}f(v->data());{{$}}
+}
+
+void k(const std::vector &v) {
+  f(&v[0]);
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
+  // CHECK-FIXES: {{^  }}f(v.data());{{$}}
+}
+
+void l() {
+  unsigned char b[32];
+  f(&b[0]);
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:5: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
+}
+
+template 
+void m(const std::vector &v) {
+  const T *p = &v[0];
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:16: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
+}
Index: clang-tools-extra/docs/clang-tidy/checks/readability-data-pointer.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/readability-data-pointer.rst
@@ -0,0 +1,13 @@
+.. title:: clang-tidy - readability-data-pointer
+
+readability-data-pointer
+
+
+Finds cases where code could use ``data()`` rather than the address of the
+element at index 0 in a container.  This pattern is commonly used to materialize
+a pointer to the backing data of a container.  ``std::vector`` and
+``std::string`` provide a ``data()`` accessor 

[PATCH] D108893: clang-tidy: introduce readability-containter-data-pointer check

2021-09-14 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

@Eugene.Zelenko - sorry, I didn't see the additional comments before the 
commit.  I'm happy to do a follow up depending on the resolution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108893

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


[PATCH] D108893: clang-tidy: introduce readability-containter-data-pointer check

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

In D108893#2999763 , @compnerd wrote:

> @Eugene.Zelenko - sorry, I didn't see the additional comments before the 
> commit.  I'm happy to do a follow up depending on the resolution.

If there's a follow-up to add this to modernize, I would say that version of 
the check should transition `&v[N]` to `v.data() + N` (perhaps optionally). I 
don't think a follow-up to add this to bugprone makes a lot of sense because of 
the high potential for false positive diagnostics (I think the bugprone one 
should be a static analyzer check that looks for a preceding predicate that 
checks the size of the container or whether it's empty).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108893

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


[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

2021-09-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

> ! In D108643#2965852 , @rjmccall 
> wrote:
>
> The choice that high bits are unspecified rather than extended is an 
> interesting one.  Can you speak to that?  That's good for +, -, *, &, |, ^, 
> <<, and narrowing conversions, but bad for ==, <, /, >>, and widening 
> conversions.

So we chose this for a few reasons:

1- Consistency with struct padding bits.  It seemed strange to specify the 
padding bits here, when the rest of the standards/ABI don't specify padding 
bits.
2- Flexibility of implementation: Requiring zeroing is a more constraining 
decision, which limits implementation to having to set these bits.  By leaving 
it unspecified, the implementation is free to zero them out if it feels it is 
worth-while.  I'll note that our backends choose NOT to zero them out when not 
necessary, since (so I'm told) 'masked' compares are trivial in most processors.
3- Implement-ability on FPGAs: Since this was our motivating example, forcing 
an FPGA to zero out these bits when dealing with an interaction with a 
byte-aligned processor would have incredible performance overhead.
4- Ease of implementation: Forcing LLVM to zero out these bits would either 
mean we had to do quite a bit of work in our CodeGen to zero them out, or 
modify most of the backends to not zero padding bits in these cases. Since 
there isn't a particular performance benefit (see #2) we didn't think it would 
be worth while.


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

https://reviews.llvm.org/D108643

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


[PATCH] D109718: [HIP] Diagnose -fopenmp-targets for HIP programs

2021-09-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:704
+C.getInputArgs().getLastArg(options::OPT_fopenmp_targets_EQ)) {
+  Diag(clang::diag::err_drv_unsupported_opt) << 
OMPTargetArg->getSpelling();
+  return;

tra wrote:
> I think "unsupported" here is a bit misleading. We need something along the 
> lines of "option X can't be used with option Y".
> 
> I think `err_drv_argument_not_allowed_with` might be a better choice.
That is for two conflicting options. However, HIP may be specified by input 
file extension instead of -x option. Another issue is that this is unsupported 
option for HIP, not option argument.

How about

unsupported option '%1' for HIP language mode


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

https://reviews.llvm.org/D109718

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


[PATCH] D109718: [HIP] Diagnose -fopenmp-targets for HIP programs

2021-09-14 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:704
+C.getInputArgs().getLastArg(options::OPT_fopenmp_targets_EQ)) {
+  Diag(clang::diag::err_drv_unsupported_opt) << 
OMPTargetArg->getSpelling();
+  return;

yaxunl wrote:
> tra wrote:
> > I think "unsupported" here is a bit misleading. We need something along the 
> > lines of "option X can't be used with option Y".
> > 
> > I think `err_drv_argument_not_allowed_with` might be a better choice.
> That is for two conflicting options. However, HIP may be specified by input 
> file extension instead of -x option. Another issue is that this is 
> unsupported option for HIP, not option argument.
> 
> How about
> 
> unsupported option '%1' for HIP language mode
SGTM.


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

https://reviews.llvm.org/D109718

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


[PATCH] D108893: clang-tidy: introduce readability-containter-data-pointer check

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

This breaks tests: http://45.33.8.238/linux/55784/step_8.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108893

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


[PATCH] D109718: [HIP] Diagnose -fopenmp-targets for HIP programs

2021-09-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 372495.
yaxunl added a comment.

revise diag message


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

https://reviews.llvm.org/D109718

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/hip-options.hip


Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -87,3 +87,15 @@
 // THINLTO-NOT: clang{{.*}}" "-triple" "amdgcn-amd-amdhsa" {{.*}} 
"-fwhole-program-vtables"
 // THINLTO: clang{{.*}}" "-triple" "x86_64-unknown-linux-gnu" {{.*}} 
"-flto=thin" {{.*}} "-fwhole-program-vtables"
 // THINLTO-NOT: clang{{.*}}" "-triple" "amdgcn-amd-amdhsa" {{.*}} 
"-fwhole-program-vtables"
+
+// Check -fopenmp is allowed with HIP but -fopenmp-targets= is not allowed.
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --offload-arch=gfx906 -fopenmp %s 2>&1 | FileCheck -check-prefix=OMP 
%s
+// OMP-NOT: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fopenmp"
+// OMP: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-fopenmp"
+
+// RUN: not %clang -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --offload-arch=gfx906 -fopenmp -fopenmp-targets=amdgcn %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=OMPTGT %s
+// OMPTGT: unsupported option '-fopenmp-targets=' for language mode 'HIP'
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -699,6 +699,12 @@
 }
 C.addOffloadDeviceToolChain(CudaTC.get(), OFK);
   } else if (IsHIP) {
+if (auto *OMPTargetArg =
+C.getInputArgs().getLastArg(options::OPT_fopenmp_targets_EQ)) {
+  Diag(clang::diag::err_drv_unsupported_opt_for_language_mode)
+  << OMPTargetArg->getSpelling() << "HIP";
+  return;
+}
 const ToolChain *HostTC = C.getSingleOffloadToolChain();
 const llvm::Triple &HostTriple = HostTC->getTriple();
 auto OFK = Action::OFK_HIP;
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -16,6 +16,8 @@
   "unsupported option '%0'; did you mean '%1'?">;
 def err_drv_unsupported_opt_for_target : Error<
   "unsupported option '%0' for target '%1'">;
+def err_drv_unsupported_opt_for_language_mode : Error<
+  "unsupported option '%0' for language mode '%1'">;
 def err_drv_unsupported_option_argument : Error<
   "unsupported argument '%1' to option '%0'">;
 def err_drv_unknown_stdin_type : Error<


Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -87,3 +87,15 @@
 // THINLTO-NOT: clang{{.*}}" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fwhole-program-vtables"
 // THINLTO: clang{{.*}}" "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-flto=thin" {{.*}} "-fwhole-program-vtables"
 // THINLTO-NOT: clang{{.*}}" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fwhole-program-vtables"
+
+// Check -fopenmp is allowed with HIP but -fopenmp-targets= is not allowed.
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --offload-arch=gfx906 -fopenmp %s 2>&1 | FileCheck -check-prefix=OMP %s
+// OMP-NOT: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fopenmp"
+// OMP: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-fopenmp"
+
+// RUN: not %clang -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --offload-arch=gfx906 -fopenmp -fopenmp-targets=amdgcn %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=OMPTGT %s
+// OMPTGT: unsupported option '-fopenmp-targets=' for language mode 'HIP'
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -699,6 +699,12 @@
 }
 C.addOffloadDeviceToolChain(CudaTC.get(), OFK);
   } else if (IsHIP) {
+if (auto *OMPTargetArg =
+C.getInputArgs().getLastArg(options::OPT_fopenmp_targets_EQ)) {
+  Diag(clang::diag::err_drv_unsupported_opt_for_language_mode)
+  << OMPTargetArg->getSpelling() << "HIP";
+  return;
+}
 const ToolChain *HostTC = C.getSingleOffloadToolChain();
 const llvm::Triple &HostTriple = HostTC->getTriple();
 auto OFK = Action::OFK_HIP;
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -16,6 +16,8 @@
   "unsupported option '%0'; did you mean '%1'?">;
 def err_drv_unsupported_opt_

[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-09-14 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.



In D109128#2997588 , @JDevlieghere 
wrote:

> Keith and I discussed this offline. My suggestion was to do the following:
>
> 1. Check the overlay for the canonicalized path
> 2. Check the fall-through for the canonicalized path
> 3. Check the fall-through for the original path

I'm not sure it's correct to do (3) at all...

In D109128#2997787 , @keith wrote:

> In D109128#2997588 , @JDevlieghere 
> wrote:
>
>> If I understand correctly, this patch does that, but swaps 2 and 3. What's 
>> the motivation for trying the non-canonical path first? If we treat the 
>> current working directory as a property directory (which is what the 
>> canonicalization is all about), then it seems like we should exhaust those 
>> options first.
>
> Using the canonical path first is the root of the problem, using that first 
> the behavior to return the absolute path virtually always, for example in my 
> new test these assertions

I think the problem is that we've been conflating two separate things:

- The path used internally to find the filesystem object.
- The path reported back to the user.

I assert that the path used internally to find the filesystem object should 
always/only be the canonical path.

1. Check the overlay for the canonicalized path.
2. Check the fall-through for the canonicalized path.

But the path reported back to the user should almost always be the original 
path used for lookup. ONLY when the path was found in the overlay with 
"use-external-names" should it be modified at all.

I think this could be implemented by with the help of adding the following APIs 
to `vfs::File`:

  class File {
  public:
// Get the same file wrapped with a different reported path.
static std::unique_ptr getWithPath(std::unique_ptr F,
 const Twine &P);
  
  protected:
// API for mutating the path. Override to avoid needing a wrapper
// object for File::getWithPath.
virtual bool setPath(const Twine &Path) { return false; }
  };

then getWithPath can be:

  namespace {
  class WrapperFile : public File { /* Change the observed path */ };
  }
  
  std::unique_ptr File::getWithPath(std::unique_ptr F, const Twine 
&P) {
if (F->setPath(P))
  return F;
return std::make_unique(F, P);
  }

Most the in-tree `vfs::File` derived classes can implement `setPath` so there 
shouldn't be many extra heap objects in practice.

@JDevlieghere / @keith, WDYT?




Comment at: llvm/lib/Support/VirtualFileSystem.cpp:2025-2028
 ErrorOr>
-RedirectingFileSystem::openFileForRead(const Twine &Path_) {
-  SmallString<256> Path;
-  Path_.toVector(Path);
+RedirectingFileSystem::openFileForRead(const Twine &Path) {
+  SmallString<256> CanonicalPath;
+  Path.toVector(CanonicalPath);

With the new comment, I think it'd be useful to have SmallString versions of 
path the original and canonical paths. In which case:
```
lang=c++
SmallString<256> Path;
Path_.toVector(Path);
SmallString<256> CanonicalPath = Path;
```
(with the original `Path_` for the parameter) seems cleanest?



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:2036-2040
+  auto Result = ExternalFS->openFileForRead(Path);
+  if (!Result.getError())
+return Result;
+
+  return ExternalFS->openFileForRead(CanonicalPath);

I think the correct logic here is something like:
```
lang=c++
if (auto Result = ExternalFS->openFileForRead(CanonicalPath))
  return Result->getPath() == CanonicalPath && Path != CanonicalPath
  ? File::getWithPath(*Result, Path)
  : *Result;
else
  return Result.getError();
```

- Ensures soundness in terms of getting the right file by always using the 
canonical path.
- If the fallthrough filesystem changes the name (e.g., if it's another 
redirecting filesystem with use-external-names) then passes that through.
- If the fallthrough filesystem reports back the name it was given, then passes 
back the name this function was given (matches `stat` behaviour) -- by 
induction, if all underlying filesystems are following a similar rule, then 
only if use-external-names=true was hit would the path be changed at all.



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:2053-2059
+if (shouldFallBackToExternalFS(ExternalFile.getError(), Result->E)) {
+  auto Result = ExternalFS->openFileForRead(Path);
+  if (!Result.getError())
+return Result;
+
+  return ExternalFS->openFileForRead(CanonicalPath);
+}

Can this logic be shared, with the above, maybe put in a lambda?



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:2069
   Status S = getRedirectedFileStatus(
-  Path, RE->useExternalName(UseExternalNames), *ExternalStatus);
+  CanonicalPath, RE->useExternalName(UseExternalNa

[PATCH] D108045: [clangd] Fix clangd crash when including a header

2021-09-14 Thread Queen Dela Cruz via Phabricator via cfe-commits
qdelacru added a comment.

Yes please land this. Thanks!


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

https://reviews.llvm.org/D108045

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


[PATCH] D109344: [AMDGPU][OpenMP] Use complex definitions from complex_cmath.h

2021-09-14 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I'm fixing this, nothing to do with this patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109344

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


[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-09-14 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

(BTW, does this problem affect OverlayFileSystem as well?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

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


[PATCH] D109770: [OpenMP] Declare variants for templates need to match # template args

2021-09-14 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: pdhaliwal, JonChesterfield.
Herald added subscribers: guansong, bollu, yaxunl.
jdoerfert requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

A declare variant template is only compatible with a base when the
number of template arguments is equal, otherwise our instantiations will
produce nonsensical results.

Exposes as part of D109344 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109770

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_4.cpp

Index: clang/test/AST/ast-dump-openmp-begin-declare-variant_template_4.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-openmp-begin-declare-variant_template_4.cpp
@@ -0,0 +1,99 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s   | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s -x c++| FileCheck %s
+// expected-no-diagnostics
+
+template 
+int template_number_mismatch_1() {
+  return 0;
+}
+
+template 
+int template_number_mismatch_2() {
+  return 1;
+}
+
+#pragma omp begin declare variant match(implementation = {extension(allow_templates)})
+template 
+int template_number_mismatch_1() {
+  return 2;
+}
+template 
+int template_number_mismatch_2() {
+  return 0;
+}
+#pragma omp end declare variant
+
+int test() {
+  // Should return 0.
+  return template_number_mismatch_1() + template_number_mismatch_2();
+}
+
+// CHECK:  |-FunctionTemplateDecl [[ADDR_0:0x[a-z0-9]*]] <{{.*}}, line:8:1> line:6:5 template_number_mismatch_1
+// CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_1:0x[a-z0-9]*]]  col:20 typename depth 0 index 0 A
+// CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_2:0x[a-z0-9]*]]  col:32 typename depth 0 index 1 B
+// CHECK-NEXT: | |-FunctionDecl [[ADDR_3:0x[a-z0-9]*]]  line:6:5 template_number_mismatch_1 'int ({{.*}})'
+// CHECK-NEXT: | | `-CompoundStmt [[ADDR_4:0x[a-z0-9]*]] 
+// CHECK-NEXT: | |   `-ReturnStmt [[ADDR_5:0x[a-z0-9]*]] 
+// CHECK-NEXT: | | `-IntegerLiteral [[ADDR_6:0x[a-z0-9]*]]  'int' 0
+// CHECK-NEXT: | `-FunctionDecl [[ADDR_7:0x[a-z0-9]*]]  line:6:5 used template_number_mismatch_1 'int ({{.*}})'
+// CHECK-NEXT: |   |-TemplateArgument type 'int'
+// CHECK-NEXT: |   | `-BuiltinType [[ADDR_8:0x[a-z0-9]*]] 'int'
+// CHECK-NEXT: |   |-TemplateArgument type 'float'
+// CHECK-NEXT: |   | `-BuiltinType [[ADDR_9:0x[a-z0-9]*]] 'float'
+// CHECK-NEXT: |   `-CompoundStmt [[ADDR_10:0x[a-z0-9]*]] 
+// CHECK-NEXT: | `-ReturnStmt [[ADDR_11:0x[a-z0-9]*]] 
+// CHECK-NEXT: |   `-IntegerLiteral [[ADDR_6]]  'int' 0
+// CHECK-NEXT: |-FunctionTemplateDecl [[ADDR_12:0x[a-z0-9]*]]  line:11:5 template_number_mismatch_2
+// CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_13:0x[a-z0-9]*]]  col:20 typename depth 0 index 0 A
+// CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_14:0x[a-z0-9]*]]  col:32 typename depth 0 index 1 B
+// CHECK-NEXT: | `-FunctionDecl [[ADDR_15:0x[a-z0-9]*]]  line:11:5 template_number_mismatch_2 'int ({{.*}})'
+// CHECK-NEXT: |   `-CompoundStmt [[ADDR_16:0x[a-z0-9]*]] 
+// CHECK-NEXT: | `-ReturnStmt [[ADDR_17:0x[a-z0-9]*]] 
+// CHECK-NEXT: |   `-IntegerLiteral [[ADDR_18:0x[a-z0-9]*]]  'int' 1
+// CHECK-NEXT: |-FunctionTemplateDecl [[ADDR_19:0x[a-z0-9]*]]  col:5 implicit template_number_mismatch_1
+// CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_20:0x[a-z0-9]*]]  col:20 typename depth 0 index 0 Q
+// CHECK-NEXT: | `-FunctionDecl [[ADDR_21:0x[a-z0-9]*]]  col:5 template_number_mismatch_1 'int ({{.*}})'
+// CHECK-NEXT: |   `-OMPDeclareVariantAttr [[ADDR_22:0x[a-z0-9]*]] <> Implicit implementation={extension(allow_templates)}
+// CHECK-NEXT: | `-DeclRefExpr [[ADDR_23:0x[a-z0-9]*]]  'int ({{.*}})' {{.*}}Function [[ADDR_24:0x[a-z0-9]*]] 'template_number_mismatch_1[implementation={extension(allow_templates)}]' 'int ({{.*}})'
+// CHECK-NEXT: |-FunctionTemplateDecl [[ADDR_25:0x[a-z0-9]*]]  line:17:1 template_number_mismatch_1[implementation={extension(allow_templates)}]
+// CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_20]]  col:20 typename depth 0 index 0 Q
+// CHECK-NEXT: | `-FunctionDecl [[ADDR_24]]  line:17:1 template_number_mismatch_1[implementation={extension(allow_templates)}] 'int ({{.*}})'
+// CHECK-NEXT: |   `-CompoundStmt [[ADDR_26:0x[a-z0-9]*]] 
+// CHECK-NEXT: | `-ReturnStmt [[ADDR_27:0x[a-z0-9]*]] 
+// CHECK-NEXT: |   `-IntegerLiteral [[ADDR_28:0x[a-z0-9]*]]  'int' 2
+// CHECK-NEXT: |-FunctionTemplateDecl [[ADDR_29:0x[a-z0-9]*]]  col:5 implicit template_number_mismatch_2
+// CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_30:0x[a-z0-9]*]]  col:20 typename depth 0 index 0 Q
+// CHECK-NEXT: | |-FunctionDecl [[ADDR_31:0x[a-z0-9]*]]  col:5 template_number_mismatch_2 'int ({{.*}})'
+// CHECK-NEXT: | | `-OMPDeclareVariantAttr [[ADDR_32:0x[a-z0-9]*]] <> Imp

[PATCH] D109770: [OpenMP] Declare variants for templates need to match # template args

2021-09-14 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

Ah, nice! Thanks for the fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109770

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


[PATCH] D106550: [PowerPC] Allow MMA built-ins to accept restrict qualified pointers

2021-09-14 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir updated this revision to Diff 372505.
saghir added a comment.

update test case name to be consistent with existing ones.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106550

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/ppc-pair-mma-types.c


Index: clang/test/Sema/ppc-pair-mma-types.c
===
--- clang/test/Sema/ppc-pair-mma-types.c
+++ clang/test/Sema/ppc-pair-mma-types.c
@@ -335,3 +335,23 @@
   __vector_pair vp = __builtin_vsx_lxvp(ll, v); // expected-error {{passing 
'__vector int' (vector of 4 'int' values) to parameter of incompatible type 
'const __vector_pair *'}}
   __builtin_vsx_stxvp(vp, ll, s);   // expected-error {{passing 
'unsigned short' to parameter of incompatible type 'const __vector_pair *'}}
 }
+
+void testRestrictQualifiedPointer1(int *__restrict acc) {
+  vector float arr[4];
+  __builtin_mma_disassemble_acc((void*)arr, acc); // expected-error {{passing 
'int *restrict' to parameter of incompatible type '__vector_quad *'}}
+}
+
+void testRestrictQualifiedPointer2(__vector_quad *__restrict acc) {
+  vector float arr[4];
+  __builtin_mma_disassemble_acc((void*)arr, acc);
+}
+
+void testVolatileQualifiedPointer1(int *__volatile acc) {
+  vector float arr[4];
+  __builtin_mma_disassemble_acc((void*)arr, acc); // expected-error {{passing 
'int *volatile' to parameter of incompatible type '__vector_quad *'}}
+}
+
+void testVolatileQualifiedPointer2(__vector_quad *__volatile acc) {
+  vector float arr[4];
+  __builtin_mma_disassemble_acc((void*)arr, acc);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -7437,9 +7437,19 @@
 Expr *Arg = TheCall->getArg(ArgNum);
 QualType ArgType = Arg->getType();
 
-if ((ExpectedType->isVoidPointerType() && !ArgType->isPointerType()) ||
-(!ExpectedType->isVoidPointerType() &&
-   ArgType.getCanonicalType() != ExpectedType))
+// Checks to see if the argument type is valid.
+bool IsValidType = true;
+if (ExpectedType->isVoidPointerType() && !ArgType->isPointerType())
+  IsValidType = false;
+else if (!ExpectedType->isVoidPointerType()) {
+  if ((ArgType.isRestrictQualified() || ArgType.isVolatileQualified()) &&
+  ArgType.getCanonicalType().getUnqualifiedType() == ExpectedType)
+IsValidType = true;
+  else if (ArgType.getCanonicalType() != ExpectedType)
+IsValidType = false;
+}
+
+if (!IsValidType)
   return Diag(Arg->getBeginLoc(), diag::err_typecheck_convert_incompatible)
  << ArgType << ExpectedType << 1 << 0 << 0;
 


Index: clang/test/Sema/ppc-pair-mma-types.c
===
--- clang/test/Sema/ppc-pair-mma-types.c
+++ clang/test/Sema/ppc-pair-mma-types.c
@@ -335,3 +335,23 @@
   __vector_pair vp = __builtin_vsx_lxvp(ll, v); // expected-error {{passing '__vector int' (vector of 4 'int' values) to parameter of incompatible type 'const __vector_pair *'}}
   __builtin_vsx_stxvp(vp, ll, s);   // expected-error {{passing 'unsigned short' to parameter of incompatible type 'const __vector_pair *'}}
 }
+
+void testRestrictQualifiedPointer1(int *__restrict acc) {
+  vector float arr[4];
+  __builtin_mma_disassemble_acc((void*)arr, acc); // expected-error {{passing 'int *restrict' to parameter of incompatible type '__vector_quad *'}}
+}
+
+void testRestrictQualifiedPointer2(__vector_quad *__restrict acc) {
+  vector float arr[4];
+  __builtin_mma_disassemble_acc((void*)arr, acc);
+}
+
+void testVolatileQualifiedPointer1(int *__volatile acc) {
+  vector float arr[4];
+  __builtin_mma_disassemble_acc((void*)arr, acc); // expected-error {{passing 'int *volatile' to parameter of incompatible type '__vector_quad *'}}
+}
+
+void testVolatileQualifiedPointer2(__vector_quad *__volatile acc) {
+  vector float arr[4];
+  __builtin_mma_disassemble_acc((void*)arr, acc);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -7437,9 +7437,19 @@
 Expr *Arg = TheCall->getArg(ArgNum);
 QualType ArgType = Arg->getType();
 
-if ((ExpectedType->isVoidPointerType() && !ArgType->isPointerType()) ||
-(!ExpectedType->isVoidPointerType() &&
-   ArgType.getCanonicalType() != ExpectedType))
+// Checks to see if the argument type is valid.
+bool IsValidType = true;
+if (ExpectedType->isVoidPointerType() && !ArgType->isPointerType())
+  IsValidType = false;
+else if (!ExpectedType->isVoidPointerType()) {
+  if ((ArgType.isRestrictQualified() || ArgType.isVolatileQualified()) &&
+  ArgType.getCanonicalType().getUnqualifiedType() =

[clang-tools-extra] 76dc8ac - Revert "clang-tidy: introduce readability-containter-data-pointer check"

2021-09-14 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-09-14T12:37:10-04:00
New Revision: 76dc8ac36d07cebe8cfe8fe757323562bb36df94

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

LOG: Revert "clang-tidy: introduce readability-containter-data-pointer check"

This reverts commit d0d9e6f0849b2e76e980e2edf365302f47f4e35f.
Breaks tests, see e.g. https://lab.llvm.org/buildbot/#/builders/188/builds/3326

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 
clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
clang-tools-extra/docs/clang-tidy/checks/readability-data-pointer.rst

clang-tools-extra/test/clang-tidy/checkers/readability-container-data-pointer.cpp



diff  --git a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
index eba0ab98cb37a..78256d6f73251 100644
--- a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
@@ -7,7 +7,6 @@ add_clang_library(clangTidyReadabilityModule
   AvoidConstParamsInDecls.cpp
   BracesAroundStatementsCheck.cpp
   ConstReturnTypeCheck.cpp
-  ContainerDataPointerCheck.cpp
   ContainerSizeEmptyCheck.cpp
   ConvertMemberFunctionsToStatic.cpp
   DeleteNullPointerCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
deleted file mode 100644
index 3a670509ec2e2..0
--- a/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-//===--- ContainerDataPointerCheck.cpp - clang-tidy 
---===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "ContainerDataPointerCheck.h"
-
-#include "clang/Lex/Lexer.h"
-#include "llvm/ADT/StringRef.h"
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace tidy {
-namespace readability {
-ContainerDataPointerCheck::ContainerDataPointerCheck(StringRef Name,
- ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context) {}
-
-void ContainerDataPointerCheck::registerMatchers(MatchFinder *Finder) {
-  const auto Record =
-  cxxRecordDecl(
-  isSameOrDerivedFrom(
-  namedDecl(
-  has(cxxMethodDecl(isPublic(), hasName("data")).bind("data")))
-  .bind("container")))
-  .bind("record");
-
-  const auto NonTemplateContainerType =
-  
qualType(hasUnqualifiedDesugaredType(recordType(hasDeclaration(Record;
-  const auto TemplateContainerType =
-  qualType(hasUnqualifiedDesugaredType(templateSpecializationType(
-  hasDeclaration(classTemplateDecl(has(Record));
-
-  const auto Container =
-  qualType(anyOf(NonTemplateContainerType, TemplateContainerType));
-
-  Finder->addMatcher(
-  unaryOperator(
-  unless(isExpansionInSystemHeader()), hasOperatorName("&"),
-  hasUnaryOperand(anyOf(
-  ignoringParenImpCasts(
-  cxxOperatorCallExpr(
-  callee(cxxMethodDecl(hasName("operator[]"))
- .bind("operator[]")),
-  argumentCountIs(2),
-  hasArgument(
-  0,
-  anyOf(ignoringParenImpCasts(
-declRefExpr(
-to(varDecl(anyOf(
-hasType(Container),
-hasType(references(Container))
-.bind("var")),
-ignoringParenImpCasts(hasDescendant(
-declRefExpr(
-to(varDecl(anyOf(
-hasType(Container),
-hasType(pointsTo(Container)),
-hasType(references(Container))
-.bind("var"),
-  hasArgument(1,
-  ignoringParenImpCasts(
-  integerLiteral(equals(0)).bind("zero"))

[PATCH] D108893: clang-tidy: introduce readability-containter-data-pointer check

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

Reverted in 76dc8ac36d07 
 for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108893

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


[PATCH] D108787: [CUDA] Pass ExecConfig through BuildCallToMemberFunction

2021-09-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

I am concerned that there may be more places which need handling, and passing 
exec config expr by function arguments may not scale. Is it possible to 
represent the kernel call expr by a derived class of call expr and add the exec 
config expr as member to it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108787

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


Re: [clang] 2bd8493 - Improve type printing of const arrays to normalize array-of-const and const-array

2021-09-14 Thread Richard Smith via cfe-commits
On Mon, 13 Sept 2021 at 19:24, David Blaikie via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: David Blaikie
> Date: 2021-09-13T19:17:05-07:00
> New Revision: 2bd84938470bf2e337801faafb8a67710f46429d
>
> URL:
> https://github.com/llvm/llvm-project/commit/2bd84938470bf2e337801faafb8a67710f46429d
> DIFF:
> https://github.com/llvm/llvm-project/commit/2bd84938470bf2e337801faafb8a67710f46429d.diff
>
> LOG: Improve type printing of const arrays to normalize array-of-const and
> const-array
>
> Since these map to the same effective type - render them the same/in the
> more legible way (const x[n]).
>

Nice!


> Added:
>
>
> Modified:
> clang/lib/AST/TypePrinter.cpp
> clang/test/ARCMT/cxx-checking.mm
> clang/test/AST/ast-dump-APValue-arithmetic.cpp
> clang/test/AST/ast-dump-APValue-array.cpp
> clang/test/CXX/basic/basic.types/p10.cpp
> clang/test/Sema/assign.c
> clang/test/Sema/typedef-retain.c
> clang/test/SemaCXX/reinterpret-cast.cpp
> clang/test/SemaCXX/static-assert-cxx17.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
> index aef1e4f3f4953..251db97c7db08 100644
> --- a/clang/lib/AST/TypePrinter.cpp
> +++ b/clang/lib/AST/TypePrinter.cpp
> @@ -200,11 +200,12 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
>// type expands to a simple string.
>bool CanPrefixQualifiers = false;
>NeedARCStrongQualifier = false;
> -  Type::TypeClass TC = T->getTypeClass();
> +  const Type *UnderlyingType = T;
>if (const auto *AT = dyn_cast(T))
> -TC = AT->desugar()->getTypeClass();
> +UnderlyingType = AT->desugar().getTypePtr();
>if (const auto *Subst = dyn_cast(T))
> -TC = Subst->getReplacementType()->getTypeClass();
> +UnderlyingType = Subst->getReplacementType().getTypePtr();
> +  Type::TypeClass TC = UnderlyingType->getTypeClass();
>
>switch (TC) {
>  case Type::Auto:
> @@ -243,6 +244,9 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
>
>  case Type::ConstantArray:
>  case Type::IncompleteArray:
> +  return canPrefixQualifiers(
> +  cast(UnderlyingType)->getElementType().getTypePtr(),
> +  NeedARCStrongQualifier);
>  case Type::VariableArray:
>  case Type::DependentSizedArray:
>

Can we give these two cases the same treatment?


>NeedARCStrongQualifier = true;


> diff  --git a/clang/test/ARCMT/cxx-checking.mm b/clang/test/ARCMT/
> cxx-checking.mm
> index 952f3cdcbb79c..d6441def09b40 100644
> --- a/clang/test/ARCMT/cxx-checking.mm
> +++ b/clang/test/ARCMT/cxx-checking.mm
> @@ -80,7 +80,7 @@
>
>  struct FlexibleArrayMember0 {
>int length;
> -  id array[]; // expected-error{{flexible array member 'array' of type
> 'id __strong[]' with non-trivial destruction}}
> +  id array[]; // expected-error{{flexible array member 'array' of type
> '__strong id []' with non-trivial destruction}}
>  };
>
>  struct FlexibleArrayMember1 {
>
> diff  --git a/clang/test/AST/ast-dump-APValue-arithmetic.cpp
> b/clang/test/AST/ast-dump-APValue-arithmetic.cpp
> index 835d8c8108346..e51c1cee04cfe 100644
> --- a/clang/test/AST/ast-dump-APValue-arithmetic.cpp
> +++ b/clang/test/AST/ast-dump-APValue-arithmetic.cpp
> @@ -36,13 +36,13 @@ void Test() {
>// CHECK-NEXT:  |   |-value: ComplexFloat 3.141500e+00 + 4.20e+01i
>
>constexpr _Complex int ArrayOfComplexInt[10] = {ComplexInt, ComplexInt,
> ComplexInt, ComplexInt};
> -  // CHECK:  | `-VarDecl {{.*}}  col:{{.*}}
> ArrayOfComplexInt '_Complex int const[10]' constexpr cinit
> +  // CHECK:  | `-VarDecl {{.*}}  col:{{.*}}
> ArrayOfComplexInt 'const _Complex int [10]' constexpr cinit
>// CHECK-NEXT:  |   |-value: Array size=10
>// CHECK-NEXT:  |   | |-elements: ComplexInt 42 + 24i, ComplexInt 42 +
> 24i, ComplexInt 42 + 24i, ComplexInt 42 + 24i
>// CHECK-NEXT:  |   | `-filler: 6 x ComplexInt 0 + 0i
>
>constexpr _Complex float ArrayOfComplexFloat[10] = {ComplexFloat,
> ComplexFloat, ComplexInt, ComplexInt};
> -  // CHECK:`-VarDecl {{.*}}  col:{{.*}}
> ArrayOfComplexFloat '_Complex float const[10]' constexpr cinit
> +  // CHECK:`-VarDecl {{.*}}  col:{{.*}}
> ArrayOfComplexFloat 'const _Complex float [10]' constexpr cinit
>// CHECK-NEXT:  |-value: Array size=10
>// CHECK-NEXT:  | |-elements: ComplexFloat 3.141500e+00 +
> 4.20e+01i, ComplexFloat 3.141500e+00 + 4.20e+01i, ComplexFloat
> 4.20e+01 + 2.40e+01i, ComplexFloat 4.20e+01 + 2.40e+01i
>// CHECK-NEXT:  | `-filler: 6 x ComplexFloat 0.00e+00 +
> 0.00e+00i
>
> diff  --git a/clang/test/AST/ast-dump-APValue-array.cpp
> b/clang/test/AST/ast-dump-APValue-array.cpp
> index f9b38ec332a5b..72e519208ac56 100644
> --- a/clang/test/AST/ast-dump-APValue-array.cpp
> +++ b/clang/test/AST/ast-dump-APValue-array.cpp
> @@ -43,7 +43,7 @@ void Test() {
>constexpr float arr_f[3][5] = {
>{1

[PATCH] D109234: [PGO] Change ThinLTO test for targets with loop unrolling disabled

2021-09-14 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: clang/test/CodeGen/pgo-sample-thinlto-summary.c:1
-// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
-// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
-// Checks if hot call is inlined by normal compile, but not inlined by
-// thinlto compile.
+// RUN: %clang_cc1 -mllvm -opt-bisect-limit=-1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -mllvm -opt-bisect-limit=-1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO

sherwin-dc wrote:
> tejohnson wrote:
> > -opt-bisect-limit seems like a roundabout way to get the pass invocations 
> > printed. How about just -mllvm -debug-pass=Structure?
> I had tried using `-mllvm -debug-pass=Structure` but could not get anything 
> to print out. It only worked when I removed `-cc1 -nostdsysteminc` and 
> `-emit-llvm` which is used when lit runs the tests.
I see - this doesn't work with the new PM which is now default. For that you 
can use -fdebug-pass-manager. For the old PM the -mllvm -debug-pass=Structure 
does work with -cc1 -emit-llvm. Since the first couple invocations appear meant 
to check the oldPM, I would add an explicit -fno-experimental-new-pass-manager 
to their invocations, since that is no longer the default. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

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


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-09-14 Thread Manman Ren via Phabricator via cfe-commits
manmanren added a comment.

@dexonsmith @bruno: are you okay with this change? It looks good to me :]

Thanks,
Manman


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D108787: [CUDA] Pass ExecConfig through BuildCallToMemberFunction

2021-09-14 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D108787#243 , @yaxunl wrote:

> I am concerned that there may be more places which need handling, and passing 
> exec config expr by function arguments may not scale. 
> Is it possible to represent the kernel call expr by a derived class of call 
> expr and add the exec config expr as member to it?

I don't think it's worth it.

This config pass-through code has been around from the very early days of 
attempting to implement CUDA and we're already passing it around during call 
resolution.
AFAICT, this particular place was a relatively new addition which didn't 
implement the pass-through of the config.

While there may be other places where a similar issue may happen in the future 
(or exists as a corner case we didn't find yet), it/when we run into it, it 
will be diagnosed, as it was in this case.
It took us few years until we ran into this one. I'm pretty sure that this 
particular code path is pretty rare and  the patch is not going to have a 
measurable impact on compiler performance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108787

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


[PATCH] D109772: [clangd] Print current request context along with the stack trace

2021-09-14 Thread Emma Blink via Phabricator via cfe-commits
0x1eaf created this revision.
0x1eaf added reviewers: sammccall, ilya-biryukov, nridge.
0x1eaf added projects: clang, clang-tools-extra.
Herald added subscribers: usaxena95, kadircet, arphaman, javed.absar, mgorny.
0x1eaf requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.

Motivation:

At the moment it is hard to attribute a clangd crash to a specific request out 
of all in-flight requests that might be processed concurrently. So before we 
can act on production clangd crashes, we have to do quite some digging through 
the log tables populated by our in-house VSCode extension or sometimes even 
directly reach out to the affected developer. Having all the details needed to 
reproduce a crash printed alongside its stack trace has a potential to save us 
quite some time, that could better be spent on fixing the actual problems.

Implementation approach:

- introduce `ThreadCrashReporter` class that allows to set a temporary signal 
handler for the current thread
- follow RAII pattern to simplify printing context for crashes occurring within 
a particular scope
- hold `std::function` as a handler to allow capturing context to print
- set local `ThreadCrashReporter` within `JSONTransport::loop()` to print 
request JSON for main thread crashes, and in `ASTWorker::run()` to print the 
file paths, arguments and contents for worker thread crashes

`ThreadCrashReporter` currently allows only one active handler per thread, but 
the approach can be extended to support stacked handlers printing context 
incrementally.

Example output for main thread crashes:

  ...
  #15 0x7f7ddc819493 __libc_start_main (/lib64/libc.so.6+0x23493)
  #16 0x0249775e _start 
(/home/emmablink/local/llvm-project/build/bin/clangd+0x249775e)
  Signalled while processing message:
  {"jsonrpc": "2.0", "method": "textDocument/didOpen", "params": 
{"textDocument": {"uri": "file:///home/emmablink/test.cpp", "languageId": 
"cpp", "version": 1, "text": "template \nclass Bar {\n  Bar 
*variables_to_modify;\n  foo() {\nfor (auto *c : *variables_to_modify)\n
  delete c;\n  }\n};\n"}}}


Example output for AST worker crashes:

  ...
  #41 0x7fb18304c14a start_thread pthread_create.c:0:0
  #42 0x7fb181bfcdc3 clone (/lib64/libc.so.6+0xfcdc3)
  Signalled during AST action:
  Filename: test.cpp
  Directory: /home/emmablink
  Command Line: /usr/bin/clang 
-resource-dir=/data/users/emmablink/llvm-project/build/lib/clang/14.0.0 -- 
/home/emmablink/test.cpp
  Version: 1
  Contents:
  template 
  class Bar {
Bar *variables_to_modify;
foo() {
  for (auto *c : *variables_to_modify)
delete c;
}
  };


Testing:

The unit test covers the thread-localitity and nesting aspects of 
`ThreadCrashReporter`. There might be way to set up a lit-based integration 
test that would spawn clangd, send a message to it, signal it immediately and 
check the standard output, but this might be prone to raceconditions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109772

Files:
  clang-tools-extra/clangd/JSONTransport.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/support/CMakeLists.txt
  clang-tools-extra/clangd/support/ThreadCrashReporter.cpp
  clang-tools-extra/clangd/support/ThreadCrashReporter.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ThreadCrashReporterTests.cpp

Index: clang-tools-extra/clangd/unittests/ThreadCrashReporterTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/ThreadCrashReporterTests.cpp
@@ -0,0 +1,71 @@
+///===- ThreadCrashReporterTests.cpp - Thread local signal handling tests -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "support/ThreadCrashReporter.h"
+#include "support/Threading.h"
+#include "llvm/Support/Signals.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+namespace {
+
+static void infoHandler() { ThreadCrashReporter::runCrashHandlers(nullptr); }
+
+TEST(ThreadCrashReporterTest, All) {
+  llvm::sys::SetInfoSignalFunction(&infoHandler);
+  AsyncTaskRunner Runner;
+  auto SignalCurrentThread = []() { raise(SIGUSR1); };
+  auto SignalAnotherThread = [&]() {
+Runner.runAsync("signal another thread", SignalCurrentThread);
+Runner.wait();
+  };
+
+  bool Called;
+  {
+ThreadCrashReporter ScopedReporter([&Called]() { Called = true; });
+// Check handler gets called when a signal gets delivered to the current
+// thread.
+Called = false;
+SignalCurrentThread();
+EXPECT_TRUE(Called);
+
+// Check handler does not get call

[PATCH] D109506: [RFC] Print current request context along with the stack trance in clangd

2021-09-14 Thread Emma Blink via Phabricator via cfe-commits
0x1eaf updated this revision to Diff 372510.
0x1eaf added a comment.

addressed review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109506

Files:
  clang-tools-extra/clangd/JSONTransport.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/support/CMakeLists.txt
  clang-tools-extra/clangd/support/ThreadCrashReporter.cpp
  clang-tools-extra/clangd/support/ThreadCrashReporter.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ThreadCrashReporterTests.cpp

Index: clang-tools-extra/clangd/unittests/ThreadCrashReporterTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/ThreadCrashReporterTests.cpp
@@ -0,0 +1,71 @@
+///===- ThreadCrashReporterTests.cpp - Thread local signal handling tests -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "support/ThreadCrashReporter.h"
+#include "support/Threading.h"
+#include "llvm/Support/Signals.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+namespace {
+
+static void infoHandler() { ThreadCrashReporter::runCrashHandlers(nullptr); }
+
+TEST(ThreadCrashReporterTest, All) {
+  llvm::sys::SetInfoSignalFunction(&infoHandler);
+  AsyncTaskRunner Runner;
+  auto SignalCurrentThread = []() { raise(SIGUSR1); };
+  auto SignalAnotherThread = [&]() {
+Runner.runAsync("signal another thread", SignalCurrentThread);
+Runner.wait();
+  };
+
+  bool Called;
+  {
+ThreadCrashReporter ScopedReporter([&Called]() { Called = true; });
+// Check handler gets called when a signal gets delivered to the current
+// thread.
+Called = false;
+SignalCurrentThread();
+EXPECT_TRUE(Called);
+
+// Check handler does not get called when another thread gets signalled.
+Called = false;
+SignalAnotherThread();
+EXPECT_FALSE(Called);
+  }
+  // Check handler does not get called when the reporter object goes out of
+  // scope.
+  Called = false;
+  SignalCurrentThread();
+  EXPECT_FALSE(Called);
+
+  std::string Order = "";
+  {
+ThreadCrashReporter ScopedReporter([&Order] { Order.push_back('a'); });
+{
+  ThreadCrashReporter ScopedReporter([&Order] { Order.push_back('b'); });
+  SignalCurrentThread();
+}
+// Check that handlers are called in FIFO order.
+EXPECT_EQ(Order, "ab");
+
+// Check that current handler is the only one after the nested scope is
+// over.
+SignalCurrentThread();
+EXPECT_EQ(Order, "aba");
+  }
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -88,6 +88,7 @@
   TestIndex.cpp
   TestTU.cpp
   TestWorkspace.cpp
+  ThreadCrashReporterTests.cpp
   TidyProviderTests.cpp
   TypeHierarchyTests.cpp
   URITests.cpp
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -24,6 +24,7 @@
 #include "refactor/Rename.h"
 #include "support/Path.h"
 #include "support/Shutdown.h"
+#include "support/ThreadCrashReporter.h"
 #include "support/ThreadsafeFS.h"
 #include "support/Trace.h"
 #include "clang/Format/Format.h"
@@ -679,6 +680,7 @@
 
   llvm::InitializeAllTargetInfos();
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+  llvm::sys::AddSignalHandler(&ThreadCrashReporter::runCrashHandlers, nullptr);
   llvm::sys::SetInterruptFunction(&requestShutdown);
   llvm::cl::SetVersionPrinter([](llvm::raw_ostream &OS) {
 OS << versionString() << "\n"
Index: clang-tools-extra/clangd/support/ThreadCrashReporter.h
===
--- /dev/null
+++ clang-tools-extra/clangd/support/ThreadCrashReporter.h
@@ -0,0 +1,48 @@
+//===--- ThreadCrashReporter.h - Thread local signal handling *- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_THREAD_CRASH_REPORTER_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_THREAD_CRASH_REPORTER_H
+
+#include 
+
+namespace clang {
+namespace cl

[PATCH] D105191: [Clang][OpenMP] Add support for Static Device Libraries

2021-09-14 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 372514.
saiislam added a comment.

Rebase and a minor fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105191

Files:
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/Inputs/hip_dev_lib/libFatArchive.a
  clang/test/Driver/fat_archive.cpp
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -180,6 +180,29 @@
   }
 };
 
+static StringRef getDeviceFileExtension(StringRef Device) {
+  if (Device.contains("gfx"))
+return ".bc";
+  if (Device.contains("sm_"))
+return ".cubin";
+  else {
+WithColor::warning() << "Could not determine extension for archive"
+"members, using \".o\"\n";
+return ".o";
+  }
+}
+
+static std::string getDeviceLibraryFileName(StringRef BundleFileName,
+StringRef Device) {
+  StringRef LibName = sys::path::stem(BundleFileName);
+  StringRef Extension = getDeviceFileExtension(Device);
+
+  std::string Result;
+  Result += LibName;
+  Result += Extension;
+  return Result;
+}
+
 /// Generic file handler interface.
 class FileHandler {
 public:
@@ -1229,7 +1252,9 @@
   BundledObjectFileName.assign(BundledObjectFile);
   auto OutputBundleName =
   Twine(llvm::sys::path::stem(BundledObjectFileName) + "-" +
-CodeObject)
+CodeObject +
+getDeviceLibraryFileName(BundledObjectFileName,
+ CodeObjectInfo.GPUArch))
   .str();
   // Replace ':' in optional target feature list with '_' to ensure
   // cross-platform validity.
Index: clang/test/Driver/fat_archive.cpp
===
--- /dev/null
+++ clang/test/Driver/fat_archive.cpp
@@ -0,0 +1,91 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// See the steps to create a fat archive near the end of the file.
+
+// Test succeeds if no linked error i.e. all external symbols in the archive
+// could be resolved correctly.
+// RUN: env LIBRARY_PATH=%T/../../../../../runtimes/runtimes-bins/openmp/libomptarget %clang -O2 -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s -L%S/Inputs/hip_dev_lib -lFatArchive -o - | FileCheck %s -check-prefix=LINKERROR
+// LINKERROR-NOT: error: linker command failed with exit code 1
+
+// Given a FatArchive, clang-offload-bundler should be called to create a
+// device specific archive, which should be passed to llvm-link.
+// RUN: env LIBRARY_PATH=%T/../../../../../runtimes/runtimes-bins/openmp/libomptarget %clang -O2 -### -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s -L%S/Inputs/hip_dev_lib -lFatArchive 2>&1 | FileCheck %s
+// CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-pc-linux-gnu"{{.*}}"-o" "[[HOSTOBJ:.*.o]]" "-x" "ir"{{.*}}
+// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm-bc"{{.*}}"-target-cpu" "gfx906"{{.*}}"-o" "[[HOSTBC:.*.bc]]" "-x" "c++"{{.*}}.cpp
+// CHECK: clang-offload-bundler" "-unbundle" "-type=a" "-inputs={{.*}}/Inputs/hip_dev_lib/libFatArchive.a" "-targets=openmp-amdgcn-amd-amdhsa-gfx906" "-outputs=[[DEVICESPECIFICARCHIVE:.*.a]]" "-allow-missing-bundles"
+// CHECK: llvm-link{{.*}}"[[HOSTBC]]" "[[DEVICESPECIFICARCHIVE]]" "-o" "{{.*}}-gfx906-linked-{{.*}}.bc"
+// CHECK: ld.lld"{{.*}}" "-L{{.*}}/Inputs/hip_dev_lib" "{{.*}}"[[HOSTOBJ]]" "-lFatArchive" "{{.*}}" "-lomp{{.*}}-lomptarget"
+// expected-no-diagnostics
+
+// Tests for linker and loader errors in case external symbols are not found in
+// the FatArchive.
+// RUN: env LIBRARY_PATH=%T/../../../../../runtimes/runtimes-bins/openmp/libomptarget not %clang -O2 -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s -L%S/Inputs/hip_dev_lib -lFatArchive -DMISSING=1 2>&1 | FileCheck %s -check-prefix=MISSINGSYM
+// MISSINGSYM: ld.lld: error: undefined symbol: func_missing
+// MISSINGSYM: error: linker command failed with exit code 1
+
+#ifndef HEADER
+#define HEADER
+
+#define N 10
+
+#pragma omp declare target
+// Functions defined in Fat Archive.
+extern "C" void func_present(float *, float *, unsigned);
+
+#ifdef MISSING
+// Function not defined in the fat archive.
+extern "C" void func_missi

[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-09-14 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a reviewer: vsapsai.
dexonsmith added a subscriber: vsapsai.
dexonsmith added a comment.

Thanks for looking at this!

I have a couple of comments inline. @vsapsai, can you also take a look?




Comment at: clang/lib/Serialization/ASTReader.cpp:8188-8190
+  for (auto *L = &List; L; L = L->getNext()) {
+seen.insert(L->getMethod());
+  }

I find quadratic algorithms a bit scary, even when current benchmarks don't 
expose problems. For example, it seems like this could blow up on the following 
workload:
- one module adds many things to the global method list
- there are many (fine-grained) modules that transitively load that module

Or have I misunderstood the complexity here?



Comment at: clang/lib/Serialization/ASTReader.cpp:8194
+if (seen.insert(M).second) {
+  S.addMethodToGlobalList(&List, M);
+}

rmaz wrote:
> manmanren wrote:
> > Does it make sense to check for duplication inside addMethodToGlobalList, 
> > as the function goes through the list as well? Maybe it is slower, as we 
> > will need to go through the list for each method, instead of a lookup.
> Yes, you are right, it is slower as we need to do a list traverse per insert 
> rather than per selector lookup. I also profiled keeping some global state 
> along with the `MethodPool` so that the set didn't have to be rebuilt each 
> time, but the performance difference was negligible.
Can you take another look at the approach you experimented with, putting the 
global state in the MethodPool? Besides the performance difference (you 
measured it as negligible but it'd avoid the concern I have about uncommon 
workloads hitting quadratic blowups), it'd also provide consistency in 
behaviour between callers of `addMethodToGlobalList`... and enable you to add a 
unit test for the API change to MethodPool.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D109506: [clangd] Print current request context along with the stack trace

2021-09-14 Thread Emma Blink via Phabricator via cfe-commits
0x1eaf updated this revision to Diff 372515.
0x1eaf retitled this revision from "[RFC] Print current request context along 
with the stack trance in clangd" to "[clangd] Print current request context 
along with the stack trace".
0x1eaf edited the summary of this revision.
0x1eaf added a comment.

updated revision description for final review after renaming the class


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109506

Files:
  clang-tools-extra/clangd/JSONTransport.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/support/CMakeLists.txt
  clang-tools-extra/clangd/support/ThreadCrashReporter.cpp
  clang-tools-extra/clangd/support/ThreadCrashReporter.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ThreadCrashReporterTests.cpp

Index: clang-tools-extra/clangd/unittests/ThreadCrashReporterTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/ThreadCrashReporterTests.cpp
@@ -0,0 +1,71 @@
+///===- ThreadCrashReporterTests.cpp - Thread local signal handling tests -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "support/ThreadCrashReporter.h"
+#include "support/Threading.h"
+#include "llvm/Support/Signals.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+namespace {
+
+static void infoHandler() { ThreadCrashReporter::runCrashHandlers(nullptr); }
+
+TEST(ThreadCrashReporterTest, All) {
+  llvm::sys::SetInfoSignalFunction(&infoHandler);
+  AsyncTaskRunner Runner;
+  auto SignalCurrentThread = []() { raise(SIGUSR1); };
+  auto SignalAnotherThread = [&]() {
+Runner.runAsync("signal another thread", SignalCurrentThread);
+Runner.wait();
+  };
+
+  bool Called;
+  {
+ThreadCrashReporter ScopedReporter([&Called]() { Called = true; });
+// Check handler gets called when a signal gets delivered to the current
+// thread.
+Called = false;
+SignalCurrentThread();
+EXPECT_TRUE(Called);
+
+// Check handler does not get called when another thread gets signalled.
+Called = false;
+SignalAnotherThread();
+EXPECT_FALSE(Called);
+  }
+  // Check handler does not get called when the reporter object goes out of
+  // scope.
+  Called = false;
+  SignalCurrentThread();
+  EXPECT_FALSE(Called);
+
+  std::string Order = "";
+  {
+ThreadCrashReporter ScopedReporter([&Order] { Order.push_back('a'); });
+{
+  ThreadCrashReporter ScopedReporter([&Order] { Order.push_back('b'); });
+  SignalCurrentThread();
+}
+// Check that handlers are called in FIFO order.
+EXPECT_EQ(Order, "ab");
+
+// Check that current handler is the only one after the nested scope is
+// over.
+SignalCurrentThread();
+EXPECT_EQ(Order, "aba");
+  }
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -88,6 +88,7 @@
   TestIndex.cpp
   TestTU.cpp
   TestWorkspace.cpp
+  ThreadCrashReporterTests.cpp
   TidyProviderTests.cpp
   TypeHierarchyTests.cpp
   URITests.cpp
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -24,6 +24,7 @@
 #include "refactor/Rename.h"
 #include "support/Path.h"
 #include "support/Shutdown.h"
+#include "support/ThreadCrashReporter.h"
 #include "support/ThreadsafeFS.h"
 #include "support/Trace.h"
 #include "clang/Format/Format.h"
@@ -679,6 +680,7 @@
 
   llvm::InitializeAllTargetInfos();
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+  llvm::sys::AddSignalHandler(&ThreadCrashReporter::runCrashHandlers, nullptr);
   llvm::sys::SetInterruptFunction(&requestShutdown);
   llvm::cl::SetVersionPrinter([](llvm::raw_ostream &OS) {
 OS << versionString() << "\n"
Index: clang-tools-extra/clangd/support/ThreadCrashReporter.h
===
--- /dev/null
+++ clang-tools-extra/clangd/support/ThreadCrashReporter.h
@@ -0,0 +1,48 @@
+//===--- ThreadCrashReporter.h - Thread local signal handling *- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//

[PATCH] D108893: clang-tidy: introduce readability-containter-data-pointer check

2021-09-14 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

@thakis - thanks, seems that I had a part of the change sitting in my stash ... 
I had added a `-NOT` to verify the behaviour, and forgot to remove it.  I'll 
revert the revert with the fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108893

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


[clang-tools-extra] 49992c0 - Revert "Revert "clang-tidy: introduce readability-containter-data-pointer check""

2021-09-14 Thread Saleem Abdulrasool via cfe-commits

Author: Saleem Abdulrasool
Date: 2021-09-14T10:52:35-07:00
New Revision: 49992c04148e5327bef9bd2dff53a0d46004b4b4

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

LOG: Revert "Revert "clang-tidy: introduce readability-containter-data-pointer 
check""

This reverts commit 76dc8ac36d07cebe8cfe8fe757323562bb36df94.

Restore the change.  The test had an incorrect negative from testing.
The test is expected to trigger a failure as mentioned in the review
comments.  This corrects the test and should resolve the failure.

Added: 
clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
clang-tools-extra/docs/clang-tidy/checks/readability-data-pointer.rst

clang-tools-extra/test/clang-tidy/checkers/readability-container-data-pointer.cpp

Modified: 
clang-tools-extra/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
index 78256d6f73251..eba0ab98cb37a 100644
--- a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
@@ -7,6 +7,7 @@ add_clang_library(clangTidyReadabilityModule
   AvoidConstParamsInDecls.cpp
   BracesAroundStatementsCheck.cpp
   ConstReturnTypeCheck.cpp
+  ContainerDataPointerCheck.cpp
   ContainerSizeEmptyCheck.cpp
   ConvertMemberFunctionsToStatic.cpp
   DeleteNullPointerCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
new file mode 100644
index 0..3a670509ec2e2
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
@@ -0,0 +1,117 @@
+//===--- ContainerDataPointerCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ContainerDataPointerCheck.h"
+
+#include "clang/Lex/Lexer.h"
+#include "llvm/ADT/StringRef.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace readability {
+ContainerDataPointerCheck::ContainerDataPointerCheck(StringRef Name,
+ ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context) {}
+
+void ContainerDataPointerCheck::registerMatchers(MatchFinder *Finder) {
+  const auto Record =
+  cxxRecordDecl(
+  isSameOrDerivedFrom(
+  namedDecl(
+  has(cxxMethodDecl(isPublic(), hasName("data")).bind("data")))
+  .bind("container")))
+  .bind("record");
+
+  const auto NonTemplateContainerType =
+  
qualType(hasUnqualifiedDesugaredType(recordType(hasDeclaration(Record;
+  const auto TemplateContainerType =
+  qualType(hasUnqualifiedDesugaredType(templateSpecializationType(
+  hasDeclaration(classTemplateDecl(has(Record));
+
+  const auto Container =
+  qualType(anyOf(NonTemplateContainerType, TemplateContainerType));
+
+  Finder->addMatcher(
+  unaryOperator(
+  unless(isExpansionInSystemHeader()), hasOperatorName("&"),
+  hasUnaryOperand(anyOf(
+  ignoringParenImpCasts(
+  cxxOperatorCallExpr(
+  callee(cxxMethodDecl(hasName("operator[]"))
+ .bind("operator[]")),
+  argumentCountIs(2),
+  hasArgument(
+  0,
+  anyOf(ignoringParenImpCasts(
+declRefExpr(
+to(varDecl(anyOf(
+hasType(Container),
+hasType(references(Container))
+.bind("var")),
+ignoringParenImpCasts(hasDescendant(
+declRefExpr(
+to(varDecl(anyOf(
+hasType(Container),
+hasType(pointsTo(Container)),
+hasType(references(Container))
+.bind("var"),
+  hasArgument

[PATCH] D109506: [clangd] Print current request context along with the stack trace

2021-09-14 Thread Emma Blink via Phabricator via cfe-commits
0x1eaf added a comment.

I've tried making an integration test in addition to the unit test, but I 
couldn't find a way to make lit ignore the crashed process exit status:

  FAIL: Clangd :: crash.test (1049 of 1049)
   TEST 'Clangd :: crash.test' FAILED 
  Script:
  --
  : 'RUN: at line 2';   yes '[' | head -n 5 | sh -c "clangd 
--input-style=delimited 2>&1 || true"
  --
  Exit Code: 141

I've also tried using `not` to the same effect:

  # RUN: yes '[' | head -n 5 | not clangd --input-style=delimited

Is there some trick that I'm missing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109506

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


[clang] 66c6bbe - Put code that avoids heapifying local blocks behind a flag

2021-09-14 Thread Walter Lee via cfe-commits

Author: Walter Lee
Date: 2021-09-14T14:06:05-04:00
New Revision: 66c6bbe7ff56441706d6cbb349fde9a02e248c9a

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

LOG: Put code that avoids heapifying local blocks behind a flag

This change puts the functionality in commit
c5792aa90fa45a1842f190c146f19e2c71ea6fbd behind a flag that is off by
default.  The original commit is not in Apple's Clang fork (and blocks
are an Apple extension in the first place), and there is one known
issue that needs to be addressed before it can be enabled safely.

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

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CGObjC.cpp
clang/test/CodeGenObjC/arc-block-copy-escape.m
clang/test/CodeGenObjC/arc-blocks.m
clang/test/CodeGenObjCXX/arc-blocks.mm
clang/test/PCH/arc-blocks.mm

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 73edae63bfc91..737d2d70bf466 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -188,6 +188,7 @@ CODEGENOPT(NoZeroInitializedInBSS , 1, 0) ///< 
-fno-zero-initialized-in-bss.
 ENUM_CODEGENOPT(ObjCDispatchMethod, ObjCDispatchMethodKind, 2, Legacy)
 /// Replace certain message sends with calls to ObjC runtime entrypoints
 CODEGENOPT(ObjCConvertMessagesToRuntimeCalls , 1, 1)
+CODEGENOPT(ObjCAvoidHeapifyLocalBlocks, 1, 0)
 
 VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< The -O[0-3] option specified.
 VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is 
specified.

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 6d0dba2bc5adc..6e8fe785ae04c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2369,6 +2369,11 @@ def fobjc_disable_direct_methods_for_testing :
   Group, Flags<[CC1Option]>,
   HelpText<"Ignore attribute objc_direct so that direct methods can be 
tested">,
   MarshallingInfoFlag>;
+defm objc_avoid_heapify_local_blocks : 
BoolFOption<"objc-avoid-heapify-local-blocks",
+  CodeGenOpts<"ObjCAvoidHeapifyLocalBlocks">, DefaultFalse,
+  PosFlag,
+  NegFlag,
+  BothFlags<[CC1Option, NoDriverOption], " to avoid heapifying local blocks">>;
 
 def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group;
 def fopenmp : Flag<["-"], "fopenmp">, Group, Flags<[CC1Option, 
NoArgumentUnused, FlangOption, FC1Option]>,

diff  --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 0aaec9af2f41e..4eced4ec046fb 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -3332,7 +3332,8 @@ struct ARCRetainExprEmitter :
 TryEmitResult result = visitExpr(e);
 // Avoid the block-retain if this is a block literal that doesn't need to 
be
 // copied to the heap.
-if (e->getBlockDecl()->canAvoidCopyToHeap())
+if (CGF.CGM.getCodeGenOpts().ObjCAvoidHeapifyLocalBlocks &&
+e->getBlockDecl()->canAvoidCopyToHeap())
   result.setInt(true);
 return result;
   }

diff  --git a/clang/test/CodeGenObjC/arc-block-copy-escape.m 
b/clang/test/CodeGenObjC/arc-block-copy-escape.m
index 9e409ce72e247..300405f852987 100644
--- a/clang/test/CodeGenObjC/arc-block-copy-escape.m
+++ b/clang/test/CodeGenObjC/arc-block-copy-escape.m
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -fobjc-arc -fblocks -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fobjc-arc -fblocks -emit-llvm %s -o - | FileCheck 
-check-prefix=CHECK -check-prefix=CHECK-HEAP %s
+// RUN: %clang_cc1 -fobjc-arc -fblocks -fobjc-avoid-heapify-local-blocks 
-emit-llvm %s -o - | FileCheck -check-prefix=CHECK -check-prefix=CHECK-NOHEAP %s
+
 
 typedef void (^block_t)(void);
 void use_block(block_t);
@@ -8,17 +10,19 @@
 
 void test0(int i) {
   block_t block = ^{ use_int(i); };
-  // CHECK-LABEL:   define {{.*}}void @test0(
-  // CHECK-NOT: @llvm.objc.retainBlock(
-  // CHECK: ret void
+  // CHECK-LABEL:  define {{.*}}void @test0(
+  // CHECK-HEAP:   call {{.*}}i8* @llvm.objc.retainBlock(i8* {{%.*}}) 
[[NUW:#[0-9]+]], !clang.arc.copy_on_escape
+  // CHECK-NOHEAP-NOT: @llvm.objc.retainBlock(
+  // CHECK:ret void
 }
 
 void test1(int i) {
   id block = ^{ use_int(i); };
   // CHECK-LABEL:   define {{.*}}void @test1(
-  // CHECK: call {{.*}}i8* @llvm.objc.retainBlock(i8* {{%.*}}) 
[[NUW:#[0-9]+]]
-  // CHECK-NOT: !clang.arc.copy_on_escape
-  // CHECK: ret void
+  // CHECK-HEAP:call {{.*}}i8* @llvm.objc.retainBlock(i8* {{%.*}}) [[NUW]]
+  // CHECK-NOHEAP:  call {{.*}}i8* @llvm.objc.retainBlock(i8*  {{%.*}}) 
[[NUW:#[0-9]+]]
+  // CHECK-NOT: !clang.arc.copy_on_escape
+

[PATCH] D108243: Put code that avoids heapifying local blocks behind a flag

2021-09-14 Thread Walter Lee 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 rG66c6bbe7ff56: Put code that avoids heapifying local blocks 
behind a flag (authored by waltl).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108243

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGObjC.cpp
  clang/test/CodeGenObjC/arc-block-copy-escape.m
  clang/test/CodeGenObjC/arc-blocks.m
  clang/test/CodeGenObjCXX/arc-blocks.mm
  clang/test/PCH/arc-blocks.mm

Index: clang/test/PCH/arc-blocks.mm
===
--- clang/test/PCH/arc-blocks.mm
+++ clang/test/PCH/arc-blocks.mm
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc -fblocks -std=c++1y -emit-pch %s -o %t
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc -fblocks -std=c++1y -include-pch %t -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc -fblocks -std=c++1y -include-pch %t -fobjc-avoid-heapify-local-blocks -emit-llvm -o - %s | FileCheck %s
 
 #ifndef HEADER_INCLUDED
 #define HEADER_INCLUDED
Index: clang/test/CodeGenObjCXX/arc-blocks.mm
===
--- clang/test/CodeGenObjCXX/arc-blocks.mm
+++ clang/test/CodeGenObjCXX/arc-blocks.mm
@@ -1,9 +1,11 @@
 // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -o - %s | FileCheck -check-prefix CHECK %s
 // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -O1 -o - %s | FileCheck -check-prefix CHECK-O1 %s
 // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck -check-prefix CHECK-NOEXCP %s
+// RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -fobjc-avoid-heapify-local-blocks -o - %s | FileCheck -check-prefix CHECK-NOHEAP %s
 
 // CHECK: [[A:.*]] = type { i64, [10 x i8*] }
 // CHECK: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 }
+// CHECK-NOHEAP: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 }
 // CHECK: %[[STRUCT_TEST1_S0:.*]] = type { i32 }
 // CHECK: %[[STRUCT_TRIVIAL_INTERNAL:.*]] = type { i32 }
 
@@ -209,8 +211,8 @@
 
 namespace test_block_retain {
 
-// CHECK-LABEL: define{{.*}} void @_ZN17test_block_retain14initializationEP11objc_object(
-// CHECK-NOT: @llvm.objc.retainBlock(
+// CHECK-NOHEAP-LABEL: define{{.*}} void @_ZN17test_block_retain14initializationEP11objc_object(
+// CHECK-NOHEAP-NOT: @llvm.objc.retainBlock(
   void initialization(id a) {
 BlockTy b0 = ^{ foo1(a); };
 BlockTy b1 = (^{ foo1(a); });
@@ -218,23 +220,23 @@
 b1();
   }
 
-// CHECK-LABEL: define{{.*}} void @_ZN17test_block_retain20initializationStaticEP11objc_object(
-// CHECK: @llvm.objc.retainBlock(
+// CHECK-NOHEAP-LABEL: define{{.*}} void @_ZN17test_block_retain20initializationStaticEP11objc_object(
+// CHECK-NOHEAP: @llvm.objc.retainBlock(
   void initializationStatic(id a) {
 static BlockTy b0 = ^{ foo1(a); };
 b0();
   }
 
-// CHECK-LABEL: define{{.*}} void @_ZN17test_block_retain15initialization2EP11objc_object
-// CHECK: %[[B0:.*]] = alloca void ()*, align 8
-// CHECK: %[[B1:.*]] = alloca void ()*, align 8
-// CHECK: load void ()*, void ()** %[[B0]], align 8
-// CHECK-NOT: @llvm.objc.retainBlock
-// CHECK: %[[V9:.*]] = load void ()*, void ()** %[[B0]], align 8
-// CHECK: %[[V10:.*]] = bitcast void ()* %[[V9]] to i8*
-// CHECK: %[[V11:.*]] = call i8* @llvm.objc.retainBlock(i8* %[[V10]])
-// CHECK: %[[V12:.*]] = bitcast i8* %[[V11]] to void ()*
-// CHECK: store void ()* %[[V12]], void ()** %[[B1]], align 8
+// CHECK-NOHEAP-LABEL: define{{.*}} void @_ZN17test_block_retain15initialization2EP11objc_object
+// CHECK-NOHEAP: %[[B0:.*]] = alloca void ()*, align 8
+// CHECK-NOHEAP: %[[B1:.*]] = alloca void ()*, align 8
+// CHECK-NOHEAP: load void ()*, void ()** %[[B0]], align 8
+// CHECK-NOHEAP-NOT: @llvm.objc.retainBlock
+// CHECK-NOHEAP: %[[V9:.*]] = load void ()*, void ()** %[[B0]], align 8
+// CHECK-NOHEAP: %[[V10:.*]] = bitcast void ()* %[[V9]] to i8*
+// CHECK-NOHEAP: %[[V11:.*]] = call i8* @llvm.objc.retainBlock(i8* %[[V10]])
+// CHECK-NOHEAP: %[[V12:.*]] = bitcast i8* %[[V11]] to void ()*
+// CHECK-NOHEAP: store void ()* %[[V12]], void ()** %[[B1]], align 8
   void initialization2(id a) {
 BlockTy b0 = ^{ foo1(a); };
 b0();
@@ -242,8 +244,8 @@
 b1();
   }
 
-// CHECK-LABEL: define{{.*}} void @_ZN17test_block_retain10assignmentEP11objc_object(
-// CHECK-NOT: @llvm.objc.retainBlock(
+// CHECK-NOHEAP-LABEL: define{{.*}} void

[PATCH] D106393: [PowerPC][AIX] Add support for varargs for complex types on AIX

2021-09-14 Thread Sean Fertile via Phabricator via cfe-commits
sfertile added a comment.

I suggest we separate the clang change and testing into a standalone patch, and 
the llvm backend tests into a standalone patch which we can commit separately.




Comment at: clang/lib/CodeGen/TargetInfo.cpp:4646
+  if (const ComplexType *CTy = Ty->getAs()) {
+CharUnits EltSize = TypeInfo.Width / 2;
+if (EltSize < SlotSize) {

Minor nit: the code for PPC64 and this is almost identical, I think it should 
be factored into a separate helper function.



Comment at: clang/test/CodeGen/aix32-complex-varargs.c:2
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -emit-llvm -o - %s | 
FileCheck %s
+

The code-gen for int and float won't change with this patch, lets pre-commit 
this test without the _Complex short and _Complex char portions now as an NFC 
patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106393

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


[PATCH] D109752: [clang-format] Top-level unwrapped lines don't follow a left brace

2021-09-14 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

If there are no new tests, what went wrong before? Said invalid code?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109752

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


[PATCH] D109557: Adds an AlignCloseBracket option

2021-09-14 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D109557#2998727 , @csmulhern wrote:

> In D109557#2998213 , 
> @HazardyKnusperkeks wrote:
>
>> With context he meant the diff context. 
>> https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface
>
> Ah sorry about that. Done.

No Problem.

> In D109557#2998226 , 
> @HazardyKnusperkeks wrote:
>
>> You state in the documentation that it is also for angle brackets and more, 
>> but there are no test cases for that.
>
> Yeah, I wasn't sure exactly how to deal with this. The default behavior is 
> already to align angle brackets and braces on newlines. See: 
> https://github.com/llvm/llvm-project/blob/8a780a2f18c590e27e51a2ab3cc81b481c42b42a/clang/lib/Format/ContinuationIndenter.cpp#L341
>  (BreakBeforeClosingBrace is true when the block was started with a newline). 
> Thus, you're already getting this behavior when CBAS_AlwaysBreak is set. I 
> didn't want to make DontAlign (the default) explicitly opt out of this 
> behavior. I guess we can narrow the scope of CloseBracketAlignmentStyle to 
> just parenthesis, but that doesn't feel great either. What are your thoughts?

I haven't looked too much into it, my main point is that there should be tests 
for both variants of that option for braces, parenthesis, and angular braces, 
if they are handled by that option. Otherwise the documentation (and naming?) 
should be adapted. If the defaults differ, the option has to be reworked, for a 
finer control.

In D109557#2999085 , @MyDeveloperDay 
wrote:

> This isn't really `AlignCloseBracket` but `BreakBeforeClosingParen` isn't it?

Yeah I thought that too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109557

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


[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-09-14 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

Yes, Keith and I came to the same conclusion yesterday. I was worried about 
tracking both paths at all times, but I like your suggestion of only changing 
the path when requested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

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


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-09-14 Thread Richard Howell via Phabricator via cfe-commits
rmaz added inline comments.



Comment at: clang/lib/Serialization/ASTReader.cpp:8188-8190
+  for (auto *L = &List; L; L = L->getNext()) {
+seen.insert(L->getMethod());
+  }

dexonsmith wrote:
> I find quadratic algorithms a bit scary, even when current benchmarks don't 
> expose problems. For example, it seems like this could blow up on the 
> following workload:
> - one module adds many things to the global method list
> - there are many (fine-grained) modules that transitively load that module
> 
> Or have I misunderstood the complexity here?
Yes, I take your point, if the method pool generation updates inbetween each of 
the later modules then it is possible to hit this case.



Comment at: clang/lib/Serialization/ASTReader.cpp:8194
+if (seen.insert(M).second) {
+  S.addMethodToGlobalList(&List, M);
+}

dexonsmith wrote:
> rmaz wrote:
> > manmanren wrote:
> > > Does it make sense to check for duplication inside addMethodToGlobalList, 
> > > as the function goes through the list as well? Maybe it is slower, as we 
> > > will need to go through the list for each method, instead of a lookup.
> > Yes, you are right, it is slower as we need to do a list traverse per 
> > insert rather than per selector lookup. I also profiled keeping some global 
> > state along with the `MethodPool` so that the set didn't have to be rebuilt 
> > each time, but the performance difference was negligible.
> Can you take another look at the approach you experimented with, putting the 
> global state in the MethodPool? Besides the performance difference (you 
> measured it as negligible but it'd avoid the concern I have about uncommon 
> workloads hitting quadratic blowups), it'd also provide consistency in 
> behaviour between callers of `addMethodToGlobalList`... and enable you to add 
> a unit test for the API change to MethodPool.
I'll update with this approach, it should allow for moving the set insert logic 
into `addMethodToGlobalList` in this case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

2021-09-14 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D108643#2999776 , @erichkeane 
wrote:

>> ! In D108643#2965852 , @rjmccall 
>> wrote:
>>
>> The choice that high bits are unspecified rather than extended is an 
>> interesting one.  Can you speak to that?  That's good for +, -, *, &, |, ^, 
>> <<, and narrowing conversions, but bad for ==, <, /, >>, and widening 
>> conversions.
>
> So we chose this for a few reasons:
>
> 1- Consistency with struct padding bits.  It seemed strange to specify the 
> padding bits here, when the rest of the standards/ABI don't specify padding 
> bits.

I think it's a mistake to think of these as padding bits.  Implementations on 
general-purpose hardware will be doing operations in word-sized chunks; these 
are the high bits of the most significant word.

> 2- Flexibility of implementation: Requiring zeroing is a more constraining 
> decision, which limits implementation to having to set these bits.  By 
> leaving it unspecified, the implementation is free to zero them out if it 
> feels it is worth-while.

This is a trade-off.  Extending constrains the implementation of operations 
that produce noise in the high bits.  Extending constrains the implementation 
of operations that are affected by noise in the high bits.  I'm willing to 
believe that the trade-off favors leaving the bits undefined, but that's why 
I'm asking, to see if you've actually evaluated this trade-off, because it 
kindof sounds like you've evaluated one side of it.

> I'll note that our backends choose NOT to zero them out when not necessary, 
> since (so I'm told) 'masked' compares are trivial in most processors.

They're trivial to implement in custom hardware, of course, but what existing 
ISAs actually provide masked compare instructions?  Is this a common feature 
I'm simply totally unaware of?  In practice I think this will be 1-2 extra 
instructions in every comparison.

> 3- Implement-ability on FPGAs: Since this was our motivating example, forcing 
> an FPGA to zero out these bits when dealing with an interaction with a 
> byte-aligned processor would have incredible performance overhead.

How on earth does making the store unit zero/sign-extend have "incredible 
performance overhead"?  This is totally trivial technologically.  It's not like 
you're otherwise sending 17-bit stores out on the bus.

I'm not sure it's appropriate to think of this as primarily an FPGA feature 
when in fact it's being added to standard targets.

> 4- Ease of implementation: Forcing LLVM to zero out these bits would either 
> mean we had to do quite a bit of work in our CodeGen to zero them out, or 
> modify most of the backends to not zero padding bits in these cases. Since 
> there isn't a particular performance benefit (see #2) we didn't think it 
> would be worth while.

The obvious lowering would be for clang to use i17 as the scalar type lowering 
but i32 as the "in-memory" lowering, then make sure that the backends are 
reasonably intelligent about folding extend/trunc operations around operations 
that aren't sensitive / don't produce noise.


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

https://reviews.llvm.org/D108643

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


[PATCH] D108893: clang-tidy: introduce readability-containter-data-pointer check

2021-09-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

49992c04148e5327bef9bd2dff53a0d46004b4b4 
 relanded 
the change. It is useful to attach the original `Differential Revision: ` so 
that it is connected to this Differential.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108893

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


[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-09-14 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D109128#3000157 , @JDevlieghere 
wrote:

> Yes, Keith and I came to the same conclusion yesterday. I was worried about 
> tracking both paths at all times, but I like your suggestion of only changing 
> the path when requested.

Another idea that could be useful would be to add a type:

  struct CanonicalizedPath {
StringRef OriginalPath;
StringRef CanonicalPath;
  };

and add an overload for `vfs::FileSystem::openFileForRead` that takes this type.

- The default implementation in `vfs::FileSystem` could call 
`openFileForRead(.Canonical)` and then do a `File::getWithPath(.Original)` (as 
with my idea above, just when `File::getPath` matches `.Canonical` and 
`.Canonical!=.Original`).
- CanonicalizedPath-aware derived classes would invert the relationship. 
`openFileForRead(FilesystemLookupPath)` would use `CanonicalPath` for lookup, 
use `OriginalPath` for creating `File`, and pass through (a potentially 
updated!) `CanonicalizedPath` to base filesystems... and implement 
`openFileForRead(Twine)` by calling `canonicalizePath`.

Seems like a bit more code, but maybe not much, and the resulting logic 
might(?) be easier to reason about. (maybe a different name than 
openFileForRead would be better for clarity, rather than an overload?)

(Probably similar to your idea about tracking both paths at all times, but I'm 
not sure that needs to be mutually exclusive)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

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


[PATCH] D109635: [WIP][OpenMP] Support construct trait set for Clang

2021-09-14 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 372529.
cchen added a comment.

Fix based on feedback (wait for comment about moving ConstructTrait to 
IRBuilder)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109635

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/declare_variant_construct_codegen_1.c

Index: clang/test/OpenMP/declare_variant_construct_codegen_1.c
===
--- /dev/null
+++ clang/test/OpenMP/declare_variant_construct_codegen_1.c
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s --check-prefix=CK1
+// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-unknown-linux -emit-pch -o %t -fopenmp-version=45 %s
+// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-unknown-linux -include-pch %t -verify %s -emit-llvm -o - -fopenmp-version=45 | FileCheck %s --check-prefix=CK1
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -o - | FileCheck %s --check-prefix=CK1
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s --check-prefix=CK1
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=amdgcn-amd-amdhsa -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=amdgcn-amd-amdhsa -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix=CK1
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -fopenmp-simd -x c -triple x86_64-unknown-linux -emit-pch -o %t -fopenmp-version=45 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c -triple x86_64-unknown-linux -include-pch %t -verify %s -emit-llvm -o - -fopenmp-version=45 | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=amdgcn-amd-amdhsa -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=amdgcn-amd-amdhsa -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+#define N 100
+
+void p_vxv(int *v1, int *v2, int *v3, int n);
+void t_vxv(int *v1, int *v2, int *v3, int n);
+
+#pragma omp declare variant(t_vxv) match(construct={target})
+#pragma omp declare variant(p_vxv) match(construct={parallel})
+void vxv(int *v1, int *v2, int *v3, int n) {
+for (int i = 0; i < n; i++) v3[i] = v1[i] * v2[i];
+}
+// CK1: define dso_local void @vxv
+
+void p_vxv(int *v1, int *v2, int *v3, int n) {
+#pragma omp for
+for (int i = 0; i < n; i++) v3[i] = v1[i] * v2[i] * 3;
+}
+// CK1: define dso_local void @p_vxv
+
+#pragma omp declare target
+void t_vxv(int *v1, int *v2, int *v3, int n) {
+#pragma distribute simd
+for (int i = 0; i < n; i++) v3[i] = v1[i] * v2[i] * 2;
+}
+#pragma omp end declare target
+// CK1: define dso_local void @t_vxv
+
+
+// CK1-LABEL: define {{[^@]+}}@main
+int main() {
+  int v1[N], v2[N], v3[N];
+
+  // init
+  for (int i = 0; i < N; i++) {
+v1[i] = (i + 1);
+v2[i] = -(i + 1);
+v3[i] = 0;
+  }
+
+#pragma omp target teams map(to: v1[:N],v2[:N]) map(from: v3[:N])
+  {
+vxv(v1, v2, v3, N);
+  }
+// CK1: call void @__omp_offloading_[[OFFLOAD:.+]]({{.+}})
+
+  vxv(v1, v2, v3, N);
+// CK1: call void @vxv
+
+#pragma omp parallel
+  {
+vxv(v1, v2, v3, N);
+  }
+// CK1: call void ({{.+}}) @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 3, void ({{.+}})* bitcast (void (i32*, i32*, [100 x i32]*, [100 x i32]*, [100 x i32]*)* [[PARALLEL_REGION:@.+]] to void
+
+  return 0;
+}
+
+// CK1: define internal void @__omp_offloading_[[OFFLOAD]]({{.+}})
+// CK1: call void ({{.+}}) @__kmpc_fork_teams(%struct.ident_t* {{.+}}, i32 3, void ({{.+}})* bitcast (void (i32*, i32*, [100 x i32]*, [100 x i32]*, [100 x i32]*)* [[TARGET_REGION:@.+]] to void
+
+// CK1: define internal void [[TARGET_REGION]](
+// CK1: call void @t_vxv
+
+// CK1: define internal void [[PARALLEL_REGION]](
+// CK1: call void @p_vxv
+
+#endif // HEADER
Index: clang/lib/Sema/SemaOpenMP.cpp
===

[PATCH] D109210: [clang-tidy] Attach fixit to warning, not note, in add_new_check.py example

2021-09-14 Thread Matt Beardsley via Phabricator via cfe-commits
mattbeardsley added a comment.

Thanks for your reply and sorry about my very sluggish reply!
I am looking into updating the docs as you suggested, and that got me looking 
at this doc page 
.
 Interestingly, that doc page's version of the add_new_check.py template 
doesn't have the `Note` diagnostic. So that got me digging into the history.
It seems like 2 commits are at odds with each other about what the right thing 
to do is with `FixItHint`s w.r.t. `Note` vs `Warning` diagnostics.

1. This commit 

 says that "fix descriptions and fixes are emitted via diagnostic::Note (rather 
than attaching the main warning diagnostic)."  - And note how that commit 
changes add_new_check.py - adding the `Note` diagnostic!
2. This commit 
 seems to 
suggest that Note diagnostics should //not// be used to provide the "standard" 
fix (and generally enforces that by `--fix-notes` being off by default)

It looks like nearly all existing check implementations disagree with the 
former, and agree with the latter.
Those two commits appear to be at odds with each other on the semantics of 
`Note` diagnostics - any opinions on how to reconcile that apparent 
disagreement?

My (limited) perspective is:
Since `--fix-notes` is off by default, it seems like `FixIt`s on `Note` 
diagnostics are pretty well enforced to be used for secondary/uncertain 
suggestions, while `FixIt`s on `Warning` diagnostics are for the primary 
fix(es). 
That seems to rule out accepting the guidance of first commit w.r.t. attaching 
fixes to `Note` diagnostics given the `--fix-notes` flag imposes that such 
note-fixes are implicitly secondary to warning-fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109210

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


  1   2   >