[clang] 34558b0 - [StaticAnalyzer] Remove redundant declaration isStdSmartPtr (NFC)

2021-12-25 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2021-12-25T00:35:41-08:00
New Revision: 34558b039b3baf057851b8d39f53402608da4927

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

LOG: [StaticAnalyzer] Remove redundant declaration isStdSmartPtr (NFC)

An identical declaration is present just a couple of lines above the
line being removed in this patch.

Identified with readability-redundant-declaration.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/SmartPtr.h

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/SmartPtr.h 
b/clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
index 6a40f8eda5fa8..b4352b450c7fa 100644
--- a/clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
+++ b/clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
@@ -25,8 +25,6 @@ bool isStdSmartPtrCall(const CallEvent &Call);
 bool isStdSmartPtr(const CXXRecordDecl *RD);
 bool isStdSmartPtr(const Expr *E);
 
-bool isStdSmartPtr(const CXXRecordDecl *RD);
-
 /// Returns whether the smart pointer is null or not.
 bool isNullSmartPtr(const ProgramStateRef State, const MemRegion *ThisRegion);
 



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


[PATCH] D116261: [WIP][Clang][OpenMP] Add support for compare capture in parser

2021-12-25 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 396199.
tianshilei1992 added a comment.

update test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116261

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/atomic_messages.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -181,6 +181,10 @@
 def OMPC_Update : Clause<"update"> { let clangClass = "OMPUpdateClause"; }
 def OMPC_Capture : Clause<"capture"> { let clangClass = "OMPCaptureClause"; }
 def OMPC_Compare : Clause<"compare"> { let clangClass = "OMPCompareClause"; }
+// A dummy clause if compare and capture clauses are present.
+def OMPC_CompareCapture : Clause<"compare_capture"> {
+  let clangClass = "OMPCompareCaptureClause";
+}
 def OMPC_SeqCst : Clause<"seq_cst"> { let clangClass = "OMPSeqCstClause"; }
 def OMPC_AcqRel : Clause<"acq_rel"> { let clangClass = "OMPAcqRelClause"; }
 def OMPC_Acquire : Clause<"acquire"> { let clangClass = "OMPAcquireClause"; }
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2277,6 +2277,9 @@
 
 void OMPClauseEnqueue::VisitOMPCompareClause(const OMPCompareClause *) {}
 
+void OMPClauseEnqueue::VisitOMPCompareCaptureClause(
+const OMPCompareCaptureClause *) {}
+
 void OMPClauseEnqueue::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
 
 void OMPClauseEnqueue::VisitOMPAcqRelClause(const OMPAcqRelClause *) {}
Index: clang/test/OpenMP/atomic_messages.cpp
===
--- clang/test/OpenMP/atomic_messages.cpp
+++ clang/test/OpenMP/atomic_messages.cpp
@@ -949,4 +949,15 @@
   a = c;
   }
 }
+
+int compare_capture() {
+  int a, b, c, x;
+// omp51-error@+1 {{atomic compare capture is not supported for now}}
+#pragma omp atomic compare capture
+  {
+x = a;
+if (a == b)
+  a = c;
+  }
+}
 #endif
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6254,6 +6254,8 @@
 
 void OMPClauseWriter::VisitOMPCompareClause(OMPCompareClause *) {}
 
+void OMPClauseWriter::VisitOMPCompareCaptureClause(OMPCompareCaptureClause *) {}
+
 void OMPClauseWriter::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
 
 void OMPClauseWriter::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -11768,6 +11768,9 @@
   case llvm::omp::OMPC_compare:
 C = new (Context) OMPCompareClause();
 break;
+  case llvm::omp::OMPC_compare_capture:
+C = new (Context) OMPCompareCaptureClause();
+break;
   case llvm::omp::OMPC_seq_cst:
 C = new (Context) OMPSeqCstClause();
 break;
@@ -12128,6 +12131,8 @@
 
 void OMPClauseReader::VisitOMPCompareClause(OMPCompareClause *) {}
 
+void OMPClauseReader::VisitOMPCompareCaptureClause(OMPCompareCaptureClause *) {}
+
 void OMPClauseReader::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
 
 void OMPClauseReader::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -9467,6 +9467,13 @@
   return C;
 }
 
+template 
+OMPClause *TreeTransform::TransformOMPCompareCaptureClause(
+OMPCompareCaptureClause *C) {
+  // No need to rebuild this clause, no template-dependent parameters.
+  return C;
+}
+
 template 
 OMPClause *
 TreeTransform::TransformOMPSeqCstClause(OMPSeqCstClause *C) {
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -35,6 +35,7 @@
 #include "llvm/ADT/IndexedMap.h"
 #include "llvm/ADT/PointerEmbeddedInt.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include 
@@ -6355,6 +6356,7 @@
   case OMPC_update:
   case OMPC_capture:
   case OMPC_compare

[PATCH] D116280: [clang] adds unary type trait checks as compiler built-ins

2021-12-25 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb created this revision.
Herald added a subscriber: dexonsmith.
cjdb requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is information that the compiler already has, and should be exposed
so that the library doesn't need to reimplement the exact same
functionality.

- `__is_null_pointer`
- `__is_bounded_array`
- `__is_scoped_enum`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116280

Files:
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/type-traits.cpp

Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -14,6 +14,9 @@
 enum Enum { EV };
 enum SignedEnum : signed int { };
 enum UnsignedEnum : unsigned int { };
+enum class EnumClass { EV };
+enum class SignedEnumClass : signed int {};
+enum class UnsignedEnumClass : unsigned int {};
 struct POD { Enum e; int i; float f; NonPOD* p; };
 struct Empty {};
 struct IncompleteStruct;
@@ -342,11 +345,19 @@
 }
 
 typedef Enum EnumType;
+typedef EnumClass EnumClassType;
 
 void is_enum()
 {
   { int arr[T(__is_enum(Enum))]; }
   { int arr[T(__is_enum(EnumType))]; }
+  { int arr[T(__is_enum(SignedEnum))]; }
+  { int arr[T(__is_enum(UnsignedEnum))]; }
+
+  { int arr[T(__is_enum(EnumClass))]; }
+  { int arr[T(__is_enum(EnumClassType))]; }
+  { int arr[T(__is_enum(SignedEnumClass))]; }
+  { int arr[T(__is_enum(UnsignedEnumClass))]; }
 
   { int arr[F(__is_enum(int))]; }
   { int arr[F(__is_enum(Union))]; }
@@ -360,6 +371,30 @@
   { int arr[F(__is_enum(HasAnonymousUnion))]; }
 }
 
+void is_scoped_enum()
+{
+  { int arr[F(__is_scoped_enum(Enum))]; }
+  { int arr[F(__is_scoped_enum(EnumType))]; }
+  { int arr[F(__is_scoped_enum(SignedEnum))]; }
+  { int arr[F(__is_scoped_enum(UnsignedEnum))]; }
+
+  { int arr[T(__is_scoped_enum(EnumClass))]; }
+  { int arr[T(__is_scoped_enum(EnumClassType))]; }
+  { int arr[T(__is_scoped_enum(SignedEnumClass))]; }
+  { int arr[T(__is_scoped_enum(UnsignedEnumClass))]; }
+
+  { int arr[F(__is_scoped_enum(int))]; }
+  { int arr[F(__is_scoped_enum(Union))]; }
+  { int arr[F(__is_scoped_enum(Int))]; }
+  { int arr[F(__is_scoped_enum(IntAr))]; }
+  { int arr[F(__is_scoped_enum(UnionAr))]; }
+  { int arr[F(__is_scoped_enum(Derives))]; }
+  { int arr[F(__is_scoped_enum(ClassType))]; }
+  { int arr[F(__is_scoped_enum(cvoid))]; }
+  { int arr[F(__is_scoped_enum(IntArNB))]; }
+  { int arr[F(__is_scoped_enum(HasAnonymousUnion))]; }
+}
+
 struct FinalClass final {
 };
 
@@ -699,6 +734,36 @@
   int t31[F(__is_array(cvoid*))];
 }
 
+void is_bounded_array()
+{
+  int t01[T(__is_bounded_array(IntAr))];
+  int t02[F(__is_bounded_array(IntArNB))];
+  int t03[T(__is_bounded_array(UnionAr))];
+
+  int t10[F(__is_bounded_array(void))];
+  int t11[F(__is_bounded_array(cvoid))];
+  int t12[F(__is_bounded_array(float))];
+  int t13[F(__is_bounded_array(double))];
+  int t14[F(__is_bounded_array(long double))];
+  int t15[F(__is_bounded_array(bool))];
+  int t16[F(__is_bounded_array(char))];
+  int t17[F(__is_bounded_array(signed char))];
+  int t18[F(__is_bounded_array(unsigned char))];
+  int t19[F(__is_bounded_array(wchar_t))];
+  int t20[F(__is_bounded_array(short))];
+  int t21[F(__is_bounded_array(unsigned short))];
+  int t22[F(__is_bounded_array(int))];
+  int t23[F(__is_bounded_array(unsigned int))];
+  int t24[F(__is_bounded_array(long))];
+  int t25[F(__is_bounded_array(unsigned long))];
+  int t26[F(__is_bounded_array(Union))];
+  int t27[F(__is_bounded_array(Derives))];
+  int t28[F(__is_bounded_array(ClassType))];
+  int t29[F(__is_bounded_array(Enum))];
+  int t30[F(__is_bounded_array(void*))];
+  int t31[F(__is_bounded_array(cvoid*))];
+}
+
 template  void tmpl_func(T&) {}
 
 template  struct type_wrapper {
@@ -931,6 +996,43 @@
   int t34[F(__is_pointer(void (StructWithMembers::*) ()))];
 }
 
+void is_null_pointer()
+{
+  StructWithMembers x;
+
+  int t00[T(__is_null_pointer(decltype(nullptr)))];
+  int t01[F(__is_null_pointer(void*))];
+  int t02[F(__is_null_pointer(cvoid*))];
+  int t03[F(__is_null_pointer(cvoid*))];
+  int t04[F(__is_null_pointer(char*))];
+  int t05[F(__is_null_pointer(int*))];
+  int t06[F(__is_null_pointer(int**))];
+  int t07[F(__is_null_pointer(ClassType*))];
+  int t08[F(__is_null_pointer(Derives*))];
+  int t09[F(__is_null_pointer(Enum*))];
+  int t10[F(__is_null_pointer(IntArNB*))];
+  int t11[F(__is_null_pointer(Union*))];
+  int t12[F(__is_null_pointer(UnionAr*))];
+  int t13[F(__is_null_pointer(StructWithMembers*))];
+  int t14[F(__is_null_pointer(void (*)()))];
+
+  int t20[F(__is_null_pointer(void))];
+  int t21[F(__is_null_pointer(cvoid))];
+  int t22[F(__is_null_pointer(cvoid))];
+  int t23[F(__is_null_pointer(char))];
+  int t24[F(__is_null_pointer(int))];
+  int t25[F(__is_null_p

[PATCH] D114425: [clang] Add __builtin_bswap128

2021-12-25 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

What does the builtin due if __int128 isn't supported? Even though the type 
isn't legal the builtin can still be called with a narrower type that would be 
implicitly converted. Does that work correctly?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114425

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